/* ===== CSS Variables ===== */
:root {
    --primary-blue: #0056b3;
    --primary-light: #e6f0fa;
    --primary-hover: #004494;
    --success-green: #28a745;
    --success-light: #e8f5e9;
    --warning-orange: #ffc107;
    --danger-red: #dc3545;
    
    --gray-50: #f8f9fa;
    --gray-100: #f1f3f5;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-600: #6c757d;
    --gray-800: #343a40;
    --gray-900: #212529;

    --font-family: 'Inter', sans-serif;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.05), 0 4px 6px rgba(0,0,0,0.05);
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* ===== Reset & Base ===== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.5;
    font-size: 14px;
}

.hidden {
    display: none !important;
}

/* ===== Utility Classes ===== */
.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.text-center { text-align: center; }
.error-text { color: var(--danger-red); font-size: 0.85rem; margin-top: 5px; }

/* ===== Typography ===== */
h1, h2, h3, h4 { color: var(--gray-900); font-weight: 600; }
a { color: var(--primary-blue); text-decoration: none; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-size: 14px;
}
.btn-primary {
    background-color: var(--primary-blue);
    color: white;
}
.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.btn-outline {
    background-color: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-800);
}
.btn-outline:hover {
    background-color: var(--gray-100);
}
.btn-danger {
    background-color: var(--danger-red);
    color: white;
}
.btn-block { width: 100%; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Forms ===== */
.form-group {
    margin-bottom: 15px;
}
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--gray-800);
    font-size: 13px;
}
input[type="text"],
input[type="password"],
input[type="number"],
input[type="month"],
select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    transition: border-color 0.2s;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.full-width { width: 100%; }

/* Form Grid System */
.form-row {
    display: flex;
    gap: 15px;
}
.form-group.half {
    width: 50%;
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
@media (max-width: 768px) {
    .form-grid { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; gap: 0; }
    .form-group.half { width: 100%; }
}
.form-section {
    background: var(--gray-50);
    padding: 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
}
.form-section.full-width {
    grid-column: 1 / -1;
}

/* Custom Checkboxes */
.test-selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 10px;
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    padding: 8px;
    border-radius: 4px;
    transition: background 0.2s;
}
.checkbox-label:hover {
    background: var(--gray-100);
}

/* ===== Global App Layout ===== */
#app-container {
    height: 100vh;
    width: 100vw;
    display: flex;
    overflow: hidden;
}

/* ===== Login View ===== */
#view-login {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--gray-50) 0%, var(--primary-light) 100%);
}
.login-wrapper {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}
.login-card {
    background: white;
    padding: 40px 30px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}
.brand {
    text-align: center;
    margin-bottom: 5px;
}
.brand-icon {
    font-size: 32px;
    color: var(--primary-blue);
    margin-bottom: 10px;
}
.subtitle {
    text-align: center;
    color: var(--gray-600);
    margin-bottom: 30px;
    font-size: 14px;
}

/* ===== Main View Layout ===== */
#view-main {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: white;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    z-index: 10;
}
.brand-small {
    padding: 24px 20px;
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-blue);
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    gap: 10px;
}
.nav-menu {
    flex: 1;
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-600);
    transition: all 0.2s;
}
.nav-item:hover {
    background: var(--gray-50);
    color: var(--primary-blue);
}
.nav-item.active {
    background: var(--primary-light);
    color: var(--primary-blue);
}
.nav-item .icon { font-size: 16px; }

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--gray-100);
}
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
}
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-blue);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}
.user-name { font-weight: 600; font-size: 14px; }
.user-role { font-size: 12px; color: var(--gray-600); text-transform: capitalize; }

/* Main Content Area */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--gray-50);
    min-width: 0; /* Prevents flex flex-grow overflow */
}
.top-header {
    height: 70px;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
}
.datetime-display {
    color: var(--gray-600);
    font-size: 14px;
}

.scroll-container {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
}

/* ===== Panes ===== */
.pane {
    display: none;
    animation: fadeIn 0.3s ease;
}
.pane.active-pane {
    display: block;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cards */
.section-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 25px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--gray-100);
    padding-bottom: 15px;
}

/* Metric Cards */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}
.metric-card {
    background: white;
    padding: 20px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    border-left: 4px solid var(--primary-blue);
}
.metric-card h3 {
    font-size: 13px;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}
.metric-card .metric-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
}
.metric-card.warning { border-left-color: var(--warning-orange); }
.metric-card.success { border-left-color: var(--success-green); }
.metric-card.highlight { border-left-color: var(--primary-blue); background: var(--primary-light); }

/* Data Tables */
.table-responsive {
    overflow-x: auto;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th, .data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}
.data-table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-600);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.data-table tbody tr:hover {
    background: var(--gray-50);
}

/* Status Badges */
.badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    display: inline-block;
}
.badge.status-registered { background: #e0f2fe; color: #0284c7; }
.badge.status-complete-collected { background: #fef08a; color: #ca8a04; }
.badge.status-partial-collected { background: #ffedd5; color: #ea580c; }
.badge.status-readings-generated { background: #ccfbf1; color: #0f766e; }
.badge.status-printed { background: #f3e8ff; color: #7e22ce; }
.badge.status-checked-and-signed { background: #dcfce7; color: #15803d; }
.badge.role-admin { background: #fce4ec; color: #c2185b; }
.badge.role-user { background: #e0f2f1; color: #00796b; }

/* Search Box */
.search-box input {
    width: 300px;
    padding: 8px 15px;
    border-radius: 20px;
    border: 1px solid var(--gray-300);
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-content {
    background: white;
    width: 100%;
    max-width: 400px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}
.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-600);
}
.modal-body {
    padding: 20px;
}
.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ===== Print Styles ===== */
@media print {
    @page {
        size: landscape;
        margin: 10mm;
    }
    .sidebar, .top-header, .no-print, .print-hidden {
        display: none !important;
    }
    .content-area, .scroll-container {
        padding: 0;
        background: white;
        overflow: visible;
    }
    .section-card {
        border: none;
        box-shadow: none;
        padding: 0;
    }
    #report-container {
        display: block !important;
        padding: 0 !important;
    }
    .data-table th, .data-table td {
        font-size: 10px;
        padding: 4px 6px;
    }
}
