:root {
    --primary: #4A6FA5;
    --secondary: #6BBF77;
    --bg-light: #F8F9FA;
    --text-dark: #333333;
    --white: #ffffff;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --glass: rgba(255, 255, 255, 0.8);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.main-content-padding {
    padding-top: 3rem;
    /* Increased spacing */
    padding-bottom: 3rem;
}

/* Navbar */
.navbar {
    background: var(--white);
    padding: 1rem 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-dark);
    font-weight: 500;
    transition: color 0.3s;
}

.nav-links a:hover {
    color: var(--primary);
}

/* Components */
.card {
    background: var(--white);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: #3b5a85;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.2);
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem 0;
    margin-top: 4rem;
    color: #666;
}

/* Glassmorphism effect */
.glass-card {
    background: var(--glass);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ---------- Mobile Responsive Navigation ---------- */
@media (max-width: 768px) {
    .navbar .container {
        flex-wrap: wrap;
        padding-bottom: 0.5rem;
    }

    .nav-toggle {
        display: block !important;
        padding: 0.5rem;
        margin-right: auto;
        border: none;
        background: transparent;
        font-size: 1.5rem;
        cursor: pointer;
    }

    .logo {
        margin-right: auto;
    }

    .nav-links-wrapper {
        width: 100%;
        display: none;
        border-top: 1px solid #eee;
        margin-top: 1rem;
        padding-top: 1rem;
    }

    .nav-links-wrapper.active {
        display: block !important;
    }

    .nav-links {
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
        display: flex;
    }

    .nav-links a {
        display: block;
        padding: 0.75rem 1rem;
        background: #f8fafc;
        border-radius: 8px;
        width: 100%;
    }

    /* Fix Grid Layouts */
    .dashboard-content,
    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    form[action*="patients"],
    form[action*="consultations"],
    form[action*="tests"] {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .header-actions {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .header-actions .btn {
        width: 100%;
        text-align: center;
    }

    /* Fix Responsive Tables */
    .responsive-table {
        display: block;
        width: 100%;
        border: 0;
    }

    .responsive-table thead {
        display: none;
    }

    .responsive-table tbody {
        display: block;
        width: 100%;
    }

    .responsive-table tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        padding: 1rem;
        background: white;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }

    .responsive-table td {
        display: flex;
        flex-direction: column;
        /* Stack vertically */
        align-items: flex-start;
        padding: 0.75rem 0;
        border-bottom: 1px solid #f3f4f6;
        text-align: left;
    }

    .responsive-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #64748b;
        text-align: left;
        margin-bottom: 0.25rem;
        /* Space below label */
        font-size: 0.85rem;
        display: block;
        width: 100%;
    }

    .responsive-table td:last-child {
        border-bottom: 0;
        align-items: flex-end;
        /* Keep actions to the right if desired, or flex-start */
        flex-direction: row;
        /* Actions usually better in a row */
        justify-content: flex-end;
        gap: 10px;
    }

    /* Fix Profile Page */
    .profile-content-grid {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }

    .profile-form-row {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .profile-header-container {
        flex-direction: column !important;
        text-align: center !important;
        gap: 1rem !important;
    }

    /* Fix Patients Filter Form */
    .patients-filter-form {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
        align-items: stretch !important;
    }

    /* Fix Patient Create Page */
    .patient-create-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Fix Patient View Page */
    .patient-view-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem !important;
    }

    .patient-view-header .btn {
        width: 100%;
        text-align: center;
    }

    .patient-view-content {
        grid-template-columns: 1fr !important;
    }

    /* Fix Form Actions (Buttons) */
    .form-actions {
        flex-direction: column !important;
        gap: 1rem !important;
    }

    .form-actions .btn {
        width: 100% !important;
        flex: none !important;
    }

    .date-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* General Form Fixes for Mobile */
    input,
    select,
    textarea {
        font-size: 16px !important;
        /* Prevent zoom on iOS */
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }
}

/* ---------- Print Styles ---------- */
@media print {
    @page {
        margin: 1cm;
        size: auto;
    }

    body {
        margin: 0;
        padding: 0;
        background: white !important;
        color: black !important;
        font-size: 12pt;
    }

    /* Hide Navigation and UI Elements */
    .navbar,
    .footer,
    .btn,
    .no-print,
    .header-actions a,
    .nav-toggle,
    .nav-links-wrapper,
    button {
        display: none !important;
    }

    /* Reset Container and Layout */
    .container,
    .test-results-container,
    .main-content-padding {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
        background: white !important;
    }

    /* Card Resets */
    .card,
    .glass-card,
    .patient-info-box {
        background: white !important;
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        border-radius: 0 !important;
        backdrop-filter: none !important;
        padding: 1rem !important;
        margin-bottom: 1rem !important;
        page-break-inside: avoid;
    }

    /* Typography Overrides */
    h1,
    h2,
    h3,
    h4 {
        color: black !important;
        page-break-after: avoid;
    }

    p,
    label,
    span,
    div {
        color: black !important;
    }

    /* Print Header/Footer specific visibility */
    .print-only {
        display: block !important;
    }

    /* Links */
    a {
        text-decoration: none;
        color: black !important;
    }

    /* Ensure charts/tables break nicely */
    .answer-row {
        page-break-inside: avoid;
        border-bottom: 1px solid #ccc !important;
    }

    /* Interpretation Box */
    .glass-card[style*="border-left"] {
        border-left: 5px solid #000 !important;
    }
}