/* ============================================================
   Mirra Colorações Pro — Global CSS
   ============================================================ */

/* ---------- Variáveis — Modo Escuro (padrão) ---------- */
:root,
:root[data-theme="dark"] {
    --bg-base:             #0B0A0F;
    --bg-surface:          #15141A;
    --bg-elevated:         #1E1C26;

    --glass-bg:            rgba(30, 28, 38, 0.45);
    --glass-bg-hover:      rgba(30, 28, 38, 0.65);
    --glass-bg-active:     rgba(30, 28, 38, 0.85);
    --glass-border:        rgba(217, 197, 163, 0.12);
    --glass-border-hover:  rgba(217, 197, 163, 0.28);
    --glass-blur:          blur(20px) saturate(1.5);

    --text-primary:        #FFFFFF;
    --text-secondary:      #d1c5b1;
    --text-muted:          rgba(209, 197, 177, 0.45);

    --accent:              #eac25d;
    --accent-soft:         rgba(234, 194, 93, 0.12);
    --accent-border:       rgba(234, 194, 93, 0.35);

    --sphere-light:        rgba(234, 194, 93, 0.08);
    --sphere-dark:         rgba(20, 20, 25, 0.85);

    --success:             rgba(120, 220, 160, 0.90);
    --warning:             rgba(240, 200, 100, 0.90);
    --danger:              rgba(240, 100, 100, 0.90);

    --shadow-up:           -4px -4px 12px rgba(255,255,255,0.01), 4px 4px 16px rgba(0,0,0,0.5);
    --shadow-inset:        inset 2px 2px 6px rgba(0,0,0,0.4), inset -2px -2px 6px rgba(255,255,255,0.01);

    --radius-sm:  4px;
    --radius-md:  8px;
    --radius-lg:  12px;
    --radius-xl:  16px;
}

/* ---------- Variáveis — Modo Claro ---------- */
:root[data-theme="light"] {
    --bg-base:             #eae1dd;
    --bg-surface:          #f4efec;
    --bg-elevated:         #ffffff;

    --glass-bg:            rgba(255, 255, 255, 0.50);
    --glass-bg-hover:      rgba(255, 255, 255, 0.70);
    --glass-bg-active:     rgba(255, 255, 255, 0.85);
    --glass-border:        rgba(178, 142, 46, 0.2);
    --glass-border-hover:  rgba(178, 142, 46, 0.45);
    --glass-blur:          blur(28px) saturate(2);

    --text-primary:        #1E1C26;
    --text-secondary:      #575249;
    --text-muted:          rgba(87, 82, 73, 0.5);

    --accent:              #b28e2e;
    --accent-soft:         rgba(178, 142, 46, 0.12);
    --accent-border:       rgba(178, 142, 46, 0.35);

    --sphere-light:        rgba(255, 255, 255, 0.75);
    --sphere-dark:         rgba(80, 80, 120, 0.45);

    --success:             rgba(34, 160, 80, 0.90);
    --warning:             rgba(200, 140, 20, 0.90);
    --danger:              rgba(200, 50, 50, 0.90);

    --shadow-up:           -4px -4px 10px rgba(255,255,255,0.75), 4px 4px 14px rgba(160,165,200,0.45);
    --shadow-inset:        inset 2px 2px 6px rgba(160,165,200,0.4), inset -2px -2px 6px rgba(255,255,255,0.75);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', sans-serif;
    font-weight: 300;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-base);
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
    position: relative;
}

/* Gradientes de fundo para o glassmorphism ser visível */
body::before {
    content: '';
    position: fixed;
    top: -20%;
    right: -10%;
    width: 55vw;
    height: 55vw;
    border-radius: 50%;
    background: radial-gradient(circle, var(--sphere-light) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}
body::after {
    content: '';
    position: fixed;
    bottom: -15%;
    left: -10%;
    width: 45vw;
    height: 45vw;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(217, 197, 163, 0.06) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* Terceiro blob de cor */
.bg-blob {
    position: fixed;
    top: 50%;
    left: 35%;
    width: 30vw;
    height: 30vw;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(234, 194, 93, 0.04) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
    transform: translateY(-50%);
}

/* Garantir que todo conteúdo fique acima dos blobs */
nav, main, #toast-container, .modal-overlay { position: relative; z-index: 1; }

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; font-size: inherit; border: none; background: none; cursor: pointer; }
ul, ol { list-style: none; }

/* ---------- Tipografia ---------- */
h1, h2, h3, .display {
    font-family: 'Manrope', sans-serif;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--text-primary);
}

h1 { font-size: clamp(1.75rem, 4vw, 2.75rem); }
h2 { font-size: clamp(1.3rem, 2.5vw, 1.9rem); }
h3 { font-size: clamp(1rem, 1.8vw, 1.35rem); }

.display { font-size: clamp(2rem, 5vw, 3.5rem); font-weight: 600; }

.label-caps {
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 500;
    font-family: 'Manrope', sans-serif;
}

.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-accent    { color: var(--accent); }

/* ---------- Esferas decorativas ---------- */
.sphere {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    animation: float 8s ease-in-out infinite;
}
.sphere-clear {
    background: radial-gradient(circle at 35% 35%, rgba(255,255,255,0.85), rgba(255,255,255,0.10) 60%, transparent);
    border: 1px solid rgba(255,255,255,0.45);
    box-shadow: inset -4px -4px 12px rgba(255,255,255,0.2), 4px 4px 20px rgba(0,0,0,0.15);
}
.sphere-dark {
    background: radial-gradient(circle at 35% 35%, rgba(80,80,120,0.6), rgba(20,20,40,0.9));
    box-shadow: 4px 4px 20px rgba(0,0,0,0.4);
}
@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    33%       { transform: translateY(-18px) rotate(3deg); }
    66%       { transform: translateY(10px) rotate(-2deg); }
}

/* ---------- Navbar ---------- */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
    padding-block: 0.875rem;
    padding-inline: max(1.5rem, calc((100% - 1200px) / 2 + 1.5rem));
    background: rgba(13, 13, 20, 0.55);
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(24px) saturate(1.8);
    -webkit-backdrop-filter: blur(24px) saturate(1.8);
}

.nav-logo {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
    flex-shrink: 0;
}
.logo-mirra {
    font-family: 'Poppins', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}
.logo-pro {
    font-family: 'Poppins', sans-serif;
    font-size: 0.6rem;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--accent);
}

.nav-logo { justify-self: start; }
.nav-search { justify-self: center; width: 100%; max-width: 420px; min-width: 0; }
.nav-actions { display: flex; align-items: center; gap: 0.5rem; justify-self: end; }

.btn-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}
.btn-icon:hover { color: var(--accent); }
.btn-theme { font-size: 1rem; }

/* Avatar */
.nav-avatar-wrapper { position: relative; }
.btn-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--accent-border);
    transition: border-color 0.2s ease;
    cursor: pointer;
    background: var(--accent-soft);
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-avatar:hover { border-color: var(--accent); }
.avatar-img { width: 100%; height: 100%; object-fit: cover; }
.avatar-placeholder {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--accent);
    font-family: 'Poppins', sans-serif;
}
.avatar-menu,
.avatar-menu.glass-card {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    padding: 0.75rem;
    z-index: 200;
    background: rgba(26, 26, 38, 0.95);
    border: 1px solid var(--glass-border);
    box-shadow: 0 12px 32px rgba(0,0,0,0.55);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}
.avatar-menu-header {
    padding: 0.25rem 0.5rem 0.75rem;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.avatar-menu-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}
.avatar-menu-item {
    display: block;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    transition: background 0.15s ease, color 0.15s ease;
}
.avatar-menu-item:hover { background: var(--glass-bg-hover); color: var(--text-primary); }
.avatar-menu-logout { color: var(--danger); margin-top: 0.25rem; }
.avatar-menu-logout:hover { background: rgba(240,100,100,0.1); }

/* ---------- Layout principal ---------- */
.main-content {
    padding-top: 64px;
    min-height: calc(100vh - 64px);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ---------- Barra de nível (1–10) ---------- */
.nivel-bar { display: flex; gap: 3px; align-items: center; }
.nivel-bar-item {
    width: 20px; height: 6px; border-radius: 3px;
    background: var(--glass-border); transition: background 0.2s;
}
.nivel-bar-item.ativo { background: var(--accent); }

/* ---------- Estrelas ---------- */
.stars { display: flex; gap: 2px; }
.star { color: var(--text-muted); font-size: 0.9rem; }
.star.ativo { color: #F1C40F; }

/* ---------- Badges / Tags ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.04em;
    background: var(--accent-soft);
    border: 1px solid var(--accent-border);
    color: var(--accent);
}
.badge-rank {
    background: linear-gradient(135deg, rgba(200,198,232,0.2), rgba(200,198,232,0.05));
    border-color: var(--accent-border);
    font-size: 0.85rem;
    font-weight: 500;
}

/* ---------- Toast Notifications ---------- */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.toast {
    background: rgba(26, 26, 38, 0.85);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: var(--text-primary);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    font-size: 14px;
    max-width: 320px;
    box-shadow: var(--shadow-up);
}
.toast.show         { opacity: 1; transform: translateY(0); }
.toast-success      { border-color: var(--success); }
.toast-danger       { border-color: var(--danger); }
.toast-warning      { border-color: var(--warning); }

/* ---------- Footer ---------- */
.site-footer {
    padding: 1.5rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--glass-border);
}

/* ---------- Bottom Navigation (mobile only) ---------- */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(13, 13, 20, 0.96);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--glass-border);
    padding: 0.4rem 0 calc(0.4rem + env(safe-area-inset-bottom, 0));
    grid-template-columns: repeat(4, 1fr);
}
.mbn-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0.4rem 0.25rem;
    color: var(--text-muted);
    font-size: 0.68rem;
    line-height: 1;
    text-decoration: none;
    transition: color .15s;
    min-width: 0;
}
.mbn-item span {
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}
.mbn-item svg { flex-shrink: 0; opacity: 0.85; }
.mbn-item:hover { color: var(--text-secondary); }
.mbn-item.ativo {
    color: var(--accent);
    font-weight: 600;
}
.mbn-item.ativo svg { opacity: 1; }

@media (max-width: 768px) {
    .mobile-bottom-nav { display: grid; }
    /* Espaço extra no final pra conteúdo não ficar tapado pelo bottom nav */
    body { padding-bottom: 70px; }
    /* Esconde ícones do topo no mobile - duplicados no bottom nav */
    .nav-actions > a[href*="cartela"],
    .nav-actions > a[href*="favoritos"],
    .nav-actions > a[href*="calculadora"] { display: none; }
}

/* ---------- Scroll horizontal ---------- */
.scroll-x {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
}
.scroll-x::-webkit-scrollbar { display: none; }
.scroll-x > * { scroll-snap-align: start; flex-shrink: 0; }

/* ---------- Grids ---------- */
.grid-categorias {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
.grid-formulas {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

/* ---------- Responsividade ---------- */
@media (min-width: 480px) {
    .grid-categorias { grid-template-columns: repeat(3, 1fr); }
    .grid-formulas   { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 768px) {
    .nav-search { display: flex; }
    .container  { padding: 0 2rem; }
    .navbar     { padding-inline: max(2rem, calc((100% - 1200px) / 2 + 2rem)); }
}
@media (min-width: 900px) {
    .grid-formulas   { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 768px) {
    .navbar     { padding: 0.75rem 1rem; display: flex; justify-content: space-between; align-items: center; }
    .nav-search { display: none; }
    .nav-logo   { font-size: 1rem; }
}

/* Touch targets mínimos */
button, a, .chip { min-height: 44px; }
.btn-icon, .btn-avatar, .chip-filter { min-height: 36px; }

/* ---------- Seção genérica ---------- */
.section { padding: 2rem 0; }
.section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    gap: 1rem;
}
.section-link {
    font-size: 0.8rem;
    color: var(--accent);
    opacity: 0.8;
    transition: opacity 0.2s;
}
.section-link:hover { opacity: 1; }

/* ---------- Página vazia ---------- */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}
.empty-state h3 { margin-bottom: 0.5rem; color: var(--text-secondary); }

/* ---------- Grid 4 colunas balanceada ---------- */
.grid-formulas.grid-4col {
    grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 600px) {
    .grid-formulas.grid-4col {
        grid-template-columns: repeat(4, 1fr);
    }
}

