﻿:root {
    /* 
   MODERN THEME SYSTEM
   Based on Slate (Neutrals) + Indigo (Primary) + Inter/System Fonts
   Design: Clean, Neutral, Elegant.
*/

    /* --- CORE PALETTE: SLATE (Neutrals) --- */
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;
    --slate-950: #020617;

    /* --- CORE PALETTE: INDIGO (Primary) --- */
    --indigo-50: #eef2ff;
    --indigo-100: #e0e7ff;
    --indigo-200: #c7d2fe;
    --indigo-300: #a5b4fc;
    --indigo-400: #818cf8;
    --indigo-500: #6366f1;
    --indigo-600: #4f46e5;
    --indigo-700: #4338ca;
    --indigo-800: #3730a3;
    --indigo-900: #312e81;
    --indigo-950: #1e1b4b;

    /* --- LIGHT MODE VARIABLES (Default) --- */
    --app-bg: var(--slate-100);
    --app-surface: #ffffff;
    --app-surface-hover: var(--slate-50);
    --app-text: var(--slate-900);
    --app-text-muted: var(--slate-600);
    --app-border: var(--slate-200);

    --app-primary: var(--indigo-600);
    --app-primary-hover: var(--indigo-700);
    --app-primary-text: #ffffff;

    --app-success: #10b981;
    /* Emerald 500 */
    --app-warning: #f59e0b;
    /* Amber 500 */
    --app-danger: #ef4444;
    /* Red 500 */
    --app-info: #3b82f6;
    /* Blue 500 */

    --app-radius: 0.75rem;
    /* 12px */
    --app-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --app-shadow-hover: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -1px rgb(0 0 0 / 0.06);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

    /* Bootstrap Override Mappings (Light) */
    --bs-body-bg: var(--app-bg);
    --bs-body-bg-rgb: 248, 250, 252;
    --bs-body-color: var(--app-text);
    --bs-body-font-family: var(--font-sans);
    --bs-border-color: var(--app-border);
    --bs-border-radius: var(--app-radius);

    --bs-card-bg: var(--app-surface);
    --bs-card-border-color: var(--app-border);
    --bs-card-cap-bg: transparent;

    --bs-primary: var(--app-primary);
    --bs-primary-rgb: 79, 70, 229;
    --bs-secondary: var(--slate-500);
    --bs-secondary-rgb: 100, 116, 139;
    --bs-success: var(--app-success);
    --bs-success-rgb: 16, 185, 129;
    --bs-info: var(--app-info);
    --bs-info-rgb: 59, 130, 246;
    --bs-warning: var(--app-warning);
    --bs-warning-rgb: 245, 158, 11;
    --bs-danger: var(--app-danger);
    --bs-danger-rgb: 239, 68, 68;

    /* LEGACY MAPPING (Backward Compatibility for Modules) */
    --term-bg: var(--app-bg);
    --term-surface: var(--app-surface);
    --term-text: var(--app-text);
    --term-dim: var(--app-text-muted);
    --term-border: var(--app-border);
    --term-font: var(--font-sans);
    /* Remove monospace enforcement */

    /* Map old colors to new semantic colors */
    --term-cyan: var(--app-primary);
    /* Cyan was primary */
    --term-purple: #8b5cf6;
    /* Violet 500 - Secondary accent */
    --term-green: var(--app-success);
    --term-red: var(--app-danger);
    --term-orange: var(--app-warning);
    --term-glow: rgba(79, 70, 229, 0.15);
    /* Primary glow */
}

/* --- DARK MODE OVERRIDES --- */
.dark-mode {
    --app-bg: var(--slate-950);
    --app-surface: var(--slate-800);
    --app-surface-hover: var(--slate-700);
    --app-text: var(--slate-100);
    --app-text-muted: var(--slate-400);
    --app-border: rgba(255, 255, 255, 0.1);

    --app-primary: var(--indigo-500);
    --app-primary-hover: var(--indigo-400);

    --app-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -1px rgb(0 0 0 / 0.2);
    --app-shadow-hover: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -2px rgb(0 0 0 / 0.3);

    /* Bootstrap Dark Overrides */
    --bs-body-bg: var(--app-bg);
    --bs-body-color: var(--app-text);
    --bs-border-color: var(--app-border);

    --bs-card-bg: var(--app-surface);
    --bs-card-border-color: var(--app-border);

    --bs-list-group-bg: var(--app-surface);
    --bs-list-group-border-color: var(--app-border);
    --bs-list-group-color: var(--app-text);
    --bs-list-group-action-hover-bg: var(--app-surface-hover);

    --bs-heading-color: var(--app-text);
    --bs-link-color: var(--indigo-400);
    --bs-link-hover-color: var(--indigo-300);

    /* Modal override for better contrast */
    --bs-modal-bg: #334155;
    /* Lighter Slate (700) for better separation */

    /* Inputs */
    --bs-body-bg-rgb: 2, 6, 23;
    /* Required for some form transparency calculations */

    --bs-secondary-color: var(--app-text-muted);
    --bs-tertiary-color: var(--slate-500);
    --bs-secondary-bg: var(--slate-800);

    /* Tooltip Fixes */
    --bs-tooltip-bg: var(--slate-800);
    --bs-tooltip-color: var(--slate-100);

    /* LEGACY DARK MAPPING (Force update for modules) */
    --term-bg: var(--app-bg);
    --term-surface: var(--app-surface);
    --term-text: var(--app-text);
    --term-dim: var(--app-text-muted);
    --term-border: var(--app-border);

    /* Form Controls Dark Fix */
    --bs-body-bg-rgb: 15, 23, 42;
    /* Slate 900 */
}


.dark-mode .form-control,
.dark-mode .form-select,
.dark-mode .input-group-text {
    background-color: var(--app-surface) !important;
    color: var(--app-text) !important;
    border-color: var(--app-border) !important;
}

.dark-mode .form-control::placeholder {
    color: var(--app-text-muted) !important;
    opacity: 0.6;
}

.dark-mode .breadcrumb-item.active {
    color: var(--app-text) !important;
}

/* Tooltip global overrides for better contrast */
.tooltip-inner {
    border: 1px solid var(--app-border) !important;
    box-shadow: var(--app-shadow-hover) !important;
    padding: 0.5rem 1rem !important;
    font-size: 0.85rem !important;
}

.dark-mode .tooltip-inner {
    background-color: var(--slate-800) !important;
    color: var(--slate-100) !important;
}

/* --- UTILITIES & COMPONENTS RESET --- */

body {
    background-color: var(--app-bg);
    color: var(--app-text);
    font-family: var(--font-sans);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    letter-spacing: -0.025em;
    /* Tighter heading tracking for modern feel */
    color: var(--app-text);
}

a {
    transition: color 0.15s ease-in-out;
}

/* Cards */
.card {
    background-color: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover {
    box-shadow: var(--app-shadow-hover);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--app-border);
    padding: 1.25rem 1.5rem;
    font-weight: 600;
    color: var(--app-text);
}

.card-body {
    padding: 1.5rem;
}

/* Alerts Modernization */
.alert {
    border-radius: var(--app-radius);
    border: 1px solid transparent;
    font-weight: 500;
    box-shadow: var(--app-shadow);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.alert-success {
    background-color: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.15);
    color: #065f46;
}

.dark-mode .alert-success {
    background-color: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.25);
    color: #34d399;
}

.alert-danger {
    background-color: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.15);
    color: #991b1b;
}

.dark-mode .alert-danger {
    background-color: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.25);
    color: #f87171;
}

.alert-warning {
    background-color: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.15);
    color: #92400e;
}

.dark-mode .alert-warning {
    background-color: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.25);
    color: #fbbf24;
}

.alert-info {
    background-color: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.15);
    color: #1e40af;
}

.dark-mode .alert-info {
    background-color: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.25);
    color: #60a5fa;
}

/* Buttons */
.btn {
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--app-primary);
    border-color: var(--app-primary);
}

.btn-primary:hover {
    background-color: var(--app-primary-hover);
    border-color: var(--app-primary-hover);
}

/* Primary Color Utilities Overrides */
.bg-primary {
    background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity, 1)) !important;
}

.text-primary {
    color: var(--app-primary) !important;
}

.border-primary {
    border-color: var(--app-primary) !important;
}

.btn-outline-primary {
    color: var(--app-primary) !important;
    border-color: var(--app-primary) !important;
    background-color: transparent !important;
}

.btn-outline-primary:hover,
.btn-outline-primary:active,
.btn-outline-primary:focus,
.btn-outline-primary.active {
    background-color: var(--app-primary) !important;
    border-color: var(--app-primary) !important;
    color: var(--app-primary-text) !important;
}

/* Navbar specific */
.navbar {
    transition: background-color 0.3s ease, border-color 0.3s ease;
    background-color: rgba(var(--bs-body-bg-rgb), 0.8) !important;
}

.mobile-header {
    background-color: rgba(var(--bs-body-bg-rgb), 0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 1040;
    margin: -1rem -1rem 1.5rem -1rem;
    /* Offset the main-content padding */
    padding: 1rem !important;
}

.dark-mode .mobile-header {
    border-bottom-color: var(--app-border) !important;
}

.navbar-brand {
    color: var(--app-text) !important;
}

.navbar-nav .nav-link {
    color: var(--app-text-muted) !important;
    font-weight: 500;
    transition: color 0.2s ease;
}

.navbar-nav .nav-link:hover {
    color: var(--app-primary) !important;
}

.dark-mode .navbar-nav .nav-link {
    color: var(--slate-300) !important;
}

.dark-mode .navbar-nav .nav-link:hover {
    color: var(--app-primary) !important;
}

.dark-mode .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Modals */
.modal-content {
    background-color: var(--app-surface);
    color: var(--app-text);
    border: 1px solid var(--app-border);
}

.modal-header,
.modal-footer {
    border-color: var(--app-border);
}

.modal-header .btn-close {
    margin: -0.5rem -0.5rem -0.5rem auto;
}

.modal-backdrop.show {
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    background-color: rgba(0, 0, 0, 0.4);
}


.btn-outline-secondary {
    border-color: var(--app-border);
    color: var(--app-text-muted);
}

.btn-outline-secondary:hover {
    background-color: var(--app-surface-hover);
    border-color: var(--app-primary);
    color: var(--app-primary);
}

.dark-mode .btn-outline-secondary {
    background-color: var(--slate-800);
    border-color: var(--slate-700);
    color: var(--slate-300);
}

.dark-mode .btn-outline-secondary:hover {
    background-color: var(--slate-700);
    border-color: var(--app-primary);
    color: var(--app-primary);
}

.dark-mode .btn-outline-success {
    background-color: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.4);
    color: var(--app-success);
}

.dark-mode .btn-outline-success:hover {
    background-color: var(--app-success);
    color: white;
}

.dark-mode .btn-outline-danger {
    background-color: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.4);
    color: var(--app-danger);
}

.dark-mode .btn-outline-danger:hover {
    background-color: var(--app-danger);
    color: white;
}

.dark-mode .btn-outline-info {
    background-color: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.4);
    color: var(--app-info);
}

.dark-mode .btn-outline-info:hover {
    background-color: var(--app-info);
    color: white;
}

/* Sidebar */
.sidebar {
    background-color: var(--app-surface) !important;
    border-right: 1px solid var(--app-border) !important;
}

.nav-link {
    color: var(--app-text-muted);
    border-radius: 0.5rem;
    padding: 0.6rem 1rem;
    font-weight: 500;
}

.nav-link:hover {
    color: var(--app-primary);
    background-color: var(--indigo-50);
}

.dark-mode .nav-link:hover {
    background-color: rgba(99, 102, 241, 0.1);
}

.nav-link.active {
    color: var(--app-primary);
    background-color: var(--indigo-50);
    font-weight: 600;
}

.dark-mode .nav-link.active {
    background-color: rgba(99, 102, 241, 0.15);
}

/* Nav Pills Active State - Match Primary Color */
.nav-pills .nav-link.active,
.nav-pills .show>.nav-link {
    background-color: var(--app-primary) !important;
    color: var(--app-primary-text) !important;
}

.nav-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--app-text-muted);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    padding-left: 1rem;
    letter-spacing: 0.05em;
}

.user-profile-box {
    transition: all 0.2s ease;
    cursor: pointer;
}

.user-profile-box:hover {
    background-color: var(--app-surface-hover) !important;
    border-color: var(--app-primary) !important;
    transform: translateY(-1px);
}

.no-caret::after {
    display: none !important;
}

.text-app-main {
    color: var(--app-text);
}

.bg-app-surface {
    background-color: var(--app-surface) !important;
}

.border-app {
    border: 1px solid var(--app-border) !important;
}

.dropdown-item {
    color: var(--app-text);
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background-color: var(--app-surface-hover);
    color: var(--app-primary);
}

/* Tables */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--app-text);
    --bs-table-border-color: var(--app-border);
}

.table> :not(caption)>*>* {
    padding: 1rem 1rem;
    border-bottom-color: var(--app-border);
}

/* Form Controls */
.form-control,
.form-select {
    background-color: var(--app-surface);
    border-color: var(--app-border);
    color: var(--app-text);
    padding: 0.6rem 1rem;
    border-radius: 0.5rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

/* Utility Helpers */
.text-dim {
    color: var(--app-text-muted) !important;
}

.text-cyan {
    color: var(--app-primary) !important;
}

.text-purple {
    color: #8b5cf6 !important;
}

.bg-surface {
    background-color: var(--app-surface) !important;
}

/* Opacity Helpers */
.opacity-75 {
    opacity: 0.75 !important;
}

.hover-opacity-100:hover {
    opacity: 1 !important;
}

.bg-app-surface-subtle {
    background-color: var(--indigo-50) !important;
}

.dark-mode .bg-app-surface-subtle {
    background-color: rgba(99, 102, 241, 0.05) !important;
}

.text-app-main {
    color: var(--app-text) !important;
}

.text-app-muted {
    color: var(--app-text-muted) !important;
}

.hover-bg-app:hover {
    background-color: var(--app-surface-hover) !important;
}

/* --- LAYOUT STRUCTURE (Fix for Side-by-Side) --- */
.layout-dashboard {
    display: flex;
    flex-direction: row;
    min-height: 100vh;
    overflow-x: hidden;
}

.layout-dashboard .sidebar {
    width: 280px;
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    z-index: 1050;
    border-right: 1px solid var(--app-border);
}

.layout-dashboard .main-content {
    flex-grow: 1;
    min-width: 0;
    padding: 2rem;
    padding-bottom: 0;
    /* Reset global padding-bottom */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.layout-dashboard .main-content>*:last-child {
    margin-bottom: 5rem;
}

/* Mobile Responsive Layout */
@media (max-width: 991.98px) {
    .layout-dashboard {
        display: block;
        /* Stack on mobile */
    }

    .layout-dashboard .sidebar {
        position: fixed;
        /* Offcanvas behavior handled by Bootstrap, but reset for safety */
        height: 100%;
        transform: translateX(-100%);
        /* Hidden by default if not using offcanvas class */
        transition: transform 0.3s ease-in-out;
    }

    .layout-dashboard .sidebar.show {
        transform: translateX(0);
    }

    .layout-dashboard .main-content {
        padding: 1rem;
    }
}

/* --- ADDITIONAL UTILITIES --- */
.border-dim {
    border-color: var(--app-border) !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animation-fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

.glass-card {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.6) !important;
    box-shadow: var(--app-shadow);
}

.dark-mode .glass-card {
    background: rgba(30, 41, 59, 0.85) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

/* User Badges - Perfectly Round */
.user-badge {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    min-height: 28px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    font-size: 0.8rem !important;
    font-weight: 700 !important;
    flex-shrink: 0 !important;
    aspect-ratio: 1/1 !important;
}

/* User Badges & Avatars - Perfectly Round */
.user-badge,
.avatar-32,
.avatar-48 {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    flex-shrink: 0 !important;
    aspect-ratio: 1/1 !important;
}

/* Avatars - Perfectly Round */

.avatar-32 {
    width: 32px !important;
    height: 32px !important;
}

.avatar-48 {
    width: 48px !important;
    height: 48px !important;
}

/* Calendar Day Cells - Strict Capsule Ends */
.rounded-pill-start,
.rounded-start-pill {
    border-top-left-radius: 50px !important;
    border-bottom-left-radius: 50px !important;
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

.rounded-pill-end,
.rounded-end-pill {
    border-top-right-radius: 50px !important;
    border-bottom-right-radius: 50px !important;
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
}

.calendar-day-cell.rounded-circle {
    border-radius: 50% !important;
}

.calendar-day-cell.rounded-pill {
    border-radius: 50px !important;
}