/* ==========================================================================
   HumanResearchLab Healthcare & Diagnostic ERP — Modern Responsive Design System
   Supports: Mobile (320px+), Tablet (768px+), Laptop/PC (992px+), Desktop (1200px+)
   ========================================================================== */

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 72px;
    --brand-primary: #007635;
    --brand-primary-hover: #005a28;
    --brand-accent: #00984a;
    --brand-dark: #0b1f15;
    --brand-dark-surface: #10281c;
    --brand-teal: #0d9488;
    --bg-light: #f8fafc;
    --text-primary: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --card-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
    --card-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
}

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-primary);
    font-size: 0.925rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ==========================================================================
   RESPONSIVE WRAPPER & SIDEBAR
   ========================================================================== */
#wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
    position: relative;
    overflow-x: hidden;
}

/* Sidebar Backdrop (Mobile & Tablet) */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    z-index: 1045;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
}

/* Sidebar Core */
#sidebar {
    width: var(--sidebar-width);
    background-color: var(--brand-dark);
    color: #94a3b8;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    z-index: 1050;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
}

#sidebar .sidebar-header {
    background-color: var(--brand-dark-surface);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

#sidebar .sidebar-menu {
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 2rem;
}

/* Clean Custom Scrollbar for Sidebar */
#sidebar .sidebar-menu::-webkit-scrollbar {
    width: 5px;
}
#sidebar .sidebar-menu::-webkit-scrollbar-track {
    background: transparent;
}
#sidebar .sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
#sidebar .sidebar-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

#sidebar .sidebar-heading {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #475569;
    padding: 1.1rem 0.75rem 0.35rem 0.75rem;
    font-weight: 700;
}

#sidebar .nav-link {
    color: #cbd5e1;
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    margin: 0.2rem 0;
    font-weight: 500;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

#sidebar .nav-link i {
    font-size: 1.1rem;
    min-width: 1.25rem;
    text-align: center;
    color: #94a3b8;
    transition: color 0.2s ease;
}

#sidebar .nav-link:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.08);
}
#sidebar .nav-link:hover i {
    color: #34d399;
}

#sidebar .nav-link.active {
    color: #ffffff;
    background: linear-gradient(90deg, rgba(0, 118, 53, 0.9) 0%, rgba(0, 152, 74, 0.7) 100%);
    box-shadow: 0 4px 10px rgba(0, 118, 53, 0.3);
    font-weight: 600;
}
#sidebar .nav-link.active i {
    color: #ffffff;
}

/* ==========================================================================
   PAGE CONTENT WRAPPER (CRITICAL FOR PC & MOBILE RESPONSIVENESS)
   ========================================================================== */
#page-content-wrapper {
    flex-grow: 1;
    min-width: 0; /* CRITICAL: Prevents wide tables/charts from expanding flex items */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: var(--bg-light);
    width: 100%;
}

.top-navbar {
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1.25rem;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.main-content {
    padding: 1.5rem;
    flex-grow: 1;
    width: 100%;
    min-width: 0;
}

.main-footer {
    background-color: #ffffff;
    border-top: 1px solid var(--border-color);
}

/* ==========================================================================
   BREAKPOINTS: MOBILE (< 992px)
   ========================================================================== */
@media (max-width: 991.98px) {
    #sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        transform: translateX(-100%);
        height: 100vh;
    }

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

    .main-content {
        padding: 1rem 0.85rem;
    }

    .top-navbar {
        padding: 0.65rem 0.85rem;
    }
}

/* BREAKPOINTS: DESKTOP COLLAPSED STATE (>= 992px) */
@media (min-width: 992px) {
    #wrapper.sidebar-collapsed #sidebar {
        margin-left: calc(-1 * var(--sidebar-width));
    }
}

/* Mobile Small Devices (< 576px) */
@media (max-width: 575.98px) {
    .stat-card {
        padding: 0.9rem !important;
    }
    .stat-card .fs-4 {
        font-size: 1.2rem !important;
    }
    .stat-icon {
        width: 38px !important;
        height: 38px !important;
        font-size: 1.15rem !important;
    }
    .user-profile-box {
        max-width: 110px;
    }
    .btn-sm {
        padding: 0.35rem 0.55rem;
        font-size: 0.8rem;
    }
}

/* ==========================================================================
   TABLES & CARDS RESPONSIVENESS
   ========================================================================== */
.card {
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    transition: box-shadow 0.2s ease;
}

.table-responsive {
    border-radius: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Smooth Touch Scrollbar for Tables */
.table-responsive::-webkit-scrollbar {
    height: 6px;
}
.table-responsive::-webkit-scrollbar-track {
    background: #f1f5f9;
}
.table-responsive::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.table {
    margin-bottom: 0;
    white-space: nowrap;
}

.table th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    border-top: none;
    background-color: #f8fafc;
}

.table-compact th, .table-compact td {
    padding: 0.65rem 0.75rem;
    vertical-align: middle;
}

/* Stat Cards */
.stat-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-2px);
}

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

/* Status Badges */
.badge-role {
    font-size: 0.75rem;
    padding: 0.3em 0.65em;
    border-radius: 6px;
    text-transform: capitalize;
    font-weight: 600;
}

.badge-pending { background-color: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.badge-collected { background-color: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.badge-processing { background-color: #f3e8ff; color: #6b21a8; border: 1px solid #e9d5ff; }
.badge-result_entered { background-color: #ffedd5; color: #c2410c; border: 1px solid #fed7aa; }
.badge-verified { background-color: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.badge-delivered { background-color: #ccfbf1; color: #0f766e; border: 1px solid #99f6e4; }
.badge-rejected { background-color: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

/* Login Page Styling */
.login-body {
    background: linear-gradient(135deg, #0b1f15 0%, #10281c 50%, #064e2e 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.login-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

@media (max-width: 480px) {
    .login-card {
        padding: 2rem 1.25rem;
    }
}
