/* ===== CSS Variables ===== */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #10b981;
    --success-dark: #059669;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --radius-sm: 6px;
}

/* ===== Access Overlay ===== */
.access-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.access-overlay.hidden {
    display: none;
}

.access-modal {
    background: white;
    padding: 2.5rem;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    max-width: 400px;
    width: 90%;
}

.access-modal h2 {
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.access-modal p {
    color: var(--text-light);
    margin-bottom: 1.5rem;
}

.access-modal input {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    text-align: center;
    margin-bottom: 1rem;
}

.access-modal input:focus {
    outline: none;
    border-color: var(--primary);
}

.access-modal .btn {
    width: 100%;
}

.access-error {
    color: var(--danger);
    font-size: 0.9rem;
    margin-top: 1rem;
    min-height: 1.2rem;
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== Header ===== */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.header p {
    opacity: 0.9;
    font-size: 0.95rem;
}

/* ===== Container ===== */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem;
}

/* ===== Grids & Layouts ===== */
.top-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: stretch;
    margin-bottom: 0.5rem;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.testing-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.cert-type-section {
    border-left: 5px solid var(--primary);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

@media (max-width: 900px) {
    .testing-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {

    .top-grid,
    .info-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== Card ===== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-desc {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* ===== Forms ===== */
.form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.form-group {
    flex: 1;
    min-width: 200px;
    margin-bottom: 0.25rem;
}

.form-group.small {
    flex: 0 1 auto;
    min-width: 120px;
}

.form-group.large {
    flex: 2;
}

.form-group label {
    display: block;
    font-weight: 500;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
    color: var(--text);
}

.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:not([type="checkbox"]):not([type="radio"]):focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group input[readonly] {
    background: var(--bg);
    color: var(--text-light);
}

.input-with-button {
    display: flex;
    gap: 0.25rem;
}

.input-with-button input {
    flex: 1;
}

/* ===== Checkbox & Radio Groups ===== */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 400;
    cursor: pointer;
    padding: 0;
    border: none;
    margin-right: 0;
    margin-bottom: 0.25rem;
}

.checkbox-label input[type="checkbox"],
.checkbox-label input[type="radio"] {
    width: auto;
    margin-right: 0.5rem;
    margin-top: 0;
}

.checkbox-label:hover {
    color: var(--primary);
}

.checkbox-label input[type="radio"]:checked+span,
.checkbox-label:has(input:checked) {
    color: var(--primary);
    font-weight: 500;
}

/* ===== Evidence Section ===== */
.evidence-options {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.evidence-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.evidence-item .checkbox-label {
    margin-right: 0.5rem;
    margin-bottom: 0;
}

.evidence-text {
    flex: 1;
    min-width: 200px;
    padding: 0.5rem 0.75rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.evidence-text:focus {
    outline: none;
    border-color: var(--primary);
}

/* ===== Status Messages ===== */
.status-message {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    min-height: 1.2rem;
}

.status-message.success {
    color: var(--success);
}

.status-message.error {
    color: var(--danger);
}

.status-message.info {
    color: var(--primary);
}

/* ===== HN Section ===== */
.hn-section {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 2px solid var(--primary);
}

.hn-section h2 {
    color: var(--primary-dark);
}

/* ===== Vaccine Tables ===== */
.vaccine-table-container {
    overflow-x: auto;
}

.vaccine-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    table-layout: fixed;
}

.vaccine-table th,
.vaccine-table td {
    padding: 0.75rem 0.5rem;
    text-align: center;
    border: 1px solid var(--border);
}

.vaccine-table th {
    background: linear-gradient(135deg, #475569 0%, #334155 100%);
    color: white;
    font-weight: 600;
    white-space: nowrap;
}

.vaccine-table th:first-child {
    width: 250px;
    text-align: left;
    padding-left: 1rem;
}

.vaccine-table th:not(:first-child) {
    width: calc((100% - 250px) / 5);
}

.vaccine-table td:first-child {
    font-weight: 500;
    background: #f8fafc;
    text-align: left;
    padding-left: 1rem;
}

.vaccine-table tbody tr:hover {
    background: #f1f5f9;
}

.date-input {
    width: 100%;
    padding: 0.5rem;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    text-align: center;
}

.date-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.date-input.invalid {
    border-color: var(--danger);
    background: #fef2f2;
}

.covid-brand-select {
    width: 100%;
    padding: 0.4rem;
    font-size: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-top: 4px;
    background: white;
}

.covid-brand-select:focus {
    outline: none;
    border-color: var(--primary);
}

.vaccine-brand-select {
    width: 100%;
    padding: 0.4rem;
    font-size: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-top: 4px;
    background: white;
}

.vaccine-brand-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ===== Add Vaccine Section ===== */
.add-vaccine-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px dashed var(--border);
}

.add-vaccine-section h4 {
    margin-bottom: 1rem;
    color: var(--primary);
}

.add-vaccine-section .form-row {
    align-items: flex-end;
}

.add-vaccine-section .btn {
    margin-bottom: 1rem;
    white-space: nowrap;
}

#customVaccinesContainer {
    margin-top: 1rem;
}

.custom-vaccine-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.75rem;
    background: #f8fafc;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.custom-vaccine-row input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.custom-vaccine-row .vaccine-name {
    min-width: 200px;
    font-weight: 500;
}

.custom-vaccine-row .remove-btn {
    background: var(--danger);
    color: white;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, var(--success-dark) 100%);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.btn-outline {
    background: transparent;
    color: var(--secondary);
    border: 2px solid var(--border);
}

.btn-outline:hover {
    background: var(--bg);
    border-color: var(--secondary);
}

/* ===== Action Buttons ===== */
.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    padding: 1rem 0;
}

.action-buttons .btn {
    min-width: 150px;
}

/* ===== Footer ===== */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
    font-size: 0.9rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.25rem;
    }

    .form-row {
        flex-direction: column;
    }

    .form-group,
    .form-group.small,
    .form-group.large {
        flex: none;
        width: 100%;
        min-width: auto;
    }

    .vaccine-table th:first-child {
        min-width: 180px;
    }

    .action-buttons {
        flex-direction: column;
    }

    .action-buttons .btn {
        width: 100%;
    }

    .checkbox-group {
        flex-direction: column;
    }

    .evidence-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .evidence-item .checkbox-label {
        min-width: auto;
    }
}

/* ===== Mobile Phone Styles ===== */
@media (max-width: 480px) {
    body {
        padding: 0;
        background: #f0f2f5;
    }

    .container {
        padding: 0;
    }

    .header {
        padding: 1rem;
        border-radius: 0;
    }

    .header h1 {
        font-size: 1rem;
    }

    .card {
        padding: 1rem;
        border-radius: 0;
        margin-bottom: 0.5rem;
        box-shadow: none;
        border-bottom: 1px solid var(--border);
    }

    h2 {
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }

    /* Form inputs - consistent sizing */
    input[type="text"],
    input[type="date"],
    select {
        font-size: 16px;
        padding: 0.6rem 0.75rem;
        height: 42px;
        border-radius: 6px;
    }

    /* Buttons - consistent and proportionate */
    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.875rem;
        height: 42px;
        border-radius: 6px;
        font-weight: 600;
    }

    .btn-primary {
        flex: 1;
    }

    .btn-secondary {
        flex: 1;
    }

    /* Action buttons row */
    .action-buttons {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .action-buttons .btn {
        width: 100%;
    }

    /* HN section - clean layout */
    .hn-section {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .hn-section input {
        width: 100%;
    }

    .hn-section .btn-group {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .hn-section .btn {
        width: 100%;
        margin: 0;
    }

    /* Form rows */
    .form-row {
        gap: 0.75rem;
    }

    .form-group {
        margin-bottom: 0.5rem;
    }

    .form-group label {
        font-size: 0.8rem;
        margin-bottom: 0.25rem;
    }

    /* Vaccine table - horizontal scroll */
    .vaccine-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem 0.5rem;
        scrollbar-width: thin;
    }

    .vaccine-table {
        min-width: 550px;
        font-size: 0.75rem;
    }

    .vaccine-table th,
    .vaccine-table td {
        padding: 0.4rem 0.3rem;
    }

    .vaccine-table th:first-child {
        min-width: 120px;
        position: sticky;
        left: 0;
        background: #4a5568;
        z-index: 2;
        box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
    }

    .vaccine-table td:first-child {
        position: sticky;
        left: 0;
        background: white;
        z-index: 1;
        box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
    }

    .date-input {
        font-size: 14px;
        padding: 0.5rem;
        min-width: 95px;
        height: 38px;
        border-radius: 6px;
        text-align: center;
    }

    .vaccine-brand-select,
    .covid-brand-select {
        font-size: 12px;
        padding: 0.4rem;
        height: 32px;
        border-radius: 4px;
    }

    /* Checkbox styling */
    .checkbox-group {
        gap: 0.5rem;
    }

    .checkbox-label {
        padding: 0.5rem 0;
        font-size: 0.85rem;
    }

    .checkbox-label input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }

    /* Evidence items */
    .evidence-item {
        padding: 0.5rem 0;
    }

    /* Title select - compact */
    .title-select {
        display: flex;
        flex-wrap: nowrap;
        gap: 0.15rem;
        justify-content: flex-start;
    }

    .title-select label {
        padding: 0.35rem 0.6rem;
        font-size: 0.75rem;
        border-radius: 4px;
    }

    /* Access modal */
    .access-modal {
        padding: 1.5rem;
        width: 90%;
        max-width: 320px;
    }

    .access-modal h2 {
        font-size: 1.25rem;
    }

    .access-modal input {
        height: 48px;
        font-size: 16px;
    }

    .access-modal .btn {
        height: 48px;
        font-size: 1rem;
    }

    /* Section descriptions */
    .section-desc {
        font-size: 0.8rem;
        margin-bottom: 0.75rem;
    }

    /* Add vaccine section */
    .add-vaccine-section {
        padding-top: 1rem;
        border-top: 1px solid var(--border);
    }

    .add-vaccine-section h4 {
        font-size: 0.9rem;
    }
}

/* ===== TB Testing Section ===== */
.tb-group {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px dashed var(--border);
}

.tb-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.tb-group h3 {
    font-size: 1rem;
    color: var(--secondary);
    margin-bottom: 0.75rem;
}

/* ===== Print Styles ===== */
@media print {
    body {
        background: white;
    }

    .header,
    .action-buttons,
    .hn-section,
    footer {
        display: none !important;
    }

    .card {
        box-shadow: none;
        border: none;
        page-break-inside: avoid;
    }
}