/* ============================================================
   MANGABA AAAS - GLOBAL STYLES
   Paleta inspirada na fruta Mangaba
   Verde folha, amarelo dourado, laranja suave, marrom amadurecido
   ============================================================ */

:root {
    /* Cores de fundo - Tema natural escuro */
    --bg-primary: #0d1210;
    --bg-secondary: #131a16;
    --bg-tertiary: #1a2420;
    --bg-card: rgba(255,255,255,0.03);
    --bg-glass: rgba(255,255,255,0.05);
    --bg-hover: rgba(255,255,255,0.08);
    
    /* Cores da Fruta Mangaba */
    --mangaba-green: #4a7c59;         /* Verde folha da mangabeira */
    --mangaba-green-light: #6b9b7a;   /* Verde claro */
    --mangaba-green-dark: #2d5a3d;    /* Verde escuro */
    --mangaba-yellow: #e6c35c;        /* Amarelo dourado da fruta madura */
    --mangaba-gold: #d4a84b;          /* Dourado */
    --mangaba-orange: #d4894b;        /* Laranja suave da fruta */
    --mangaba-cream: #f5e6c8;         /* Creme da polpa */
    --mangaba-brown: #8b6b4a;         /* Marrom amadurecido */
    
    /* Cores de acento - Paleta Mangaba */
    --mangaba-primary: #4a7c59;       /* Verde principal */
    --mangaba-secondary: #e6c35c;     /* Amarelo dourado */
    --mangaba-accent: #d4894b;        /* Laranja suave */
    --accent-green: #4a7c59;
    --accent-green-light: #6b9b7a;
    --accent-yellow: #e6c35c;
    --accent-gold: #d4a84b;
    --accent-orange: #d4894b;
    --accent-cream: #f5e6c8;
    --accent-brown: #8b6b4a;
    --accent-emerald: #10b981;
    --accent-red: #ef4444;

    /* Compat: tokens antigos (alias Mangaba) */
    --accent-purple: var(--mangaba-green);
    --accent-cyan: var(--mangaba-yellow);
    --accent-fuchsia: var(--mangaba-orange);
    --focus-ring: rgba(74, 124, 89, 0.35);
    
    /* Texto */
    --text-primary: #ffffff;
    --text-secondary: #e5e7eb;
    --text-muted: #9ca3af;
    --text-subtle: #6b7280;
    
    /* Bordas */
    --border-subtle: rgba(255,255,255,0.06);
    --border-light: rgba(255,255,255,0.1);
    --border-active: rgba(74, 124, 89, 0.5);
    
    /* Gradientes principais - Cores da Mangaba */
    --gradient-primary: linear-gradient(135deg, #4a7c59 0%, #e6c35c 50%, #d4894b 100%);
    --gradient-button: linear-gradient(135deg, #4a7c59 0%, #6b9b7a 100%);
    --gradient-glow: linear-gradient(135deg, rgba(74,124,89,0.4), rgba(230,195,92,0.4));
    --gradient-fruit: linear-gradient(135deg, #6b9b7a 0%, #e6c35c 50%, #d4894b 100%);
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 30px rgba(74, 124, 89, 0.3);
}

/* Reset e Base */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-secondary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* Background decorativo - estilo Mangaba natural */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: 
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(74,124,89,0.15), transparent),
        radial-gradient(ellipse 60% 40% at 100% 0%, rgba(230,195,92,0.1), transparent),
        radial-gradient(ellipse 50% 30% at 0% 100%, rgba(212,137,75,0.08), transparent);
    pointer-events: none;
    z-index: -1;
}

/* Scrollbar personalizada - estilo Mangaba */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: var(--mangaba-primary);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--mangaba-secondary);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--mangaba-primary) var(--bg-secondary);
}

/* Classes utilitárias */
.glass {
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
    transform: translateY(-2px);
    border-color: var(--border-active);
    box-shadow: var(--shadow-glow);
}

.pill {
    background: linear-gradient(120deg, rgba(74,124,89,0.18), rgba(230,195,92,0.16));
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 9999px;
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.gradient-text {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.glow-purple {
    box-shadow: 0 0 30px rgba(74, 124, 89, 0.35);
}

.glow-cyan {
    box-shadow: 0 0 30px rgba(230, 195, 92, 0.25);
}

.glow-fuchsia {
    box-shadow: 0 0 30px rgba(212, 137, 75, 0.25);
}

/* Animações */
@keyframes pulse-glow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.animate-pulse-glow {
    animation: pulse-glow 2s ease-in-out infinite;
}

.animate-float {
    animation: float 6s ease-in-out infinite;
}

/* Sidebar fixa com scroll no conteúdo */
.sidebar-fixed {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 40;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
    z-index: 35;
}

.sidebar-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}

body.sidebar-open {
    overflow: hidden;
}

.mobile-topbar {
    display: none;
}

.icon-btn {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.10);
    color: white;
    cursor: pointer;
    transition: all 0.15s ease;
}

.icon-btn:hover {
    background: rgba(255,255,255,0.10);
    border-color: rgba(255,255,255,0.18);
}

.sidebar-close {
    display: none;
}

.main-content {
    margin-left: 18rem; /* 72 * 4px = 288px = 18rem */
    min-height: 100vh;
    padding-bottom: 4rem;
}

@media (max-width: 1024px) {
    .mobile-topbar {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 4.75rem;
        align-items: center;
        justify-content: space-between;
        padding: 0.75rem 1rem;
        z-index: 45;
        background: rgba(13, 18, 16, 0.75);
        border-bottom: 1px solid rgba(255,255,255,0.08);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
    }

    .sidebar-close {
        display: inline-flex;
        margin-left: auto;
    }

    .sidebar-fixed {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar-fixed.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }

    .app-shell:not(.no-sidebar) .main-content {
        padding-top: 5.5rem;
    }
}

/* Botões - Estilo Mangaba */
.btn-primary {
    background: var(--gradient-button);
    color: white;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 8px 28px rgba(74, 124, 89, 0.28);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 38px rgba(74, 124, 89, 0.36);
    filter: brightness(1.1);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-outline:focus-visible,
.btn-ghost:focus-visible,
.nav-link:focus-visible {
    outline: 2px solid var(--mangaba-secondary);
    outline-offset: 3px;
}

.is-copied {
    color: #34d399 !important;
}

.btn-secondary {
    background: var(--bg-glass);
    color: white;
    border: 1px solid var(--border-light);
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--mangaba-primary);
}

.btn-outline {
    background: transparent;
    color: var(--mangaba-primary);
    border: 1px solid var(--mangaba-primary);
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-outline:hover {
    background: rgba(74, 124, 89, 0.12);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: white;
}

/* Formulários */
.input-field {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    color: white;
    transition: all 0.2s ease;
}

.input-field:focus {
    outline: none;
    border-color: var(--mangaba-primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.input-field::placeholder {
    color: var(--text-muted);
}

/* Tabelas */
.table-dark {
    width: 100%;
    border-collapse: collapse;
}

.table-dark th {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table-dark td {
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.table-dark tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* Badges e Tags */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-economy {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-standard {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-premium {
    background: rgba(168, 85, 247, 0.15);
    color: #c4b5fd;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.badge-ultra {
    background: rgba(245, 158, 11, 0.15);
    color: #fcd34d;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Logo Component */
.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 1rem;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-fuchsia), var(--accent-cyan));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(74, 124, 89, 0.28);
    overflow: hidden;
}

.logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: white;
    line-height: 1.2;
}

.logo-subtitle {
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--text-muted);
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    min-width: 260px;
    max-width: min(440px, calc(100vw - 2.5rem));
    background: rgba(17, 24, 39, 0.55);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 0.95rem;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    transform: translateY(0);
    opacity: 1;
    transition: transform 180ms ease, opacity 180ms ease;
}

.toast--success {
    border-color: rgba(16, 185, 129, 0.35);
}

.toast--info {
    border-color: rgba(230, 195, 92, 0.35);
}

.toast--error {
    border-color: rgba(239, 68, 68, 0.35);
}

.toast--hide {
    opacity: 0;
    transform: translateY(8px);
}

.toast__inner {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.9rem 1rem;
}

.toast__icon {
    margin-top: 0.15rem;
    color: var(--accent-emerald);
}

.toast--info .toast__icon {
    color: var(--mangaba-secondary);
}

.toast--error .toast__icon {
    color: var(--accent-red);
}

.toast__message {
    flex: 1;
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.35;
}

.toast__close {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    padding: 0.25rem 0.35rem;
    border-radius: 0.5rem;
}

.toast__close:hover {
    background: rgba(255,255,255,0.08);
    color: white;
}

/* Background decorativo fixo */
.bg-decoration {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

.bg-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
}

.bg-blob-1 {
    width: 20rem;
    height: 20rem;
    background: var(--accent-purple);
    opacity: 0.25;
    top: 5%;
    left: -5%;
}

.bg-blob-2 {
    width: 24rem;
    height: 24rem;
    background: var(--accent-cyan);
    opacity: 0.2;
    top: -10%;
    right: 0;
}

.bg-blob-3 {
    width: 28rem;
    height: 28rem;
    background: var(--accent-fuchsia);
    opacity: 0.15;
    bottom: 0;
    left: 30%;
}

/* App shell */
.app-shell {
    position: relative;
    min-height: 100vh;
    background: var(--bg-primary);
    color: var(--text-secondary);
}

.bg-decoration .bg-blob {
    animation: pulse-glow 10s ease-in-out infinite alternate;
}

.logo-mark {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.9rem;
    background: var(--gradient-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
}

/* Sidebar */
.sidebar-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.9rem;
    color: var(--text-muted);
    text-decoration: none;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.nav-link i {
    width: 1.25rem;
    text-align: center;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    border-color: var(--border-light);
}

.nav-link.active {
    color: var(--text-primary);
    background: linear-gradient(135deg, rgba(74, 124, 89, 0.25), rgba(230, 195, 92, 0.16));
    border-color: var(--border-active);
    box-shadow: var(--shadow-glow);
}

.sidebar-footer {
    margin-top: auto;
}

.main-content {
    margin-left: 18rem;
    min-height: 100vh;
    padding-bottom: 4rem;
}

.no-sidebar .main-content {
    margin-left: 0;
}

.surface {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 1rem;
}

.chart-shell {
    position: relative;
    width: 100%;
    height: 280px;
}

.chart-shell canvas {
    width: 100% !important;
    height: 100% !important;
}

.input-invalid {
    border-color: var(--accent-red) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25);
}

/* Admin theme override (sem reescrever HTML) */
.admin-shell {
    background: var(--bg-primary);
    color: var(--text-secondary);
}

.admin-shell .bg-white,
.admin-shell .bg-gray-50 {
    background: var(--bg-card) !important;
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.admin-shell .text-gray-900,
.admin-shell .text-gray-700,
.admin-shell .text-gray-600,
.admin-shell .text-gray-500 {
    color: var(--text-secondary);
}

.admin-shell table th {
    color: var(--text-muted);
    background: var(--bg-tertiary);
}

.admin-shell table tr:hover {
    background: var(--bg-hover);
}

.admin-shell .badge {
    border-color: var(--border-light);
}

.admin-shell a {
    color: var(--text-secondary);
}

.admin-shell .text-green-600,
.admin-shell .text-green-700,
.admin-shell .text-emerald-600 {
    color: #34d399 !important;
}

.admin-shell .text-red-600,
.admin-shell .text-red-700 {
    color: #fca5a5 !important;
}

.admin-shell .text-blue-600,
.admin-shell .text-blue-700 {
    color: #93c5fd !important;
}

.admin-shell .text-yellow-700,
.admin-shell .text-yellow-800 {
    color: #fcd34d !important;
}

.admin-shell .bg-blue-100 {
    background: rgba(59, 130, 246, 0.12) !important;
    border: 1px solid rgba(59, 130, 246, 0.22) !important;
}

.admin-shell .bg-green-100 {
    background: rgba(16, 185, 129, 0.10) !important;
    border: 1px solid rgba(16, 185, 129, 0.20) !important;
}

.admin-shell .bg-red-100 {
    background: rgba(239, 68, 68, 0.10) !important;
    border: 1px solid rgba(239, 68, 68, 0.20) !important;
}

.admin-shell .bg-yellow-100 {
    background: rgba(245, 158, 11, 0.10) !important;
    border: 1px solid rgba(245, 158, 11, 0.20) !important;
}

.admin-shell .bg-gray-100,
.admin-shell .bg-gray-200 {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.admin-shell .bg-red-50 {
    background: rgba(239, 68, 68, 0.08) !important;
    border-color: rgba(239, 68, 68, 0.20) !important;
}

/* System logs: keep readable on dark */
.admin-shell .bg-gray-900 {
    background: rgba(0, 0, 0, 0.45) !important;
}

.admin-shell .bg-gray-800 {
    background: rgba(0, 0, 0, 0.30) !important;
}

.admin-shell .log-DEBUG {
    background-color: rgba(148, 163, 184, 0.08) !important;
}

.admin-shell .log-INFO {
    background-color: rgba(59, 130, 246, 0.10) !important;
}

.admin-shell .log-WARNING {
    background-color: rgba(245, 158, 11, 0.10) !important;
}

.admin-shell .log-ERROR,
.admin-shell .log-CRITICAL {
    background-color: rgba(239, 68, 68, 0.10) !important;
}

.admin-shell input,
.admin-shell select,
.admin-shell textarea {
    background: rgba(255,255,255,0.04) !important;
    color: var(--text-secondary) !important;
    border-color: rgba(255,255,255,0.12) !important;
}

.admin-shell input:focus,
.admin-shell select:focus,
.admin-shell textarea:focus {
    outline: none !important;
    border-color: rgba(74, 124, 89, 0.75) !important;
    box-shadow: 0 0 0 3px var(--focus-ring) !important;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }
}
