@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700&family=Inter:wght@300;400;500;600;700&display=swap');

/* Default & Theme 1: Midnight Executive (Dark Navy & Indigo) */
:root, [data-theme="midnight"] {
    --font-primary: 'Outfit', sans-serif;
    --bg-primary: #090d16;
    --bg-secondary: #111827;
    --bg-card: rgba(30, 41, 59, 0.45);
    --border-color: rgba(255, 255, 255, 0.08);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-primary: #6366f1; /* Indigo */
    --accent-primary-hover: #4f46e5;
    --accent-glow: rgba(99, 102, 241, 0.25);
    --gradient-brand: linear-gradient(135deg, #a5b4fc, #6366f1);
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.15);
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.15);
    
    --sidebar-width: 260px;
    --header-height: 70px;
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Theme 2: Titanium Slate (Dark Sapphire & Steel) */
[data-theme="titanium"] {
    --font-primary: 'Inter', sans-serif;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: rgba(30, 41, 59, 0.55);
    --border-color: rgba(148, 163, 184, 0.15);
    
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    
    --accent-primary: #38bdf8; /* Sapphire Sky Blue */
    --accent-primary-hover: #0284c7;
    --accent-glow: rgba(56, 189, 248, 0.25);
    --gradient-brand: linear-gradient(135deg, #bae6fd, #38bdf8);
    
    --success: #38bdf8;
    --success-glow: rgba(56, 189, 248, 0.15);
}

/* Theme 3: Royal Amethyst (Dark Purple & Violet - replaces emerald green) */
[data-theme="amethyst"] {
    --font-primary: 'Plus Jakarta Sans', sans-serif;
    --bg-primary: #12091f;
    --bg-secondary: #1d1033;
    --bg-card: rgba(45, 20, 75, 0.45);
    --border-color: rgba(192, 132, 252, 0.15);
    
    --text-primary: #fcf5ff;
    --text-secondary: #e9d5ff;
    --text-muted: #c084fc;
    
    --accent-primary: #a855f7; /* Royal Purple */
    --accent-primary-hover: #9333ea;
    --accent-glow: rgba(168, 85, 247, 0.28);
    --gradient-brand: linear-gradient(135deg, #f0abfc, #a855f7);
    
    --success: #c084fc;
    --success-glow: rgba(192, 132, 252, 0.18);
}

/* Theme 4: Cyber Obsidian (Dark Cyber Cyan & Obsidian Black) */
[data-theme="obsidian"] {
    --font-primary: 'Outfit', sans-serif;
    --bg-primary: #05080e;
    --bg-secondary: #0c121e;
    --bg-card: rgba(15, 25, 45, 0.5);
    --border-color: rgba(6, 182, 212, 0.15);
    
    --text-primary: #ecfeff;
    --text-secondary: #a5f3fc;
    --text-muted: #67e8f9;
    
    --accent-primary: #06b6d4; /* Cyber Cyan */
    --accent-primary-hover: #0891b2;
    --accent-glow: rgba(6, 182, 212, 0.28);
    --gradient-brand: linear-gradient(135deg, #67e8f9, #06b6d4);
    
    --success: #22d3ee;
    --success-glow: rgba(34, 211, 238, 0.18);
}

/* Theme 5: Sunset Copper (Dark Amber Bronze & Espresso) */
[data-theme="copper"] {
    --font-primary: 'Inter', sans-serif;
    --bg-primary: #140d0a;
    --bg-secondary: #221612;
    --bg-card: rgba(50, 30, 20, 0.45);
    --border-color: rgba(245, 158, 11, 0.15);
    
    --text-primary: #fffbeb;
    --text-secondary: #fde68a;
    --text-muted: #fbbf24;
    
    --accent-primary: #f59e0b; /* Copper Amber */
    --accent-primary-hover: #d97706;
    --accent-glow: rgba(245, 158, 11, 0.28);
    --gradient-brand: linear-gradient(135deg, #fef08a, #f59e0b);
    
    --success: #fbbf24;
    --success-glow: rgba(251, 191, 36, 0.18);
}

/* Theme 6: Lumière Pearl (Ultra-Nice Luxury Corporate Light Mode) */
[data-theme="pearl"] {
    --font-primary: 'Plus Jakarta Sans', sans-serif;
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    
    --accent-primary: #4f46e5;
    --accent-primary-hover: #4338ca;
    --accent-glow: rgba(79, 70, 229, 0.15);
    --gradient-brand: linear-gradient(135deg, #4f46e5, #0284c7);
    
    --success: #059669;
    --success-glow: rgba(5, 150, 105, 0.15);
    --warning: #d97706;
    --danger: #dc2626;
    --danger-glow: rgba(220, 38, 38, 0.15);
}

/* Specific Light Mode UI Overrides for Pearl Theme */
[data-theme="pearl"] .glass-panel {
    background: #ffffff !important;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
    border: 1px solid #e2e8f0 !important;
}

[data-theme="pearl"] .form-control {
    background: #f1f5f9 !important;
    color: #0f172a !important;
    border-color: #cbd5e1 !important;
}

[data-theme="pearl"] .form-control:focus {
    background: #ffffff !important;
    border-color: #4f46e5 !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15) !important;
}

[data-theme="pearl"] .sidebar {
    background: #ffffff !important;
    border-right: 1px solid #e2e8f0 !important;
}

[data-theme="pearl"] .sidebar-brand a {
    color: #0f172a !important;
}

[data-theme="pearl"] .sidebar-item a {
    color: #475569 !important;
}

[data-theme="pearl"] .sidebar-item a:hover {
    color: #0f172a !important;
    background: #f1f5f9 !important;
}

[data-theme="pearl"] .sidebar-item.active a {
    color: #ffffff !important;
    background: #4f46e5 !important;
}

[data-theme="pearl"] .top-header {
    background: #ffffff !important;
    border-bottom: 1px solid #e2e8f0 !important;
}

[data-theme="pearl"] .excel-table th {
    background: #f1f5f9 !important;
    color: #334155 !important;
    border: 1px solid #cbd5e1 !important;
}

[data-theme="pearl"] .excel-table td {
    background: #ffffff !important;
    color: #0f172a !important;
    border: 1px solid #e2e8f0 !important;
}

[data-theme="pearl"] .excel-table td.active-cell {
    background: rgba(79, 70, 229, 0.08) !important;
    border: 2px solid #4f46e5 !important;
}

[data-theme="pearl"] .formula-bar-container {
    background: #f8fafc !important;
    border: 1px solid #cbd5e1 !important;
}

[data-theme="pearl"] .formula-input {
    color: #0f172a !important;
}

[data-theme="pearl"] .modal-card {
    background: #ffffff !important;
    color: #0f172a !important;
}

[data-theme="pearl"] .modal-header h2 {
    color: #0f172a !important;
}

[data-theme="pearl"] .custom-table th {
    color: #475569 !important;
    border-bottom-color: #e2e8f0 !important;
}

[data-theme="pearl"] .custom-table td {
    color: #0f172a !important;
    border-bottom-color: #e2e8f0 !important;
}

/* Automatic Light Mode Text Overrides for hardcoded inline white text */
[data-theme="pearl"] [style*="color: white"]:not(.btn-primary):not(.btn-danger):not(.btn-success):not(.sidebar-item.active a):not(.toast):not(.badge-primary):not(.badge-danger),
[data-theme="pearl"] [style*="color:white"]:not(.btn-primary):not(.btn-danger):not(.btn-success):not(.sidebar-item.active a):not(.toast):not(.badge-primary):not(.badge-danger),
[data-theme="pearl"] [style*="color: #fff"]:not(.btn-primary):not(.btn-danger):not(.btn-success):not(.sidebar-item.active a):not(.toast):not(.badge-primary):not(.badge-danger),
[data-theme="pearl"] [style*="color:#fff"]:not(.btn-primary):not(.btn-danger):not(.btn-success):not(.sidebar-item.active a):not(.toast):not(.badge-primary):not(.badge-danger) {
    color: #0f172a !important;
}

[data-theme="pearl"] h1,
[data-theme="pearl"] h2,
[data-theme="pearl"] h3,
[data-theme="pearl"] h4,
[data-theme="pearl"] h5,
[data-theme="pearl"] h6,
[data-theme="pearl"] strong {
    color: #0f172a;
}

[data-theme="pearl"] .stat-details h3 {
    color: #0f172a !important;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-primary, 'Outfit', sans-serif);
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--bg-card);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* Glassmorphism Common */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    font-size: 0.95rem;
}

.btn-primary {
    background-color: var(--accent-primary);
    color: white;
    box-shadow: 0 4px 14px var(--accent-glow);
}
.btn-primary:hover {
    background-color: var(--accent-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.05);
    transform: translateY(-2px);
}

.btn-danger {
    background-color: var(--danger);
    color: white;
    box-shadow: 0 4px 14px var(--danger-glow);
}
.btn-danger:hover {
    background-color: #dc2626;
    transform: translateY(-2px);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: 6px;
}

/* Login Page Styling */
.login-container {
    display: flex;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(circle at 50% 50%, #1e1b4b 0%, var(--bg-primary) 70%);
}

.login-card {
    width: 100%;
    max-width: 440px;
    padding: 40px;
    animation: fadeIn 0.6s ease-out;
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo h1 {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #a5b4fc, var(--accent-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-logo p {
    color: var(--text-secondary);
    margin-top: 8px;
    font-size: 0.95rem;
}

.form-group {
    margin-bottom: 20px;
    position: relative;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: white;
    font-size: 0.95rem;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: rgba(15, 23, 42, 0.8);
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-checkbox input {
    accent-color: var(--accent-primary);
    width: 16px;
    height: 16px;
}

/* Layout Dashboard */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-brand a {
    text-decoration: none;
    font-size: 1.4rem;
    font-weight: 700;
    color: white;
    background: linear-gradient(135deg, #a5b4fc, var(--accent-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-menu {
    list-style: none;
    padding: 24px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.sidebar-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    transition: var(--transition);
    font-weight: 500;
}

.sidebar-item a:hover {
    color: white;
    background: rgba(255, 255, 255, 0.03);
}

.sidebar-item.active a {
    color: white;
    background: var(--accent-primary);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
}

.user-info {
    flex: 1;
    overflow: hidden;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.logout-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    padding: 4px;
}

.logout-btn:hover {
    color: var(--danger);
}

/* Main Content Panel */
.main-panel {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Header */
.top-header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.content-container {
    padding: 32px;
    flex: 1;
    animation: fadeIn 0.4s ease-out;
}

/* Grid & Cards Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-details h3 {
    font-size: 2rem;
    font-weight: 700;
    margin-top: 4px;
}

.stat-details p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--accent-glow);
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* Tables & CRUD Content */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.custom-table th {
    padding: 16px;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    font-size: 0.9rem;
}

.custom-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
    vertical-align: middle;
}

.custom-table tbody tr {
    transition: var(--transition);
}

.custom-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: 4px;
    margin-bottom: 4px;
}

.badge-primary {
    background: var(--accent-glow);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.badge-success {
    background: var(--success-glow);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

/* Action buttons */
.action-buttons {
    display: flex;
    gap: 8px;
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
    padding: 20px;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    width: 100%;
    max-width: 550px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 32px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.modal-header h2 {
    font-size: 1.4rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.modal-close:hover {
    color: white;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 8px;
    padding: 12px;
    background: rgba(15, 23, 42, 0.4);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    max-height: 160px;
    overflow-y: auto;
}

/* Toast System */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    padding: 16px 24px;
    border-radius: var(--border-radius);
    color: white;
    font-weight: 500;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    min-width: 300px;
}

.toast.show {
    transform: translateX(0);
}

.toast-success {
    background: #065f46;
    border-left: 5px solid var(--success);
}

.toast-danger {
    background: #7f1d1d;
    border-left: 5px solid var(--danger);
}

/* Zoom-In Notification Style */
.toast-zoom-in {
    background: linear-gradient(135deg, #1e1b4b 0%, #065f46 100%) !important;
    border: 2px solid #34d399 !important;
    box-shadow: 0 0 25px rgba(52, 211, 153, 0.4) !important;
    transform: scale(0.3) translateY(-20px) !important;
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.4s ease !important;
}

.toast-zoom-in.show {
    transform: scale(1) translateY(0) !important;
    opacity: 1;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Mobile Responsiveness & Spreadsheet Scrollbar Optimizations */
.grid-container {
    overflow-x: auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
}

.grid-container::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.grid-container::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.8);
}

.grid-container::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 5px;
}

.grid-container::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary-hover);
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-panel {
        margin-left: 0;
    }
    
    .top-header {
        padding: 0 16px;
    }
    
    .content-container {
        padding: 16px;
    }

    .spreadsheet-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .formula-bar-container {
        flex-wrap: wrap;
    }

    .modal-card {
        padding: 20px;
        width: 95vw;
    }

    .welcome-text {
        display: none;
    }
}

