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

:root {
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;

    /* Elegant Light Hybrid (Default Theme) Palette */
    --bg-main: #f1f5f9;                 /* Soft slate grey background */
    --bg-card: rgba(255, 255, 255, 0.85); /* Frosty white glass card */
    --bg-sidebar: #f8fafc;              /* Gorgeous off-white bright sidebar panel */
    --bg-header: rgba(255, 255, 255, 0.45); /* Frosted light header */
    --bg-chat-bot: rgba(15, 23, 42, 0.04);  /* Subtle dark tint for bot chats */
    --bg-table-th: rgba(15, 23, 42, 0.02);  /* Table header background light tint */
    --border-color: rgba(15, 23, 42, 0.08); /* Subtly defined dark borders */
    --text-primary: #0f172a;            /* Charcoal for high contrast readability */
    --text-secondary: #475569;          /* Slate grey for sub-labels */
    --text-muted: #64748b;              /* Soft grey for helpers */

    /* Sidebar specific contrast tokens */
    --sidebar-link-color: #475569;          /* Readable dark charcoal slate */
    --sidebar-link-hover-bg: rgba(79, 70, 229, 0.05); /* Light Indigo hover tint */
    --sidebar-link-hover-color: #4f46e5;    /* Glowing active indigo */
    --sidebar-link-active-bg: rgba(79, 70, 229, 0.08); /* Indigo active background */
    --sidebar-link-active-color: #4f46e5;   /* Luminous active indigo */
    --sidebar-sublink-color: #64748b;       /* Muted grey-blue for sub-menus */
    --sidebar-sublink-hover-bg: rgba(79, 70, 229, 0.05);
    --sidebar-sublink-hover-color: #0f172a; /* Sharp charcoal text */
    
    /* Primary Accent Gradients (Deep Indigo / Cyan) */
    --accent-primary: #4f46e5;          /* Deep Indigo */
    --accent-secondary: #0891b2;        /* Teal Cyan */
    --accent-gradient: linear-gradient(135deg, #4f46e5 0%, #0891b2 100%);
    --accent-gradient-hover: linear-gradient(135deg, #3730a3 0%, #0e7490 100%);
    
    /* UI States adapted for light backgrounds */
    --state-success: #10b981;
    --state-warning: #f59e0b;
    --state-danger: #ef4444;
    --state-info: #3b82f6;

    /* Shadow and Blur */
    --card-shadow: 0 10px 30px -10px rgba(15, 23, 42, 0.08);
    --glass-blur: blur(16px);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Theme overrides when user toggles theme */
[data-theme="dark"] {
    --bg-main: #0b0f19;
    --bg-card: rgba(17, 24, 39, 0.75);
    --bg-sidebar: rgba(10, 15, 30, 0.9);
    --bg-header: rgba(11, 15, 25, 0.5);
    --bg-chat-bot: rgba(255, 255, 255, 0.05);
    --bg-table-th: rgba(255, 255, 255, 0.02);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Sidebar specific dark contrast tokens */
    --sidebar-link-color: #94a3b8;          /* Slate grey */
    --sidebar-link-hover-bg: rgba(99, 102, 241, 0.1); /* Indigo dark hover tint */
    --sidebar-link-hover-color: #f8fafc;    /* Glowing white */
    --sidebar-link-active-bg: rgba(99, 102, 241, 0.15); /* Indigo active background */
    --sidebar-link-active-color: #f8fafc;   /* White text */
    --sidebar-sublink-color: #64748b;       /* Muted slate */
    --sidebar-sublink-hover-bg: rgba(99, 102, 241, 0.08);
    --sidebar-sublink-hover-color: #f8fafc;
    
    --accent-primary: #6366f1;
    --accent-secondary: #06b6d4;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #06b6d4 100%);
    --accent-gradient-hover: linear-gradient(135deg, #4f46e5 0%, #0891b2 100%);
    
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Global Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: var(--text-muted) transparent;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-main);
    color: var(--text-primary);
    overflow-x: hidden;
    transition: var(--transition-smooth);
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--text-primary);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* Glassmorphism Card Style */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    padding: 1.5rem;
    transition: var(--transition-smooth);
}
.glass-card:hover {
    transform: translateY(-2px);
    border-color: rgba(99, 102, 241, 0.25);
}

/* Interactive Elements & Buttons */
.btn-premium {
    background: var(--accent-gradient);
    border: none;
    color: #ffffff;
    font-weight: 500;
    border-radius: 10px;
    padding: 0.6rem 1.5rem;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}
.btn-premium:hover {
    background: var(--accent-gradient-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
    color: #ffffff;
}

.form-control-premium {
    background: rgba(15, 23, 42, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary) !important;
    padding: 0.75rem 1rem;
    transition: var(--transition-smooth);
}
.form-control-premium:focus {
    background: rgba(15, 23, 42, 0.04);
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
    outline: none;
}

[data-theme="dark"] .form-control-premium {
    background: rgba(255, 255, 255, 0.03);
}
[data-theme="dark"] .form-control-premium:focus {
    background: rgba(255, 255, 255, 0.05);
}

/* App Shell Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 1000;
    transition: var(--transition-smooth);
}

.sidebar-brand {
    padding: 1.5rem;
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-menu {
    list-style: none;
    padding: 1rem;
    flex: 1;
    overflow-y: auto;
}

.sidebar-item {
    margin-bottom: 0.5rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--sidebar-link-color);
    text-decoration: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition-smooth);
}
.sidebar-link:hover {
    background: var(--sidebar-link-hover-bg);
    color: var(--sidebar-link-hover-color);
}
.sidebar-item.active .sidebar-link {
    border-left: 3px solid var(--accent-primary);
    background: var(--sidebar-link-active-bg);
    color: var(--sidebar-link-active-color);
}

/* Main Content Wrapper */
.main-wrapper {
    margin-left: 260px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Header Navbar */
.main-header {
    height: 70px;
    background: var(--bg-header);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 999;
}

.content-body {
    padding: 2rem;
    flex: 1;
}

/* KPI Widgets Layout */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.kpi-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
    font-size: 1.5rem;
}

.kpi-info h3 {
    font-size: 1.8rem;
    margin-bottom: 0.2rem;
}

.kpi-info p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0;
}

/* Admin AI Chatbot Style */
.chatbot-panel {
    display: flex;
    flex-direction: column;
    height: 450px;
}

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-msg {
    max-width: 80%;
    padding: 0.8rem 1.2rem;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.chat-msg.admin {
    align-self: flex-end;
    background: var(--accent-primary);
    color: #ffffff;
    border-bottom-right-radius: 2px;
}

.chat-msg.bot {
    align-self: flex-start;
    background: var(--bg-chat-bot);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-bottom-left-radius: 2px;
}

.chatbot-input-area {
    display: flex;
    gap: 0.5rem;
    padding: 1rem 0 0 0;
    border-top: 1px solid var(--border-color);
}

/* Custom Table Styles */
.table-premium {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
.table-premium th {
    background: var(--bg-table-th);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}
.table-premium td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.95rem;
    vertical-align: middle;
}
.table-premium tr:hover td {
    background: rgba(99, 102, 241, 0.03);
}

/* Micro-animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animated-fade {
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Responsive Overrides */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-wrapper {
        margin-left: 0;
    }
    .main-header {
        padding: 0 1rem;
    }
}

/* ----------------------------------------------------------------
   Sidebar Sub-menu (Collapsible)
---------------------------------------------------------------- */
.sidebar-submenu {
    list-style: none;
    padding: 0.25rem 0 0.5rem 1.25rem;
    margin: 0;
}
.sidebar-sublink {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--sidebar-sublink-color);
    text-decoration: none;
    font-size: 0.875rem;
    border-radius: 8px;
    transition: var(--transition-smooth);
    border-left: 2px solid transparent;
}
.sidebar-sublink:hover {
    color: var(--sidebar-sublink-hover-color);
    background: var(--sidebar-sublink-hover-bg);
    border-left-color: var(--accent-primary);
}

/* ----------------------------------------------------------------
   Page Header Toolbar
---------------------------------------------------------------- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.page-header h1 {
    font-size: 1.65rem;
    margin: 0;
}
.page-header .breadcrumb {
    background: transparent;
    margin: 0;
    padding: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ----------------------------------------------------------------
   DataTables Dark Theme Integration
---------------------------------------------------------------- */
.dataTables_wrapper {
    color: var(--text-primary);
    font-family: var(--font-body);
}
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    background: rgba(15, 23, 42, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 0.35rem 0.75rem;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 6px !important;
    color: var(--text-secondary) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--accent-primary) !important;
    border-color: var(--accent-primary) !important;
    color: #fff !important;
}
.dataTables_wrapper .dataTables_info {
    color: var(--text-muted);
    font-size: 0.85rem;
}
.dataTables_wrapper .dt-buttons {
    margin-bottom: 1rem;
    display: inline-flex;
    gap: 0.35rem;
}
.dataTables_wrapper .dt-button {
    background: rgba(15, 23, 42, 0.02) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-secondary) !important;
    font-family: var(--font-body);
    font-size: 0.82rem !important;
    font-weight: 500;
    border-radius: 8px !important;
    padding: 0.45rem 1rem !important;
    transition: var(--transition-smooth) !important;
    box-shadow: none !important;
}
.dataTables_wrapper .dt-button:hover {
    background: var(--accent-gradient) !important;
    border-color: var(--accent-primary) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3) !important;
    transform: translateY(-1px);
}
[data-theme="dark"] .dataTables_wrapper .dt-button {
    background: rgba(255, 255, 255, 0.03) !important;
    color: var(--text-secondary) !important;
}
[data-theme="dark"] .dataTables_wrapper .dataTables_length select,
[data-theme="dark"] .dataTables_wrapper .dataTables_filter input {
    background: rgba(255, 255, 255, 0.04);
}

/* ----------------------------------------------------------------
   Status Badge Chips
---------------------------------------------------------------- */
.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.status-chip.posted   { background: rgba(16,185,129,.15); color:#10b981; border:1px solid rgba(16,185,129,.25); }
.status-chip.pending  { background: rgba(245,158,11,.15); color:#f59e0b; border:1px solid rgba(245,158,11,.25); }
.status-chip.rejected { background: rgba(239,68,68,.15);  color:#ef4444; border:1px solid rgba(239,68,68,.25); }

/* ----------------------------------------------------------------
   Premium Forms (labels, groups, cards)
---------------------------------------------------------------- */
.form-label-premium {
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    display: block;
}
.form-section-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-primary);
    margin: 1.5rem 0 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

/* Voucher amount total bar */
.amount-bar {
    background: linear-gradient(135deg, rgba(99,102,241,.12) 0%, rgba(6,182,212,.08) 100%);
    border: 1px solid rgba(99,102,241,.2);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.amount-bar .amount-label { font-size: 0.85rem; color: var(--text-muted); }
.amount-bar .amount-value { font-size: 1.6rem; font-family: var(--font-heading); font-weight: 700; color: var(--accent-primary); }

/* Alert Boxes */
.alert-premium {
    border-radius: 10px;
    padding: 0.85rem 1.25rem;
    font-size: 0.9rem;
    border: none;
}
.alert-premium.success { background: rgba(16,185,129,.1); color:#10b981; border:1px solid rgba(16,185,129,.2); }
.alert-premium.danger  { background: rgba(239,68,68,.1);  color:#ef4444; border:1px solid rgba(239,68,68,.2); }

/* ----------------------------------------------------------------
   System-wide Global Light & Dark Theme Contrast Normalizations
   ---------------------------------------------------------------- */

/* 1. Global modal theme adaptations overriding inline dark styles */
.modal-content {
    background: rgba(255, 255, 255, 0.98) !important;
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--card-shadow) !important;
}
[data-theme="dark"] .modal-content {
    background: rgba(23, 27, 41, 0.95) !important;
}

/* 2. Responsive text contrast (overrides static text-white class on light background) */
[data-theme="light"] .text-white:not(.btn):not(.btn-premium):not(.btn-premium *):not(.status-chip):not(.alert-premium):not(.alert):not(.badge):not(.btn-close):not(.btn-close-white):not(button):not(.nav-link):not(.btn-outline-secondary) {
    color: var(--text-primary) !important;
}

/* 3. Global Form Control & Select normalization overrides */
.form-control,
.form-select {
    background-color: rgba(15, 23, 42, 0.02) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    border-radius: 10px !important;
    padding: 0.75rem 1rem !important;
    transition: var(--transition-smooth) !important;
}
.form-control:focus,
.form-select:focus {
    background-color: rgba(15, 23, 42, 0.04) !important;
    border-color: var(--accent-primary) !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25) !important;
    outline: none !important;
}
.form-control::placeholder {
    color: var(--text-muted) !important;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: rgba(255, 255, 255, 0.03) !important;
    color: var(--text-primary) !important;
}
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background-color: rgba(255, 255, 255, 0.05) !important;
}
