/* ==========================================================================
   SaaS Doctor RX Builder - Premium Design System
   Version: 2.0.0
   Last Updated: 2026-06-12
   ========================================================================== */


/* ==========================================================================
   1. CSS VARIABLES & THEMING
   ========================================================================== */
:root {
    /* Primary Palette */
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --primary-light: rgba(79, 70, 229, 0.1);
    --primary-dark: #3730A3;

    /* Secondary */
    --secondary: #64748b;
    --secondary-light: rgba(100, 116, 139, 0.1);

    /* Semantic Colors */
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.1);
    --success-dark: #059669;

    --info: #0ea5e9;
    --info-light: rgba(14, 165, 233, 0.1);
    --info-dark: #0284c7;

    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.1);
    --warning-dark: #d97706;

    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.1);
    --danger-dark: #dc2626;

    /* Neutrals */
    --dark: #0f172a;
    --light: #f8fafc;
    --body-bg: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;

    /* Sidebar */
    --sidebar-bg: #0f172a;
    --sidebar-bg-end: #1e293b;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 80px;

    /* Header */
    --header-height: 70px;

    /* Typography */
    --font-family-base: 'Inter', system-ui, -apple-system, sans-serif;

    /* Border Radius */
    --border-radius: 0.75rem;
    --border-radius-sm: 0.5rem;
    --border-radius-lg: 1rem;
    --border-radius-xl: 1.5rem;
    --border-radius-pill: 50rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

    /* Transition */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease;
}


/* ==========================================================================
   2. BASE STYLES & TYPOGRAPHY
   ========================================================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: var(--font-family-base);
    background-color: var(--body-bg);
    color: #334155;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--dark);
    letter-spacing: -0.025em;
    line-height: 1.3;
}

/* Font Size Utilities */
.fs-xs { font-size: 0.75rem; }
.fs-sm { font-size: 0.875rem; }
.fs-md { font-size: 1rem; }
.fs-lg { font-size: 1.125rem; }
.fs-xl { font-size: 1.25rem; }

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-hover);
}

/* Text Color Utilities */
.text-primary-light { color: #818cf8; }
.text-success-light { color: #34d399; }
.text-warning-light { color: #fbbf24; }
.text-danger-light { color: #f87171; }
.text-info-light { color: #38bdf8; }
.text-muted-custom { color: var(--text-muted); }

/* Background Color Utilities */
.bg-primary-light { background-color: var(--primary-light) !important; }
.bg-success-light { background-color: var(--success-light) !important; }
.bg-warning-light { background-color: var(--warning-light) !important; }
.bg-danger-light { background-color: var(--danger-light) !important; }
.bg-info-light { background-color: var(--info-light) !important; }
.bg-secondary-light { background-color: var(--secondary-light) !important; }

/* Interactive Utilities */
.hover-bg-light:hover { background-color: #f8fafc !important; }
.transition-all { transition: var(--transition); }
.cursor-pointer { cursor: pointer; }
.no-select { user-select: none; }

/* Gradient Utilities */
.gradient-primary { background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%) !important; }
.gradient-success { background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important; }
.gradient-info { background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%) !important; }
.gradient-warning { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important; }
.gradient-danger { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important; }
.gradient-dark { background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%) !important; }


/* ==========================================================================
   3. LAYOUT STRUCTURE
   ========================================================================== */
.wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-end) 100%);
    z-index: 1040;
    box-shadow: var(--shadow-lg);
    top: 0;
    bottom: 0;
    left: 0;
    position: fixed;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-content {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--header-height);
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    z-index: 1030;
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
}

.content-wrapper {
    padding: 1.5rem;
    flex: 1;
}


/* ==========================================================================
   4. SIDEBAR STYLES
   ========================================================================== */
.sidebar-header {
    height: var(--header-height);
}

.nav-item .nav-link {
    color: rgba(255, 255, 255, 0.7);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    position: relative;
    border-left: 3px solid transparent;
    transition: var(--transition);
    font-size: 0.875rem;
    white-space: nowrap;
}

.nav-item .nav-icon {
    font-size: 1.25rem;
    margin-right: 1rem;
    transition: var(--transition);
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.nav-item .nav-link:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.05);
}

.nav-item .nav-link:hover .nav-icon {
    transform: scale(1.1);
}

.nav-item .nav-link.active {
    color: #ffffff;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 100%);
    border-left-color: var(--primary);
    font-weight: 500;
}

.nav-item .nav-link.active .nav-icon {
    color: var(--primary-light);
}

.nav-item .nav-link .badge {
    margin-left: auto;
    font-size: 0.65rem;
    padding: 0.2em 0.5em;
}


/* ==========================================================================
   5. UI COMPONENTS
   ========================================================================== */

/* ----- Cards ----- */
.rx-card {
    background: #ffffff;
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.rx-card .card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.rx-card .card-body {
    padding: 1.25rem;
}

.hover-lift:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.stat-card {
    border-radius: var(--border-radius-lg);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 150px;
    height: 150px;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0) 100%);
    border-radius: 50%;
    transform: translate(30%, -30%);
}

/* ----- Buttons ----- */
.btn {
    border-radius: var(--border-radius-sm);
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: var(--transition);
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover {
    background-color: var(--primary);
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius-sm);
}

.btn-icon-lg {
    width: 44px;
    height: 44px;
}

.btn-icon-sm {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
}

/* ----- Inputs & Forms ----- */
.form-control, .form-select {
    border-radius: var(--border-radius-sm);
    border: 1px solid #cbd5e1;
    padding: 0.6rem 1rem;
    transition: var(--transition);
    font-size: 0.875rem;
    color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.25rem var(--primary-light);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-label {
    font-weight: 500;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label {
    color: var(--primary);
}

.input-group-text {
    border-color: #cbd5e1;
    background-color: #f8fafc;
    color: var(--secondary);
    font-size: 0.875rem;
}

/* ----- Badges ----- */
.badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
    border-radius: 0.375rem;
}

/* ----- Tables ----- */
.custom-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.custom-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    color: var(--secondary);
    border-bottom-width: 1px;
    padding: 0.75rem;
    background: #f8fafc;
    white-space: nowrap;
}

.custom-table td {
    padding: 1rem 0.75rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
}

.custom-table tbody tr {
    transition: var(--transition-fast);
}

.custom-table tbody tr:hover {
    background-color: #f8fafc;
}

.custom-table tbody tr:last-child td {
    border-bottom: none;
}


/* ==========================================================================
   6. PRESCRIPTION BUILDER LAYOUT (Create/Edit Form)
   ========================================================================== */
.rx-builder-container {
    display: flex;
    height: calc(100vh - var(--header-height) - 3rem);
    gap: 1.5rem;
}

.rx-clinical-panel {
    width: 35%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.rx-medicine-panel {
    width: 65%;
    display: flex;
    flex-direction: column;
}

.rx-medicine-row {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--border-radius-sm);
    padding: 1rem;
    margin-bottom: 1rem;
    position: relative;
    transition: var(--transition);
}

.rx-medicine-row:hover {
    border-color: #cbd5e1;
    box-shadow: var(--shadow-sm);
}

.rx-remove-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--danger);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    cursor: pointer;
    opacity: 0;
    transition: var(--transition);
    font-size: 0.65rem;
}

.rx-medicine-row:hover .rx-remove-btn {
    opacity: 1;
}

/* ----- Autocomplete Dropdown ----- */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-md);
    max-height: 250px;
    overflow-y: auto;
    display: none;
}

.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background-color 0.2s;
    font-size: 0.875rem;
}

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

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item .medicine-name {
    font-weight: 600;
    color: var(--dark);
}

.autocomplete-item .medicine-generic {
    font-size: 0.75rem;
    color: var(--secondary);
}

/* ----- Tags/Pills Input ----- */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem;
    border: 1px solid #cbd5e1;
    border-radius: var(--border-radius-sm);
    min-height: 42px;
    cursor: text;
    transition: var(--transition);
}

.tags-container:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.25rem var(--primary-light);
}

.tag-pill {
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    animation: fadeInUp 0.2s ease;
}

.tag-pill .remove-tag {
    cursor: pointer;
    opacity: 0.5;
    font-size: 0.75rem;
}

.tag-pill .remove-tag:hover {
    opacity: 1;
}


/* ==========================================================================
   7. RESPONSIVE DESIGN
   ========================================================================== */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1035;
    display: none;
    backdrop-filter: blur(2px);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

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

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .rx-builder-container {
        flex-direction: column;
        height: auto;
    }

    .rx-clinical-panel,
    .rx-medicine-panel {
        width: 100%;
        height: auto;
    }

    .rx-body {
        flex-direction: column;
    }

    .rx-left,
    .rx-right {
        width: 100%;
        border-right: none;
    }

    .rx-left {
        border-bottom: 1px dashed #cbd5e1;
    }

    .topbar {
        padding: 0 1rem;
    }

    .content-wrapper {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.4rem;
    }

    .paper-pad {
        padding: 1rem;
        min-height: auto;
    }

    .quick-action {
        padding: 14px;
    }

    .quick-action i {
        font-size: 1.25rem;
    }
}

@media (max-width: 575.98px) {
    .content-wrapper {
        padding: 0.75rem;
    }

    .rx-header {
        padding: 16px;
    }

    .rx-left,
    .rx-right {
        padding: 16px;
    }

    .rx-footer {
        padding: 12px 16px;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    .page-title {
        font-size: 1rem;
    }

    .avatar-circle {
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
    }

    .custom-toast {
        min-width: 240px;
    }
}


/* ==========================================================================
   8. PAPER PAD AESTHETIC (DoctorKoi Style)
   ========================================================================== */
.paper-pad {
    background: #ffffff;
    box-shadow: 0 10px 40px rgba(0,0,0,0.08);
    margin: 0 auto;
    max-width: 1000px;
    min-height: 800px;
    padding: 2rem;
    position: relative;
    border-top: 8px solid var(--primary);
}

.paper-pad::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    background-image: repeating-linear-gradient(transparent, transparent 31px, #f1f5f9 31px, #f1f5f9 32px);
    opacity: 0.4;
    z-index: 0;
}

.paper-content {
    position: relative;
    z-index: 1;
}

.paper-input {
    border: none;
    border-bottom: 1px dashed #cbd5e1;
    background: transparent;
    border-radius: 0;
    padding: 4px 0;
    box-shadow: none !important;
    font-family: inherit;
    color: var(--text-primary);
}

.paper-input:focus {
    border-bottom-color: var(--primary);
    background: rgba(248, 250, 252, 0.5);
}

.paper-select {
    border: none;
    border-bottom: 1px dashed #cbd5e1;
    background: transparent;
    appearance: none;
    padding: 4px 16px 4px 0;
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    box-shadow: none !important;
}

.paper-select:focus {
    border-bottom-color: var(--primary);
}

.rx-watermark {
    font-size: 8rem;
    font-family: serif;
    color: #f1f5f9;
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 0;
    pointer-events: none;
    user-select: none;
}

.paper-medicine-row {
    position: relative;
    padding: 0.5rem 0;
    border-bottom: 1px solid transparent;
    transition: all 0.2s;
    z-index: 1;
}

.paper-medicine-row:hover {
    border-bottom-color: #f1f5f9;
}

.paper-remove-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.2s;
    background: transparent;
    border: none;
    color: var(--danger);
    cursor: pointer;
}

.paper-medicine-row:hover .paper-remove-btn {
    opacity: 1;
}

.paper-add-btn {
    opacity: 0;
    transition: opacity 0.2s;
    transform: scale(0.8);
}

.input-group:hover .paper-add-btn {
    opacity: 1;
}


/* ==========================================================================
   9. BADGE STATUS SYSTEM
   ========================================================================== */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.4;
    white-space: nowrap;
}

.badge-status i,
.badge-status .bi {
    font-size: 0.5rem;
}

.badge-active {
    background: var(--success-light);
    color: var(--success);
}

.badge-active::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    margin-right: 4px;
}

.badge-pending {
    background: var(--warning-light);
    color: #b45309;
}

.badge-pending::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #b45309;
    margin-right: 4px;
}

.badge-trial {
    background: var(--info-light);
    color: var(--info);
}

.badge-trial::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--info);
    margin-right: 4px;
}

.badge-inactive {
    background: var(--danger-light);
    color: var(--danger);
}

.badge-inactive::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--danger);
    margin-right: 4px;
}

.badge-expired {
    background: #fef2f2;
    color: #dc2626;
}

.badge-expired::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #dc2626;
    margin-right: 4px;
}

.badge-paid {
    background: var(--success-light);
    color: var(--success-dark);
}

.badge-unpaid {
    background: var(--danger-light);
    color: var(--danger-dark);
}

.badge-partial {
    background: var(--warning-light);
    color: var(--warning-dark);
}


/* ==========================================================================
   10. SIDEBAR BRAND, PROFILE & NAVIGATION
   ========================================================================== */

/* ----- Sidebar Brand ----- */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    text-decoration: none;
    color: #ffffff;
    transition: var(--transition-fast);
}

.sidebar-brand:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.02);
}

.sidebar-brand img {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: contain;
    flex-shrink: 0;
}

.sidebar-brand h5,
.sidebar-brand .brand-name {
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
    line-height: 1.3;
}

.sidebar-brand small,
.sidebar-brand .brand-subtitle {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
}

/* ----- Sidebar Profile ----- */
.sidebar-profile {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-profile .profile-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

.sidebar-profile .profile-info {
    overflow: hidden;
}

.sidebar-profile .profile-name {
    color: #ffffff;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.sidebar-profile .profile-role {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.72rem;
    margin: 0;
}

/* ----- Sidebar Navigation ----- */
.sidebar-nav {
    padding: 12px 0;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 0;
    -webkit-overflow-scrolling: touch;
}

.sidebar-nav .nav-section-title {
    padding: 12px 20px 6px;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.35);
    font-weight: 600;
}

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

.sidebar-menu li {
    margin: 1px 0;
}

.sidebar-menu li a {
    color: rgba(255, 255, 255, 0.7);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
    font-size: 0.855rem;
    border-left: 3px solid transparent;
    text-decoration: none;
    position: relative;
}

.sidebar-menu li a i,
.sidebar-menu li a .bi {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    transition: var(--transition);
}

.sidebar-menu li a:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.05);
}

.sidebar-menu li a:hover i {
    transform: scale(1.1);
}

.sidebar-menu li a.active,
.sidebar-menu li.active > a {
    color: #ffffff;
    background: linear-gradient(90deg, rgba(79, 70, 229, 0.15) 0%, rgba(255, 255, 255, 0) 100%);
    border-left-color: var(--primary);
    font-weight: 500;
}

.sidebar-menu li a.active i,
.sidebar-menu li.active > a i {
    color: #a5b4fc;
}

.sidebar-menu li a .menu-badge {
    margin-left: auto;
    font-size: 0.65rem;
    padding: 2px 7px;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
}

/* ----- Sidebar Footer ----- */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin-top: auto;
}

.sidebar-footer a {
    color: rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.835rem;
    transition: var(--transition);
    padding: 6px 0;
    text-decoration: none;
}

.sidebar-footer a:hover {
    color: #ffffff;
}

.sidebar-footer a i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}


/* ==========================================================================
   11. RX BUILDER (Prescription Show/View Page)
   ========================================================================== */
.rx-builder {
    background: #fff;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    border-top: 6px solid var(--primary);
}

.rx-header {
    padding: 24px;
    border-bottom: 2px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 16px;
}

.rx-header .clinic-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 2px;
}

.rx-header .doctor-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 0;
}

.rx-header .doctor-qualification {
    font-size: 0.78rem;
    color: var(--secondary);
}

.rx-body {
    display: flex;
    min-height: 400px;
}

.rx-left {
    width: 35%;
    padding: 24px;
    border-right: 1px dashed #cbd5e1;
    background: #fafbfd;
}

.rx-left .patient-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--secondary);
    font-weight: 600;
    margin-bottom: 2px;
}

.rx-left .patient-value {
    font-size: 0.9rem;
    color: var(--dark);
    font-weight: 500;
    margin-bottom: 12px;
}

.rx-right {
    width: 65%;
    padding: 24px;
    position: relative;
}

.rx-right .medicine-item {
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
}

.rx-right .medicine-item:last-child {
    border-bottom: none;
}

.rx-right .medicine-name {
    font-weight: 600;
    color: var(--dark);
    font-size: 0.92rem;
}

.rx-right .medicine-dosage {
    font-size: 0.82rem;
    color: var(--secondary);
}

.rx-right .medicine-instruction {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
}

.rx-footer {
    padding: 20px 24px;
    border-top: 2px solid #e2e8f0;
    background: #f8fafc;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.rx-footer .signature-area {
    text-align: center;
}

.rx-footer .signature-line {
    width: 180px;
    border-top: 1px solid #334155;
    padding-top: 6px;
    font-size: 0.78rem;
    color: var(--secondary);
}

.rx-symbol {
    font-size: 2.5rem;
    font-family: 'Times New Roman', serif;
    color: var(--primary);
    font-weight: 700;
    line-height: 1;
    user-select: none;
    margin-bottom: 8px;
}


/* ==========================================================================
   12. STAT CARDS (SuperAdmin & FrontDesk Dashboard)
   ========================================================================== */
.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary, #0f172a);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--secondary);
    font-weight: 600;
    margin-top: 4px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stat-icon.primary {
    background: var(--primary-light);
    color: var(--primary);
}

.stat-icon.success {
    background: var(--success-light);
    color: var(--success);
}

.stat-icon.info {
    background: var(--info-light);
    color: var(--info);
}

.stat-icon.warning {
    background: var(--warning-light);
    color: var(--warning);
}

.stat-icon.danger {
    background: var(--danger-light);
    color: var(--danger);
}

.stat-change {
    font-size: 0.72rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.stat-change.up {
    color: var(--success);
}

.stat-change.down {
    color: var(--danger);
}


/* ==========================================================================
   13. QUICK ACTIONS & ACTION CARDS
   ========================================================================== */
.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    border-radius: var(--border-radius);
    background: #fff;
    border: 1px solid #e2e8f0;
    transition: var(--transition);
    text-decoration: none;
    color: var(--dark);
    text-align: center;
    cursor: pointer;
    min-height: 100px;
}

.quick-action:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
    color: var(--primary);
}

.quick-action:active {
    transform: translateY(-1px);
}

.quick-action i,
.quick-action .bi {
    font-size: 1.5rem;
    margin-bottom: 8px;
    transition: var(--transition);
}

.quick-action:hover i,
.quick-action:hover .bi {
    transform: scale(1.15);
}

.quick-action span,
.quick-action .action-text {
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.3;
}

.action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    border-radius: var(--border-radius);
    background: #fff;
    border: 1px solid #e2e8f0;
    transition: var(--transition);
    text-decoration: none;
    color: var(--dark);
    text-align: center;
    cursor: pointer;
}

.action-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
    color: var(--primary);
}

.action-card .action-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin-bottom: 12px;
    transition: var(--transition);
}

.action-card:hover .action-icon {
    transform: scale(1.1);
}

.action-card .action-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin: 0;
}

.action-card .action-description {
    font-size: 0.75rem;
    color: var(--secondary);
    margin-top: 4px;
}


/* ==========================================================================
   14. QUEUE STATUS
   ========================================================================== */
.queue-item {
    padding: 12px 16px;
    border-radius: var(--border-radius-sm);
    background: #fff;
    margin-bottom: 8px;
    transition: var(--transition);
}

.queue-waiting {
    border-left: 4px solid var(--warning);
}

.queue-waiting .queue-status-text {
    color: #b45309;
    font-weight: 600;
    font-size: 0.75rem;
}

.queue-consulting {
    border-left: 4px solid var(--info);
    background: var(--info-light);
}

.queue-consulting .queue-status-text {
    color: var(--info-dark);
    font-weight: 600;
    font-size: 0.75rem;
}

.queue-completed {
    border-left: 4px solid var(--success);
    opacity: 0.7;
}

.queue-completed .queue-status-text {
    color: var(--success-dark);
    font-weight: 600;
    font-size: 0.75rem;
}

.queue-cancelled {
    border-left: 4px solid var(--danger);
    opacity: 0.5;
}

.queue-item:hover {
    box-shadow: var(--shadow-sm);
}

.queue-number {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--dark);
    min-width: 32px;
}

.queue-patient-name {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--dark);
}

.queue-time {
    font-size: 0.75rem;
    color: var(--secondary);
}


/* ==========================================================================
   15. AVATAR SYSTEM
   ========================================================================== */
.avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
    text-transform: uppercase;
    user-select: none;
}

.avatar-circle.sm {
    width: 32px;
    height: 32px;
    font-size: 0.72rem;
}

.avatar-circle.lg {
    width: 56px;
    height: 56px;
    font-size: 1.1rem;
}

.avatar-circle.xl {
    width: 72px;
    height: 72px;
    font-size: 1.4rem;
}

.avatar-circle.success {
    background: var(--success-light);
    color: var(--success);
}

.avatar-circle.info {
    background: var(--info-light);
    color: var(--info);
}

.avatar-circle.warning {
    background: var(--warning-light);
    color: var(--warning);
}

.avatar-circle.danger {
    background: var(--danger-light);
    color: var(--danger);
}

.avatar-circle img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-group {
    display: flex;
}

.avatar-group .avatar-circle {
    border: 2px solid #fff;
    margin-left: -10px;
}

.avatar-group .avatar-circle:first-child {
    margin-left: 0;
}


/* ==========================================================================
   16. PAGE TITLE & PAGE HEADER
   ========================================================================== */
.page-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--dark);
    margin: 0;
    line-height: 1.3;
}

.page-subtitle {
    font-size: 0.82rem;
    color: var(--secondary);
    margin: 4px 0 0 0;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}


/* ==========================================================================
   17. TOAST NOTIFICATIONS
   ========================================================================== */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    pointer-events: none;
}

.toast-container > * {
    pointer-events: auto;
}

.custom-toast {
    padding: 12px 20px;
    border-radius: var(--border-radius-sm);
    color: #fff;
    font-weight: 500;
    font-size: 0.875rem;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    min-width: 280px;
    max-width: 420px;
    position: relative;
}

.custom-toast.success {
    background: var(--success);
}

.custom-toast.error {
    background: var(--danger);
}

.custom-toast.warning {
    background: var(--warning);
    color: #000;
}

.custom-toast.info {
    background: var(--info);
}

.custom-toast i,
.custom-toast .bi {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.custom-toast .toast-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    opacity: 0.7;
    cursor: pointer;
    padding: 0 4px;
    font-size: 1rem;
}

.custom-toast .toast-close:hover {
    opacity: 1;
}

.custom-toast.toast-exit {
    animation: slideOutRight 0.3s ease forwards;
}


/* ==========================================================================
   18. BREADCRUMBS
   ========================================================================== */
.breadcrumb-custom {
    background: transparent;
    padding: 0;
    margin-bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    list-style: none;
}

.breadcrumb-custom .breadcrumb-item {
    font-size: 0.82rem;
    display: flex;
    align-items: center;
}

.breadcrumb-custom .breadcrumb-item + .breadcrumb-item::before {
    content: '/';
    color: var(--text-muted);
    padding: 0 8px;
    font-size: 0.75rem;
}

.breadcrumb-custom .breadcrumb-item a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition-fast);
}

.breadcrumb-custom .breadcrumb-item a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.breadcrumb-custom .breadcrumb-item.active {
    color: var(--secondary);
}

.breadcrumb-custom .breadcrumb-item i,
.breadcrumb-custom .breadcrumb-item .bi {
    font-size: 0.72rem;
    margin-right: 4px;
}


/* ==========================================================================
   19. PAGINATION
   ========================================================================== */
.pagination-custom {
    display: flex;
    align-items: center;
    gap: 4px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.pagination-custom .page-item .page-link {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius-sm);
    border: 1px solid #e2e8f0;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    background: #fff;
    transition: var(--transition);
    text-decoration: none;
}

.pagination-custom .page-item .page-link:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.pagination-custom .page-item.active .page-link {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.pagination-custom .page-item.disabled .page-link {
    color: var(--text-muted);
    background: #f8fafc;
    border-color: #e2e8f0;
    cursor: not-allowed;
    opacity: 0.5;
}

.pagination-custom .page-item:first-child .page-link,
.pagination-custom .page-item:last-child .page-link {
    width: auto;
    padding: 0 12px;
}

.pagination-info {
    font-size: 0.82rem;
    color: var(--secondary);
}


/* ==========================================================================
   20. SKELETON LOADERS
   ========================================================================== */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--border-radius-sm);
}

.skeleton-text {
    height: 12px;
    margin-bottom: 8px;
    border-radius: 4px;
}

.skeleton-text.short {
    width: 60%;
}

.skeleton-text.medium {
    width: 80%;
}

.skeleton-heading {
    height: 20px;
    width: 50%;
    margin-bottom: 12px;
    border-radius: 4px;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-avatar.lg {
    width: 56px;
    height: 56px;
}

.skeleton-card {
    height: 120px;
    border-radius: var(--border-radius);
}

.skeleton-image {
    height: 200px;
    border-radius: var(--border-radius);
}

.skeleton-table-row {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}

.skeleton-table-row .skeleton-cell {
    height: 14px;
    border-radius: 4px;
    flex: 1;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}


/* ==========================================================================
   21. ANIMATIONS & KEYFRAMES
   ========================================================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-6px);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Animation Utility Classes */
.animate-fade-in {
    animation: fadeIn 0.3s ease;
}

.animate-fade-in-up {
    animation: fadeInUp 0.4s ease;
}

.animate-fade-in-down {
    animation: fadeInDown 0.4s ease;
}

.animate-slide-in-right {
    animation: slideInRight 0.3s ease;
}

.animate-slide-in-left {
    animation: slideInLeft 0.3s ease;
}

.animate-pulse {
    animation: pulse 2s infinite;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

.animate-bounce {
    animation: bounce 1s ease infinite;
}

.animate-scale-in {
    animation: scaleIn 0.3s ease;
}


/* ==========================================================================
   22. PRINT STYLES
   ========================================================================== */
@media print {
    /* Hide non-printable elements */
    .sidebar,
    .topbar,
    .no-print,
    .btn,
    .sidebar-overlay,
    .toast-container,
    .breadcrumb-custom,
    .page-header-right,
    .quick-action,
    .action-card {
        display: none !important;
    }

    /* Reset layout */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .content-wrapper {
        padding: 0 !important;
    }

    /* Reset backgrounds */
    body {
        background: #fff !important;
        color: #000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Prescription builder print */
    .rx-builder {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        border-top: 4px solid var(--primary) !important;
    }

    .rx-card {
        box-shadow: none !important;
        border: 1px solid #e2e8f0 !important;
    }

    .paper-pad {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        max-width: 100% !important;
        padding: 1rem !important;
    }

    /* Links */
    a {
        color: #000 !important;
        text-decoration: none !important;
    }

    /* Page breaks */
    .rx-builder,
    .paper-pad {
        page-break-inside: avoid;
    }

    .stat-card {
        box-shadow: none !important;
        border: 1px solid #e2e8f0 !important;
    }

    /* Ensure colors print */
    .badge-active,
    .badge-pending,
    .badge-trial,
    .badge-inactive,
    .badge-expired {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}


/* ==========================================================================
   23. CUSTOM SCROLLBAR
   ========================================================================== */

/* Sidebar scrollbar */
.sidebar::-webkit-scrollbar,
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track,
.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb,
.sidebar-nav::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* General content scrollbar */
.rx-clinical-panel::-webkit-scrollbar,
.autocomplete-dropdown::-webkit-scrollbar {
    width: 6px;
}

.rx-clinical-panel::-webkit-scrollbar-track,
.autocomplete-dropdown::-webkit-scrollbar-track {
    background: #f8fafc;
}

.rx-clinical-panel::-webkit-scrollbar-thumb,
.autocomplete-dropdown::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 10px;
}

.rx-clinical-panel::-webkit-scrollbar-thumb:hover,
.autocomplete-dropdown::-webkit-scrollbar-thumb:hover {
    background-color: #94a3b8;
}

/* Firefox scrollbar */
.sidebar,
.sidebar-nav {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.rx-clinical-panel,
.autocomplete-dropdown {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f8fafc;
}


/* ==========================================================================
   24. ERROR PAGES
   ========================================================================== */
.error-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--body-bg);
    text-align: center;
    padding: 2rem;
}

.error-page .error-code {
    font-size: 8rem;
    font-weight: 900;
    color: var(--primary);
    line-height: 1;
    letter-spacing: -0.05em;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--primary) 0%, #818cf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.error-page .error-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 8px;
}

.error-page .error-message {
    font-size: 1rem;
    color: var(--secondary);
    max-width: 480px;
    margin: 0 auto 24px;
    line-height: 1.6;
}

.error-page .error-illustration {
    max-width: 320px;
    margin: 0 auto 32px;
}

.error-page .error-illustration img,
.error-page .error-illustration svg {
    width: 100%;
    height: auto;
}

.error-page .error-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.error-page .error-actions .btn {
    min-width: 140px;
}

/* 403 Forbidden specific */
.error-page.forbidden .error-code {
    background: linear-gradient(135deg, var(--warning) 0%, var(--danger) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* 500 Server Error specific */
.error-page.server-error .error-code {
    background: linear-gradient(135deg, var(--danger) 0%, #be185d 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}


/* ==========================================================================
   25. MODAL CUSTOMIZATIONS
   ========================================================================== */
.modal-content {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-xl);
}

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

.modal-header .modal-title {
    font-weight: 700;
    font-size: 1rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    gap: 8px;
}

.modal-backdrop.show {
    opacity: 0.4;
}


/* ==========================================================================
   26. DROPDOWN MENU ENHANCEMENTS
   ========================================================================== */
.dropdown-menu {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-md);
    padding: 0.375rem;
    animation: fadeInDown 0.15s ease;
}

.dropdown-item {
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.855rem;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 8px;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: var(--primary-light);
    color: var(--primary);
}

.dropdown-item i,
.dropdown-item .bi {
    width: 16px;
    text-align: center;
    font-size: 0.9rem;
    color: var(--secondary);
}

.dropdown-item:hover i,
.dropdown-item:hover .bi {
    color: var(--primary);
}

.dropdown-divider {
    margin: 0.25rem 0;
    border-color: var(--border-color);
}

.dropdown-header {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
    padding: 0.5rem 0.75rem 0.25rem;
}


/* ==========================================================================
   27. EMPTY STATE
   ========================================================================== */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
}

.empty-state .empty-icon {
    font-size: 3rem;
    color: #cbd5e1;
    margin-bottom: 16px;
}

.empty-state .empty-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 8px;
}

.empty-state .empty-message {
    font-size: 0.875rem;
    color: var(--secondary);
    max-width: 360px;
    margin: 0 auto 20px;
    line-height: 1.5;
}

.empty-state .empty-illustration {
    max-width: 200px;
    margin: 0 auto 20px;
    opacity: 0.6;
}

.empty-state .empty-illustration img {
    width: 100%;
    height: auto;
}


/* ==========================================================================
   28. MISCELLANEOUS UTILITIES
   ========================================================================== */

/* Divider */
.divider {
    height: 1px;
    background: var(--border-color);
    margin: 1rem 0;
}

.divider-vertical {
    width: 1px;
    background: var(--border-color);
    align-self: stretch;
}

/* Truncate text */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.text-truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Dot separator */
.dot-separator::before {
    content: '·';
    margin: 0 6px;
    color: var(--text-muted);
}

/* Status dot */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 0 3px var(--success-light);
}

.status-dot.offline {
    background: var(--secondary);
}

.status-dot.busy {
    background: var(--danger);
    box-shadow: 0 0 0 3px var(--danger-light);
}

/* Overlay */
.overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: inherit;
    backdrop-filter: blur(2px);
}

/* Loading spinner */
.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-spinner.sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.loading-spinner.lg {
    width: 48px;
    height: 48px;
    border-width: 4px;
}

/* Clickable row */
.clickable-row {
    cursor: pointer;
    transition: var(--transition-fast);
}

.clickable-row:hover {
    background-color: #f8fafc !important;
}

/* Counter badge */
.counter-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--danger);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

/* Selection highlight */
::selection {
    background: var(--primary-light);
    color: var(--primary-dark);
}

/* Focus visible outline */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ==========================================================================
   MOBILE PRESCRIPTION BUILDER - Touch-Friendly Overrides
   Only activates on screens < 768px (phones). Desktop is unaffected.
   ========================================================================== */
@media (max-width: 767.98px) {

    /* --- Global Touch Targets --- */
    /* Increase min tap target to 44px (Apple HIG) for all form controls in RX forms */
    #rxForm .form-control,
    #rxForm .form-select,
    #rxForm .input-group-text {
        min-height: 44px;
        font-size: 0.9rem;
    }

    #rxForm .form-control-sm,
    #rxForm .form-select-sm,
    #rxForm .input-group-sm > .form-control,
    #rxForm .input-group-sm > .form-select,
    #rxForm .input-group-sm > .input-group-text {
        min-height: 42px;
        font-size: 0.875rem;
    }

    #rxForm .btn {
        min-height: 44px;
        font-size: 0.875rem;
    }

    /* --- Top Patient Card (Sticky Header) --- */
    .rx-card.sticky-top {
        position: relative !important;
        top: auto !important;
    }

    /* Hide the large avatar circle on mobile */
    #rxForm .rx-card .bg-primary.rounded-circle {
        display: none !important;
    }

    /* Make patient select full width */
    #rxForm .rx-card .flex-grow-1 {
        width: 100%;
    }

    /* Date-time and Doctor select: full width on mobile */
    #rxForm input[type="datetime-local"],
    #rxForm #doctorSelect {
        width: 100% !important;
        display: block !important;
    }

    /* --- On Examination Grid --- */
    #rxForm .bg-light .input-group-text[style*="width: 60px"] {
        width: 50px !important;
        font-size: 0.75rem;
        padding: 0.25rem 0.4rem;
    }

    /* --- Medicine Rows --- */
    .builder-medicine-row {
        padding: 1rem !important;
        padding-top: 1.25rem !important;
    }

    .builder-medicine-row .ps-3 {
        padding-left: 0.5rem !important;
    }

    /* Drag handle - smaller on mobile */
    .builder-medicine-row > .drag-handle,
    .builder-medicine-row > span.position-absolute.cursor-grab {
        display: none !important;
    }

    /* Remove (x) button - larger tap area */
    .builder-medicine-row .btn-link.text-danger {
        padding: 0.5rem !important;
        font-size: 1.1rem;
    }

    /* Drug type select */
    .builder-medicine-row select[name*="drug_type"] {
        max-width: 80px !important;
        font-size: 0.8rem;
    }

    /* --- Floating Action Dock --- */
    .rx-action-dock {
        left: 0 !important;
        right: 0 !important;
        transform: none !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100%;
    }

    .rx-action-dock .dock-inner {
        border-radius: 0 !important;
        width: 100%;
        padding: 0.5rem 0.75rem !important;
        gap: 0.5rem !important;
        flex-wrap: wrap;
        justify-content: center;
    }

    /* Hide template select, save fav, SMS, and divider on mobile */
    .rx-action-dock .dock-secondary {
        display: none !important;
    }

    /* Primary buttons fill available space */
    .rx-action-dock .btn-primary,
    .rx-action-dock .btn-success {
        flex: 1;
        min-width: 0;
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    /* Hide keyboard shortcut hints on mobile */
    .rx-action-dock .opacity-50.fs-xs {
        display: none !important;
    }

    /* --- Investigation Modal --- */
    #investigationModal .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100%;
    }

    #investigationModal .modal-content {
        border-radius: 0 !important;
        height: 100%;
    }

    #investigationModal .d-flex:has(> .nav) {
        flex-direction: column !important;
    }

    /* Category sidebar → horizontal scroll strip on mobile */
    #investigationModal .nav.flex-column {
        flex-direction: row !important;
        width: 100% !important;
        overflow-x: auto;
        white-space: nowrap;
        padding: 0.5rem !important;
        border-right: none !important;
        border-bottom: 1px solid #e2e8f0 !important;
        -webkit-overflow-scrolling: touch;
    }

    #investigationModal .nav.flex-column .nav-link {
        white-space: nowrap;
        flex-shrink: 0;
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
        margin-bottom: 0 !important;
        margin-right: 0.25rem;
    }

    /* Investigation checkboxes full width */
    #investigationModal .investigation-list .col-6 {
        width: 100% !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    #investigationModal .form-check-label {
        padding: 0.5rem 0;
    }

    /* --- Quick Templates Modal --- */
    #favoritesModal .col-md-6 {
        width: 100% !important;
        flex: 0 0 100% !important;
    }

    /* --- Add Medicine Button --- */
    #addMedicine {
        width: 100%;
    }

    /* --- Autocomplete Dropdown --- */
    .autocomplete-dropdown {
        position: absolute !important;
        width: 100% !important;
    }

    .autocomplete-item {
        padding: 0.75rem 1rem !important;
    }

    /* --- Page Bottom Padding (for floating dock) --- */
    #rxForm > .row.g-4 {
        padding-bottom: 5rem !important;
        margin-bottom: 0 !important;
    }

    /* --- Tags --- */
    .tag-pill {
        font-size: 0.8rem;
        padding: 0.4rem 0.85rem;
    }

    /* --- Keyboard Shortcut Labels --- */
    #rxForm .opacity-50.fs-xs:has(kbd),
    #rxForm span.opacity-50.fs-xs {
        display: none;
    }

    /* --- Card padding reduction --- */
    #rxForm .rx-card .card-body {
        padding: 1rem !important;
    }

    #rxForm .rx-card .card-header {
        padding: 1rem 1rem 0 !important;
    }
}

/* Mobile dock specific classes */
@media (max-width: 767.98px) {
    .position-fixed.bottom-0.start-50 {
        left: 0 !important;
        right: 0 !important;
        transform: none !important;
        width: 100% !important;
    }

    .position-fixed.bottom-0.start-50 > .rounded-pill {
        border-radius: 0 !important;
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    /* Hide secondary dock items on mobile */
    .position-fixed.bottom-0.start-50 .vr,
    .position-fixed.bottom-0.start-50 select[name="template_id"],
    .position-fixed.bottom-0.start-50 select[name="template_id"] + div,
    .position-fixed.bottom-0.start-50 button[data-bs-target="#saveFavoriteModal"] {
        display: none !important;
    }

    /* Primary action buttons in dock */
    .position-fixed.bottom-0.start-50 .btn-primary,
    .position-fixed.bottom-0.start-50 .btn-success {
        flex: 1;
        border-radius: 50rem !important;
    }

    .position-fixed.bottom-0.start-50 .btn-info {
        display: none !important;
    }
}


/* ==========================================================================
   DARK MODE
   ========================================================================== */
[data-theme="dark"] {
    --dark: #f8fafc;
    --light: #0f172a;
    --body-bg: #0f172a;
    --text-primary: #e2e8f0;
    --text-muted: #94a3b8;
    
    /* Semantic Colors Adjustments */
    --primary-light: rgba(79, 70, 229, 0.2);
    
    /* Backgrounds */
    --bs-body-bg: #0f172a;
    --bs-body-color: #e2e8f0;
}

[data-theme="dark"] body {
    background-color: var(--body-bg);
    color: var(--text-primary);
}

[data-theme="dark"] .bg-white,
[data-theme="dark"] .card {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

[data-theme="dark"] .rx-card {
    background: rgba(30, 41, 59, 0.95);
    border-color: #334155;
}

[data-theme="dark"] .sidebar {
    background-color: #1e293b;
    border-right-color: #334155;
}

[data-theme="dark"] .topbar {
    background-color: rgba(30, 41, 59, 0.85);
    border-bottom-color: #334155;
}

[data-theme="dark"] .text-dark {
    color: #f8fafc !important;
}

[data-theme="dark"] .text-muted,
[data-theme="dark"] .text-secondary {
    color: #94a3b8 !important;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background-color: #0f172a;
    border-color: var(--primary);
    color: #e2e8f0;
}

[data-theme="dark"] .dropdown-menu {
    background-color: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .dropdown-item {
    color: #e2e8f0;
}

[data-theme="dark"] .dropdown-item:hover {
    background-color: #334155;
    color: #fff;
}

[data-theme="dark"] .table {
    color: #e2e8f0;
}

[data-theme="dark"] .table-light {
    background-color: #334155;
    color: #e2e8f0;
}
