:root {
    /* --- 1. PRIMARY: TRUST (Professional Medical Blue) --- */
    --primary-color: #0284c7;
    /* Sky-600 */
    --primary-hover: #0369a1;
    /* Sky-700 */
    --primary-light: #e0f2fe;
    /* Sky-50 */

    /* --- 2. SECONDARY: HYGIENE (True Clean Slate) --- */
    --secondary-color: #475569;
    /* Slate-600 */
    --secondary-light: #94a3b8;
    /* Slate-400 */

    --bg-body: #f8fafc;
    /* Slate-50 */
    --bg-card: #ffffff;
    /* Pure white */
    --border-color: #e2e8f0;
    /* Slate-200 */

    /* --- 3. TERTIARY: ACTION (Calm Emerald) --- */
    --action-success: #059669;
    /* Emerald-600 */
    --action-success-bg: #ecfdf5;
    /* Emerald-50 */

    --action-danger: #dc2626;
    /* Red-600 */
    --action-danger-bg: #fef2f2;
    /* Red-50 */

    /* --- LAYOUT VARIABLES --- */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 80px;
    /* NEW: Width when minimized */
    --sidebar-bg: var(--bg-card);
    --sidebar-hover: #f1f5f9;
    /* Slate-100 */
}

body {
    min-height: 100vh;
    background-color: var(--bg-body);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    overflow-x: hidden;
    display: flex;
    color: var(--secondary-color);
}

/* --- Sidebar Structure --- */
.sidebar {
    width: var(--sidebar-width);
    background: #daebf5;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 1040;
    transition: width 0.3s ease, margin-left 0.3s ease;
    /* Animate width change */
}

.content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.bi-check-circle-fill {
    color: var(--primary-color);
}

/* --- Sidebar Styling --- */
.menu-item {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    color: var(--secondary-color);
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 500;
    gap: 10px;
    white-space: nowrap;
    /* Prevent text wrapping during animation */
    overflow: hidden;
    /* Hide overflowing text */
}

.menu-item:hover,
.menu-item.active {
    background-color: var(--sidebar-hover);
    color: var(--primary-color);
}

.menu-item.active {
    border-right: 1px solid var(--primary-color);
    background-color: #f0f7ff;
}

.menu-item i {
    font-size: 1.2rem;
    /* Slightly larger for visibility when collapsed */
    min-width: 24px;
    /* Ensure icon stays centered */
    text-align: center;
}

.sidebar-footer {
    /* padding: 20px; */
    border-top: 1px solid var(--border-color);
}

/* --- NEW: Minimized Sidebar State --- */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

/* Hide text elements when collapsed */
.sidebar.collapsed .menu-text,
.sidebar.collapsed .hospital-info,
.sidebar.collapsed .sidebar-footer-text {
    display: none;
    opacity: 0;
}

/* Center items when collapsed */
.sidebar.collapsed .menu-item {
    justify-content: center;
    padding: 12px 0;
}

.sidebar.collapsed .sidebar-header {
    padding: 15px 5px !important;
}

.sidebar.collapsed .profile-img {
    width: 40px !important;
    height: 40px !important;
    border-width: 2px !important;
}

/* Toggle Button Styling */
.sidebar-toggle-btn {
    position: absolute;
    top: 10px;
    right: -12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--secondary-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    z-index: 1050;
    transition: transform 0.3s;
}

.sidebar.collapsed .sidebar-toggle-btn {
    transform: rotate(180deg);
}

/* --- Mobile Responsiveness --- */
@media (max-width: 991.98px) {
    .sidebar-toggle-btn {
        display: none;
        /* Hide desktop minimizer on mobile */
    }

    .sidebar {
        position: fixed;
        left: 0;
        margin-left: calc(var(--sidebar-width) * -1);
        width: var(--sidebar-width) !important;
        /* Force full width on mobile */
    }

    /* Reset collapsed state styles on mobile if accidentally triggered */
    .sidebar.collapsed .menu-text,
    .sidebar.collapsed .hospital-info {
        display: block !important;
        opacity: 1 !important;
    }

    .sidebar.collapsed .menu-item {
        justify-content: flex-start;
        padding: 12px 24px;
    }

    .sidebar.active {
        margin-left: 0;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1030;
    }

    .sidebar-overlay.active {
        display: block;
    }
}

/* Overriding Bootstrap defaults to match --secondary-color (Slate-600) */
.tooltip-inner {
    background-color: var(--secondary-color) !important;
    color: #fff !important;
    padding: 8px 16px !important;
    /* Larger padding for readability */
    border-radius: 6px !important;
    font-family: 'Segoe UI', system-ui, sans-serif !important;
    font-size: 0.85rem !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

/* Color the arrow to match the background */
.bs-tooltip-end .tooltip-arrow::before {
    border-right-color: var(--secondary-color) !important;
}

.select2-container--bootstrap-5 .select2-selection {
    border-color: var(--border-color) !important;
    color: var(--secondary-color) !important;
    background-color: var(--bg-card) !important;
}

/* 2. Focus/Open State (Trust Blue Glow) */
.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: var(--primary-color) !important;
    /* Create a faint blue glow using the primary color */
    box-shadow: 0 0 0 0.25rem rgba(2, 132, 199, 0.25) !important;
}

/* 3. Dropdown Container */
.select2-container--bootstrap-5 .select2-dropdown {
    border-color: var(--border-color) !important;
    background-color: var(--bg-card) !important;
}

/* 4. Search Box Inside Dropdown */
.select2-container--bootstrap-5 .select2-search__field:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 0.25rem rgba(2, 132, 199, 0.25) !important;
}

/* 5. Hover/Highlighted Option (Sky-600 background, White text) */
.select2-container--bootstrap-5 .select2-results__option--highlighted[aria-selected] {
    background-color: var(--primary-color) !important;
    color: #ffffff !important;
}

/* 6. Already Selected Option (Sky-50 background, Sky-600 text) */
.select2-container--bootstrap-5 .select2-results__option[aria-selected="true"] {
    background-color: var(--primary-light) !important;
    color: var(--primary-color) !important;
    font-weight: 600;
}

/* Fix for icons inside the selection to match text color */
.select2-container--bootstrap-5 .select2-selection__rendered {
    color: var(--secondary-color) !important;
}

.select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option.select2-results__option--selected {
    background-color: var(--primary-light) !important;
    color: var(--primary-color) !important;
}


/* =========================================
   LOADER COMPONENT STYLES
   ========================================= */

/* 1. Full Page Loader */
#full-page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.85);
    /* Semi-transparent white */
    z-index: 9999;
    /* Above sidebar and modals */
    display: none;
    /* Hidden by default */
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

/* 2. Inner Div Loader */
/* This class ensures the parent is positioned correctly for the absolute child */
.inner {
    position: relative;
    min-height: 200px;
    /* Minimum height to make loader look good */
    transition: opacity 0.3s ease;
}

/* The overlay that appears inside .inner */
.inner-loader-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: inherit;
    /* Matches parent border radius */
}

/* =========================================
   SELECT2 BORDER REMOVAL (Universal Fix)
   ========================================= */

/* 1. Target ANY Select2 Single Selection (Default or Bootstrap Theme) */
.select2-container .select2-selection--single,
.select2-container--bootstrap-5 .select2-selection {
    box-shadow: none !important;
}

/* 2. Target the FOCUS/OPEN state (When you click it) */
/* This removes the blue glow */
.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection,
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
    box-shadow: none !important;
}

.sticky-header-custom {
    position: sticky;
    top: 0;
    z-index: 1020;
    background: rgba(218, 235, 245, 0.774);
    backdrop-filter: blur(12px);
    margin: -25px -25px 0px -25px;
    padding: 15px 25px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

@media (max-width: 991.98px) {
    .sticky-header-custom {
        display: block;
        padding-bottom: 10px;
    }

    .header-controls {
        width: 100%;
        display: flex !important;
        flex-wrap: nowrap !important;
        justify-content: space-between;
        gap: 6px;
    }

    .header-controls>div:first-child {
        width: calc(60% - 6px) !important;
        flex: 0 0 calc(60% - 6px);
    }
}


/* ==========================================================================
   GLOBAL BOOTSTRAP OVERRIDES (MODALS, BUTTONS, ALERTS)
   These styles ensure a consistent 'Trust Blue' theme across the entire app.
   ========================================================================== */

/* --- 1. MODAL THEME --- */
.modal-content {
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04) !important;
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    color: var(--secondary-color);
}

.modal-body-custom {
    padding: 25px;
    color: var(--secondary-color);
}

.modal-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--secondary-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    display: block;
}

/* --- 2. GLOBAL FORM CONTROLS --- */
/* Removes default Bootstrap blue glow and applies Trust Blue */
.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem var(--primary-light);
}

/* --- 3. BUTTON THEME OVERRIDES --- */

/* Primary Button (Use for Main Actions) */
.btn-primary {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: #ffffff !important;
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
    box-shadow: 0 0 0 0.2rem var(--primary-light) !important;
}

.btn-primary:disabled {
    background-color: var(--secondary-light) !important;
    border-color: var(--secondary-light) !important;
    opacity: 0.6;
}

/* Success Button (Use for confirmations/completions) */
.btn-success {
    background-color: var(--action-success) !important;
    border-color: var(--action-success) !important;
    color: #ffffff !important;
}

.btn-success:hover,
.btn-success:focus {
    background-color: #047857 !important;
    /* Emerald-700 */
    border-color: #047857 !important;
    box-shadow: 0 0 0 0.2rem var(--action-success-bg) !important;
}

/* Danger Button (Use for destructive actions) */
.btn-danger {
    background-color: var(--action-danger) !important;
    border-color: var(--action-danger) !important;
    color: #ffffff !important;
}

.btn-danger:hover,
.btn-danger:focus {
    background-color: #b91c1c !important;
    /* Red-700 */
    border-color: #b91c1c !important;
    box-shadow: 0 0 0 0.2rem var(--action-danger-bg) !important;
}

/* Outline Buttons (Radio Inputs in Modals) */
.btn-outline-primary {
    color: var(--secondary-color) !important;
    border-color: var(--border-color) !important;
    background-color: var(--bg-card) !important;
}

.btn-check:checked+.btn-outline-primary {
    background-color: var(--primary-light) !important;
    color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    font-weight: 700;
}

.btn-outline-primary:hover {
    background-color: var(--sidebar-hover) !important;
    border-color: var(--primary-color) !important;
}

/* --- 4. ALERTS & HELPERS --- */
.alert-warning {
    background-color: #fffbeb;
    /* Amber-50 */
    border-color: #fde68a;
    /* Amber-200 */
    color: #92400e;
    /* Amber-800 */
}

.text-success {
    color: var(--action-success) !important;
}

.page-link {
    color: white !important;
    background-color: var(--primary-color) !important;
    border-radius: 4px !important;
}

.active>.page-link {
    color: var(--primary-color) !important;
    background-color: white !important;
}

.page-link:focus {
    box-shadow: none !important;
}

.text-primary {
    color: var(--primary-color) !important;
}

.bg-primary{
    background-color: var(--primary-color) !important;
    color: var(--primary-light) !important;
}