/* ==========================================
   1. Variáveis de Cores (Temas Claro e Escuro)
   ========================================== */
:root {
    --bg-color: #f4f7f6;
    --card-background: #ffffff;
    --text-main: #333333;
    --header-title: #2c3e50;
    --text-muted: #7f8c8d;
    --border-color: #ccc;
    --input-bg: #ffffff;
    --sidebar-bg: #ffffff;
}

[data-theme="dark"] {
    --bg-color: #121212;
    --card-background: #1e1e1e;
    --text-main: #f5f6fa;
    --header-title: #f5f6fa;
    --text-muted: #b2bec3;
    --border-color: #2d3436;
    --input-bg: #2d3436;
    --sidebar-bg: #1a1a1a;
}

/* ==========================================
   2. Configurações Gerais e Cores Base
   ========================================== */
body {
    font-family: Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    padding-bottom: 100px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

/* Cabeçalho Principal Fixo */
.main-sticky-header {
    position: sticky;
    top: 0;
    background-color: var(--bg-color);
    padding: 10px 0;
    z-index: 102;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 15px;
}

.main-sticky-header h1 {
    color: var(--header-title);
}

.main-sticky-header p {
    color: var(--text-muted);
}

/* ==========================================
   Menu Lateral (Sidebar) e Overlay
   ========================================== */
.sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100%;
    background-color: var(--card-background);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    transition: left 0.3s ease;
    z-index: 2000;
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar.open {
    left: 0;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1500;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.open {
    display: block;
    opacity: 1;
}

#closeSidebarBtn {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-main);
    cursor: pointer;
    padding: 0;
}

.sidebar .btn-menu-principal {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 12px 16px;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    box-sizing: border-box;
    text-align: left;
    gap: 10px;
    color: white;
}

.btn-explorar {
    background-color: #3498db;
}

.btn-trending {
    background-color: #e74c3c;
}

.btn-historico {
    background-color: #9b59b6;
}

.sidebar .theme-container {
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-radius: 6px;
    box-sizing: border-box;
    width: 100%;
    font-size: 15px;
    font-weight: 500;
}

/* ==========================================
   4. Caixa de Pesquisa e Filtros
   ========================================== */
.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    flex-wrap: wrap;
    align-items: center;
}

.search-box select {
    padding: 12px;
    font-size: 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--input-bg);
    color: var(--text-main);
    outline: none;
    min-width: 150px;
}

.search-box input[type="text"] {
    padding: 12px;
    font-size: 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--input-bg);
    color: var(--text-main);
    outline: none;
    max-width: 200px;
    flex: 1;
}

.search-box select option {
    background-color: var(--input-bg);
    color: var(--text-main);
}

.search-box button {
    padding: 12px 20px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s;
}

.search-box button:hover {
    background-color: #2980b9;
}

.btn-limpar-filtros-rapido {
    background-color: transparent;
    border: 1px dashed var(--border-color);
    color: var(--text-muted);
    padding: 11px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    display: none;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.btn-limpar-filtros-rapido:hover {
    background-color: rgba(231, 76, 60, 0.1);
    border-color: #e74c3c;
    color: #e74c3c;
}

/* ==========================================
   5. Grelha e Cartões de Rádios
   ========================================== */
.radio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.radio-card {
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
    position: relative;
}

.radio-card h3 {
    font-size: 15px;
    margin: 0 0 10px 0;
    color: var(--header-title);
}

.radio-card p {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0 0 15px 0;
}

.card-superfav-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    padding: 0;
    transition: transform 0.2s;
}

.card-superfav-badge:hover {
    transform: scale(1.15);
}

/* ==========================================
   6. Animações e Elementos Visuais Especiais
   ========================================== */
.loading {
    text-align: center;
    grid-column: 1 / -1;
    color: var(--text-muted);
    font-size: 16px;
}

@keyframes pulsar {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }

    100% {
        opacity: 1;
    }
}

.animating-pulse {
    animation: pulsar 1.2s infinite ease-in-out;
}

.equalizer {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 12px;
    vertical-align: middle;
    margin-right: 6px;
}

.equalizer span {
    display: block;
    width: 3px;
    background-color: yellow;
    animation: equalize 0.6s infinite alternate;
    border-radius: 1px;
}

.equalizer span:nth-child(1) {
    animation-delay: 0.1s;
}

.equalizer span:nth-child(2) {
    animation-delay: 0.3s;
}

.equalizer span:nth-child(3) {
    animation-delay: 0.2s;
}

@keyframes equalize {
    0% {
        height: 3px;
    }

    100% {
        height: 12px;
    }
}

#voiceSearchBtn {
    transition: background-color 0.2s, transform 0.1s;
}

#voiceSearchBtn:hover {
    background-color: #8e44ad !important;
}

#voiceSearchBtn.escutando {
    background-color: #e74c3c !important;
    animation: pulsar 1.2s infinite ease-in-out;
}

select.filtro-ativo {
    color: #2980b9 !important;
    font-weight: bold;
    border-color: #2980b9 !important;
}

body.dark-theme select.filtro-ativo,
.dark-theme select.filtro-ativo {
    color: #3498db !important;
    border-color: #3498db !important;
}

/* Cabeçalho dinâmico da lista e barra de navegação rápida */
.list-sticky-header {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 15px;
    padding: 10px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-main);

    position: sticky;
    top: 55px;
    background-color: var(--bg-color);
    z-index: 101;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

@media (max-width: 768px) {
    .list-sticky-header {
        top: 71px;
    }
}

.quick-nav-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-quick-nav {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s, transform 0.1s;
}

.btn-quick-nav:hover {
    background-color: rgba(128, 128, 128, 0.2);
    transform: scale(1.1);
}

.btn-quick-nav-style {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

#playingTitle {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    position: relative;
    font-size: 14px;
    color: #ffffff;
}

#playingTitle.marquee-active .marquee-content {
    display: inline-block;
    padding-left: 100%;
    animation: deslizarTexto 12s linear infinite;
    color: #ffffff;
}

@keyframes deslizarTexto {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-100%);
    }
}

/* Estilo para avisos flutuantes */
.toast-aviso {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #2c3e50;
    color: white;
    padding: 10px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    font-size: 14px;
    animation: fadeInOut 2.5s ease forwards;
}

@keyframes fadeInOut {
    0% {
        opacity: 0;
        transform: translate(-50%, 20px);
    }

    15% {
        opacity: 1;
        transform: translate(-50%, 0);
    }

    85% {
        opacity: 1;
        transform: translate(-50%, 0);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -20px);
    }
}

#songMetadata {
    font-size: 0.8rem;
    color: #f39c12;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==========================================
   7. Adaptação para Controlo Remoto (TV)
   ========================================== */

/* Garante que o visual normal não é alterado por cliques de rato ou toque */
button:focus,
.radio-card:focus,
.radio-item:focus,
input:focus,
select:focus {
    outline: none !important;
}

/* O destaque verde e o zoom só aparecem se o utilizador estiver a usar o teclado ou comando de TV */
body.keyboard-nav button:focus,
body.keyboard-nav .radio-card:focus,
body.keyboard-nav .radio-item:focus,
body.keyboard-nav input:focus,
body.keyboard-nav select:focus {
    outline: 4px solid #2ecc71 !important;
    background-color: var(--card-background) !important;
    border-color: #2ecc71 !important;
    transform: scale(1.03);
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.6);
    z-index: 10;
}