/* ============================================================
   GLOBAL.CSS - Reset, Variáveis, Tipografia e Utilitários
   Recarga Fácil - Design System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ----- CSS Variables ----- */
:root {
    /* Cores principais */
    --color-primary: #667eea;
    --color-primary-dark: #5a67d8;
    --color-accent: #764ba2;
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-primary-hover: linear-gradient(135deg, #5a67d8 0%, #6b3fa0 100%);

    /* Sidebar */
    --sidebar-bg: #1e1e2f;
    --sidebar-hover: #2d2d44;
    --sidebar-active: #3d3d5c;
    --sidebar-text: #a0aec0;
    --sidebar-text-active: #ffffff;
    --sidebar-width: 260px;

    /* Superfícies */
    --bg-body: #f0f2f5;
    --bg-card: #ffffff;
    --bg-card-hover: #fafbfc;

    /* Texto */
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #64748b;
    --text-white: #ffffff;

    /* Bordas */
    --border-light: #e2e8f0;
    --border-input: #cbd5e0;

    /* Status */
    --color-success: #48bb78;
    --color-success-bg: #f0fff4;
    --color-success-text: #276749;
    --color-danger: #f56565;
    --color-danger-bg: #fff5f5;
    --color-danger-text: #9b2c2c;
    --color-warning: #ed8936;
    --color-warning-bg: #fffaf0;
    --color-warning-text: #9c4221;
    --color-info: #4299e1;
    --color-info-bg: #ebf8ff;
    --color-info-text: #2b6cb0;

    /* Sombras */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.12);

    /* Bordas arredondadas */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Transições */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 350ms ease;

    /* Aliases para variáveis usadas no markup mas que não existiam (ficavam inválidas) */
    --text-color: var(--text-primary);
    --primary: var(--color-primary);
    --color-primary-hover: var(--color-primary-dark);
    --warning: var(--color-warning-text);
    --bg-hover: var(--bg-card-hover);
    --border-color: var(--border-light);
    --transition-normal: 250ms ease;

    /* ----- Tokens semânticos (substituem cores fixas de tema escuro em HTML/JS inline) ----- */
    /* Camadas translúcidas (fundos/bordas sutis). Claro: tinta escura; Escuro: branco. */
    --ol-02: rgba(15, 23, 42, 0.025);
    --ol-03: rgba(15, 23, 42, 0.035);
    --ol-04: rgba(15, 23, 42, 0.04);
    --ol-05: rgba(15, 23, 42, 0.05);
    --ol-06: rgba(15, 23, 42, 0.06);
    --ol-08: rgba(15, 23, 42, 0.08);
    --ol-10: rgba(15, 23, 42, 0.12);
    --ol-12: rgba(15, 23, 42, 0.14);
    --ol-15: rgba(15, 23, 42, 0.16);
    /* Insets escuros */
    --ink-10: rgba(15, 23, 42, 0.04);
    --ink-15: rgba(15, 23, 42, 0.05);
    --ink-20: rgba(15, 23, 42, 0.06);
    /* Superfícies de modal/popup */
    --surface-modal: #ffffff;
    --surface-popup: rgba(255, 255, 255, 0.98);
    --surface-raised: #f8fafc;
    --surface-field: #f1f5f9;
    --surface-modal-b: #ffffff;
    --surface-modal-c: #ffffff;
    --surface-modal-d: #ffffff;
    --surface-overlay: #f1f5f9;
    --surface-overlay-card: #ffffff;
    --surface-btn: #e2e8f0;
    --text-on-btn: #334155;
    --backdrop: rgba(15, 23, 42, 0.55);
    --backdrop-strong: rgba(15, 23, 42, 0.72);
    --backdrop-60: rgba(15, 23, 42, 0.5);
    --backdrop-80: rgba(15, 23, 42, 0.62);
    --line-modal: #e2e8f0;
    --t-mint: #047857;
    /* Texto */
    --text-hi: #0f172a;
    --text-soft: #334155;
    --text-dim: #64748b;
    /* Cores de status em texto (versões legíveis em fundo claro) */
    --t-red: #b91c1c;
    --t-rose: #be123c;
    --t-amber: #b45309;
    --t-orange: #c2410c;
    --t-green: #047857;
    --t-green-2: #15803d;
    --t-indigo: #4338ca;
    --t-indigo-2: #3730a3;
    --t-violet: #6d28d9;
    --t-blue: #1d4ed8;
}

/* ----- Dark Theme ----- */
[data-theme="dark"] {
    /* Superfícies */
    --bg-body: #0f1117;
    --bg-card: #1a1d27;
    --bg-card-hover: #22252f;

    /* Texto */
    --text-primary: #e8eaed;
    --text-secondary: #a8adb8;
    --text-muted: #6b7280;

    /* Bordas */
    --border-light: #2a2d37;
    --border-input: #3a3d47;

    /* Sidebar (já é escura, mas ajustar pro dark) */
    --sidebar-bg: #111318;
    --sidebar-hover: #1e2030;
    --sidebar-active: #2a2d44;

    /* Status — backgrounds adaptados para dark */
    --color-success-bg: rgba(72, 187, 120, 0.12);
    --color-success-text: #68d391;
    --color-danger-bg: rgba(245, 101, 101, 0.12);
    --color-danger-text: #fc8181;
    --color-warning-bg: rgba(237, 137, 54, 0.12);
    --color-warning-text: #f6ad55;
    --color-info-bg: rgba(66, 153, 225, 0.12);
    --color-info-text: #63b3ed;

    /* Sombras mais sutis no dark */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.5);

    /* Tokens semânticos — valores originais (inalterados) do tema escuro */
    --ol-02: rgba(255, 255, 255, 0.02);
    --ol-03: rgba(255, 255, 255, 0.03);
    --ol-04: rgba(255, 255, 255, 0.04);
    --ol-05: rgba(255, 255, 255, 0.05);
    --ol-06: rgba(255, 255, 255, 0.06);
    --ol-08: rgba(255, 255, 255, 0.08);
    --ol-10: rgba(255, 255, 255, 0.1);
    --ol-12: rgba(255, 255, 255, 0.12);
    --ol-15: rgba(255, 255, 255, 0.15);
    --ink-10: rgba(0, 0, 0, 0.1);
    --ink-15: rgba(0, 0, 0, 0.15);
    --ink-20: rgba(0, 0, 0, 0.2);
    --surface-modal: #11141c;
    --surface-popup: rgba(20, 24, 35, 0.95);
    --surface-raised: #1c2230;
    --surface-field: #2a3040;
    --surface-modal-b: #1a1e2a;
    --surface-modal-c: #1a1f2b;
    --surface-modal-d: #1e293b;
    --surface-overlay: #1a1a2e;
    --surface-overlay-card: #16213e;
    --surface-btn: #3a4150;
    --text-on-btn: #ffffff;
    --backdrop: rgba(0, 0, 0, 0.7);
    --backdrop-strong: rgba(10, 10, 20, 0.95);
    --backdrop-60: rgba(0, 0, 0, 0.6);
    --backdrop-80: rgba(0, 0, 0, 0.8);
    --line-modal: #2a3040;
    --t-mint: #4ecca3;
    --text-hi: #f3f4f6;
    --text-soft: #d1d5db;
    --text-dim: #9ca3af;
    --t-red: #f87171;
    --t-rose: #fb7185;
    --t-amber: #fbbf24;
    --t-orange: #fb923c;
    --t-green: #34d399;
    --t-green-2: #22c55e;
    --t-indigo: #a5b4fc;
    --t-indigo-2: #c7d2fe;
    --t-violet: #a78bfa;
    --t-blue: #60a5fa;
}


/* ----- Sidebar: permanece escura nos dois temas. No tema claro, os tokens de
   texto/borda usados dentro dela precisam ser os "de superfície escura" ----- */
html:not([data-theme="dark"]) .sidebar {
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-light: rgba(255, 255, 255, 0.08);
    --border-input: rgba(255, 255, 255, 0.16);
    --bg-body: rgba(255, 255, 255, 0.05);
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-card-hover: rgba(255, 255, 255, 0.08);
    --color-success-text: #68d391;
    --color-danger-text: #fc8181;
    --color-warning-text: #f6ad55;
    /* tokens semânticos com valores de superfície escura */
    --ol-02: rgba(255, 255, 255, 0.02);
    --ol-03: rgba(255, 255, 255, 0.03);
    --ol-04: rgba(255, 255, 255, 0.04);
    --ol-05: rgba(255, 255, 255, 0.05);
    --ol-06: rgba(255, 255, 255, 0.06);
    --ol-08: rgba(255, 255, 255, 0.08);
    --ol-10: rgba(255, 255, 255, 0.1);
    --text-hi: #f3f4f6;
    --text-soft: #d1d5db;
    --text-dim: #9ca3af;
    --t-red: #f87171;
    --t-rose: #fb7185;
    --t-amber: #fbbf24;
    --t-orange: #fb923c;
    --t-green: #34d399;
    --t-green-2: #22c55e;
    --t-indigo: #a5b4fc;
    --t-violet: #a78bfa;
    --t-blue: #60a5fa;
}

/* Logo (⚡) sobre gradiente roxo: sempre branco, independente do tema */
.logo-icon,
.login-logo .logo-icon,
.sidebar-header .logo-icon {
    color: #ffffff;
}

/* Smooth transition ao trocar tema */
html[data-theme] body,
html[data-theme] .sidebar,
html[data-theme] .topbar,
html[data-theme] .card,
html[data-theme] .modal,
html[data-theme] .stat-card {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ----- Theme Toggle Button ----- */
.theme-toggle-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-full);
    background: transparent;
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.theme-toggle-btn:hover {
    background: var(--bg-card-hover);
    color: var(--color-primary);
    border-color: var(--color-primary);
}

.theme-toggle-btn svg {
    width: 18px;
    height: 18px;
}

/* Floating theme toggle (login/register) */
.theme-toggle-float {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 50;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.6);
}

.theme-toggle-float:hover {
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.9);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Theme toggle float — light mode */
html:not([data-theme="dark"]) .theme-toggle-float {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: var(--text-secondary);
}

html:not([data-theme="dark"]) .theme-toggle-float:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
    border-color: rgba(0, 0, 0, 0.2);
}

/* ----- Reset ----- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

@media (max-width: 768px) {
    html {
        font-size: 14px;
    }
}

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

a {
    text-decoration: none;
    color: inherit;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
}

input,
select,
textarea {
    font-family: inherit;
    font-size: inherit;
}

img {
    max-width: 100%;
    display: block;
}

/* ----- Tipografia ----- */
h1 {
    font-size: 1.875rem;
    font-weight: 700;
    line-height: 1.2;
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.3;
}

h3 {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.4;
}

h4 {
    font-size: 1.125rem;
    font-weight: 500;
    line-height: 1.4;
}

.text-sm {
    font-size: 0.875rem;
}

.text-xs {
    font-size: 0.75rem;
}

.text-lg {
    font-size: 1.125rem;
}

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

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

.text-center {
    text-align: center;
}

.font-bold {
    font-weight: 700;
}

.font-semibold {
    font-weight: 600;
}

/* ----- Utilitários ----- */
.hidden {
    display: none !important;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-sm {
    gap: 8px;
}

.gap-md {
    gap: 16px;
}

.gap-lg {
    gap: 24px;
}

.mt-sm {
    margin-top: 8px;
}

.mt-md {
    margin-top: 16px;
}

.mt-lg {
    margin-top: 24px;
}

.mb-sm {
    margin-bottom: 8px;
}

.mb-md {
    margin-bottom: 16px;
}

.mb-lg {
    margin-bottom: 24px;
}

/* ----- Animações ----- */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.animate-fade-in {
    animation: fadeIn 0.4s ease-out;
}

.animate-fade-in-scale {
    animation: fadeInScale 0.3s ease-out;
}

.animate-slide-in {
    animation: slideInLeft 0.3s ease-out;
}

/* ----- Loading skeleton ----- */
.skeleton {
    background: linear-gradient(90deg, var(--bg-body) 25%, var(--border-light) 50%, var(--bg-body) 75%);
    background-size: 200% 100%;
    animation: pulse 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

/* ----- Spinner ----- */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-light);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin: 0 auto;
}

.spinner-lg {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

/* ----- WhatsApp Float Button ----- */
.whatsapp-float {
    position: fixed;
    width: 60px;
    height: 60px;
    bottom: 25px;
    right: 25px;
    background-color: #25d366;
    color: #FFF !important;
    border-radius: 50px;
    text-align: center;
    font-size: 30px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.whatsapp-float:hover {
    background-color: #128c7e;
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.whatsapp-float i, .whatsapp-float svg {
    width: 30px;
    height: 30px;
}

@media (max-width: 768px) {
    .whatsapp-float {
        width: 50px;
        height: 50px;
        bottom: 20px;
        right: 20px;
        font-size: 24px;
    }
}