/* ==========================================================================
   MMM PLAYER — ESTILOS CUSTOMIZADOS (STYLE.CSS)
   Autor: Márcio Melo Martins
   Projeto: MMM Player (mmm.rio.br)
   ==========================================================================
   ÍNDICE DE MÓDULOS (MENU DE NAVEGAÇÃO INTERNA):
   1. VARIÁVEIS GLOBAIS E RESET DE ESTILOS
   2. CABEÇALHO & LOGO (HEADER)
   3. NAVEGAÇÃO & MENU DROPDOWN
   4. ESTRUTURA PRINCIPAL & SEÇÕES (APP CONTENT)
   5. CAMPO DE BUSCA & ALTERNADOR DE TEMA (LIGHT/DARK)
   6. CARTÕES, BANNERS & FORMULÁRIOS
   7. BOTÕES DE AÇÃO & ELEMENTOS INLINE
   8. MINI-PLAYER FIXO FLUTUANTE
   9. MODAIS OVERLAY & POPUPS
   10. RODAPÉ FIXO & SLIDE RSS
   11. REGRAS DE MODO ESCURO (DARK THEME OVERRIDES)
   ========================================================================== */

/* ==========================================================================
   1. VARIÁVEIS GLOBAIS E RESET DE ESTILOS
   ========================================================================== */
:root {
    --bg-dark: #f4f4f4;
    --bg-card: #ffffff;
    --text-dark: #111111;
    --text-muted: #666666;
    --accent: #ff5500;
    --border-light: #e0e0e0;
    --btn-black: #111111;
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; 
}

body {
    background-color: var(--bg-dark);
    color: var(--text-dark);
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px));
}


/* ==========================================================================
   2. CABEÇALHO & LOGO (HEADER)
   ========================================================================== */
.app-header {
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-light, #e0e0e0);
    padding: 10px 20px;
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    width: 100%;
}

.header-container {
    width: 100%;
    max-width: 650px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    background: transparent !important;
    padding: 0;
    border: none;
    outline: none;
}

.logo-img {
    height: 36px;
    width: auto;
    display: block;
    object-fit: contain;
}


/* ==========================================================================
   3. NAVEGAÇÃO & MENU DROPDOWN
   ========================================================================== */
.nav-tabs { 
    display: flex; 
    align-items: center;
    gap: 6px; 
    overflow: visible !important;
}

.tab-btn { 
    background: transparent; 
    border: none; 
    color: var(--text-muted, #666); 
    padding: 6px 12px; 
    cursor: pointer; 
    font-size: 0.88rem; 
    border-radius: 16px; 
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: background 0.2s, color 0.2s;
}

.tab-btn.active { 
    background-color: var(--btn-black, #111); 
    color: #ffffff; 
}

/* ESTRUTURA DO DROPDOWN SUSPENSO */
.dropdown-menu {
    position: relative;
    display: inline-block;
}

.dropdown-trigger {
    background-color: #f0f0f0;
    border: 1px solid var(--border-light, #ccc);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    outline: none;
}

.dropdown-arrow {
    font-size: 0.75rem;
    color: #111111;
    transition: color 0.2s;
}

.dropdown-trigger:hover {
    background-color: #e0e0e0;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 6px;
    background-color: #ffffff;
    min-width: 150px;
    box-shadow: 0px 8px 20px rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 6px;
    z-index: 2000;
}

.dropdown-menu:hover .dropdown-content,
.dropdown-menu:focus-within .dropdown-content,
.dropdown-menu.open .dropdown-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dropdown-item {
    display: flex !important;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: transparent;
    border-radius: 8px;
    text-align: left;
    font-size: 0.9rem;
    cursor: pointer;
    color: #334155;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background-color: #f8fafc;
    color: #0f172a;
}


/* ==========================================================================
   4. ESTRUTURA PRINCIPAL & SEÇÕES (APP CONTENT)
   ========================================================================== */
.app-content { 
    padding: 20px; 
    max-width: 650px; 
    margin: 0 auto; 
    width: 100%; 
    padding-bottom: calc(160px + env(safe-area-inset-bottom, 0px));
}

.page-section { 
    display: none; 
}

.page-section.active { 
    display: block; 
}

.section-subtitle { 
    font-size: 0.75rem; 
    color: var(--text-muted); 
    letter-spacing: 1px; 
    font-weight: 600; 
    text-transform: uppercase; 
    margin-bottom: 4px; 
}

h2 { 
    font-size: 1.8rem; 
    font-weight: 700; 
    margin-bottom: 16px; 
    color: var(--text-dark); 
}

.back-link { 
    font-size: 0.9rem; 
    color: var(--text-muted); 
    text-decoration: none; 
    cursor: pointer; 
    display: inline-block; 
    margin-bottom: 12px; 
}

.section-title { margin-bottom: 12px; }
.section-gap { margin-bottom: 30px; }
.section-divider {
    border: 0;
    border-top: 1px solid var(--border-light);
    margin: 25px 0;
}

.prose-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#page-sobre .prose-stack > .light-card {
    flex-shrink: 0;
    width: 100%;
}

/* ==========================================================================
   5. CAMPO DE BUSCA & ALTERNADOR DE TEMA (LIGHT/DARK)
   ========================================================================== */
.search-and-theme-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    width: 100%;
}

.search-box-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.95rem;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input-field {
    width: 100%;
    padding: 12px 16px 12px 40px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    font-size: 0.95rem;
    color: var(--text-dark);
    outline: none;
    transition: border-color 0.2s;
}

.search-input-field:focus {
    border-color: var(--btn-black);
}

.theme-toggle-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    background-color: var(--bg-card);
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.1s;
}

.theme-toggle-btn:active {
    transform: scale(0.95);
}


/* ==========================================================================
   6. CARTÕES, BANNERS & FORMULÁRIOS
   ========================================================================== */
.create-playlist-banner {
    background-color: var(--btn-black);
    color: #ffffff;
    padding: 16px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    margin-bottom: 20px;
}

.plus-icon { 
    font-size: 1.5rem; 
    background: rgba(255,255,255,0.2); 
    width: 36px; 
    height: 36px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    border-radius: 50%; 
}

.list-container { 
    display: flex; 
    flex-direction: column; 
    gap: 10px; 
}

.light-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.light-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-light);
    border-radius: 20px;
    background-color: var(--bg-card);
    color: var(--text-dark);
    font-size: 0.95rem;
    outline: none;
    margin-bottom: 12px;
}

.pix-box {
    background: var(--bg-dark);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 18px 14px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 6px;
}

.pix-box-label {
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.72rem;
    font-weight: bold;
}

.pix-key-input {
    width: 100%;
    max-width: 320px;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--border-light);
    background: var(--bg-card);
    color: var(--text-dark);
    font-family: monospace;
    font-size: 0.9rem;
    text-align: center;
}

/* ==========================================================================
   AJUSTE DE ESPAÇAMENTO DA IMAGEM E CONTEÚDO DOS CARTÕES DE FAIXA
   ========================================================================== */

/* Imagem da capa com espaçamento fixo e cantos arredondados */
.track-thumb {
    width: 60px;
    height: 60px;
    min-width: 60px;
    object-fit: cover;
    border-radius: 8px;
    margin-right: 14px; /* Garante o respiro em relação ao texto */
    flex-shrink: 0;
}

/* Garante espaço entre os elementos internos do cartão */
.track-card {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Organização do texto das músicas */
.track-info {
    flex: 1;
    min-width: 0;
    padding-right: 8px;
}
.sheet-panel {
    background: var(--bg-card);
    color: var(--text-dark);
    width: min(720px, 100%);
    max-height: calc(85vh - 110px);
    overflow: auto;
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-light);
}

.sheet-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    position: sticky;
    top: 0;
    background: var(--bg-card);
    padding-bottom: 12px;
    z-index: 10;
}

.sheet-panel-header small,
.sheet-panel small {
    color: var(--text-muted);
}

.modal-add-list-container {
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    background: var(--bg-dark);
    padding: 4px;
}

/* ==========================================================================
   7. BOTÕES DE AÇÃO & ELEMENTOS INLINE
   ========================================================================== */
.btn-dark-pill {
    background-color: var(--btn-black);
    color: #ffffff;
    border: none;
    padding: 12px 20px;
    border-radius: 24px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.btn-gray { 
    background-color: #e0e0e0; 
    color: var(--text-dark); 
    border: none; 
    padding: 10px 20px; 
    border-radius: 20px; 
    cursor: pointer; 
    font-weight: 600; 
}

.like-btn {
    background: none;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 2px 8px;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.8rem;
    margin-left: 6px;
}

.track-actions-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-icon-btn, .play-icon-btn, .action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #f0f0f0;
    border: none;
    font-size: 0.95rem;
    color: var(--text-dark);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
}

.action-icon-btn:hover, .play-icon-btn:hover, .action-icon:hover {
    background: #e0e0e0;
}

.play-icon-btn {
    color: var(--accent);
}


/* ==========================================================================
   8. MINI-PLAYER FIXO FLUTUANTE
   ========================================================================== */
.mini-player { 
    position: fixed; 
    left: 50%;
    transform: translateX(-50%);
    width: min(92%, 650px);
    max-width: 650px;
    bottom: calc(36px + env(safe-area-inset-bottom, 0px));
    background: #1e1e1e; 
    color: #ffffff;
    border: 1px solid #333; 
    padding: 12px 20px; 
    border-radius: 28px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
    z-index: 1000; 
}

.mini-player.hidden { 
    display: none; 
}

.mini-player .player-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.88rem;
}

.mini-player .player-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
}

.mini-player .player-controls button {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 1.2rem;
    padding: 6px 10px;
    cursor: pointer;
}

.mini-player .player-controls input[type="range"] {
    flex: 1;
    height: 24px;
    max-width: 320px;
    cursor: pointer;
    accent-color: var(--accent);
}

/* ==========================================================================
   9. MODAIS OVERLAY & POPUPS
   ========================================================================== */
.modal-overlay {
    position: fixed; 
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex; 
    align-items: center; 
    justify-content: center; 
    z-index: 2000;
}

.modal-overlay.hidden { 
    display: none; 
}

.modal-content {
    background: var(--bg-card);
    color: var(--text-dark);
    padding: 24px;
    border-radius: 20px;
    max-width: 400px;
    width: 90%;
    position: relative;
    text-align: center;
    border: 1px solid var(--border-light);
}

.modal-close { 
    position: absolute; 
    top: 12px; 
    right: 16px; 
    border: none; 
    background: none; 
    font-size: 1.5rem; 
    cursor: pointer;
    color: var(--text-dark);
}

.modal-icon { 
    font-size: 2.5rem; 
    margin-bottom: 10px; 
}

.modal-content h3 {
    color: var(--text-dark);
}

.modal-content p,
.modal-content .sub-text { 
    font-size: 0.9rem; 
    color: var(--text-muted); 
    margin: 12px 0; 
    text-align: left; 
}

.full-width { 
    width: 100%; 
    margin-top: 10px; 
}

/* TOAST NOTIFICATION FLUTUANTE */
.toast-notification {
    position: fixed;
    bottom: calc(96px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    background: rgba(17, 17, 17, 0.9);
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.85rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    z-index: 3000;
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 1;
    pointer-events: none;
    white-space: nowrap;
}

.toast-notification.hidden {
    opacity: 0;
    transform: translate(-50%, 10px);
}


/* ==========================================================================
   10. RODAPÉ FIXO & SLIDE RSS
   ========================================================================== */
.app-footer { 
    position: fixed; 
    bottom: 0; 
    left: 0; 
    right: 0; 
    height: calc(32px + env(safe-area-inset-bottom, 0px)); 
    background: #ffffff; 
    border-top: 1px solid var(--border-light); 
    display: flex; 
    align-items: center; 
    justify-content: center;
    padding: 0 15px env(safe-area-inset-bottom, 0px); 
    font-size: 0.8rem; 
    color: var(--text-muted); 
    z-index: 900;
    overflow: hidden;
    white-space: nowrap;
}

.rss-slide-container {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease-in-out;
    opacity: 1;
    transform: translateX(0);
    will-change: transform, opacity;
}

.rss-slide-out {
    opacity: 0;
    transform: translateX(-50px);
}

.rss-slide-in {
    opacity: 0;
    transform: translateX(50px);
}


/* ==========================================================================
   11. REGRAS DE MODO ESCURO (DARK THEME OVERRIDES)
   ========================================================================== */
body.dark-theme {
    --bg-dark: #121212;
    --bg-card: #1e1e1e;
    --text-dark: #f1f1f1;
    --text-muted: #aaaaaa;
    --border-light: #2d2d2d;
    --btn-black: #2a2a2a;
    background-color: #121212;
    color: #f1f1f1;
}

body.dark-theme .app-header,
body.dark-theme .app-footer,
body.dark-theme .dropdown-content {
    background-color: #1a1a1a;
    border-color: #2d2d2d;
}

body.dark-theme .dropdown-trigger {
    background-color: #2a2a2a;
    border-color: #3d3d3d;
}

body.dark-theme .dropdown-arrow {
    color: #ffffff;
}

body.dark-theme .dropdown-trigger:hover {
    background-color: #3a3a3a;
}

body.dark-theme .dropdown-item {
    color: #e2e8f0;
}

body.dark-theme .dropdown-item:hover {
    background-color: #2a2a2a;
}

body.dark-theme .search-input-field,
body.dark-theme .light-card,
body.dark-theme .theme-toggle-btn {
    background-color: #1e1e1e;
    color: #ffffff;
    border-color: #333333;
}

body.dark-theme .action-icon-btn, 
body.dark-theme .play-icon-btn, 
body.dark-theme .action-icon {
    background: #2a2a2a;
    color: #ffffff;
}

/* SOBRESSCRITA DE CORES PARA CONTEÚDO DE CARDS NO DARK MODE (SOBRE, FAQ, PRIVACIDADE) */
body.dark-theme .light-card,
body.dark-theme .light-card p,
body.dark-theme .light-card span,
body.dark-theme .light-card strong,
body.dark-theme .light-card summary,
body.dark-theme .light-card small,
body.dark-theme .light-card div {
    color: #e2e8f0 !important;
}

body.dark-theme .light-card small,
body.dark-theme .light-card p[style*="color: #666"],
body.dark-theme .light-card p[style*="color: #555"] {
    color: #cbd5e1 !important;
}

body.dark-theme summary {
    color: #f8fafc !important;
}

body.dark-theme details > div,
body.dark-theme .light-card div[style*="border-top"],
body.dark-theme .light-card div[style*="border-bottom"] {
    border-color: #334155 !important;
}

body.dark-theme div[style*="background: #fffdf5"] {
    background: #272010 !important;
    border-left-color: #eab308 !important;
}

body.dark-theme div[style*="background: #fffdf5"] p {
    color: #fef08a !important;
}
/* ==========================================================================
   AJUSTE DE CONTRASTE PARA BOTÕES DE LINK E AÇÃO NO MODO ESCURO
   ========================================================================== */

/* Botões de links externos e ações dentro dos cards */
body.dark-theme .light-card[onclick],
body.dark-theme .light-card a,
body.dark-theme a.light-card,
body.dark-theme .btn-dark-pill,
body.dark-theme .btn-gray {
    background-color: #2a2a2a !important;
    border-color: #3d3d3d !important;
    color: #ffffff !important;
}

/* Força a cor dos textos e subtítulos internos desses botões */
body.dark-theme .light-card[onclick] strong,
body.dark-theme .light-card a strong,
body.dark-theme a.light-card strong,
body.dark-theme .light-card[onclick] span,
body.dark-theme .light-card a span,
body.dark-theme a.light-card span {
    color: #ffffff !important;
}

body.dark-theme .light-card[onclick] small,
body.dark-theme .light-card a small,
body.dark-theme a.light-card small,
body.dark-theme .light-card[onclick] p,
body.dark-theme .light-card a p,
body.dark-theme a.light-card p {
    color: #cbd5e1 !important; /* Cinza claro bem legível para descrições */
}

/* Efeito ao passar o cursor ou tocar no botão */
body.dark-theme .light-card[onclick]:hover,
body.dark-theme .light-card a:hover,
body.dark-theme a.light-card:hover {
    background-color: #333333 !important;
    border-color: #4b5563 !important;
}

/* ==========================================================================
   ANIMAÇÃO DE CARREGAMENTO PARA BOTÕES DE AÇÃO (FEEDBACK VISUAL)
   ========================================================================== */

/* Animação de rotação contínua */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spinner-icon {
    display: inline-block;
    animation: spin 1s linear infinite;
    margin-right: 6px;
}

/* Estilo do botão em estado de verificação/espera */
button[data-verificando="true"] {
    opacity: 0.8 !important;
    cursor: wait !important;
}

/* --------------------------------------------------------------------------
   12. RESPONSIVO + PWA (desktop vs smartphone)
   -------------------------------------------------------------------------- */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

@media (max-width: 420px) {
    .tab-btn {
        padding: 6px 8px;
        font-size: 0.8rem;
    }
    .header-container,
    .app-content {
        padding-left: 12px;
        padding-right: 12px;
    }
    .track-thumb {
        width: 52px;
        height: 52px;
        min-width: 52px;
        margin-right: 10px;
    }
}

/* Desktop: abre o layout sem mexer no mobile */
@media (min-width: 769px) {
    .header-container,
    .app-content {
        max-width: 1040px;
    }

    .cards-grid,
    .list-container {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px 16px;
    }

    .mini-player {
        width: min(92%, 720px);
        max-width: 720px;
        bottom: calc(44px + env(safe-area-inset-bottom, 0px));
    }

    #page-offline .header-with-info,
    #page-offline .offline-actions,
    #offline-tracks-list.list-container {
        max-width: 760px;
    }
}

@media (min-width: 1200px) {
    .header-container,
    .app-content {
        max-width: 1120px;
    }

    .list-container {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

#page-offline .header-with-info,
#page-offline .offline-actions {
    max-width: 720px;
}

#offline-tracks-list.list-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 720px;
}

#offline-tracks-list .offline-summary {
    margin-bottom: 4px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

body.dark-theme .modal-overlay {
    background: rgba(0, 0, 0, 0.72);
}

body.dark-theme .modal-content {
    background: var(--bg-card) !important;
    color: var(--text-dark) !important;
    border: 1px solid var(--border-light) !important;
}

body.dark-theme .modal-content h3 {
    color: #f8fafc !important;
}

body.dark-theme .modal-content p,
body.dark-theme .modal-content .sub-text {
    color: #cbd5e1 !important;
}

body.dark-theme .modal-close {
    color: #e2e8f0 !important;
}
