/* Theme Variables */
:root {
    /* Body Background */
    --body-bg-rgb: 240, 241, 247;
    
    /* Theme color RGB values - matching template */
    --primary-rgb: 132, 90, 223;
    --secondary-rgb: 35, 183, 229;
    --success-rgb: 38, 191, 148;
    --danger-rgb: 230, 83, 60;
    --warning-rgb: 245, 184, 73;
    --info-rgb: 73, 182, 245;
    --light-rgb: 243, 246, 248;
    --dark-rgb: 35, 35, 35;
    --orange-rgb: 255, 165, 5;
    --pink-rgb: 231, 145, 188;
    --teal-rgb: 18, 194, 194;
    --purple-rgb: 137, 32, 173;
    
    /* Computed colors from RGB */
    --default-body-bg-color: rgb(var(--body-bg-rgb));
    --primary-color: rgb(var(--primary-rgb));
    --primary-border: rgb(var(--primary-rgb));
    --primary01: rgba(var(--primary-rgb), 0.1);
    --primary02: rgba(var(--primary-rgb), 0.2);
    --primary03: rgba(var(--primary-rgb), 0.3);
    --primary04: rgba(var(--primary-rgb), 0.4);
    --primary05: rgba(var(--primary-rgb), 0.5);
    --primary06: rgba(var(--primary-rgb), 0.6);
    --primary07: rgba(var(--primary-rgb), 0.7);
    --primary08: rgba(var(--primary-rgb), 0.8);
    --primary09: rgba(var(--primary-rgb), 0.9);
    --primary005: rgba(var(--primary-rgb), 0.05);
    
    /* Font Settings */
    --default-font-family: 'Inter', sans-serif;
    --default-font-weight: 400;
    --default-text-color: #333335;
    
    /* Default Styles */
    --default-border: #f3f3f3;
    --default-background: #f7f8f9;
    
    /* Menu Variables */
    --menu-bg: #fff;
    --menu-prime-color: #536485;
    --menu-border-color: #f3f3f3;
    
    /* Header Variables */
    --header-bg: #fff;
    --header-prime-color: #536485;
    --header-border-color: #f3f3f3;
    
    /* Other Variables */
    --custom-white: #fff;
    --custom-black: #000;
    --bootstrap-card-border: #f3f3f3;
    --list-hover-focus-bg: #f5f6f7;
    --text-muted: #8c9097;
    --input-border: #e9edf6;
    --form-control-bg: #ffffff;
    
    /* Gray Set */
    --gray-1: #f9fafb;
    --gray-2: #f2f4f5;
    --gray-3: #e6eaeb;
    --gray-4: #dbdfe1;
    --gray-5: #949eb7;
    --gray-6: #7987a1;
    --gray-7: #4d5875;
    --gray-8: #383853;
    --gray-9: #323251;
    
    /* White Set */
    --white-1: rgba(255,255,255, 0.1);
    --white-2: rgba(255,255,255, 0.2);
    --white-3: rgba(255,255,255, 0.3);
    --white-4: rgba(255,255,255, 0.4);
    --white-5: rgba(255,255,255, 0.5);
    --white-6: rgba(255,255,255, 0.6);
    --white-7: rgba(255,255,255, 0.7);
    --white-8: rgba(255,255,255, 0.8);
    --white-9: rgba(255,255,255, 0.9);
    
    /* Black Set */
    --black-1: rgba(0,0,0, 0.1);
    --black-2: rgba(0,0,0, 0.2);
    --black-3: rgba(0,0,0, 0.3);
    --black-4: rgba(0,0,0, 0.4);
    --black-5: rgba(0,0,0, 0.5);
    --black-6: rgba(0,0,0, 0.6);
    --black-7: rgba(0,0,0, 0.7);
    --black-8: rgba(0,0,0, 0.8);
    --black-9: rgba(0,0,0, 0.9);
}

/* Light Theme */
html[data-theme-mode="light"] {
    --body-bg-rgb: 240, 241, 247;
    --header-bg: #fff;
    --text-color: #333335;
    --default-text-color: #333335;
    --menu-bg: #fff;
    --menu-prime-color: #536485;
    --menu-border-color: #f3f3f3;
    --header-prime-color: #536485;
    --header-border-color: #f3f3f3;
    --default-border: #f3f3f3;
}

/* Dark Theme */
html[data-theme-mode="dark"] {
    --body-bg-rgb: 26, 28, 30;
    --body-bg-rgb2: 37, 39, 41;
    --menu-bg: rgb(var(--body-bg-rgb));
    --menu-border-color: rgba(255,255,255,0.1);
    --menu-prime-color: rgba(255,255,255,0.8); /* Increased contrast from 0.6 */
    --header-bg: rgb(var(--body-bg-rgb));
    --header-prime-color: rgba(255,255,255,0.85); /* Increased contrast from 0.6 */
    --header-border-color: rgba(255,255,255,0.1);
    --custom-white: rgb(var(--body-bg-rgb));
    --custom-black: #fff;
    --default-border: rgba(255,255,255,0.1);
    --default-text-color: rgba(255,255,255,0.8); /* Increased contrast from 0.7 */
    --text-color: rgba(255,255,255,0.8); /* Increased contrast from 0.7 */
    --light-rgb: 43, 46, 49;
    --dark-rgb: 240, 245, 248;
    --bootstrap-card-border: rgba(255,255,255,0.1);
    --list-hover-focus-bg: rgba(255,255,255,0.1);
    --default-background: rgba(255,255,255,0.07);
    --default-body-bg-color: rgb(var(--body-bg-rgb2));
    --text-muted: rgba(255,255,255,0.6); /* Increased contrast from 0.5 */
    --input-border: #313335;
    --form-control-bg: #232628;
}

body {
    background-color: rgb(var(--body-bg-rgb));
    color: var(--default-text-color);
    font-family: var(--default-font-family);
}

/* Page Layout */
.page {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: rgb(var(--body-bg-rgb));
}

/* Main Content Area */
.main-content {
    margin-left: 240px;
    position: absolute;
    left: 0;
    right: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
    padding: 0.25rem 0 0.25rem 0.25rem;
}

/* Content container - white background on light gray body */
.main-content > .container-fluid {
    flex: 1;
    overflow-y: auto;
    --bs-gutter-x: 0.5rem;
    background-color: var(--custom-white);
    border-radius: 0.5rem 0 0 0.5rem;
    padding: 0.25rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

html[data-theme-mode="dark"] .main-content > .container-fluid {
    background-color: rgb(var(--body-bg-rgb));
    box-shadow: none;
}

html[data-nav-layout="horizontal"] .main-content {
    margin-left: 0;
}

html[data-width="boxed"] .main-content .container-fluid {
    max-width: 1320px;
    margin: 0 auto;
}

/* Header Styles */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--header-border-color);
    padding: 0.25rem 1.5rem;
    min-height: 40px;
    display: flex;
    align-items: center;
}

html[data-header-position="scrollable"] .app-header {
    position: relative;
}

.main-header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-content-left,
.header-content-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidemenu-toggle {
    cursor: pointer;
    font-size: 1.5rem;
    padding: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Header Icons and Elements */
.header-link,
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    cursor: pointer;
    text-decoration: none;
    color: var(--header-prime-color);
    background: transparent;
    border: none;
}

/* Ensure bright white for hover/elements in dark mode */
html[data-theme-mode="dark"] .header-link:hover,
html[data-theme-mode="dark"] .btn-icon:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.15);
}

html[data-theme-mode="dark"] .app-header .mud-typography {
    color: rgba(255, 255, 255, 0.9) !important;
}

html[data-theme-mode="dark"] .btn-icon {
    color: rgba(255, 255, 255, 0.85);
}

.header-link:hover,
.btn-icon:hover {
    background-color: var(--list-hover-focus-bg);
    color: var(--primary-color);
}

.header-link-icon {
    font-size: 1.125rem;
}

.header-element {
    display: flex;
    align-items: center;
}

/* Theme Mode Toggle */
.header-theme-mode .dark-layout {
    display: none;
}

html[data-theme-mode="dark"] .header-theme-mode .light-layout {
    display: none;
}

html[data-theme-mode="dark"] .header-theme-mode .dark-layout {
    display: inline;
}

/* Fullscreen Toggle */
.full-screen-close {
    /* Removed display: none to allow d-none to control visibility */
}

/* Responsive Visibility */
@media (max-width: 991px) {
    .d-lg-block {
        display: none !important;
    }
}

/* Layout Modes */
html[data-nav-layout="vertical"] .app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: 240px;
    z-index: 1000;
    overflow-x: hidden;
}

html[data-nav-layout="horizontal"] .app-sidebar {
    position: relative;
    width: 100%;
    height: auto;
}

html[data-menu-position="scrollable"] .app-sidebar {
    position: absolute;
}

/* Menu Colors */
html[data-menu-styles="dark"] .app-sidebar {
    background-color: rgb(26, 28, 30); /* Explicit dark background for dark menu style */
    color: #ffffff;
    border-right: 1px solid rgba(255,255,255,0.1);
}

html[data-menu-styles="light"] .app-sidebar {
    background-color: #ffffff;
    color: #2c3e50;  /* Darker text for better contrast */
    border-right: 1px solid var(--menu-border-color);
}

/* Menu text color override for light mode */
html[data-menu-styles="light"] .side-menu__item {
    color: #2c3e50;  /* Dark blue-gray for excellent contrast on white */
    font-weight: 500;
}

html[data-menu-styles="light"] .side-menu__item.active {
    color: rgb(var(--primary-rgb));  /* Primary purple for active items */
    font-weight: 600;
}

/* Ensure dark menu text is white even in light theme */
html[data-menu-styles="dark"] .side-menu__item {
    color: rgba(255, 255, 255, 0.7);
}

html[data-menu-styles="dark"] .side-menu__item:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.1);
}

html[data-menu-styles="dark"] .side-menu__item.active {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.15);
    border-left: 3px solid rgb(var(--primary-rgb));
}

/* Logo visibility control */
.desktop-logo {
    display: block;
}
.toggle-logo {
    display: none;
}

/* Icon Hover Style */
html[data-nav-style="icon-hover"][data-nav-layout="vertical"] .app-sidebar {
    width: 5rem;
    overflow: visible;
}

html[data-nav-style="icon-hover"][data-nav-layout="vertical"] .main-content {
    margin-left: 5rem;
}

html[data-nav-style="icon-hover"][data-nav-layout="vertical"] .app-sidebar .side-menu__label,
html[data-nav-style="icon-hover"][data-nav-layout="vertical"] .app-sidebar .side-menu__angle,
html[data-nav-style="icon-hover"][data-nav-layout="vertical"] .app-sidebar .category-name,
html[data-nav-style="icon-hover"][data-nav-layout="vertical"] .app-sidebar .header-logo .navbar-brand,
html[data-nav-style="icon-hover"][data-nav-layout="vertical"] .app-sidebar .header-logo .desktop-logo {
    display: none;
}

html[data-nav-style="icon-hover"][data-nav-layout="vertical"] .app-sidebar .header-logo .toggle-logo {
    display: block;
}

html[data-nav-style="icon-hover"][data-nav-layout="vertical"] .app-sidebar .main-sidebar-header {
    padding: 1rem;
    display: flex;
    justify-content: center;
}

/* Show icon only in center when collapsed */
html[data-nav-style="icon-hover"][data-nav-layout="vertical"] .app-sidebar .side-menu__icon {
    margin-right: 0;
}

/* Hover State */
html[data-nav-style="icon-hover"][data-nav-layout="vertical"] .app-sidebar:hover {
    width: 240px;
}

html[data-nav-style="icon-hover"][data-nav-layout="vertical"] .app-sidebar:hover .side-menu__label {
    display: block;
}

html[data-nav-style="icon-hover"][data-nav-layout="vertical"] .app-sidebar:hover .side-menu__angle {
    display: inline-block;
}

html[data-nav-style="icon-hover"][data-nav-layout="vertical"] .app-sidebar:hover .category-name {
    display: block;
}

html[data-nav-style="icon-hover"][data-nav-layout="vertical"] .app-sidebar:hover .header-logo .navbar-brand {
    display: block;
}

html[data-nav-style="icon-hover"][data-nav-layout="vertical"] .app-sidebar:hover .header-logo .desktop-logo {
    display: block;
}

html[data-nav-style="icon-hover"][data-nav-layout="vertical"] .app-sidebar:hover .header-logo .toggle-logo {
    display: none;
}

html[data-nav-style="icon-hover"][data-nav-layout="vertical"] .app-sidebar:hover .main-sidebar-header {
    justify-content: flex-start;
    padding: 1rem 1.5rem;
}

html[data-nav-style="icon-hover"][data-nav-layout="vertical"] .app-sidebar:hover .side-menu__icon {
    margin-right: 0.75rem;
}

/* Basic Sidebar Styles */
.app-sidebar {
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.main-sidebar-header {
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 56px;
    display: flex;
    align-items: center;
}

html[data-menu-styles="light"] .main-sidebar-header {
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

.header-logo {
    text-decoration: none;
    color: inherit;
    font-weight: bold;
    font-size: 1.25rem;
}

.main-sidebar {
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    padding: 1rem 0;
}

.main-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.main-menu > li {
    margin-bottom: 0.25rem;
}

.side-menu__item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: inherit;
    text-decoration: none;
    transition: background-color 0.2s;
    cursor: pointer;
}

html[data-menu-styles="dark"] .side-menu__item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

html[data-menu-styles="light"] .side-menu__item:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.side-menu__item.active {
    background-color: rgba(var(--primary-rgb), 0.15);
    border-left: 3px solid rgb(var(--primary-rgb));
    font-weight: 500;
}

.side-menu__icon {
    margin-right: 0.75rem;
    font-size: 1.2rem;
    display: inline-block;
    vertical-align: middle;
    line-height: 1;
}

.side-menu__angle {
    margin-left: auto;
    font-size: 1rem;
    display: inline-block;
}

.side-menu__label {
    flex: 1;
}

.category-name {
    display: block;
    padding: 0.5rem 1.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 600;
    margin-top: 1rem;
    letter-spacing: 0.5px;
}

html[data-menu-styles="light"] .category-name {
    color: var(--text-muted);  /* Muted gray for category labels */
    opacity: 1;
}

html[data-menu-styles="dark"] .category-name {
    color: rgba(255, 255, 255, 0.5);
    opacity: 1;
}

.category-name:first-child {
    margin-top: 0;
}
}

/* Submenu Styles */
.slide-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease;
}

.slide.open > .slide-menu {
    max-height: 500px;
}

.slide-menu .side-menu__item {
    padding-left: 3.5rem;
    font-size: 0.9rem;
}

/* Footer */
.footer {
    margin-top: auto;
    padding: 1rem 0;
    background-color: #e9ecef;
    color: #495057;
}

/* Theme Switcher */
.theme-switcher-toggle {
    position: relative;
}

.theme-switcher-toggle .btn-icon {
    background: transparent;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    transition: background-color 0.2s;
}

.theme-switcher-toggle .btn-icon:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

html[data-theme-mode="dark"] .theme-switcher-toggle .btn-icon:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.theme-switcher-panel {
    position: fixed;
    top: 0;
    right: -320px;
    width: 320px;
    height: 100vh;
    background-color: #ffffff;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    z-index: 1050;
    overflow-y: auto;
}

html[data-theme-mode="dark"] .theme-switcher-panel {
    background-color: #2a2a2a;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.5);
}

.theme-switcher-panel.open {
    right: 0;
}

.theme-switcher-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

html[data-theme-mode="dark"] .theme-switcher-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.theme-switcher-header h5 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.theme-switcher-header .btn-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-switcher-body {
    padding: 1.5rem;
}

.theme-option-group {
    margin-bottom: 1.5rem;
}

.theme-option-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.theme-option-group .btn-group {
    display: flex;
}

.theme-option-group .btn-group .btn {
    flex: 1;
}

.theme-switcher-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1049;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.theme-switcher-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Responsive Overlay */
#responsive-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* Responsive Behavior */
@media (max-width: 991px) {
    .main-content {
        margin-left: 0;
    }
    
    .app-sidebar {
        transform: translateX(-100%);
    }
    
    html[data-toggled="open"] .app-sidebar {
        transform: translateX(0);
    }
    
    html[data-toggled="open"] #responsive-overlay {
        display: block;
    }
}

/* Dark mode specific adjustments */
html[data-theme-mode="dark"] .app-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

html[data-theme-mode="dark"] .footer {
    background-color: #1e1e1e !important;
    color: #e0e0e0 !important;
}

html[data-theme-mode="dark"] .bg-light {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: #e0e0e0;
}

html[data-theme-mode="dark"] .btn-outline-primary {
    color: #6c757d;
    border-color: #495057;
}

html[data-theme-mode="dark"] .btn-outline-primary:hover {
    background-color: #495057;
    border-color: #495057;
    color: #ffffff;
}
