/* --- FUENTES LOCALES --- */
@font-face { font-family: 'Roboto'; font-style: normal; font-weight: 400; src: url('./fonts/roboto-regular.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Roboto'; font-style: normal; font-weight: 500; src: url('./fonts/roboto-medium.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Roboto'; font-style: normal; font-weight: 700; src: url('./fonts/roboto-bold.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Roboto Mono'; font-style: normal; font-weight: 400; src: url('./fonts/roboto-mono.woff2') format('woff2'); font-display: swap; }
@font-face {
    font-family: 'Material Symbols Rounded';
    font-style: normal;
    font-weight: 100 700; 
    src: url('./fonts/icons.woff2') format('woff2');
    font-display: block;
}

.material-symbols-rounded {
    font-family: 'Material Symbols Rounded';
    font-weight: normal; font-style: normal; font-size: 24px; line-height: 1; letter-spacing: normal; text-transform: none; display: inline-block; white-space: nowrap; word-wrap: normal; direction: ltr; -webkit-font-smoothing: antialiased;
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* --- GENERALES --- */
:root {
    --bg-color: #131314;
    --sidebar-bg: #1E1F20;
    --surface-color: #28292A;
    --primary-color: #A8C7FA;
    --primary-hover: #8AB4F8;
    --text-main: #E3E3E3;
    --text-secondary: #C4C7C5;
    --error-color: #F2B8B5;
    --border-color: #444746;
    --radius-lg: 24px;
    --radius-md: 12px;
    --transition: all 0.2s ease;
}

* {
    box-sizing: border-box; margin: 0; padding: 0;
    -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;
    -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; 
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--bg-color); color: var(--text-main);
    height: 100vh; display: flex; overflow: hidden;
}

/* --- SIDEBAR --- */
.sidebar {
    width: 320px; padding: 20px;
    background-color: var(--sidebar-bg);
    border-right: none; box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
    display: flex; flex-direction: column;
    flex-shrink: 0; z-index: 2;
}

/* --- HEADER / BRAND --- */
.brand {
    display: flex; align-items: center; line-height: 1; justify-content: center;
    margin-bottom: 20px; padding: 15px 20px; color: var(--text-main);
}
.brand span.highlight {
    font-size: 28px; font-weight: 700; margin-top: -3px; margin-right: 8px;
    background: linear-gradient(90deg, #4285F4, #9B72CB);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.brand h1 { margin: 0; font-size: 22px; font-weight: 500; }
.version-tag {
    margin-left: 8px; margin-top: 0; font-size: 0.7rem; font-family: 'Roboto Mono', monospace;
    color: var(--text-secondary); background: rgba(255,255,255,0.05);
    padding: 2px 6px; border-radius: 4px; border: 1px solid rgba(255,255,255,0.05);
}

/* --- BOTÓN INSTALAR PWA --- */
.btn-install {
    margin: 0 15px 15px 15px; padding: 10px 16px;
    background-color: rgba(168, 199, 250, 0.1); color: var(--primary-color);
    border: 1px solid rgba(168, 199, 250, 0.2); border-radius: 12px;
    font-family: 'Roboto', sans-serif; font-weight: 500; font-size: 0.9rem;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    gap: 8px; transition: all 0.2s ease; width: calc(100% - 30px);
}
.btn-install:hover { background-color: rgba(168, 199, 250, 0.2); border-color: var(--primary-color); }
.btn-install span { font-size: 20px; }

/* --- PROMPT iOS --- */
.ios-prompt {
    margin: 0 15px 15px 15px; padding: 12px;
    background-color: #2D2E30; border-left: 3px solid var(--primary-color);
    border-radius: 8px; font-size: 0.8rem; color: var(--text-secondary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3); animation: fadeIn 0.5s ease;
}
.ios-prompt p { margin-bottom: 8px; line-height: 1.4; }
.ios-prompt strong { color: var(--text-main); }
.ios-prompt button {
    background: none; border: none; color: var(--primary-color);
    font-weight: 500; font-size: 0.75rem; cursor: pointer; text-transform: uppercase; float: right;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }

/* --- LISTA --- */
.station-list { list-style: none; overflow-y: auto; flex: 1; padding-right: 5px; }
.station-item {
    display: flex; align-items: center; gap: 12px; padding: 14px 16px;
    margin-bottom: 8px; border-radius: var(--radius-md); cursor: pointer;
    transition: var(--transition); border: 1px solid transparent;
}
.station-item:hover { background-color: rgba(255, 255, 255, 0.05); }
.station-item.active { background-color: #004A77; border-color: var(--primary-color); color: var(--primary-color); }
.station-item.error {
    background-color: #000; box-shadow: inset 0 0 10px rgba(0,0,0,0.8);
    color: #5e5e5e; border: 1px solid #333;
}

/* Nombre + enlace al sitio (homepage) */
.station-name { flex: 1; min-width: 0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.station-home {
    flex-shrink: 0; font-size: 20px; padding: 6px; margin: -6px -6px -6px 0; border-radius: 50%;
    color: var(--text-secondary); text-decoration: none; cursor: pointer; transition: var(--transition);
}
.station-home:hover { color: var(--primary-color); background-color: rgba(255, 255, 255, 0.08); }
.station-item.active .station-home { color: var(--primary-color); }
.station-item.error .station-home { color: #5e5e5e; }

/* Carpetas */
.folder-item { margin-bottom: 8px; }
.folder-header {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 16px;
    background: none; border: none; border-radius: var(--radius-md); cursor: pointer;
    color: var(--text-secondary); font-family: 'Roboto', sans-serif; font-size: 0.8rem; font-weight: 500;
    letter-spacing: 0.08em; text-transform: uppercase; text-align: left; transition: var(--transition);
}
.folder-header:hover { background-color: rgba(255, 255, 255, 0.05); }
.folder-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-count { font-family: 'Roboto Mono', monospace; font-size: 0.7rem; opacity: 0.7; }
.folder-chevron {
    width: 7px; height: 7px; margin: 0 5px 3px 3px; flex-shrink: 0;
    border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
    transform: rotate(45deg); transition: transform 0.2s ease;
}
.folder-item.collapsed .folder-chevron { transform: rotate(-45deg); margin-bottom: 0; }
.folder-children { list-style: none; margin-left: 18px; padding-left: 8px; border-left: 2px solid var(--border-color); }
.folder-item.collapsed .folder-children { display: none; }

/* Mensajes de la lista (cargando / sin conexión) */
.list-message {
    display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 24px 16px;
    color: var(--text-secondary); font-size: 0.9rem; text-align: center;
}
.list-message button {
    padding: 8px 18px; border-radius: 100px; cursor: pointer; font-family: 'Roboto', sans-serif; font-weight: 500;
    color: var(--primary-color); background: rgba(168, 199, 250, 0.1); border: 1px solid rgba(168, 199, 250, 0.2);
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: #444746; border-radius: 3px; }

/* --- MAIN / PLAYER --- */
.main-content {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: radial-gradient(circle at top right, #1f2b3e 0%, transparent 40%); position: relative;
}

/* PLAYER CARD */
.player-card {
    width: 450px; max-width: 90%; padding: 40px 50px;
    display: flex; flex-direction: column; align-items: center; transition: all 0.3s ease;
    text-align: center; background-color: var(--sidebar-bg);
    border: none; border-radius: var(--radius-lg);
    box-shadow: 0px 4px 18px rgba(0, 0, 0, 0.55);
}

.album-art-placeholder {
    width: 140px; height: 140px; background: linear-gradient(135deg, #4285F4, #9B72CB);
    border-radius: 50%; margin-bottom: 20px; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.icon-art { font-size: 56px; color: #fff; }
.album-art-placeholder.playing { animation: pulse 2s infinite; }
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(168, 199, 250, 0.4); }
    70% { box-shadow: 0 0 0 20px rgba(168, 199, 250, 0); }
    100% { box-shadow: 0 0 0 0 rgba(168, 199, 250, 0); }
}

#stationName { 
    text-transform: uppercase; font-size: 1.5rem; margin-bottom: 24px;
    font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 100%; display: block; line-height: 1.2;
}

/* BADGE ESTADOS */
.current-info p {
    display: inline-block; padding: 6px 16px; border-radius: 100px; 
    font-size: 0.85rem; font-weight: 500; letter-spacing: 0.5px; margin-bottom: 24px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); font-family: 'Roboto', sans-serif;
    background-color: transparent; color: var(--text-secondary); border: 1px solid var(--border-color);
}
.current-info p.status-live {
    background-color: rgba(168, 199, 250, 0.15); color: #A8C7FA; 
    border-color: transparent; box-shadow: 0 0 15px rgba(168, 199, 250, 0.1); 
}
.current-info p.status-error {
    background-color: rgba(242, 184, 181, 0.1); color: #F2B8B5; border-color: transparent;
}
.current-info p.status-loading {
    background-color: rgba(255, 255, 255, 0.05); color: var(--text-main); border-color: rgba(255, 255, 255, 0.1);
}

.controls {
    display: flex; align-items: center; justify-content: center; gap: 25px; margin-bottom: 25px;
}
.btn-control {
    background: none; border: none; color: var(--text-main); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.btn-control span { font-size: 28px; }

.btn-main {
    background-color: var(--primary-color); color: #000; width: 64px; height: 64px;
    border-radius: 20px; box-shadow: 0 4px 12px rgba(168, 199, 250, 0.3);
}
.btn-main span { font-size: 32px; }
.btn-main:hover { background-color: var(--primary-hover); }

/* MD3 SLIDER */
.volume-wrapper { width: 100%; height: 40px; display: flex; align-items: center; }
.md3-slider { -webkit-appearance: none; width: 100%; height: 20px; background: transparent; cursor: pointer; }
.md3-slider:focus { outline: none; }
.md3-slider::-webkit-slider-runnable-track { width: 100%; height: 100%; background: transparent; border: none; border-radius: 2px; }
.md3-slider::-webkit-slider-thumb {
    -webkit-appearance: none; height: 16px; width: 16px; border-radius: 50%;
    background: var(--primary-color); margin-top: 2px; border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4); transition: transform 0.1s; z-index: 2;
}
.md3-slider::-moz-range-track { width: 100%; height: 4px; background: transparent; border-radius: 2px; border: none; }
.md3-slider::-moz-range-thumb {
    height: 16px; width: 16px; border: none; border-radius: 50%; background: var(--primary-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.4); transition: transform 0.1s;
}
.md3-slider:hover::-webkit-slider-thumb { transform: scale(1.15); }
.md3-slider:hover::-moz-range-thumb { transform: scale(1.15); }

/* VISUALIZER & LOADING */
.mini-visualizer { display: flex; align-items: flex-end; justify-content: center; gap: 3px; width: 24px; height: 24px; padding-bottom: 4px; }
.mini-visualizer .bar { width: 4px; background-color: var(--primary-color); border-radius: 2px; animation: miniBounce 1s infinite ease-in-out; }
@keyframes miniBounce { 0%, 100% { height: 4px; } 50% { height: 18px; } }
.mini-visualizer .bar:nth-child(1) { animation-delay: 0s; }
.mini-visualizer .bar:nth-child(2) { animation-delay: 0.2s; }
.mini-visualizer .bar:nth-child(3) { animation-delay: 0.4s; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.station-icon.loading { animation: spin 1s linear infinite; color: var(--primary-color); }

#btnMobileVol { display: none; }

/* --- RESPONSIVE MOBILE (V28 Final) --- */
@media (max-width: 850px) {
    body {
        display: grid;
        grid-template-rows: auto auto auto 1fr min-content;
        height: 100vh; height: 100dvh;
        overflow: hidden; 
    }

    .svg-radio { width: 28px; height: 28px; }

    /* Desempaquetar */
    .sidebar, .main-content, .player-card { display: contents; }

    /* F1: HEADER (Ajuste usuario: Sin sombra, padding corregido) */
    .brand {
        grid-row: 1; width: 100%; height: auto;
        background-color: var(--sidebar-bg); 
        margin: 0; padding: 10px 20px 5px 10px; /* Padding corregido */
        display: flex; align-items: center; justify-content: center; 
        z-index: 10; border-bottom: none;
        box-shadow: none; /* Sombra eliminada aquí */
    }

    /* F2: BADGE (Ajuste usuario: Con sombra) */
    .current-info {
        grid-row: 2; width: 100%; text-align: center;
        background-color: var(--sidebar-bg); 
        padding-bottom: 10px; /* Padding corregido */
        display: flex; justify-content: center; align-items: center; 
        z-index: 9;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.65); /* Sombra añadida aquí */
    }
    #stationName { display: none; }
    .current-info p { margin: 0 !important; font-size: 0.75rem; padding: 4px 12px; }

    /* F3: PROMPTS */
    .btn-install, .ios-prompt { grid-row: 3; margin: 5px 15px 10px 15px; }

    /* F4: LISTA SCROLL */
    .station-list {
        grid-row: 4; min-height: 0;
        overflow-y: auto; -webkit-overflow-scrolling: touch; 
        background: #141416; padding: 10px;
    }
    .station-item { background-color: rgba(255,255,255,0.03); margin-bottom: 10px; }

    /* F5: CONTROLES */
    .controls { 
        grid-row: 5; width: 100%;
        background: var(--sidebar-bg);
        display: flex; justify-content: center; align-items: center;
        gap: 40px; 
        margin: 0; 
        padding: 12px 0;
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.5); 
        z-index: 20;
    }

    .album-art-placeholder { display: none !important; }
    .btn-control { display: none; }
    #btnDesktopMute { display: none !important; }
    .station-item.error { border: none; } 

    /* BOTONES MÓVILES */
    #btnMobileVol { display: flex !important; width: 40px; height: 40px; color: var(--text-secondary); }
    #btnMobileVol span { font-size: 24px; }
    
    /* BOTÓN PLAY GRANDE (Regresado a la gloria) */
    .btn-control.btn-main { 
        display: flex !important; 
        width: 60px; /* Grande y cómodo */
        height: 60px; 
        border-radius: 50%; 
        box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    }
    .btn-control.btn-main span { font-size: 32px; } /* Icono más grande */
    
    #btnSleepTimer { display: flex !important; width: 40px; height: 40px; color: var(--text-secondary); }
    #btnSleepTimer span { font-size: 24px; }

    /* POPUP */
    .volume-wrapper {
        display: flex; position: absolute; bottom: 85px; /* Un pelín más arriba por el botón grande */
        left: 50%; transform: translateX(-50%) scale(0.9); width: 85%; height: 60px;
        background-color: #28292A; border: 1px solid var(--border-color); border-radius: 30px; 
        padding: 0 20px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); z-index: 100;
        opacity: 0; visibility: hidden; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .volume-wrapper.active { opacity: 1; visibility: visible; transform: translateX(-50%) scale(1); }
}