@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #818cf8;
    --accent: #8b5cf6;
    --bg-dark: #0b1120;
    --card-bg: rgba(17, 24, 39, 0.82);
    --input-bg: rgba(15, 23, 42, 0.65);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    --error: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(circle at 12% 18%, rgba(99, 102, 241, 0.18), transparent 42%),
        radial-gradient(circle at 88% 82%, rgba(139, 92, 246, 0.16), transparent 45%),
        linear-gradient(160deg, #0b1120 0%, #0f172a 55%, #111827 100%);
}

/* =========================================
   Light Theme
========================================= */
body.light-theme {
    --bg-dark: #f4f6fb;
    --card-bg: rgba(255, 255, 255, 0.94);
    --input-bg: #f8fafc;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: rgba(15, 23, 42, 0.1);
    background:
        radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.13), transparent 40%),
        radial-gradient(circle at 85% 85%, rgba(14, 165, 233, 0.11), transparent 45%),
        linear-gradient(145deg, #eef2ff 0%, #f8fafc 48%, #f1f5f9 100%);
}

body.light-theme .form-control {
    background: var(--input-bg);
    color: #0f172a;
    border-color: rgba(15, 23, 42, 0.12);
}

body.light-theme .form-control:hover:not(:focus) {
    border-color: rgba(99, 102, 241, 0.35);
    background: #ffffff;
}

body.light-theme .form-control:focus {
    background: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.14);
}

body.light-theme .sidebar-logo,
body.light-theme .config-card h3,
body.light-theme .stat-card .value,
body.light-theme .header h2,
body.light-theme .grid-2 h4,
body.light-theme .auth-card h2 {
    color: #0f172a !important;
}

body.light-theme .auth-card h2 {
    background: none !important;
    -webkit-background-clip: border-box !important;
    -webkit-text-fill-color: #0f172a !important;
    color: #0f172a !important;
}

body.light-theme .auth-card {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(15, 23, 42, 0.07);
    box-shadow:
        0 28px 64px -18px rgba(15, 23, 42, 0.14),
        0 8px 24px -8px rgba(99, 102, 241, 0.10),
        0 1px 2px rgba(15, 23, 42, 0.04);
}

body.light-theme .auth-footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

body.light-theme .auth-glow { opacity: 0.18; }
body.light-theme .auth-glow-2 { opacity: 0.14; }

/* Correcao de autofill do Chrome/Edge/Safari */
input.form-control:-webkit-autofill,
input.form-control:-webkit-autofill:hover,
input.form-control:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px #131c31 inset !important;
    -webkit-text-fill-color: #f8fafc !important;
    transition: background-color 5000s ease-in-out 0s;
    caret-color: #f8fafc;
}

body.light-theme input.form-control:-webkit-autofill,
body.light-theme input.form-control:-webkit-autofill:hover,
body.light-theme input.form-control:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px #f8fafc inset !important;
    -webkit-text-fill-color: #0f172a !important;
    caret-color: #0f172a;
}

/* =========================================
   Theme Toggle Button
========================================= */
.theme-toggle {
    position: fixed;
    bottom: 28px;
    right: 28px;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 50%;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.theme-toggle:hover {
    transform: translateY(-2px) scale(1.06);
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 12px 24px -6px rgba(99, 102, 241, 0.45);
}

.theme-toggle svg { width: 20px; height: 20px; fill: currentColor; }

/* =========================================
   Auth Layout (Login / Registro / Recuperacao)
========================================= */
.auth-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 28px 18px;
    position: relative;
    overflow: hidden;
}

/* Grade arquitetonica sutil no fundo */
.auth-container::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: radial-gradient(rgba(99, 102, 241, 0.16) 1px, transparent 1px);
    background-size: 28px 28px;
    mask-image: radial-gradient(ellipse 70% 65% at 50% 45%, #000 35%, transparent 100%);
    -webkit-mask-image: radial-gradient(ellipse 70% 65% at 50% 45%, #000 35%, transparent 100%);
    pointer-events: none;
    z-index: 0;
}

body.light-theme .auth-container::before {
    background-image: radial-gradient(rgba(99, 102, 241, 0.18) 1px, transparent 1px);
}

/* Orbs luminosos animados */
.auth-glow {
    position: fixed;
    width: 420px;
    height: 420px;
    background: radial-gradient(circle, #6366f1 0%, transparent 70%);
    filter: blur(90px);
    border-radius: 50%;
    opacity: 0.28;
    z-index: 0;
    top: -100px;
    left: -80px;
    pointer-events: none;
    animation: floatGlow 14s ease-in-out infinite alternate;
}

.auth-glow-2 {
    position: fixed;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #06b6d4 0%, transparent 70%);
    filter: blur(100px);
    border-radius: 50%;
    opacity: 0.2;
    z-index: 0;
    bottom: -120px;
    right: -80px;
    pointer-events: none;
    animation: floatGlow 16s ease-in-out infinite alternate-reverse;
}

@keyframes floatGlow {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(40px, 30px) scale(1.12); }
}

.auth-card {
    background: var(--card-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 24px;
    padding: 40px 38px 34px;
    width: 100%;
    max-width: 440px;
    max-height: 92vh;
    overflow-y: auto;
    position: relative;
    z-index: 1;
    box-shadow:
        0 30px 70px -15px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.07);
    animation: slideUp 0.55s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Barra de destaque premium no topo do card */
.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #6366f1 0%, #8b5cf6 50%, #06b6d4 100%);
    border-radius: 24px 24px 0 0;
}

.auth-card-large {
    max-width: 680px;
    padding: 38px 42px 34px;
}

@media (max-width: 520px) {
    .auth-card, .auth-card-large {
        padding: 30px 22px 26px;
        border-radius: 20px;
    }
}

/* Brand Header dentro do auth-card */
.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 22px;
}

.auth-logo-wrap {
    width: 72px;
    height: 72px;
    padding: 4px;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.45), rgba(6, 182, 212, 0.35));
    box-shadow: 0 12px 28px -8px rgba(99, 102, 241, 0.38);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-logo-wrap:hover {
    transform: translateY(-2px) scale(1.03);
}

.auth-logo-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 16px;
    display: block;
}

.auth-brand-badge {
    margin-top: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--primary-light);
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.25);
}

body.light-theme .auth-brand-badge {
    color: #4f46e5;
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.2);
}

.auth-card h2 {
    font-family: 'Outfit', 'Plus Jakarta Sans', sans-serif;
    font-size: 1.85rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 6px;
    text-align: center;
    background: linear-gradient(135deg, #ffffff 20%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-card p.subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 26px;
    font-size: 0.93rem;
    line-height: 1.5;
}

/* Responsividade de grid no cadastro */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 520px) {
    .form-grid.g-2 { grid-template-columns: 1fr 1fr; }
    .form-grid.g-3 { grid-template-columns: 1fr 1fr 1fr; }
    .form-grid.g-cep { grid-template-columns: 1fr 2fr; }
}

.auth-card::-webkit-scrollbar { width: 6px; }
.auth-card::-webkit-scrollbar-track { background: transparent; }
.auth-card::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }

.form-group {
    margin-bottom: 18px;
}

.form-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 7px;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 7px;
    letter-spacing: 0.01em;
}

.form-label-row label {
    margin-bottom: 0;
}

.form-link-subtle {
    font-size: 0.8rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: opacity 0.2s, color 0.2s;
}

.form-link-subtle:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Input com icone integrado */
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper .input-icon {
    position: absolute;
    left: 15px;
    color: var(--text-muted);
    font-size: 0.95rem;
    pointer-events: none;
    transition: color 0.2s ease;
    z-index: 2;
}

.input-wrapper:focus-within .input-icon {
    color: var(--primary);
}

.input-wrapper .form-control.has-icon {
    padding-left: 44px;
}

.input-wrapper .form-control.has-toggle {
    padding-right: 44px;
}

.pass-toggle-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    z-index: 2;
}

.pass-toggle-btn:hover {
    background: rgba(99, 102, 241, 0.12);
    color: var(--primary);
}

.form-control {
    width: 100%;
    padding: 13px 16px;
    background: var(--input-bg);
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-main);
    font-size: 0.96rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.form-control::placeholder {
    color: #94a3b8;
    opacity: 0.78;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.18);
}

/* Alerta sutil de Caps Lock */
.caps-warning {
    display: none;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 0.76rem;
    font-weight: 600;
    color: #d97706;
}

.caps-warning.visible {
    display: inline-flex;
}

/* Barra de forca da senha */
.password-strength {
    margin-top: 8px;
    display: none;
}

.password-strength.active {
    display: block;
}

.password-strength-track {
    height: 5px;
    background: rgba(148, 163, 184, 0.22);
    border-radius: 999px;
    overflow: hidden;
}

.password-strength-bar {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    transition: width 0.25s ease, background 0.25s ease;
}

.password-strength-label {
    font-size: 0.75rem;
    margin-top: 4px;
    font-weight: 600;
    color: var(--text-muted);
}

/* Segmented Control / Channel Cards */
.auth-segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 5px;
    background: rgba(15, 23, 42, 0.45);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    margin-bottom: 20px;
}

body.light-theme .auth-segmented {
    background: #f1f5f9;
}

.auth-segmented label {
    margin: 0 !important;
    cursor: pointer;
    position: relative;
}

.auth-segmented input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.auth-segmented .seg-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.auth-segmented input[type="radio"]:checked + .seg-pill {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 6px 16px -4px rgba(99, 102, 241, 0.45);
}

body.light-theme .auth-segmented input[type="radio"]:checked + .seg-pill {
    background: #ffffff;
    color: #4f46e5;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

/* Primary Button */
.btn-primary {
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 55%, #7c3aed 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 0.98rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease, filter 0.2s ease;
    margin-top: 8px;
    box-shadow: 0 10px 24px -8px rgba(99, 102, 241, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.btn-primary:hover:not(:disabled) {
    filter: brightness(1.05);
    transform: translateY(-1.5px);
    box-shadow: 0 16px 30px -10px rgba(99, 102, 241, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0) scale(0.99);
}

.btn-primary:disabled {
    opacity: 0.68;
    cursor: not-allowed;
}

.btn-primary.btn-success-gradient {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 10px 24px -8px rgba(16, 185, 129, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--text-muted);
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
    transition: color 0.2s;
}

.auth-footer a:hover {
    color: #fff;
}

/* Rodape de confianca abaixo do card */
.auth-trust {
    margin-top: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 0.78rem;
    color: var(--text-muted);
    z-index: 1;
}

.auth-trust span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.auth-trust i {
    color: var(--success);
    font-size: 0.82rem;
}

/* =========================================
   Loading Screen Overlay
========================================= */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(11, 17, 32, 0.82);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3.5px solid rgba(255, 255, 255, 0.14);
    border-left-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.85s linear infinite;
    margin-bottom: 16px;
}

.loading-overlay p {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.02em;
}

/* =========================================
   Alerts (Alto Contraste Dark & Light)
========================================= */
.alert {
    padding: 13px 16px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-size: 0.88rem;
    font-weight: 500;
    line-height: 1.45;
    display: none;
    animation: fadeInAlert 0.25s ease;
}

@keyframes fadeInAlert {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert.error {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.38);
    color: #fca5a5;
}

.alert.success {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.38);
    color: #6ee7b7;
}

body.light-theme .alert.error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

body.light-theme .alert.success {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #047857;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(22px) scale(0.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Profile Button */
.header-profile-btn {
    display: flex; align-items: center; background: var(--card-bg);
    border: 1px solid var(--border-color); padding: 5px 15px 5px 5px;
    border-radius: 30px; color: var(--text-main); text-decoration: none;
    font-weight: 600; transition: all 0.25s; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}
.header-profile-btn:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 6px 18px rgba(99, 102, 241, 0.15); }
.header-profile-avatar {
    width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: bold; font-size: 1rem; margin-right: 12px;
}
body.light-theme .header-profile-btn { color: var(--text-main); }

/* Botao Sair Sidebar */
.nav-logout {
    margin-top: auto;
    color: var(--error) !important;
    display: flex;
    align-items: center;
}
.nav-logout:hover {
    background: rgba(239, 68, 68, 0.1) !important;
    transform: translateX(4px);
    border-left: 3px solid var(--error);
}
