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

:root {
    --bg-base: #020202;
    --bg-surface: #0a0a0c;
    --bg-glass: rgba(15, 15, 20, 0.7);
    
    --accent-primary: #8b5cf6;
    --accent-secondary: #6366f1;
    --accent-glow: rgba(139, 92, 246, 0.5);
    
    --text-primary: #ffffff;
    --text-secondary: #cbd5e1; /* Slate 300 - Brighter for better contrast */
    --text-muted: #94a3b8; /* Slate 400 - Significantly more legible */
    
    --border-glass: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(139, 92, 246, 0.4);
    
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px var(--accent-glow);
    --bg-glass-inner: rgba(255, 255, 255, 0.05);
}

/* ===== PREMIUM LIGHT MODE OVERRIDES ===== */
body.light-mode {
    --bg-base: #fdfcff;
    --bg-surface: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.65);

    --text-primary: #0f172a; /* Slate 900 - Deepest */
    --text-secondary: #334155; /* Slate 700 - Good For labels */
    --text-muted: #475569; /* Slate 600 - Still dark enough for contrast */

    --border-glass: rgba(139, 92, 246, 0.1);
    --border-hover: rgba(139, 92, 246, 0.25);

    --shadow-glass: 0 4px 24px rgba(139, 92, 246, 0.08);
    --bg-glass-inner: rgba(139, 92, 246, 0.06);
}

body.light-mode::before {
    content: "";
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(circle at 0% 0%, rgba(139, 92, 246, 0.05) 0%, transparent 40%),
                radial-gradient(circle at 100% 100%, rgba(99, 102, 241, 0.05) 0%, transparent 40%);
    z-index: -1;
    pointer-events: none;
}

body.light-mode .glass-panel,
body.light-mode .glass-card {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(139, 92, 246, 0.15);
    box-shadow: 0 8px 32px rgba(139, 92, 246, 0.05);
}

body.light-mode .glass-card:hover {
    box-shadow: 0 12px 48px rgba(139, 92, 246, 0.12);
    border-color: var(--accent-primary);
}

body.light-mode #sidebar {
    background: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: blur(20px) !important;
    border-right-color: rgba(139, 92, 246, 0.1) !important;
}

body.light-mode #sidebar .sidebar-header {
    background: rgba(139, 92, 246, 0.04) !important;
    border-bottom-color: rgba(139, 92, 246, 0.1) !important;
}

body.light-mode #sidebar ul li a {
    color: #475569 !important;
    font-weight: 500;
}

body.light-mode #sidebar ul li.active a,
body.light-mode #sidebar ul li a:hover {
    color: var(--accent-primary) !important;
    background: rgba(139, 92, 246, 0.08) !important;
}

body.light-mode .navbar-glass {
    background: rgba(255, 255, 255, 0.7) !important;
    backdrop-filter: blur(16px) !important;
    border-bottom: 1px solid rgba(139, 92, 246, 0.1) !important;
}

body.light-mode .navbar-glass .nav-link,
body.light-mode .navbar-glass .navbar-brand {
    color: #0f172a !important;
}

body.light-mode .navbar-toggler,
body.light-mode #sidebarCollapse,
body.light-mode .btn-outline-light {
    color: #0f172a !important;
    border-color: rgba(139, 92, 246, 0.4) !important;
}

body.light-mode .navbar-toggler i,
body.light-mode #sidebarCollapse i,
body.light-mode .btn-outline-light i {
    color: #0f172a !important;
}

body.light-mode .btn-outline-light:hover {
    background: var(--accent-primary) !important;
    color: #fff !important;
}

/* Smart Text Adaptive Overrides */
body.light-mode .text-white:not(.badge):not(.btn),
body.light-mode .text-white-50:not(.badge):not(.btn),
body.light-mode .navbar-dark .navbar-brand,
body.light-mode .navbar-dark .nav-link {
    color: var(--text-primary) !important;
}

body.light-mode .text-secondary { color: var(--text-secondary) !important; }
body.light-mode .text-muted { color: var(--text-muted) !important; }
body.light-mode .small.text-muted { color: var(--text-secondary) !important; }

/* Dashboard Card Fixes */
.card-title.text-secondary {
    color: var(--text-secondary) !important;
}

body.light-mode .card-title.text-secondary {
    color: #1e293b !important;
    font-weight: 700;
}

/* Theme-Aware Glass Table */
.table-glass {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--border-glass);
    --bs-table-hover-color: var(--text-primary);
    --bs-table-hover-bg: rgba(139, 92, 246, 0.05);
    background: transparent;
    color: var(--text-primary);
}

.table-glass thead th {
    background: rgba(139, 92, 246, 0.03);
    color: var(--text-secondary);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-glass);
}

body.light-mode .table-glass thead th {
    background: rgba(139, 92, 246, 0.08) !important;
    color: #0f172a !important; /* Force Slate 900 */
}

.table-glass td {
    border-bottom: 1px solid var(--border-glass);
    padding: 1rem 0.75rem;
}

/* Sidebar Adaptive Links */
body.light-mode #sidebar ul li a,
body.light-mode #sidebar ul li a i {
    color: #334155 !important;
}

body.light-mode #sidebar ul li a:hover,
body.light-mode #sidebar ul li a:hover i {
    color: var(--accent-primary) !important;
}

body.light-mode #sidebar .text-white {
    color: var(--text-primary) !important;
}

/* Global Utility Overrides for Light Mode */
body.light-mode .bg-dark {
    background-color: rgba(139, 92, 246, 0.05) !important;
    color: var(--text-primary) !important;
}

body.light-mode .alert.bg-dark {
    background-color: #f8fafc !important; /* Extremely light grey/white background for alerts */
    border-color: rgba(139, 92, 246, 0.2) !important;
}

body.light-mode .alert-success.bg-dark {
    background-color: #f0fdf4 !important; /* Light green */
    color: #166534 !important;
    border-color: #bbf7d0 !important;
}

body.light-mode .alert-danger.bg-dark {
    background-color: #fef2f2 !important; /* Light red */
    color: #991b1b !important;
    border-color: #fecaca !important;
}

body.light-mode .badge.bg-dark {
    background-color: #e2e8f0 !important;
    color: #1e293b !important;
}

body.light-mode .form-control-glass {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(139, 92, 246, 0.2);
    color: #0f172a;
}

body.light-mode .form-control-glass:focus {
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1);
}

body.light-mode .btn-glass {
    background: rgba(139, 92, 246, 0.06);
    border-color: rgba(139, 92, 246, 0.2);
    color: #0f172a;
}

body.light-mode .btn-glass:hover {
    background: rgba(139, 92, 246, 0.12);
    color: var(--accent-primary);
}

body.light-mode .text-secondary { color: #1e293b !important; } /* Slate 800 for max legibility */
body.light-mode .text-muted     { color: #334155 !important; } /* Slate 700 */
body.light-mode .border-secondary { border-color: rgba(139,92,246,0.1) !important; }
body.light-mode .card-header.bg-dark { 
    background-color: rgba(139, 92, 246, 0.08) !important;
    color: #0f172a !important;
}

/* Smooth theme transition */
*, *::before, *::after {
    transition: background-color 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                color 0.2s linear,
                box-shadow 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Theme Toggle Button */
.theme-toggle-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--border-glass);
    background: var(--bg-glass);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
}

/* Theme-Aware Navbar Toggler Icon */
#mainNav .navbar-toggler-icon {
    filter: invert(1); /* Homepage Dark -> White */
}
body.light-mode #mainNav .navbar-toggler-icon {
    filter: invert(0); /* Homepage Light -> Dark */
}

body.light-mode #mainNav .navbar-toggler {
    border-color: rgba(139, 92, 246, 0.3) !important;
}

.navbar-dark .navbar-toggler-icon {
    filter: none; /* Dashboard Dark -> Already White */
}
body.light-mode .navbar-dark .navbar-toggler-icon {
    filter: invert(1); /* Dashboard Light -> Dark */
}

.theme-toggle-btn:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
    transform: translateY(-2px) scale(1.05);
}

html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

body {
    font-family: 'Sora', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
    position: relative;
}

/* DataTables Mobile Fixes */
@media (max-width: 768px) {
    .dataTables_wrapper .row {
        margin-left: 0;
        margin-right: 0;
    }
    .dataTables_wrapper .col-sm-12, 
    .dataTables_wrapper .col-md-6 {
        padding-left: 0;
        padding-right: 0;
        margin-bottom: 15px;
        text-align: left !important;
    }
    .dataTables_filter {
        text-align: left !important;
    }
    .dataTables_paginate {
        justify-content: center !important;
        margin-top: 15px;
        flex-wrap: wrap;
    }
    div.dataTables_wrapper div.dataTables_length label, 
    div.dataTables_wrapper div.dataTables_filter label {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
    }
    div.dataTables_wrapper div.dataTables_filter input {
        margin-left: 0;
        width: 100%;
        margin-top: 5px;
    }
}

body::before {
    content: "";
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0.03;
    pointer-events: none;
    z-index: 9999;
}

/* ===== INTERACTIVE UTILITIES ===== */

.spotlight-card {
    position: relative;
    overflow: hidden;
}

.spotlight-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(
        600px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
        rgba(139, 92, 246, 0.1),
        transparent 40%
    );
    z-index: 1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s;
}

.spotlight-card:hover::after {
    opacity: 1;
}

.magnetic-wrap {
    display: inline-block;
    transition: transform 0.2s cubic-bezier(0.23, 1, 0.32, 1);
}

.premium-ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: scale(0);
    animation: ripple-effect 0.6s linear;
    pointer-events: none;
    z-index: 10;
}

@keyframes ripple-effect {
    to { transform: scale(4); opacity: 0; }
}

/* Glass Enhancement */
.glass-panel, .glass-card {
    border: 1px solid var(--border-glass) !important;
    background: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0) 100%);
    backdrop-filter: blur(20px) saturate(180%);
}

/* Typography Enhancements */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Sora', system-ui, sans-serif;
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1.2;
}

h1 { font-weight: 800; }
h2 { font-weight: 700; }

/* Monospace accent for numbers, IDs, prices, API keys */
.mono, .mono *,
.badge,
.text-success.fw-bold,
[id$="charge"], [id$="balance"] {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
}

.glass-card {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.glass-card:hover {
    transform: translateY(-8px) scale(1.02);
    border-color: var(--accent-primary);
    box-shadow: 0 15px 45px rgba(139, 92, 246, 0.25);
}

/* Hero Image Floating Animation */
@keyframes float {
    0% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(1deg); }
    100% { transform: translateY(0px) rotate(0deg); }
}

.hero-img {
    animation: float 6s ease-in-out infinite;
    filter: drop-shadow(0 20px 40px rgba(139, 92, 246, 0.4));
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-lg);
}

.glass-box-inner {
    background: var(--bg-glass-inner);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 1rem;
}

/* Buttons */
.btn-primary-glow {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 0.75rem 1.75rem;
    font-family: 'Sora', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.02em;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.btn-primary-glow:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.5);
    color: white;
}

.btn-glass {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    backdrop-filter: blur(4px);
    border-radius: var(--radius-md);
    font-family: 'Sora', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.btn-glass:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: var(--border-hover);
}

/* Text Gradients */
.text-gradient {
    background: linear-gradient(to right, #c084fc, #6366f1);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Input Fields */
.form-control-glass {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    color: white;
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    transition: all 0.3s ease;
}

.form-control-glass:focus {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
    color: white;
    outline: none;
}

.form-control-glass::placeholder {
    color: var(--text-muted);
}

/* Custom Dropdown Styling */
.form-select.form-control-glass,
.form-select {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
}

.form-select.form-control-glass option,
.form-select option {
    background-color: var(--bg-surface);
    color: var(--text-primary);
}

/* Fix dropdown arrow for dark mode */
.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
}

body.light-mode .form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%230f172a' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
}



