/**
 * NS Pro Pathology - Modern Medical SaaS Theme
 * Highly Responsive Design System (Bootstrap 5.3 Extension)
 */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    --brand-primary: #0284c7;
    --brand-primary-hover: #0369a1;
    --brand-primary-light: #e0f2fe;
    --brand-secondary: #475569;
    --brand-dark: #0f172a;
    --brand-sidebar-bg: #0b1329;
    --brand-sidebar-hover: #1e293b;
    --brand-card-bg: #ffffff;
    --brand-bg: #f8fafc;
    --brand-border: #e2e8f0;
    --brand-text: #1e293b;
    --brand-muted: #64748b;
    --brand-success: #10b981;
    --brand-warning: #f59e0b;
    --brand-danger: #ef4444;
    --brand-info: #06b6d4;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--brand-bg);
    color: var(--brand-text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

/* Monospace font for codes, IDs, ranges */
.font-mono,
.badge-mono {
    font-family: 'JetBrains Mono', monospace;
}

/* Application Layout Structure */
#app-wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
    position: relative;
}

/* Sidebar Styles */
#sidebar {
    width: var(--sidebar-width);
    background: var(--brand-sidebar-bg);
    color: #94a3b8;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1045;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    color: #ffffff;
    font-size: 1.1rem;
    font-weight: 700;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-brand i {
    color: #38bdf8;
    font-size: 1.35rem;
    margin-right: 0.65rem;
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0.75rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.sidebar-heading {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #64748b;
    padding: 0.75rem 0.75rem 0.35rem;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.65rem 0.85rem;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    border-radius: 0.5rem;
    transition: var(--transition);
    margin-bottom: 0.2rem;
    cursor: pointer;
}

.sidebar-link i {
    width: 22px;
    font-size: 1.1rem;
    margin-right: 0.65rem;
    color: #64748b;
    transition: var(--transition);
    flex-shrink: 0;
}

.sidebar-link:hover {
    color: #ffffff;
    background: var(--brand-sidebar-hover);
}

.sidebar-link:hover i {
    color: #38bdf8;
}

.sidebar-link.active {
    color: #ffffff;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-hover));
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
}

.sidebar-link.active i {
    color: #ffffff;
}

.sidebar-footer {
    padding: 0.85rem 1rem;
    background: rgba(0, 0, 0, 0.25);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Main Content Area */
#main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
    transition: var(--transition);
}

/* Top Navbar */
#top-navbar {
    min-height: var(--topbar-height);
    background: #ffffff;
    border-bottom: 1px solid var(--brand-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

/* Cards & UI Components */
.card {
    background: var(--brand-card-bg);
    border: 1px solid var(--brand-border);
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    transition: var(--transition);
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--brand-border);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

/* Metric KPI Cards */
.stat-card {
    border-radius: 0.75rem;
    padding: 1.15rem;
    background: #ffffff;
    border: 1px solid var(--brand-border);
    display: flex;
    align-items: center;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-right: 1rem;
    flex-shrink: 0;
}

.stat-icon.primary {
    background: #e0f2fe;
    color: #0284c7;
}

.stat-icon.success {
    background: #dcfce7;
    color: #16a34a;
}

.stat-icon.warning {
    background: #fef3c7;
    color: #d97706;
}

.stat-icon.danger {
    background: #fee2e2;
    color: #dc2626;
}

.stat-icon.purple {
    background: #f3e8ff;
    color: #9333ea;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--brand-dark);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--brand-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Modern Tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-custom {
    margin-bottom: 0;
    white-space: nowrap;
}

.table-custom thead th {
    background-color: #f8fafc;
    color: #475569;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-bottom: 1px solid var(--brand-border);
    padding: 0.85rem 1rem;
}

.table-custom tbody td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.88rem;
}

.table-custom tbody tr:hover {
    background-color: #f8fafc;
}

/* Sticky Impersonation Support Banner */
.impersonation-bar {
    background: linear-gradient(90deg, #b91c1c, #dc2626);
    color: #ffffff;
    padding: 0.6rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1050;
    box-shadow: 0 2px 8px rgba(185, 28, 28, 0.4);
}

/* Subscription Expiry Warning Bar */
.subscription-warning-bar {
    background: linear-gradient(90deg, #d97706, #f59e0b);
    color: #ffffff;
    padding: 0.55rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Buttons & Controls */
.btn-brand {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
    color: #ffffff;
    font-weight: 600;
    padding: 0.55rem 1.15rem;
    border-radius: 0.5rem;
    transition: var(--transition);
}

.btn-brand:hover,
.btn-brand:focus {
    background-color: var(--brand-primary-hover);
    border-color: var(--brand-primary-hover);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.form-control,
.form-select {
    border-radius: 0.5rem;
    border: 1px solid var(--brand-border);
    padding: 0.55rem 0.85rem;
    font-size: 0.88rem;
    transition: var(--transition);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

/* Flag Colors for Diagnostic Results */
.flag-normal {
    color: #16a34a;
    font-weight: 600;
}

.flag-low {
    color: #0284c7;
    font-weight: 600;
}

.flag-high {
    color: #d97706;
    font-weight: 700;
}

.flag-critical {
    color: #dc2626;
    font-weight: 800;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }

    100% {
        opacity: 1;
    }
}

/* Responsive Offcanvas & Mobile Phone View Optimizations */
@media (max-width: 991.98px) {
    #sidebar {
        transform: translateX(-100%);
        width: 280px;
        max-width: 85vw;
        box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    }

    #sidebar.show {
        transform: translateX(0);
    }

    #main-content {
        margin-left: 0;
        width: 100%;
    }

    #top-navbar {
        padding: 0.5rem 1rem;
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(15, 23, 42, 0.65);
        backdrop-filter: blur(4px);
        z-index: 1040;
        display: none;
        opacity: 0;
        transition: opacity 0.25s ease-in-out;
    }

    .sidebar-overlay.show {
        display: block;
        opacity: 1;
    }

    /* Lab Top Subnav Mobile Drawer Styling */
    .lab-main-subnav .navbar-collapse {
        background: #00363f;
        border-radius: 10px;
        padding: 12px 14px;
        margin-top: 8px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
        max-height: 82vh;
        overflow-y: auto;
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    .lab-main-subnav .navbar-nav {
        flex-direction: column;
        gap: 4px !important;
    }

    .lab-main-subnav .nav-link {
        font-size: 0.92rem;
        padding: 9px 12px !important;
        border-radius: 6px;
        display: flex;
        align-items: center;
        width: 100%;
    }

    .lab-main-subnav .nav-link:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    .lab-main-subnav .dropdown-menu {
        background: #00252b;
        border: 1px solid rgba(255, 255, 255, 0.1);
        margin: 4px 0 8px 12px;
        border-radius: 8px;
        box-shadow: none;
    }

    .lab-main-subnav .dropdown-item {
        color: #e2e8f0;
        font-size: 0.88rem;
        padding: 8px 14px;
        border-radius: 4px;
    }

    .lab-main-subnav .dropdown-item:hover {
        background: #004d5a;
        color: #ffffff;
    }

    .stat-card {
        padding: 0.85rem;
    }

    .stat-value {
        font-size: 1.3rem;
    }

    .card-body {
        padding: 1rem;
    }
}

/* Mobile Tablets and Phones (< 768px) */
@media (max-width: 767.98px) {
    /* Fast Intake & 1-Screen Order Table Mobile Transformation */
    .mcl-table {
        display: block;
        width: 100%;
    }

    .mcl-table tbody {
        display: block;
        width: 100%;
    }

    .mcl-table tr {
        display: flex;
        flex-wrap: wrap;
        border-bottom: 1px solid #e2e8f0;
        padding: 6px 4px;
        background: #ffffff;
    }

    .mcl-table td {
        border: none !important;
        padding: 3px 4px !important;
    }

    .mcl-table td.mcl-label {
        width: 100% !important;
        font-weight: 700;
        font-size: 0.78rem;
        color: #006070;
        background: transparent;
        padding-bottom: 0 !important;
        margin-top: 4px;
    }

    .mcl-table td:not(.mcl-label) {
        width: 100% !important;
    }

    .mcl-input {
        border: 1px solid #cbd5e1 !important;
        border-radius: 4px;
        padding: 6px 8px;
        font-size: 15px !important;
        background: #f8fafc;
    }

    .mcl-input:focus {
        background: #ffffff;
    }

    /* Fixed Bottom Action Dock on Mobile */
    .mcl-toolbar {
        padding: 8px 10px;
        gap: 6px;
        background: #004d5a;
    }

    .mcl-action-btn {
        font-size: 12px;
        padding: 6px 12px;
        flex: 1 1 auto;
        justify-content: center;
    }

    .mcl-action-btn-primary {
        flex: 2 1 100%;
        order: -1;
        padding: 10px 16px;
        font-size: 14px;
        letter-spacing: 0.5px;
    }

    /* Form Controls Font-size on Mobile (Avoids iOS Safari Zoom-in) */
    .form-control,
    .form-select,
    .ts-control input {
        font-size: 16px !important;
    }

    /* Tables Touch Optimization */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        margin-bottom: 0.5rem;
    }

    .table-custom thead th {
        font-size: 0.72rem;
        padding: 0.65rem 0.75rem;
    }

    .table-custom tbody td {
        font-size: 0.82rem;
        padding: 0.65rem 0.75rem;
    }
}

/* Small Phones (< 576px) */
@media (max-width: 575.98px) {
    #top-navbar {
        padding: 0.5rem 0.75rem;
    }

    #top-navbar h5 {
        font-size: 1rem;
    }

    .impersonation-bar,
    .subscription-warning-bar {
        flex-direction: column;
        gap: 0.4rem;
        text-align: center;
        padding: 0.5rem 0.75rem;
        font-size: 0.78rem;
    }

    .stat-value {
        font-size: 1.15rem !important;
    }

    .stat-label {
        font-size: 0.68rem !important;
        letter-spacing: 0.3px;
    }

    .card-header {
        padding: 0.75rem 0.85rem;
    }

    .card-body {
        padding: 0.85rem;
    }

    /* WhatsApp floating widget mobile placement */
    #whatsapp-support-widget {
        bottom: 12px !important;
        right: 12px !important;
    }

    #whatsapp-support-widget a {
        padding: 6px 12px !important;
        font-size: 0.78rem;
    }
}

/* Touch-friendly buttons and inputs */
button, a, input, select, textarea {
    touch-action: manipulation;
}

/* ==========================================================================
   Tom Select Custom Styling (Searchable Dropdowns Theme Extension)
   ========================================================================== */
.ts-control {
    border: 1px solid #cbd5e1 !important;
    border-radius: 0.375rem !important;
    padding: 0.45rem 0.75rem !important;
    font-size: 0.925rem !important;
    font-family: inherit !important;
    min-height: calc(1.5em + 0.9rem + 2px) !important;
    background-color: #ffffff !important;
    transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out !important;
}

.ts-control.focus,
.ts-wrapper.focus .ts-control {
    border-color: #38bdf8 !important;
    box-shadow: 0 0 0 0.25rem rgba(2, 132, 199, 0.2) !important;
}

.ts-dropdown {
    border: 1px solid #e2e8f0 !important;
    border-radius: 0.5rem !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12) !important;
    margin-top: 4px !important;
    padding: 4px 0 !important;
    z-index: 1060 !important;
    background: #ffffff !important;
    font-size: 0.9rem !important;
}

.ts-dropdown .optgroup-header {
    font-weight: 700 !important;
    font-size: 0.75rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    color: #64748b !important;
    padding: 6px 12px 2px !important;
    background: #f8fafc !important;
    border-bottom: 1px solid #f1f5f9 !important;
}

.ts-dropdown .option {
    padding: 8px 12px !important;
    transition: background-color 0.15s ease !important;
    cursor: pointer !important;
}

.ts-dropdown .option.active,
.ts-dropdown .option:hover {
    background-color: #e0f2fe !important;
    color: #0369a1 !important;
}

.ts-dropdown .option.selected {
    background-color: #0284c7 !important;
    color: #ffffff !important;
    font-weight: 600 !important;
}

.ts-wrapper .clear_button {
    font-size: 1.25rem !important;
    right: 28px !important;
    color: #94a3b8 !important;
}

.ts-wrapper .clear_button:hover {
    color: #ef4444 !important;
}

/* ==========================================================================
   SweetAlert2 & Toast Notification Styling
   ========================================================================== */
.swal2-popup.app-swal-toast {
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18) !important;
    border: 1px solid rgba(226, 232, 240, 0.8) !important;
    border-radius: 12px !important;
    font-family: 'Plus Jakarta Sans', sans-serif !important;
    padding: 0.75rem 1rem !important;
    font-size: 0.925rem !important;
}

.swal2-popup.app-swal-toast .swal2-title {
    font-weight: 700 !important;
    font-size: 0.95rem !important;
    margin: 0 !important;
    color: #0f172a !important;
}

.swal2-popup.app-swal-toast .swal2-html-container {
    font-size: 0.875rem !important;
    color: #475569 !important;
    margin: 2px 0 0 !important;
}

.swal2-popup.swal2-modal {
    font-family: 'Plus Jakarta Sans', sans-serif !important;
    border-radius: 16px !important;
}