body {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    font-family: 'Cairo', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    margin: 0;
    min-height: 100vh;
}

/* Fix RTL spacing */
.me-2 { margin-left: 0.5rem !important; margin-right: 0 !important; }
.ms-auto { margin-right: auto !important; margin-left: 0 !important; }

/* 
   THEME DEFINITIONS 
   We leverage Bootstrap 5 CSS variables to create different themes.
   Light and Dark are built-in, but we can tweak them too if we want.
*/

/* 1. Midnight Theme (Deep Blue) */
[data-bs-theme="midnight"] {
    --bs-body-bg: #0f172a;
    --bs-body-color: #f1f5f9;
    --bs-heading-color: #f1f5f9;
    --bs-body-bg-rgb: 15, 23, 42;
    --bs-tertiary-bg: #1e293b;
    --bs-secondary-bg: #334155;
    --bs-border-color: #334155;
    --bs-link-color: #60a5fa;
    --bs-link-hover-color: #93c5fd;
    --bs-card-bg: #1e293b;
    --bs-card-border-color: #334155;
}

/* 2. Forest Theme (Deep Green) */
[data-bs-theme="forest"] {
    --bs-body-bg: #052e16;
    --bs-body-color: #ecfdf5;
    --bs-heading-color: #ecfdf5;
    --bs-body-bg-rgb: 5, 46, 22;
    --bs-tertiary-bg: #064e3b;
    --bs-secondary-bg: #065f46;
    --bs-border-color: #047857;
    --bs-link-color: #34d399;
    --bs-link-hover-color: #6ee7b7;
    --bs-card-bg: #064e3b;
    --bs-card-border-color: #047857;
}

/* 3. Ocean Theme (Deep Teal/Blue) */
[data-bs-theme="ocean"] {
    --bs-body-bg: #0c4a6e;
    --bs-body-color: #f0f9ff;
    --bs-heading-color: #f0f9ff;
    --bs-body-bg-rgb: 12, 74, 110;
    --bs-tertiary-bg: #075985;
    --bs-secondary-bg: #0369a1;
    --bs-border-color: #0284c7;
    --bs-link-color: #38bdf8;
    --bs-link-hover-color: #7dd3fc;
    --bs-card-bg: #075985;
    --bs-card-border-color: #0284c7;
}

/* 4. Sunset Theme (Warm Dark) */
[data-bs-theme="sunset"] {
    --bs-body-bg: #431407;
    --bs-body-color: #fff7ed;
    --bs-heading-color: #fff7ed;
    --bs-body-bg-rgb: 67, 20, 7;
    --bs-tertiary-bg: #7c2d12;
    --bs-secondary-bg: #9a3412;
    --bs-border-color: #c2410c;
    --bs-link-color: #fdba74;
    --bs-link-hover-color: #ffedd5;
    --bs-card-bg: #7c2d12;
    --bs-card-border-color: #c2410c;
}

/* 5. Royal Theme (Deep Purple) */
[data-bs-theme="royal"] {
    --bs-body-bg: #2e1065;
    --bs-body-color: #faf5ff;
    --bs-heading-color: #faf5ff;
    --bs-body-bg-rgb: 46, 16, 101;
    --bs-tertiary-bg: #4c1d95;
    --bs-secondary-bg: #5b21b6;
    --bs-border-color: #6d28d9;
    --bs-link-color: #c084fc;
    --bs-link-hover-color: #e9d5ff;
    --bs-card-bg: #4c1d95;
    --bs-card-border-color: #6d28d9;
}

/* 
   Shared overrides for ALL dark themes 
   This ensures standard Bootstrap classes like .text-dark don't cause visibility issues.
*/
[data-bs-theme="midnight"],
[data-bs-theme="forest"],
[data-bs-theme="ocean"],
[data-bs-theme="sunset"],
[data-bs-theme="royal"] {
    color-scheme: dark;
}

/* Text color overrides */
[data-bs-theme="midnight"] .text-dark,
[data-bs-theme="forest"] .text-dark,
[data-bs-theme="ocean"] .text-dark,
[data-bs-theme="sunset"] .text-dark,
[data-bs-theme="royal"] .text-dark {
    color: #f8f9fa !important;
}

[data-bs-theme="midnight"] .text-muted,
[data-bs-theme="forest"] .text-muted,
[data-bs-theme="ocean"] .text-muted,
[data-bs-theme="sunset"] .text-muted,
[data-bs-theme="royal"] .text-muted {
    color: rgba(255, 255, 255, 0.6) !important;
}

[data-bs-theme="midnight"] .text-secondary,
[data-bs-theme="forest"] .text-secondary,
[data-bs-theme="ocean"] .text-secondary,
[data-bs-theme="sunset"] .text-secondary,
[data-bs-theme="royal"] .text-secondary {
    color: rgba(255, 255, 255, 0.75) !important;
}

/* Background overrides for hardcoded bg-light/bg-white classes */
[data-bs-theme="midnight"] .bg-light,
[data-bs-theme="forest"] .bg-light,
[data-bs-theme="ocean"] .bg-light,
[data-bs-theme="sunset"] .bg-light,
[data-bs-theme="royal"] .bg-light {
    background-color: var(--bs-tertiary-bg) !important;
    color: var(--bs-body-color) !important;
}

[data-bs-theme="midnight"] .bg-white,
[data-bs-theme="forest"] .bg-white,
[data-bs-theme="ocean"] .bg-white,
[data-bs-theme="sunset"] .bg-white,
[data-bs-theme="royal"] .bg-white {
    background-color: var(--bs-card-bg) !important;
    color: var(--bs-body-color) !important;
}

[data-bs-theme="midnight"] .table th,
[data-bs-theme="forest"] .table th,
[data-bs-theme="ocean"] .table th,
[data-bs-theme="sunset"] .table th,
[data-bs-theme="royal"] .table th {
    color: rgba(255, 255, 255, 0.8);
}


/* Ensure cards and tables inherit theme colors correctly */
[data-bs-theme="midnight"] .card,
[data-bs-theme="forest"] .card,
[data-bs-theme="ocean"] .card,
[data-bs-theme="sunset"] .card,
[data-bs-theme="royal"] .card {
    background-color: var(--bs-card-bg);
    border-color: var(--bs-card-border-color);
    color: var(--bs-body-color);
}

[data-bs-theme="midnight"] .table,
[data-bs-theme="forest"] .table,
[data-bs-theme="ocean"] .table,
[data-bs-theme="sunset"] .table,
[data-bs-theme="royal"] .table {
    color: var(--bs-body-color);
    --bs-table-color: var(--bs-body-color);
    --bs-table-bg: transparent;
    --bs-table-border-color: var(--bs-border-color);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.05);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="midnight"] .modal-content,
[data-bs-theme="forest"] .modal-content,
[data-bs-theme="ocean"] .modal-content,
[data-bs-theme="sunset"] .modal-content,
[data-bs-theme="royal"] .modal-content {
    background-color: var(--bs-tertiary-bg);
    border-color: var(--bs-border-color);
    color: var(--bs-body-color);
}

/* Sidebar overrides for specific themes */
[data-bs-theme="midnight"] .sidebar { background-color: #1e293b !important; border-left: 1px solid #334155; }
[data-bs-theme="forest"] .sidebar { background-color: #064e3b !important; border-left: 1px solid #065f46; }
[data-bs-theme="ocean"] .sidebar { background-color: #075985 !important; border-left: 1px solid #0369a1; }
[data-bs-theme="sunset"] .sidebar { background-color: #7c2d12 !important; border-left: 1px solid #9a3412; }
[data-bs-theme="royal"] .sidebar { background-color: #4c1d95 !important; border-left: 1px solid #5b21b6; }


.main-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
    position: relative;
    z-index: 1;
}

@keyframes gradient {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.chat-container {
    width: 100%;
    max-width: 600px;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    height: 85vh;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    overflow: hidden;
}

.chat-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--bs-border-color);
    background: var(--bs-tertiary-bg);
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--bs-body-color);
}

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

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

[data-bs-theme="dark"] ::-webkit-scrollbar-thumb,
[data-bs-theme="midnight"] ::-webkit-scrollbar-thumb,
[data-bs-theme="forest"] ::-webkit-scrollbar-thumb,
[data-bs-theme="ocean"] ::-webkit-scrollbar-thumb,
[data-bs-theme="sunset"] ::-webkit-scrollbar-thumb,
[data-bs-theme="royal"] ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

.message {
    max-width: 85%;
    padding: 0.85rem 1.1rem;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 0.95rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    animation: fadeIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.visitor {
    align-self: flex-end;
    background: #0d6efd;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message.bot {
    align-self: flex-start;
    background: var(--bs-tertiary-bg); /* Use theme bg */
    color: var(--bs-body-color);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--bs-border-color);
}

.chat-input-area {
    padding: 1.25rem;
    background: var(--bs-body-bg);
    border-top: 1px solid var(--bs-border-color);
}

.chat-input-area form {
    display: flex;
    gap: 0.75rem;
}

.chat-input-area input {
    flex: 1;
    border: 1px solid var(--bs-border-color);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    outline: none;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    transition: all 0.3s ease;
}

.chat-input-area input:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

.chat-input-area button {
    background: #0d6efd;
    color: #fff;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.chat-input-area button:hover {
    background: #0b5ed7;
    transform: translateY(-1px);
}

.admin-link {
    font-size: 14px;
    color: #6c757d;
    text-decoration: none;
    background: rgba(0, 0, 0, 0.05);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.admin-link:hover {
    background: rgba(0, 0, 0, 0.1);
    text-decoration: none;
}

/* Admin Styles */
.admin-container {
    max-width: 900px;
    margin: 2rem auto;
    padding: 2rem;
    background: var(--bs-body-bg);
    border-radius: 16px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.05);
    border: 1px solid var(--bs-border-color);
    position: relative;
    z-index: 1;
    color: var(--bs-body-color);
}

.admin-container h1 {
    margin-top: 0;
    color: var(--bs-heading-color, var(--bs-body-color)); /* Use variable or fallback */
    font-weight: 700;
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
    margin-top: 1.5rem;
    color: var(--bs-body-color);
}

.table th {
    background: transparent;
    border: none;
    padding: 1rem;
    color: #6c757d; /* Keep subtle for headers, but overridden for dark themes */
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
}

.table td {
    background: var(--bs-body-bg);
    padding: 1rem;
    border-top: 1px solid var(--bs-border-color);
    border-bottom: 1px solid var(--bs-border-color);
    color: var(--bs-body-color);
}

.table tr td:first-child { border-left: 1px solid var(--bs-border-color); border-radius: 8px 0 0 8px; }
.table tr td:last-child { border-right: 1px solid var(--bs-border-color); border-radius: 0 8px 8px 0; }

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--bs-body-color);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 8px;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
}

/* Compact Table Class */
.table-compact td, .table-compact th {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.9rem;
}
.table-compact tr td:first-child { border-radius: 4px 0 0 4px; }
.table-compact tr td:last-child { border-radius: 0 4px 4px 0; }

/* ---------------------------------------------------------
   NEW SIDEBAR STYLES (Collapsible Groups)
   --------------------------------------------------------- */
.sidebar-group-btn {
    width: 100%;
    text-align: right; /* RTL */
    padding: 12px 20px;
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.7);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
}
.sidebar-group-btn:hover {
    color: #fff;
    background-color: rgba(255,255,255,0.05);
}
.sidebar-group-btn[aria-expanded="true"] {
    background-color: rgba(255,255,255,0.05);
    color: #fff;
}
.sidebar-group-btn .group-content {
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-group-btn .arrow-icon {
    font-size: 0.8em;
    transition: transform 0.3s;
    opacity: 0.5;
}
.sidebar-group-btn[aria-expanded="true"] .arrow-icon {
    transform: rotate(-180deg); /* Adjust for RTL if needed, usually just flips vertically */
}

/* Colors for groups (Text & Icon) */
.group-mail { color: #ffca28 !important; }   /* Amber */
.group-acct { color: #42a5f5 !important; }   /* Blue */
.group-hr { color: #66bb6a !important; }     /* Green */
.group-admin { color: #ef5350 !important; }  /* Red */
.group-reports { color: #ab47bc !important; }/* Purple */
.group-stock { color: #fd7e14 !important; } /* Orange */
.group-expenses { color: #e83e8c !important; } /* Pink */

/* Submenu indentation */
.sidebar .collapse .nav-link {
    padding-right: 45px; /* RTL indent */
    padding-left: 20px;
    font-size: 0.9em;
    color: rgba(255,255,255,0.6);
}
.sidebar .collapse .nav-link:hover, 
.sidebar .collapse .nav-link.active {
    color: #fff;
}
.group-meetings { color: #20c997 !important; } /* Teal */
.group-committees { color: #8e24aa !important; } /* Purple */
