/* ==========================================================================
   1. GLOBAL VARIABLES & RESET
   ========================================================================== */
:root {
    --primary: #DC143C;       /* Lemon Green */
    --primary-dark: #FF2400;
    --primary-light: #FA8072;
    --text-main: black;
    --text-muted: #7f8c8d;
    --bg-body: #f4f7f6;
    --bg-card: #ffffff;
    --border: #e0e0e0;
    --danger: #e53935;
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
}

body { 
    font-family: 'Inter', sans-serif; 
    background: var(--bg-body); 
    color: var(--text-main); 
    line-height: 1.6; 
}

a { 
    text-decoration: none; 
    color: var(--primary-dark); 
}

/* ==========================================================================
   2. LAYOUT & NAVBAR
   ========================================================================== */
.navbar { 
    background: var(--bg-card); 
    padding: 15px 30px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    box-shadow: 0 2px 10px rgba(0,0,0,0.05); 
    border-bottom: 3px solid var(--primary); 
}

.nav-brand { 
    display: flex; 
    align-items: center; 
    gap: 15px; 
}

.nav-logo { 
    height: 40px; 
    width: auto; 
    object-fit: contain; 
}

.nav-brand h1 { 
    font-size: 20px; 
    color: var(--primary-dark); 
    text-transform: uppercase; 
}

.nav-links { 
    display: flex; 
    gap: 20px; 
    align-items: center; 
    font-weight: 600; 
}

.container { 
    max-width: 1100px; 
    margin: 40px auto; 
    padding: 0 20px; 
}

.dashboard-header { 
    margin-bottom: 30px; 
}

.dashboard-header h2 { 
    color: var(--primary-dark); 
    margin-bottom: 5px; 
}

.mb-4 { margin-bottom: 1.5rem; }
.mt-4 { margin-top: 1.5rem; }
.text-center { text-align: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* ==========================================================================
   3. COMPONENTS: CARDS, FORMS, BUTTONS
   ========================================================================== */
.card { 
    background: var(--bg-card); 
    border-radius: 8px; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.03); 
    overflow: hidden; 
    border: 1px solid var(--border); 
    margin-bottom: 20px;
}

.card-header { 
    background: var(--primary-light); 
    padding: 15px 20px; 
    border-bottom: 1px solid var(--border); 
}

.card-header h3 { 
    color: var(--primary-dark); 
    font-size: 18px; 
}

.card-body { 
    padding: 20px; 
}

/* Forms */
.grid-form { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 20px; 
}

.form-group { 
    display: flex; 
    flex-direction: column; 
}

.form-group label { 
    font-size: 14px; 
    font-weight: 600; 
    margin-bottom: 8px; 
    color: var(--text-main); 
}

input, select, textarea { 
    width: 100%; 
    padding: 12px; 
    border: 1px solid var(--border); 
    border-radius: 6px; 
    font-family: inherit; 
    font-size: 15px; 
    transition: all 0.3s; 
}

input:focus, select:focus, textarea:focus { 
    border-color: var(--primary); 
    outline: none; 
    box-shadow: 0 0 0 3px rgba(139, 195, 74, 0.2); 
}

.form-actions { 
    justify-content: flex-end; 
    display: flex; 
}

/* Buttons */
.btn { 
    padding: 10px 20px; 
    border-radius: 6px; 
    border: none; 
    cursor: pointer; 
    font-weight: 600; 
    font-size: 14px; 
    transition: 0.3s; 
    display: inline-block; 
    text-align: center; 
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #c62828; }
.btn-secondary { background: #95a5a6; color: white; }
.btn-secondary:hover { background: #7f8c8d; }
.btn-success { background: #2e7d32; color: white; }
.btn-block { width: 100%; padding: 12px; font-size: 16px; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-outline { border: 1px solid var(--primary); color: var(--primary-dark); background: transparent; }
.btn-outline:hover { background: var(--primary-light); }

/* Tables */
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 20px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: #fafafa; font-weight: 600; color: var(--text-muted); font-size: 13px; text-transform: uppercase; }
.badge { padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.badge-success { background: var(--primary-light); color: var(--primary-dark); }
.badge-outline { border: 1px solid #999; color: #666; background: transparent; }
.action-buttons { display: flex; gap: 5px; }

/* Alerts */
.alert { padding: 15px; border-radius: 6px; margin-bottom: 20px; font-weight: 500; }
.alert-error { background: #ffebee; color: var(--danger); border: 1px solid #ffcdd2; }
.alert-success { background: var(--primary-light); color: var(--primary-dark); border: 1px solid var(--primary); }

/* Pagination */
.pagination { display: flex; justify-content: center; gap: 5px; padding: 20px; background: #fff; border-top: 1px solid var(--border); }
.page-link { padding: 8px 14px; border: 1px solid var(--border); border-radius: 4px; color: var(--text-main); text-decoration: none; font-weight: 600; font-size: 14px; transition: 0.2s; }
.page-link:hover { background: var(--primary-light); border-color: var(--primary); }
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ==========================================================================
   4. PAGES: VERIFICATION
   ========================================================================== */
.verify-body { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: #f8f9fa; }
.verify-card { background: white; padding: 50px; border-radius: 16px; box-shadow: 0 15px 35px rgba(0,0,0,0.05); width: 100%; max-width: 450px; text-align: center; border-top: 6px solid var(--primary); }
.verify-icon { width: 80px; height: 80px; border-radius: 50%; display: flex; justify-content: center; align-items: center; margin: 0 auto 20px; }
.verify-icon.success { background: var(--primary); }
.verify-icon.danger { background: var(--danger); }
.verify-icon svg { fill: white; width: 40px; height: 40px; }
.verify-card h2 { color: var(--text-main); margin-bottom: 10px; }
.verify-subtext { color: var(--text-muted); font-size: 14px; margin-bottom: 30px; }
.verify-details { text-align: left; background: #fafafa; padding: 25px; border-radius: 10px; }
.v-row { display: flex; justify-content: space-between; margin-bottom: 15px; font-size: 15px; }
.v-row span { color: var(--text-muted); }
.v-row strong { color: var(--text-main); text-align: right; }
.align-center { align-items: center; }
.status-pill { background: var(--primary); color: white; padding: 5px 15px; border-radius: 20px; font-weight: 600; font-size: 13px; }

/* ==========================================================================
   5. A4 CERTIFICATE DESIGN (FULL PAGE CLASSIC)
   ========================================================================== */
.print-body { 
    background: #555; 
    padding: 20px; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
}
.no-print { display: flex; gap: 10px; margin-bottom: 20px; }

/* A4 Canvas Setup */
.a4-canvas { 
    width: 210mm; 
    height: 297mm; 
    background: #fff; 
    position: relative; 
    box-shadow: 0 0 20px rgba(0,0,0,0.5); 
    padding: 10mm;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Faint Background Watermark */
.cert-bg-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    height: 400px;
    color: rgba(200, 200, 200, 0.15); 
    z-index: 0;
    pointer-events: none;
}

/* The Borders */
.cert-outer-border {
    border: 4px solid; /* Color is dynamically injected via inline style in PHP */
    padding: 4px;
    height: 100%;
    width: 100%;
    position: relative;
    z-index: 1;
}
.cert-inner-border {
    border: 2px solid #000; 
    height: 100%;
    width: 100%;
    padding: 20px;
}

.cert-content-wrapper {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between; 
}

/* Typography & Layout */
.cert-header { text-align: center; padding-top: 10px; }
.cert-logo { max-height: 70px; margin-bottom: 15px; object-fit: contain; }
.cert-hosp-name { 
    font-family: 'Arial Black', Impact, sans-serif; 
    font-size: 32px; 
    color: #1a3c1a; 
    text-transform: uppercase; 
    margin-bottom: 10px; 
    letter-spacing: 1px;
}
.cert-hosp-address { font-size: 14px; color: #333; font-weight: 700; margin-bottom: 5px; line-height: 1.4; }
.cert-hosp-contact { font-size: 14px; color: #cc0000; font-weight: 700; }

.cert-dept-title {
    text-align: center;
    font-size: 18px;
    font-weight: 900;
    color: #000;
    margin-top: 15px;
    margin-bottom: 20px;
    line-height: 1.3;
}

/* Test Badge */
.cert-title-box { text-align: center; margin-bottom: 30px; }
.cert-title-box h2 { 
    color: #fff; 
    display: inline-block; 
    padding: 10px 50px; 
    border-radius: 30px; 
    font-size: 26px; 
    font-family: 'Arial Black', sans-serif;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

/* Body */
.cert-body { text-align: center; flex-grow: 1; display: flex; flex-direction: column; justify-content: center; }

/* Centralised Bold Name */
.cert-patient-name-central {
    font-size: 32px;
    font-weight: 900;
    text-transform: uppercase;
    color: #000;
    margin-bottom: 25px;
    letter-spacing: 1.5px;
}

.cert-text { font-size: 18px; margin-bottom: 15px; color: #000; font-weight: 700; }
.cert-test-name { font-size: 18px; color: #000; margin-bottom: 20px; text-transform: uppercase; font-weight: 800; }

/* Result Text */
.cert-result {
    font-size: 26px;
    font-weight: 900;
    margin-bottom: 30px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Date Section */
.cert-on-date { margin-top: 20px; }
.cert-on-text { font-size: 20px; font-weight: 900; color: #000; margin-bottom: 10px; }
.cert-date-display {
    font-size: 20px;
    font-weight: 700;
    color: #000;
    margin-bottom: 5px;
    font-family: 'Courier New', Courier, monospace;
}
.cert-date-line { 
    width: 300px; 
    border-bottom: 2px solid #000; 
    margin: 0 auto 5px;
    height: 2px;
}
.cert-date-sub { font-size: 18px; font-weight: 800; font-style: italic; }

/* Footer Section */
.cert-footer { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 30px; padding: 0 10px; }
.cert-qr { text-align: center; }
.cert-qr img { width: 90px; height: 90px; }
.cert-qr p { font-size: 11px; color: #000; margin-top: 5px; font-weight: 800; }

.cert-signature { text-align: center; width: 320px; }
.sig-doctor-name { font-size: 20px; font-weight: 900; color: #000; margin-bottom: 5px; text-transform: uppercase; }
.sig-dots { font-size: 14px; letter-spacing: 1px; color: #000; margin-bottom: 5px; overflow: hidden; white-space: nowrap; }
.sig-title { font-size: 16px; color: #000; font-style: italic; font-weight: 700; }

/* Expiry */
.cert-expiry {
    margin-top: 30px;
    font-size: 16px;
    font-weight: 900;
    text-align: left;
    color: #000;
    text-transform: uppercase;
}
.expiry-data {
    border-bottom: 2px solid #000;
    display: inline-block;
    padding: 0 10px;
    font-family: 'Courier New', Courier, monospace;
    text-transform: none; 
    font-size: 18px;
}

.cert-meta {
    position: absolute;
    bottom: 5px;
    right: 15px;
    font-size: 10px;
    color: #777;
    font-weight: bold;
}

/* ==========================================================================
   6. RESPONSIVE ADJUSTMENTS & PRINT OVERRIDES
   ========================================================================== */
@media (max-width: 768px) {
    .grid-form { grid-template-columns: 1fr; }
    .form-actions { justify-content: stretch; }
    .form-actions button { width: 100%; }
    .navbar { flex-direction: column; gap: 15px; text-align: center; }
    .nav-links { flex-wrap: wrap; justify-content: center; }
    .flex-between { flex-direction: column; gap: 10px; align-items: flex-start; }
}

/* Print overrides - Hides web UI and formats perfectly for A4 paper */
@media print {
    @page { size: A4; margin: 0; }
    body { background: white; padding: 0; margin: 0; }
    .no-print { display: none !important; }
    .a4-canvas { box-shadow: none; margin: 0; width: 100%; height: 100%; border: none; padding: 0; }
}

/* ==========================================================================
   7. MODERN LOGIN PAGE (Split Screen Design with Doctor Image)
   ========================================================================== */
.login-body-modern {
    display: flex;
    min-height: 100vh;
    font-family: 'Inter', sans-serif;
    background: #ffffff;
    margin: 0;
}

/* Left Side - Doctor Image Background */
.login-left-image {
    flex: 1;
    /* Change the URL below to your actual doctor image (e.g., assets/uploads/doctor-bg.jpg) */
    background-image: url('https://images.unsplash.com/photo-1559839734-2b71ea197ec2?q=80&w=2070&auto=format&fit=crop');
    background-size: cover;
    background-position: center;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Dark Green Gradient Overlay for Readability */
.login-left-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(85, 139, 47, 0.85) 0%, rgba(26, 60, 26, 0.95) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    text-align: center;
}

.login-left-content {
    position: relative;
    z-index: 2;
    max-width: 400px;
    color: white;
}

.login-left h1 {
    font-size: 36px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: 1px;
    margin-bottom: 10px;
    text-transform: uppercase;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.login-left p {
    font-size: 18px;
    font-weight: 400;
    opacity: 0.9;
    margin-bottom: 40px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.login-features {
    display: flex;
    flex-direction: column;
    gap: 15px;
    font-size: 16px;
    font-weight: 500;
    text-align: left;
    background: rgba(255, 255, 255, 0.1);
    padding: 25px;
    border-radius: 12px;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.2);
}

/* Right Side - Form */
.login-right {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    background: #f8fafc;
}

.login-card-modern {
    background: #ffffff;
    width: 100%;
    max-width: 420px;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.04);
    border: 1px solid #eaeaea;
}

.login-header h2 {
    font-size: 28px;
    color: #1a202c;
    font-weight: 800;
    margin-bottom: 5px;
}

.login-header p {
    color: #718096;
    font-size: 15px;
    margin-bottom: 30px;
}

/* Modern Inputs */
.modern-input-group {
    margin-bottom: 20px;
}

.modern-input-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 8px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 15px;
    width: 20px;
    height: 20px;
    color: #a0aec0;
    pointer-events: none;
}

.modern-input-group input {
    width: 100%;
    padding: 14px 14px 14px 45px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 15px;
    background: #f8fafc;
    transition: all 0.2s ease;
}

.modern-input-group input:focus {
    background: #ffffff;
    border-color: #DC143C;
    box-shadow: 0 0 0 3px rgba(139, 195, 74, 0.15);
    outline: none;
}

/* Modern Button */
.btn-modern-login {
    width: 100%;
    padding: 15px;
    background: #DC143C;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.btn-modern-login:hover {
    background: #558b2f;
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(85, 139, 47, 0.2);
}

.btn-modern-login svg {
    transition: transform 0.3s ease;
}

.btn-modern-login:hover svg {
    transform: translateX(5px);
}

.login-footer-modern {
    text-align: center;
    margin-top: 30px;
    color: #a0aec0;
    font-size: 13px;
    border-top: 1px solid #eaeaea;
    padding-top: 20px;
}

/* Responsive */
@media (max-width: 900px) {
    .login-body-modern {
        flex-direction: column;
    }
    .login-left-image {
        padding: 60px 20px;
        flex: none;
        min-height: 350px;
    }
    .login-left h1 { font-size: 28px; }
    .login-right {
        padding: 20px;
        flex: none;
    }
    .login-card-modern {
        padding: 30px;
    }
}

/* ==========================================================================
   8. MODERN DATA TABLE (Dashboard)
   ========================================================================== */
.text-right { text-align: right !important; }
.record-count { color: var(--text-muted); font-size: 15px; font-weight: 500; }

.modern-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
}

.modern-table thead {
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
}

.modern-table th {
    padding: 16px 20px;
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
}

.modern-table td {
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    color: #334155;
    transition: background 0.2s ease;
}

.modern-table tbody tr:hover td {
    background: #f8fafc;
}

/* Styling specific elements inside the table */
.cert-code {
    background: #e2e8f0;
    color: #475569;
    padding: 4px 10px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    font-weight: 600;
}

.test-type-text {
    font-weight: 500;
    color: #475569;
}

/* Modern Badges */
.modern-table .badge {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.3px;
    background: #dcfce7;
    color: #166534;
}

/* Modern Action Buttons */
.modern-table .action-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.modern-table .action-buttons .btn {
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 13px;
}

.empty-state {
    padding: 40px !important;
    color: #94a3b8 !important;
    font-style: italic;
}

/* ==========================================================================
   9. RESPONSIVE TABLE (Transforms to Cards on Mobile)
   ========================================================================== */
@media (max-width: 768px) {
    .modern-table thead {
        display: none; /* Hide headers on mobile */
    }
    
    .modern-table, .modern-table tbody, .modern-table tr, .modern-table td {
        display: block;
        width: 100%;
    }
    
    .modern-table tr {
        margin-bottom: 15px;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.02);
        overflow: hidden;
    }
    
    .modern-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 16px;
        border-bottom: 1px solid #f1f5f9;
        text-align: right;
    }
    
    .modern-table td:last-child {
        border-bottom: none;
        background: #f8fafc;
    }
    
    /* Create labels for mobile cards */
    .modern-table td::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: #64748b;
        text-align: left;
        margin-right: 15px;
    }
    
    /* Reset text alignment for mobile */
    .modern-table td.text-right {
        text-align: right;
    }
    
    .modern-table .action-buttons {
        width: 100%;
        justify-content: flex-end;
    }
}


/* ==========================================================================
   10. DASHBOARD HEADER ACTIONS & SEARCH BAR
   ========================================================================== */
.header-wrap {
    flex-wrap: wrap;
    gap: 15px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.ml-2 { margin-left: 10px; }

/* Search Form */
.search-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 12px;
    width: 18px;
    height: 18px;
    color: #94a3b8;
    pointer-events: none;
}

.search-input-wrapper input {
    padding: 8px 35px 8px 38px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    font-size: 14px;
    width: 240px;
    background: #fff;
    transition: all 0.2s ease;
}

.search-input-wrapper input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 195, 74, 0.15);
    outline: none;
    width: 280px; /* Slight expansion on focus */
}

/* Clear (X) Button inside search */
.clear-search {
    position: absolute;
    right: 12px;
    color: #94a3b8;
    font-size: 18px;
    line-height: 1;
    transition: color 0.2s;
}

.clear-search:hover {
    color: var(--danger);
}

/* Responsive adjustments for the header */
@media (max-width: 768px) {
    .header-wrap {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .header-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-form {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-input-wrapper input {
        width: 100%;
    }
    
    .search-input-wrapper input:focus {
        width: 100%;
    }

    .ml-2 {
        margin-left: 0;
        margin-top: 5px;
    }
}