/* ==================== Reset / base ==================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #0c0518;
    color: #fff;
    min-height: 100vh;
    overflow-x: hidden;
}
button { font: inherit; cursor: pointer; }

/* ==================== Fondo animado ==================== */
#bg-canvas {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    background: #0c0518;
}

/* ==================== Top bar + tabs ==================== */
.sticky-shell {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(12, 5, 24, 0.78);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    padding-top: env(safe-area-inset-top);
}
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px 6px;
}
.brand {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.demo-pill {
    background: #f59e0b;
    color: #1a1208;
    font-size: 11px;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 999px;
    letter-spacing: 1px;
}
#station-picker {
    appearance: none;
    background: rgba(255,255,255,0.08);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 999px;
    padding: 6px 32px 6px 14px;
    font-size: 14px;
    backdrop-filter: blur(10px);
    cursor: pointer;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'><path fill='white' d='M6 8L0 0h12z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 10px;
}

.tabs {
    display: flex;
    gap: 4px;
    padding: 8px 12px 12px;
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
    flex: 0 0 auto;
    background: rgba(255,255,255,0.07);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 999px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    backdrop-filter: blur(10px);
    transition: background 0.2s;
}
.tab-btn:hover { background: rgba(255,255,255,0.12); }
.tab-btn.active {
    background: #f23a5c;
    border-color: #f23a5c;
    color: #fff;
}

/* ==================== Paneles ==================== */
main {
    padding: 8px 20px 40px;
    max-width: 720px;
    margin: 0 auto;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.25s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ==================== Directo ==================== */
.cover-wrap {
    display: flex;
    justify-content: center;
    margin: 16px 0;
}
#cover {
    width: 220px;
    height: 220px;
    border-radius: 24px;
    object-fit: cover;
    background: rgba(255,255,255,0.05);
}
.now-playing {
    text-align: center;
    margin: 4px 0 12px;
}
.now-playing h2 {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 4px;
    text-shadow: 0 2px 6px rgba(0,0,0,0.6);
}
.now-playing p {
    font-size: 15px;
    opacity: 0.85;
    margin: 0;
}
.status {
    display: flex;
    justify-content: center;
    gap: 14px;
    font-size: 12px;
    opacity: 0.8;
    margin-top: 8px;
    flex-wrap: wrap;
}
.live {
    color: #ff4d6e;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.live::before { content: "● "; }
.hidden { display: none; }

.play-button {
    display: block;
    margin: 16px auto;
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: #f23a5c;
    border: none;
    color: #fff;
    font-size: 30px;
    transition: transform 0.15s, background 0.2s;
}
.play-button:hover { transform: scale(1.05); }
.play-button:active { transform: scale(0.97); }
.play-button .play-icon::before { content: "▶"; padding-left: 4px; }
.play-button.playing .play-icon::before { content: "❚❚"; padding-left: 0; letter-spacing: -2px; }
.play-button.buffering .play-icon::before {
    content: "";
    display: inline-block;
    width: 22px;
    height: 22px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.reactions {
    display: flex;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
    margin: 8px 0;
}
.react {
    background: rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 16px;
    color: #fff;
    backdrop-filter: blur(10px);
    transition: transform 0.1s, background 0.2s;
}
.react:hover { background: rgba(255,255,255,0.18); }
.react:active { transform: scale(0.92); }
.react .count { font-size: 12px; font-weight: 600; opacity: 0.85; margin-left: 4px; }

.actions {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 12px 0;
    flex-wrap: wrap;
}
.action-btn, .ghost {
    background: rgba(255,255,255,0.10);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 12px;
    padding: 8px 14px;
    font-size: 14px;
    text-decoration: none;
    backdrop-filter: blur(10px);
    transition: background 0.2s;
}
.action-btn:hover, .ghost:hover { background: rgba(255,255,255,0.16); }
.primary {
    background: #f23a5c;
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 600;
}

/* ==================== Preview del chat en directo ==================== */
.chat-preview {
    margin-top: 16px;
    max-height: 160px;
    overflow: hidden;
    mask-image: linear-gradient(to bottom, transparent 0%, black 40%, black 100%);
}
#chat-preview-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 4px;
    min-height: 100%;
}
#chat-preview-list li {
    font-size: 12px;
    background: rgba(0,0,0,0.35);
    padding: 5px 10px;
    border-radius: 12px;
    color: #fff;
    line-height: 1.35;
}
#chat-preview-list li.dedication {
    background: rgba(242,58,92,0.75);
}
#chat-preview-list li b { font-weight: 700; }

/* ==================== Chat (pestaña) ==================== */
/* El panel del chat ocupa toda la altura disponible debajo del sticky-shell. */
#tab-chat.active {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 130px); /* aproximación; el composer es sticky por si acaso */
    padding-bottom: 0;
}
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin: 12px 0 10px;
}
.chat-header h2 { margin: 0; font-size: 18px; font-weight: 700; }
.chat-sub { margin: 2px 0 0; font-size: 12px; opacity: 0.6; }
.nick-btn {
    background: rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.18);
    color: #fff;
    border-radius: 999px;
    padding: 7px 13px;
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1 1 auto;
    min-height: 240px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px 2px 12px;
    scroll-behavior: smooth;
}
.chat-messages .msg {
    background: rgba(255,255,255,0.10);
    padding: 7px 10px 5px;
    border-radius: 14px 14px 14px 4px;
    align-self: flex-start;
    max-width: 82%;
    font-size: 14px;
    line-height: 1.35;
    word-wrap: break-word;
    position: relative;
    display: flex;
    flex-direction: column;
}
.chat-messages .msg.mine {
    align-self: flex-end;
    background: #f23a5c;
    border-radius: 14px 14px 4px 14px;
}
.chat-messages .msg.dedication {
    align-self: stretch;
    background: linear-gradient(135deg, #f55a5a 0%, #ed3373 100%);
    max-width: none;
    border-radius: 14px;
}
.chat-messages .msg .author {
    font-size: 11px;
    font-weight: 700;
    opacity: 0.85;
    margin-bottom: 2px;
}
.chat-messages .msg .body { white-space: pre-wrap; }
.chat-messages .msg .time {
    align-self: flex-end;
    font-size: 10px;
    opacity: 0.6;
    margin-top: 2px;
    margin-left: 8px;
    font-variant-numeric: tabular-nums;
}
.chat-messages .msg.mine .time { opacity: 0.85; }

/* Botón "⋮" para reportar/bloquear. Discreto: visible al hover en desktop, siempre visible pequeño en móvil. */
.chat-messages .msg { padding-right: 24px; }
.chat-messages .msg.mine { padding-right: 12px; padding-left: 24px; }
.chat-messages .msg .msg-more {
    position: absolute;
    top: 4px;
    right: 4px;
    background: transparent;
    border: 0;
    color: rgba(255,255,255,0.5);
    font-size: 18px;
    width: 22px;
    height: 22px;
    line-height: 1;
    padding: 0;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0.6;
}
.chat-messages .msg .msg-more:hover {
    background: rgba(0,0,0,0.4);
    color: #fff;
    opacity: 1;
}
@media (hover: hover) {
    .chat-messages .msg .msg-more { opacity: 0; }
    .chat-messages .msg:hover .msg-more { opacity: 0.8; }
}

/* === EULA checkbox en nickname-modal === */
.eula-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13px;
    line-height: 1.4;
    margin: 4px 0;
    cursor: pointer;
}
.eula-check input[type=checkbox] {
    margin: 2px 0 0;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    accent-color: #f23a5c;
}
.eula-check a { color: #ff8aa1; }

/* === Preview de mensaje dentro del modal de acciones === */
.msg-preview {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
    max-height: 120px;
    overflow-y: auto;
    white-space: pre-wrap;
    margin-top: 6px;
}

/* Separadores por día estilo WhatsApp */
.chat-messages .day-sep {
    align-self: center;
    background: rgba(0,0,0,0.35);
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 11px;
    opacity: 0.8;
    margin: 8px 0;
    font-weight: 600;
}

.chat-empty {
    text-align: center;
    padding: 40px 20px;
    opacity: 0.5;
    font-size: 14px;
}

.composer {
    display: flex;
    gap: 8px;
    padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
    position: sticky;
    bottom: 0;
    background: linear-gradient(to top, rgba(12,5,24,0.95) 50%, rgba(12,5,24,0.65) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    margin-top: auto;
    z-index: 5;
}
.composer input {
    flex: 1;
    background: rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.18);
    color: #fff;
    border-radius: 22px;
    padding: 11px 18px;
    font-size: 15px;
    min-width: 0;
}
.composer input::placeholder { color: rgba(255,255,255,0.5); }
.composer input:focus {
    outline: none;
    border-color: rgba(242,58,92,0.7);
    background: rgba(255,255,255,0.14);
}
.composer button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #f23a5c;
    color: #fff;
    border: none;
    font-size: 20px;
    flex-shrink: 0;
    transition: transform 0.1s, background 0.2s;
}
.composer button:hover { background: #d9304f; }
.composer button:active { transform: scale(0.92); }
.composer button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ==================== Listados (blog, noticias) ==================== */
.article-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.article-list li {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 14px;
    padding: 14px;
    cursor: pointer;
    transition: background 0.2s;
}
.article-list li:hover { background: rgba(255,255,255,0.12); }
.article-list .title {
    font-weight: 700;
    font-size: 16px;
    margin: 0 0 4px;
}
.article-list .summary {
    margin: 0 0 6px;
    font-size: 14px;
    opacity: 0.85;
}
.article-list .meta {
    font-size: 11px;
    opacity: 0.6;
}
.article-list .category {
    color: #ff4d6e;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.5px;
}

/* ==================== Cartelera ==================== */
.events-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.events-list li {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 14px;
    padding: 14px;
}
.events-list .town {
    display: inline-block;
    background: rgba(242,58,92,0.25);
    color: #ff8aa1;
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}
.events-list .title { font-weight: 700; margin: 6px 0 4px; }
.events-list .loc, .events-list .when { font-size: 12px; opacity: 0.8; }

.news-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 12px 0 8px;
}
.news-header h2 { margin: 0; font-size: 18px; font-weight: 700; }

/* ==================== Modales ==================== */
.modal {
    background: rgba(20,8,28,0.95);
    border: 1px solid rgba(255,255,255,0.10);
    color: #fff;
    border-radius: 18px;
    padding: 20px;
    min-width: 300px;
    max-width: 90vw;
    backdrop-filter: blur(20px);
}
.modal::backdrop { background: rgba(0,0,0,0.55); backdrop-filter: blur(6px); }
.modal header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.modal header h3 { margin: 0; font-size: 18px; }
.modal .close, .modal [data-close] {
    background: transparent;
    color: #fff;
    border: 0;
    font-size: 16px;
}
.modal .meta { font-size: 13px; opacity: 0.7; margin: 0 0 12px; }
.modal .body { font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.modal form { display: flex; flex-direction: column; gap: 10px; }
.modal input, .modal textarea {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.18);
    color: #fff;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
}
.modal input::placeholder, .modal textarea::placeholder { color: rgba(255,255,255,0.5); }
.modal .actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

audio { display: none; }

/* ==================== Footer / créditos ==================== */
.credits {
    text-align: center;
    padding: 18px 20px 30px;
    font-size: 12px;
    opacity: 0.55;
    color: #fff;
    backdrop-filter: blur(8px);
}
.credits a {
    color: #ff8aa1;
    text-decoration: none;
    font-weight: 600;
}
.credits a:hover { text-decoration: underline; }

/* ==================== Responsive: TABLET (≥ 641px) ==================== */
@media (min-width: 641px) {
    .topbar { padding: 20px 32px 10px; }
    .brand { font-size: 26px; }
    .tabs { padding: 10px 32px 14px; justify-content: center; }
    .tab-btn { padding: 9px 18px; font-size: 15px; }

    main { max-width: 880px; padding: 16px 32px 60px; }

    #cover { width: 280px; height: 280px; border-radius: 28px; }
    .now-playing h2 { font-size: 26px; }
    .now-playing p { font-size: 17px; }
    .status { font-size: 13px; gap: 18px; }

    .play-button { width: 96px; height: 96px; font-size: 34px; }
    .reactions { gap: 10px; }
    .react { padding: 8px 16px; font-size: 18px; }
    .react .count { font-size: 13px; }

    .chat-preview { max-height: 220px; }
    .chat-messages .msg { font-size: 15px; max-width: 70%; }
    .composer input { font-size: 15px; padding: 12px 18px; }
    .composer button { width: 44px; height: 44px; font-size: 20px; }

    .article-list, .events-list { gap: 14px; }
    .article-list .title, .events-list .title { font-size: 17px; }
    .article-list .summary { font-size: 15px; }
}

/* ==================== Responsive: DESKTOP (≥ 1024px) ==================== */
@media (min-width: 1024px) {
    main { max-width: 1180px; padding: 24px 40px 80px; }
    .topbar { padding: 22px 48px 12px; }
    .tabs { padding: 12px 48px 18px; }

    /* === Directo en dos columnas: cover + play a la izquierda, info+reacciones+chat a la derecha === */
    #tab-directo.active {
        display: grid;
        grid-template-columns: 380px 1fr;
        grid-template-areas:
            "cover  info"
            "cover  reactions"
            "cover  actions"
            "play   chat";
        gap: 18px 44px;
        align-items: start;
        margin-top: 12px;
    }
    #tab-directo .cover-wrap   { grid-area: cover; margin: 0; align-self: start; }
    #tab-directo #cover        { width: 380px; height: 380px; border-radius: 32px; }
    #tab-directo .now-playing  { grid-area: info; text-align: left; margin: 0; }
    #tab-directo .now-playing h2 { font-size: 30px; }
    #tab-directo .now-playing p  { font-size: 18px; }
    #tab-directo .status       { justify-content: flex-start; }
    #tab-directo .reactions    { grid-area: reactions; justify-content: flex-start; margin: 0; }
    #tab-directo .actions      { grid-area: actions; justify-content: flex-start; margin: 0; }
    #tab-directo #play-btn     { grid-area: play; margin: 12px auto 0; width: 110px; height: 110px; font-size: 38px; }
    #tab-directo .chat-preview { grid-area: chat; max-height: 360px; margin: 0; align-self: end; }

    /* === Listados a 2 columnas === */
    .article-list, .events-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }
    .article-list li, .events-list li { padding: 18px; }

    /* === Chat full-width con altura más generosa === */
    .chat-messages { max-height: 70vh; padding: 8px; }
    .chat-messages .msg { font-size: 15px; max-width: 60%; }

    /* === Modales un pelín más anchos === */
    .modal { min-width: 420px; max-width: 540px; padding: 24px; }
}

/* ==================== Responsive: PC ANCHO (≥ 1400px) ==================== */
@media (min-width: 1400px) {
    main { max-width: 1320px; }
    .article-list, .events-list { grid-template-columns: 1fr 1fr 1fr; }
    #tab-directo.active { grid-template-columns: 440px 1fr; gap: 22px 56px; }
    #tab-directo #cover { width: 440px; height: 440px; }
}
