/**
 * components.css
 * -----------------------------------------------------------------------
 * Componentes reutilizables: botones, tarjetas de emisora, reproductor
 * persistente, formulario de contacto, menú móvil, alternador de tema.
 * -----------------------------------------------------------------------
 */

/* ================================ BUTTONS ================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-5);
    border-radius: var(--radius-full);
    border: 1px solid transparent;
    font-weight: 600;
    font-size: var(--fs-sm);
    transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
    white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn--primary {
    background: var(--accent);
    color: var(--text-on-accent);
    box-shadow: var(--shadow-sm);
}

.btn--primary:hover { box-shadow: var(--shadow-md); }

.btn--ghost {
    background: transparent;
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.btn--ghost:hover { background: var(--surface-hover); }

.btn--lg {
    padding: var(--sp-4) var(--sp-6);
    font-size: var(--fs-base);
}

.btn--station {
    width: 100%;
    justify-content: center;
    background: var(--surface-hover);
    color: var(--text-primary);
    margin-top: auto;
    padding-top: var(--sp-3);
}

.btn--station:hover {
    background: var(--accent);
    color: var(--text-on-accent);
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
    flex-shrink: 0;
}

.icon-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

/* ============================= STATION SELECT ============================= */
.station-select {
    display: none;
    align-items: center;
    gap: var(--sp-2);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding-inline: var(--sp-3);
}

.station-select select {
    background: transparent;
    border: none;
    padding-block: var(--sp-2);
    color: var(--text-primary);
}

/* El navegador dibuja la lista desplegable de <option> con su propio
   renderizado nativo (fuera del control normal de nuestro CSS), que en
   muchos navegadores IGNORA el color heredado del <select> y cae a un
   gris del sistema casi ilegible sobre nuestro fondo oscuro. Fijar
   explícitamente color y fondo en cada <option> evita ese problema. */
.station-select select option,
.player-bar__mobile-select select option {
    background-color: var(--bg-elevated);
    color: var(--text-primary);
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e8543d;
    box-shadow: 0 0 0 0 rgba(232, 84, 61, 0.6);
    animation: pulse-live 2s var(--ease) infinite;
    flex-shrink: 0;
}

@keyframes pulse-live {
    0% { box-shadow: 0 0 0 0 rgba(232, 84, 61, 0.55); }
    70% { box-shadow: 0 0 0 8px rgba(232, 84, 61, 0); }
    100% { box-shadow: 0 0 0 0 rgba(232, 84, 61, 0); }
}

/* ================================ NAV TOGGLE ================================ */
.nav-toggle { display: inline-flex; }

@media (min-width: 960px) {
    .nav-toggle { display: none; }
}

.main-nav.is-open {
    display: block;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    padding: var(--sp-4);
}

.main-nav.is-open .main-nav__list {
    flex-direction: column;
    gap: var(--sp-1);
}

.main-nav.is-open .main-nav__list a {
    display: block;
    padding: var(--sp-3);
    border-radius: var(--radius-sm);
}

.main-nav.is-open .main-nav__list a:hover { background: var(--surface-hover); }

/* ============================== THEME TOGGLE ============================== */
.icon-moon { display: none; }
[data-theme='light'] .icon-sun { display: none; }
[data-theme='light'] .icon-moon { display: block; }

/* =============================== STATION CARD =============================== */
.station-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: transform var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease), border-color var(--t-base) var(--ease);
}

.station-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-glow);
    border-color: color-mix(in srgb, var(--accent) 50%, var(--border-strong));
}

.station-card__media {
    position: relative;
    aspect-ratio: 16 / 10;
    background: var(--bg-elevated-2);
}

.station-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.station-card__badges {
    position: absolute;
    top: var(--sp-3);
    left: var(--sp-3);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-2);
}

.station-card__live {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    background: rgba(10, 10, 16, 0.7);
    backdrop-filter: blur(6px);
    color: #fff;
    font-size: var(--fs-xs);
    font-weight: 600;
    padding: var(--sp-1) var(--sp-3);
    border-radius: var(--radius-full);
}

/* Una tercera parte del tamaño anterior: el logotipo de la emisora es lo
   importante aquí, este indicador es sólo un detalle secundario. */
.station-card__live img {
    display: block;
    height: 7px;
    width: auto;
}

.station-card__body {
    padding: var(--sp-5);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.station-card__body h3 {
    font-size: var(--fs-lg);
    color: var(--accent);
}

.station-card__tagline {
    font-size: var(--fs-sm);
    margin-bottom: var(--sp-3);
}

.station-card__genres {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    margin-bottom: var(--sp-4);
}

.station-card__genres li {
    font-size: var(--fs-xs);
    color: var(--text-tertiary);
    background: var(--bg-elevated-2);
    padding: 2px var(--sp-3);
    border-radius: var(--radius-full);
}

.station-card__now-playing {
    min-height: 2.6em;
    padding-top: var(--sp-3);
    border-top: 1px solid var(--border);
}

.station-card__song {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.station-card__artist {
    font-size: var(--fs-xs);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ================================= NOW CARD ================================= */
.now-card {
    display: flex;
    align-items: center;
    gap: var(--sp-5);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    margin-top: var(--sp-5);
}

.now-card__cover {
    width: 96px;
    height: 96px;
    border-radius: var(--radius-md);
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-elevated-2);
    box-shadow: var(--shadow-md);
}

.now-card__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.now-card__station {
    font-family: var(--font-display);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
    margin: 0 0 var(--sp-1);
}

.now-card__song {
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.now-card__artist {
    margin: 0;
}

.now-card__meta {
    font-size: var(--fs-xs);
    color: var(--text-tertiary);
    margin-top: var(--sp-2);
}

/* ================================ HISTORY LIST ================================ */
.ahora-suena__history h3 {
    font-size: var(--fs-md);
    margin-bottom: var(--sp-3);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    max-height: 360px;
    overflow-y: auto;
}

.history-list li:not(.history-list__empty) {
    display: flex;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: var(--sp-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
}

.history-list__empty {
    color: var(--text-tertiary);
    font-size: var(--fs-sm);
    padding: var(--sp-3);
}

.history-song { color: var(--text-primary); font-weight: 500; }
.history-time { color: var(--text-tertiary); font-size: var(--fs-xs); white-space: nowrap; }

/* ============================== TIMELINE CARD ============================== */
.timeline__card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--sp-4);
    transition: border-color var(--t-base) var(--ease);
}

.timeline__item.is-active .timeline__card {
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
}

.timeline__station {
    display: inline-block;
    font-size: var(--fs-xs);
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--sp-1);
}

.timeline__card h3 {
    font-size: var(--fs-base);
    margin-bottom: var(--sp-1);
}

.timeline__card p {
    font-size: var(--fs-sm);
    margin: 0;
}

/* ================================= ABOUT CARD ================================= */
.about__card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--sp-5);
}

.about__card h3 {
    font-size: var(--fs-base);
    color: var(--accent);
}

.about__card p { margin: 0; font-size: var(--fs-sm); }

/* ================================ CONTACT FORM ================================ */
.contact-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--sp-6);
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.form-row label {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-primary);
}

.form-row input,
.form-row select,
.form-row textarea {
    background: var(--bg-elevated-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--sp-3);
    color: var(--text-primary);
    resize: vertical;
    transition: border-color var(--t-fast) var(--ease);
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
    border-color: var(--accent);
}

.form-row input:invalid:not(:placeholder-shown) {
    border-color: #e8543d;
}

.hp-field {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.form-status {
    min-height: 1.4em;
    font-size: var(--fs-sm);
    margin: 0;
}

.form-status[data-state='success'] { color: #4bbf8a; }
.form-status[data-state='error'] { color: #e8543d; }

/* =================================== SOCIAL =================================== */
.social-list {
    display: flex;
    gap: var(--sp-3);
    margin-top: var(--sp-4);
}

.social-list a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}

.social-list a:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* ================================= PLAYER BAR ================================= */
.player-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-player);
    background: color-mix(in srgb, var(--bg-elevated) 96%, transparent);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    border-top: 1px solid var(--border);
}

.player-bar__inner {
    max-width: 1240px;
    margin-inline: auto;
    padding: var(--sp-3) var(--sp-4);
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: var(--sp-3);
}

.player-bar__track {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    min-width: 0;
}

.player-bar__cover {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-elevated-2);
}

.player-bar__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.player-bar__eq {
    position: absolute;
    inset: 0;
    display: none;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
    background: rgba(10, 10, 16, 0.55);
    padding-bottom: 6px;
}

.player-bar.is-playing .player-bar__eq { display: flex; }

.player-bar__eq i {
    width: 3px;
    background: #fff;
    border-radius: 1px;
    animation: waveform 0.9s ease-in-out infinite;
}
.player-bar__eq i:nth-child(2) { animation-duration: 1.2s; }
.player-bar__eq i:nth-child(3) { animation-duration: 0.7s; }
.player-bar__eq i:nth-child(4) { animation-duration: 1s; }

.player-bar__meta { min-width: 0; }

.player-bar__song,
.player-bar__artist,
.player-bar__station {
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-bar__song { font-size: var(--fs-sm); font-weight: 600; color: var(--text-primary); }
.player-bar__artist { font-size: var(--fs-xs); }
.player-bar__station { font-size: var(--fs-xs); color: var(--accent); display: none; }

.player-bar__controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-1);
}

.player-bar__buttons {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.btn-play {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--text-on-accent);
    border: none;
    box-shadow: var(--shadow-sm);
    transition: transform var(--t-fast) var(--ease);
}

.btn-play:hover { transform: scale(1.05); }
.btn-play:active { transform: scale(0.95); }

.icon-loading { animation: spin 1s linear infinite; }

@keyframes spin {
    to { transform: rotate(360deg); }
}

.player-bar__status {
    display: none;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-xs);
    color: var(--text-tertiary);
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-tertiary);
}

.status-dot[data-state='playing'] { background: #4bbf8a; }
.status-dot[data-state='connecting'] { background: #e8a33d; animation: pulse-live 1.4s ease-in-out infinite; }
.status-dot[data-state='error'] { background: #e8543d; }

.player-bar__volume {
    display: none;
    align-items: center;
    gap: var(--sp-2);
}

#volume-slider {
    width: 90px;
    accent-color: var(--accent);
}

.icon-vol-off { color: #e8543d; }

.player-bar__mobile-select {
    display: block;
}

.player-bar__mobile-select select {
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: var(--sp-2) var(--sp-3);
    color: var(--text-primary);
    font-size: var(--fs-xs);
    max-width: 92px;
}
