* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden; /* No scrollbars! Se achica todo automáticamente */
    background: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #0a0c0e 0%, #1a1d20 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0; /* Sin padding externo para maximizar la tarjeta */
}

/* El radio-container establece el contexto de medidas Container Queries (cqw, cqh, cqmin) */
.radio-container {
    width: 100%;
    height: 100%;
    container-type: size;
    container-name: player;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Variables fluidas dependientes del tamaño del contenedor padre */
.radio-card {
    --fs-lg: clamp(1rem, 6cqmin, 1.8rem);
    --fs-md: clamp(0.9rem, 4.5cqmin, 1.4rem);
    --fs-sm: clamp(0.7rem, 3.5cqmin, 1rem);

    --card-padding: clamp(8px, 4cqmin, 24px);
    --gap-size: clamp(8px, 4cqh, 20px);

    --play-size: clamp(35px, 20cqmin, 80px);
    --icon-size: clamp(1rem, 6cqmin, 2.5rem);

    --eq-height: clamp(15px, 10cqh, 55px);
    --eq-gap: clamp(2px, 1cqmin, 6px);
    --eq-width: clamp(2px, 1cqmin, 6px);

    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: linear-gradient(145deg, #1e2126, #16191e);
    padding: var(--card-padding);
    box-shadow: inset 0 0 0 1px rgba(220, 53, 69, 0.2);
    overflow: hidden;
}

/* HEADER */
.radio-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    width: 100%;
}

.station-info {
    display: flex;
    flex-direction: column;
    gap: clamp(2px, 1cqh, 8px);
    overflow: hidden;
    width: 100%;
}

.station-name {
    font-size: var(--fs-lg);
    font-weight: 800;
    background: linear-gradient(135deg, #dc3545, #ff4757);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.1;
}

.location-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(220, 53, 69, 0.15);
    padding: clamp(4px, 1cqh, 6px) clamp(8px, 2cqmin, 12px);
    border-radius: 40px;
    font-size: var(--fs-sm);
    color: #ff6b7c;
    border: 1px solid rgba(220, 53, 69, 0.3);
    white-space: nowrap;
    width: fit-content;
}

.weather-box {
    background: rgba(220, 53, 69, 0.08);
    border: 1px solid rgba(220, 53, 69, 0.25);
    border-radius: 12px;
    padding: clamp(4px, 2cqh, 8px) clamp(8px, 2cqmin, 14px);
    text-align: center;
    flex-shrink: 0;
}

.weather-temp {
    font-size: var(--fs-md);
    font-weight: 700;
    color: #dc3545;
}

.weather-desc {
    font-size: calc(var(--fs-sm) * 0.9);
    color: #9ca3af;
    margin-top: 2px;
}

/* PLAYER AREA */
.player-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    gap: var(--gap-size);
    min-height: 0; /* Importantísimo para que el Flex interno se encoja correctamente */
}

.equalizer {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: var(--eq-gap);
    height: var(--eq-height);
}

.equalizer-bar {
    width: var(--eq-width);
    background: linear-gradient(to top, #dc3545, #ff6b7c);
    border-radius: 2px;
    transition: height 0.1s ease;
}

.equalizer-bar:nth-child(1) { height: clamp(20%, 30%, 100%); animation: pulse 0.8s infinite alternate 0s; }
.equalizer-bar:nth-child(2) { height: clamp(30%, 50%, 100%); animation: pulse 0.8s infinite alternate 0.1s; }
.equalizer-bar:nth-child(3) { height: clamp(40%, 70%, 100%); animation: pulse 0.8s infinite alternate 0.2s; }
.equalizer-bar:nth-child(4) { height: clamp(25%, 45%, 100%); animation: pulse 0.8s infinite alternate 0.3s; }
.equalizer-bar:nth-child(5) { height: clamp(35%, 60%, 100%); animation: pulse 0.8s infinite alternate 0.4s; }
.equalizer-bar:nth-child(6) { height: clamp(20%, 40%, 100%); animation: pulse 0.8s infinite alternate 0.5s; }

@keyframes pulse {
    0% { transform: scaleY(0.4); opacity: 0.6; }
    100% { transform: scaleY(1); opacity: 1; }
}

.equalizer.paused .equalizer-bar {
    animation-play-state: paused;
    transform: scaleY(0.3);
    opacity: 0.4;
}

.play-btn {
    width: var(--play-size);
    height: var(--play-size);
    flex-shrink: 0;
    border-radius: 50%;
    background: linear-gradient(145deg, #dc3545, #b91c2c);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(220, 53, 69, 0.4);
    min-height: 35px;
    min-width: 35px;
}

.play-btn i {
    font-size: var(--icon-size);
    color: white;
    margin-left: 2px; 
}

.status-text {
    font-size: var(--fs-sm);
    color: #9ca3af;
    font-weight: 500;
}
.status-text.playing { color: #dc3545; }

.volume-control {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: clamp(4px, 2cqh, 6px) clamp(10px, 3cqmin, 16px);
    background: rgba(0, 0, 0, 0.3);
    border-radius: 40px;
}

.volume-control i {
    color: #dc3545;
    font-size: var(--fs-md);
}

.volume-slider {
    width: clamp(60px, 20cqmin, 120px);
    height: 4px;
    -webkit-appearance: none;
    background: rgba(220, 53, 69, 0.3);
    border-radius: 2px;
    outline: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #dc3545;
    cursor: pointer;
}

/* FOOTER */
.radio-footer {
    display: flex;
    gap: clamp(6px, 2cqmin, 12px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: clamp(8px, 3cqh, 16px);
    flex-shrink: 0;
    width: 100%;
}

.footer-btn {
    flex: 1;
    padding: clamp(6px, 2cqh, 10px);
    background: rgba(26, 29, 32, 0.9);
    border: 1px solid rgba(220, 53, 69, 0.35);
    border-radius: 40px;
    color: #e5e7eb;
    font-size: var(--fs-sm);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}

/* MODAL */
.modal {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.95); align-items: center; justify-content: center; z-index: 1000;
}
.modal-content {
    background: #1a1d20; padding: 20px; border-radius: 20px; width: 90%; max-width: 400px; border: 1px solid #dc3545;
}
.modal-content h3 { color: #dc3545; margin-bottom: 12px; font-size: 1.1rem; }
.modal-content textarea { width: 100%; padding: 10px; background: #0f1115; border: 1px solid #dc3545; border-radius: 10px; color: #fff; font-family: monospace; font-size: 0.8rem; margin-bottom: 12px; }
.modal-close { background: #dc3545; color: white; border: none; padding: 8px; border-radius: 20px; width: 100%; cursor: pointer; }

/* ================= CONTAINER QUERIES (Inteligentes) ================= */

/* Horizontal (ej: barrita inferior) */
@container player (min-width: 500px) and (max-height: 250px) {
    .radio-card { flex-direction: row; gap: 15px; }
    .radio-header { width: auto; flex: 1; border-right: 1px solid rgba(255,255,255,0.1); padding-right: 15px; }
    .location-badge { display: none; }
    .weather-box { display: none; }
    .player-area { flex-direction: row; flex: 2; border-right: 1px solid rgba(255,255,255,0.1); padding-right: 15px; }
    .equalizer { display: none; }
    .radio-footer { width: auto; flex-direction: column; flex: 1; border-top: 0; padding-top: 0; justify-content: center; gap: 6px; }
    .footer-btn { padding: 4px; font-size: 0.7rem; }
}

/* Extra pequeña altura (Micro barra) */
@container player (max-height: 120px) {
    .radio-card { flex-direction: row; gap: 10px; padding: 5px 15px; justify-content: space-around; }
    .radio-header { flex-direction: row; align-items: center; width: auto; flex: unset; }
    .weather-box, .location-badge, .status-text, .equalizer { display: none; }
    .player-area { flex-direction: row; flex: auto; justify-content: space-around; }
    .volume-control { padding: 4px 10px; }
    .radio-footer { width: auto; display: flex; flex-direction: row; align-items: center; border:0; padding: 0; }
    .footer-btn span { display: none; } 
    .footer-btn { padding: 6px; min-width: 30px; border-radius: 5px; }
}

/* Extra ancho pero alta altura */
@container player (min-width: 600px) and (min-height: 250px) {
    .radio-card { flex-direction: row; gap: 3vw; align-items: center;}
    .radio-header { width: 30%; flex-direction: column; justify-content: center; text-align: center; }
    .weather-box { align-self: center; margin-top: 10px;}
    .player-area { width: 40%; }
    .radio-footer { width: 30%; flex-direction: column; border-top: none; padding-top: 0; border-left: 1px solid rgba(255,255,255,0.1); padding-left: 2vw;}
}
