/* ══════════════════════════════════════
   BRODI 3.0 THEME - CORE ASSETS
   ══════════════════════════════════════ */

:root {
    --bg-base: #f0f4ff;
    --bg-surface: #ffffff;
    --bg-surface2: #f7f9ff;
    --bg-nav: rgba(255, 255, 255, 0.88);
    --border: rgba(59, 90, 180, 0.1);
    --border-strong: rgba(59, 90, 180, 0.18);
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --accent: #3b5ab8;
    --accent-light: #eef2ff;
    --accent-hover: #2f4a9a;
    --amber: #c2780f;
    --amber-light: #fffbeb;
    --green: #15803d;
    --green-light: #f0fdf4;
    --red: #dc2626;
    --red-light: #fef2f2;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(59, 90, 180, 0.08), 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 12px 40px rgba(59, 90, 180, 0.12), 0 4px 8px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 20px 50px rgba(59, 90, 180, 0.16), 0 8px 16px rgba(0, 0, 0, 0.06);
    --mesh-a: rgba(59, 90, 184, 0.06);
    --mesh-b: rgba(192, 132, 60, 0.05);
    --loader-glow-sm: brightness(1) drop-shadow(0 0 5px var(--accent));
    --loader-glow-lg: brightness(1.1) drop-shadow(0 0 15px var(--accent));
}

[data-theme="dark"] {
    --bg-base: #0c1120;
    --bg-surface: #141e35;
    --bg-surface2: #1a2744;
    --bg-nav: rgba(12, 17, 32, 0.9);
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);
    --text-primary: #f1f5ff;
    --text-secondary: #94a3b8;
    --text-muted: #475569;
    --accent: #6480e8;
    --accent-light: rgba(100, 128, 232, 0.12);
    --accent-hover: #7b96f0;
    --amber: #f59e0b;
    --amber-light: rgba(245, 158, 11, 0.12);
    --green: #3ecf8e;
    --green-light: rgba(62, 207, 142, 0.12);
    --red: #f87171;
    --red-light: rgba(248, 113, 113, 0.12);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.35);
    --shadow-hover: 0 20px 50px rgba(0, 0, 0, 0.4);
    --mesh-a: rgba(100, 128, 232, 0.08);
    --mesh-b: rgba(245, 158, 11, 0.05);
    --loader-glow-sm: brightness(0.8) invert(1) drop-shadow(0 0 5px var(--accent));
    --loader-glow-lg: brightness(1.2) invert(1) drop-shadow(0 0 15px var(--accent));
}

/* ══════════════════════════════════════
   DARK MODE TAILWIND OVERRIDES
   ══════════════════════════════════════ */
[data-theme="dark"] .bg-white { background-color: var(--bg-surface) !important; }
[data-theme="dark"] .bg-slate-50, [data-theme="dark"] .bg-gray-50 { background-color: var(--bg-surface2) !important; }
[data-theme="dark"] .bg-slate-50\/30, [data-theme="dark"] .bg-slate-50\/40, [data-theme="dark"] .bg-slate-50\/50, [data-theme="dark"] .bg-slate-50\/60,
[data-theme="dark"] .hover\:bg-slate-50\/50:hover { background-color: rgba(255, 255, 255, 0.03) !important; }
[data-theme="dark"] .bg-slate-100, [data-theme="dark"] .bg-gray-100 { background-color: rgba(255, 255, 255, 0.05) !important; }

[data-theme="dark"] .text-slate-900, [data-theme="dark"] .text-slate-800, [data-theme="dark"] .text-gray-900, [data-theme="dark"] .text-gray-800 { color: var(--text-primary) !important; }
[data-theme="dark"] .text-slate-700, [data-theme="dark"] .text-slate-600, [data-theme="dark"] .text-gray-700, [data-theme="dark"] .text-gray-600 { color: var(--text-secondary) !important; }
[data-theme="dark"] .text-slate-500, [data-theme="dark"] .text-slate-400, [data-theme="dark"] .text-gray-500, [data-theme="dark"] .text-gray-400 { color: var(--text-muted) !important; }
[data-theme="dark"] .placeholder-slate-400::placeholder, [data-theme="dark"] .placeholder-slate-300::placeholder { color: var(--text-muted) !important; opacity: 0.5; }

[data-theme="dark"] .border-slate-50, [data-theme="dark"] .border-slate-100, [data-theme="dark"] .border-slate-200, [data-theme="dark"] .border-gray-100, [data-theme="dark"] .border-gray-200 { border-color: var(--border) !important; }

[data-theme="dark"] .divide-slate-50 > :not([hidden]) ~ :not([hidden]),
[data-theme="dark"] .divide-slate-100 > :not([hidden]) ~ :not([hidden]),
[data-theme="dark"] .divide-slate-200 > :not([hidden]) ~ :not([hidden]),
[data-theme="dark"] .divide-gray-100 > :not([hidden]) ~ :not([hidden]),
[data-theme="dark"] .divide-gray-200 > :not([hidden]) ~ :not([hidden]) { border-color: var(--border) !important; }

[data-theme="dark"] .ring-slate-100, [data-theme="dark"] .ring-slate-200, [data-theme="dark"] .ring-gray-100, [data-theme="dark"] .ring-gray-200,
[data-theme="dark"] .focus\:ring-slate-100:focus, [data-theme="dark"] .focus\:ring-slate-200:focus { --tw-ring-color: var(--border-strong) !important; }

[data-theme="dark"] .shadow-sm { box-shadow: var(--shadow-sm) !important; }
[data-theme="dark"] .shadow { box-shadow: var(--shadow-md) !important; }
[data-theme="dark"] .shadow-md { box-shadow: var(--shadow-md) !important; }
[data-theme="dark"] .shadow-lg { box-shadow: var(--shadow-lg) !important; }
[data-theme="dark"] .shadow-xl { box-shadow: var(--shadow-hover) !important; }

[data-theme="dark"] .bg-rose-50  { background-color: rgba(244, 63, 94, 0.08) !important; border-color: rgba(244, 63, 94, 0.2) !important; }
[data-theme="dark"] .bg-rose-100 { background-color: rgba(244, 63, 94, 0.15) !important; border-color: rgba(244, 63, 94, 0.3) !important; }
[data-theme="dark"] .text-rose-600 { color: #fb7185 !important; }

[data-theme="dark"] .bg-emerald-50  { background-color: rgba(16, 185, 129, 0.08) !important; border-color: rgba(16, 185, 129, 0.2) !important; }
[data-theme="dark"] .bg-emerald-100 { background-color: rgba(16, 185, 129, 0.15) !important; border-color: rgba(16, 185, 129, 0.3) !important; }
[data-theme="dark"] .text-emerald-600 { color: #34d399 !important; }

[data-theme="dark"] .bg-indigo-50  { background-color: var(--accent-light) !important; border-color: rgba(99, 102, 241, 0.2) !important; }
[data-theme="dark"] .bg-indigo-100 { background-color: rgba(99, 102, 241, 0.15) !important; border-color: rgba(99, 102, 241, 0.3) !important; }
[data-theme="dark"] .hover\:bg-indigo-600:hover { background-color: var(--accent) !important; }
[data-theme="dark"] .text-indigo-600 { color: #818cf8 !important; }
[data-theme="dark"] .text-indigo-500 { color: #818cf8 !important; }
[data-theme="dark"] .hover\:text-indigo-600:hover { color: #6366f1 !important; }

/* ══════════════════════════════════════
   UTILITIES & GLOBAL TRANSITIONS
   ══════════════════════════════════════ */
html,
body {
    scroll-behavior: smooth;
}

body {
    animation: globalFadeIn 0.8s ease-out;
}

@keyframes globalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

a,
button,
input,
select,
textarea {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-entrance {
    animation: pageEntrance 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes pageEntrance {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

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

.surface2 {
    background: var(--bg-surface2);
    border: 1px solid var(--border);
}

.nav-glass {
    background: var(--bg-nav);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.app-card {
    background: var(--bg-surface);
    border: 1.5px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow-md);
    transition: transform 0.3s cubic-bezier(.4, 0, .2, 1), box-shadow 0.3s cubic-bezier(.4, 0, .2, 1), border-color 0.3s;
    position: relative;
    overflow: hidden;
}

.badge-accent {
    background: var(--accent-light);
    color: var(--accent);
    border: 1px solid var(--border-strong);
}

.badge-amber {
    background: var(--amber-light);
    color: var(--amber);
}

.badge-green {
    background: var(--green-light);
    color: var(--green);
}

.badge-red {
    background: var(--red-light);
    color: var(--red);
}

/* ── Button Loading System ────────────────── */
.btn-loading {
    position: relative !important;
    color: transparent !important;
    pointer-events: none !important;
    cursor: default !important;
}

.btn-loading .btn-content {
    opacity: 0 !important;
}

.btn-loading::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin: -10px 0 0 -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    z-index: 2;
}

/* For light background buttons */
.btn-loading-dark::after {
    border: 3px solid var(--border-strong);
    border-top-color: var(--accent);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

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

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

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

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(18px);
    }

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

.fade-up {
    opacity: 0;
    animation: fadeUp 0.5s cubic-bezier(.4, 0, .2, 1) forwards;
}

.clock-digit {
    font-family: 'Outfit', sans-serif;
    font-weight: 900;
    letter-spacing: -3px;
    color: var(--text-primary);
    line-height: 1;
    transition: color 0.5s ease;
}

/* ── Smooth Navigation ────────────────────── */
.nav-item {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item:hover {
    transform: translateX(4px);
}

.nav-icon {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-item:hover .nav-icon {
    transform: scale(1.1) rotate(5deg);
}

/* ══════════════════════════════════════
   THEME TOGGLE SYSTEM
   ══════════════════════════════════════ */
.theme-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 99px;
    background: var(--bg-surface2);
    border: 1.5px solid var(--border-strong);
    color: var(--text-primary);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.theme-pill:hover {
    transform: translateY(-1px);
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}

.theme-pill:active {
    transform: translateY(0);
}

/* Sun Glow Effect (Light Mode only) */
[data-theme="light"] .theme-pill {
    background: white;
    border-color: rgba(194, 120, 15, 0.2);
    /* Subtle Amber */
}

[data-theme="light"] .theme-icon-light {
    color: var(--amber);
    filter: drop-shadow(0 0 4px rgba(194, 120, 15, 0.4));
}

/* Moon Glow Effect (Dark Mode only) */
[data-theme="dark"] .theme-pill {
    border-color: rgba(100, 128, 232, 0.3);
}

[data-theme="dark"] .theme-icon-dark {
    color: #a5b4fc;
    filter: drop-shadow(0 0 5px rgba(165, 180, 252, 0.5));
}

.theme-label {
    line-height: 1;
    display: inline-block;
}

/* ══════════════════════════════════════
   "SILK & STEEL" GLOBAL LOADER
   ══════════════════════════════════════ */
.loader-canvas {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

.logo-reveal {
    position: fixed;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    opacity: 0;
    pointer-events: none;
}

.logo-reveal.show {
    animation: logoAppear 1.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes logoAppear {
    0% {
        opacity: 0;
        transform: scale(0.75);
        filter: blur(24px);
    }

    50% {
        opacity: 1;
        filter: blur(0);
    }

    100% {
        opacity: 1;
        transform: scale(1);
        filter: blur(0);
    }
}

.logo-img {
    width: min(300px, 58vw);
    filter: drop-shadow(0 0 25px rgba(30, 80, 200, 0.9)) drop-shadow(0 0 60px rgba(20, 60, 180, 0.5));
}

.logo-tagline {
    font-size: clamp(0.7rem, 2vw, 0.85rem);
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.3em;
    text-transform: uppercase;
    opacity: 0;
}

.logo-reveal.show .logo-tagline {
    animation: tagIn 1s ease 0.8s forwards;
}

@keyframes tagIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.load-bar-container {
    position: fixed;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.load-track {
    width: 180px;
    height: 1.5px;
    background: var(--border-strong);
    border-radius: 99px;
    overflow: hidden;
}

.load-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #1a3a9a, #4a82ff, #f5c842);
    box-shadow: 0 0 8px rgba(74, 130, 255, 0.6);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.load-pct {
    font-family: 'Outfit', sans-serif;
    font-size: 8.5px;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: 0.15em;
}

/* Legacy Loader Elements (to be removed once fully migrated) */
.loader-old-elements {
    display: none;
}

/* ── Cinematic Video Addon ── */
.loader-video-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -2;
    opacity: 0.25;
    filter: saturate(0) brightness(0.4) blur(2px);
}

/* Responsive Cinematic Loader adjustments */
@media (min-width: 1024px) {
    .loader-video-bg {
        display: none;
        /* Hide video on desktop for cleaner focus */
    }
}

@media (max-width: 1023px) {

    #auth-loader .loader-logo-wrapper,
    #auth-loader .text-center {
        display: none;
        /* Hide branding on mobile login to show ONLY video */
    }

    .loader-video-bg {
        opacity: 1 !important;
        /* Original clarity on mobile */
        filter: none !important;
        /* Original colors/HD on mobile */
    }

    .loader-video-overlay {
        display: none;
        /* Remove overlay on mobile for raw video feel */
    }
}

.loader-video-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, transparent 0%, var(--bg-surface) 90%);
    z-index: -1;
    opacity: 0.9;
}

@media (min-width: 1024px) {
    .loader-video-overlay {
        background: radial-gradient(circle at center, transparent 0%, #000 100%);
        opacity: 0.7;
        /* Lighter overlay on desktop to let mesh shine */
    }
}

/* Informative Desktop Elements */
.loader-status-container {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.loader-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: rgba(var(--accent-rgb), 0.05);
    border: 1px solid rgba(var(--accent-rgb), 0.1);
    border-radius: 2rem;
    font-size: 8.5px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--accent);
}

.status-dot {
    width: 4px;
    height: 4px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent);
    animation: statusPulse 1.5s ease-in-out infinite;
}

.loader-technical-text {
    font-size: 8.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    opacity: 0.6;
    height: 12px;
    transition: all 0.4s ease;
}

@keyframes statusPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.5);
        opacity: 0.4;
    }
}

/* Procedural Neural Mesh for Desktop - DRAMATIZED */
.loader-mesh-desktop {
    position: absolute;
    inset: 0;
    z-index: -2;
    background: #020617;
    /* Deep midnight base */
    overflow: hidden;
}

.mesh-sphere {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.6;
    will-change: transform;
    animation: meshDrift 15s ease-in-out infinite alternate;
}

.mesh-sphere-1 {
    width: 80%;
    height: 80%;
    top: -10%;
    left: -10%;
    background: radial-gradient(circle, #3b82f6 0%, transparent 70%);
    /* Electric Blue */
}

.mesh-sphere-2 {
    width: 70%;
    height: 70%;
    bottom: -10%;
    right: -10%;
    background: radial-gradient(circle, #a855f7 0%, transparent 75%);
    /* Deep Violet */
    animation-delay: -4s;
}

.mesh-sphere-3 {
    width: 60%;
    height: 60%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, #06b6d4 0%, transparent 60%);
    /* Electric Cyan */
    opacity: 0.3;
    animation: corePulse 6s ease-in-out infinite alternate;
}

@keyframes corePulse {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0.2;
    }

    100% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.5;
    }
}

@keyframes meshDrift {
    0% {
        transform: translate(-5%, -5%) rotate(0deg);
    }

    100% {
        transform: translate(5%, 5%) rotate(5deg);
    }
}

[data-theme="dark"] .loader-video-overlay {
    background: radial-gradient(circle at center, transparent 0%, #0c1120 90%);
}

#auth-loader,
#action-loader {
    z-index: 99999 !important;
}

body.loader-active {
    overflow: hidden !important;
}

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

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

@keyframes loaderBreathe {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.7;
    }

    50% {
        transform: scale(1.05);
        opacity: 1;
    }
}

@keyframes loaderGlimmer {
    0% {
        mask-position: -150% 0;
    }

    100% {
        mask-position: 150% 0;
    }
}

@keyframes loaderGlow {

    0%,
    100% {
        opacity: 0.1;
        transform: scale(1);
    }

    50% {
        opacity: 0.3;
        transform: scale(1.2);
    }
}