:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --accent-color: #0d9488;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --success-bg: #dcfce7;
    --success-color: #15803d;
    --danger-bg: #fee2e2;
    --danger-color: #b91c1c;
    --warning-bg: #fef3c7;
    --warning-color: #b45309;
    --radius: 6px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==========================================
   STRICT UNIFORM ALIGNED WRAPPERS (88% WIDTH)
   ========================================== */
.container,
.navbar-wrapper,
.footer-wrapper {
    width: 88%;
    max-width: 1600px;
    margin: 0 auto;
    box-sizing: border-box;
}

/* Navbar Outer Layout */
.navbar {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 0.5rem 0;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.03);
    width: 100%;
}

.navbar-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    max-width: 1600px;
}

.navbar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.nav-links {
    display: flex;
    gap: 1.25rem;
    list-style: none;
    align-items: center;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.nav-links a {
    text-decoration: none;
    color: #000000;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: #000000;
}

/* Container & Cards */
.container {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    flex: 1;
    padding: 0;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    box-shadow: var(--shadow);
    border-radius: 4px;
    width: 100%;
}

.card-title {
    font-size: 1.00rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

/* Forms & Inputs */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
}

.required {
    color: var(--danger-color);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="tel"],
select,
textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.95rem;
    background-color: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* ==========================================
   BUTTON SYSTEM
   ========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.45rem 0.9rem;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.25;
    border-radius: 3px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
    color: #ffffff; /* Base text color for all buttons */
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.btn:hover {
    color: #000000; /* Font color turns black on hover */
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.btn:disabled, .btn.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
    box-shadow: none;
}

/* Color Variants */
.btn-primary {
    background-color: #ff8000;
    color: #ffffff;
    border-color: #2563eb;
}
.btn-primary:hover {
    background-color: #ffb266;
    color: #000000;
    border-color: #9999ff;
}

.btn-secondary {
    background-color: #ff8000;
    color: #ffffff;
    border-color: #64748b;
}
.btn-secondary:hover {
    background-color: #ffb266;
    color: #000000;
    border-color: #475569;
}

.btn-success {
    background-color: #ff8000;
    color: #ffffff;
    border-color: #16a34a;
}
.btn-success:hover {
    background-color: #ffb266;
    color: #000000;
    border-color: #15803d;
}

.btn-danger {
    background-color: #dc2626;
    color: #ffffff;
    border-color: #dc2626;
}
.btn-danger:hover {
    background-color: #b91c1c;
    color: #000000;
    border-color: #b91c1c;
}

.btn-warning {
    background-color: #d97706;
    color: #ffffff;
    border-color: #d97706;
}
.btn-warning:hover {
    background-color: #b45309;
    color: #000000;
    border-color: #b45309;
}

/* Outline Variants */
.btn-outline-primary {
    background-color: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
}
.btn-outline-primary:hover {
    background-color: #1d4ed8;
    color: #000000;
}

.btn-outline-danger {
    background-color: #dc2626;
    color: #ffffff;
    border-color: #dc2626;
}
.btn-outline-danger:hover {
    background-color: #b91c1c;
    color: #000000;
}

/* Sizing Utilities */
.btn-sm {
    padding: 0.45rem 0.9rem;
    font-size: 0.75rem;
    border-radius: 2px;
}

.btn-lg {
    padding: 0.65rem 1.25rem;
    font-size: 1rem;
    border-radius: 4px;
}

.btn-block {
    display: flex;
    width: 100%;
}

/* Alerts */
.alert {
    border-radius: 4px;
    font-size: 0.9rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.alert-danger {
    background-color: var(--danger-bg);
    color: var(--danger-color);
}

.alert-success {
    background-color: var(--success-bg);
    color: var(--success-color);
}

/* Data Tables */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    background: #f1f5f9;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.925rem;
}

tr:last-child td {
    border-bottom: none;
}

/* Footer Layout */
footer {
    background: #fff;
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: auto;
    width: 100%;
}

.footer-wrapper {
    text-align: center;
}

/* Dashboard UI */
.dashboard-tabs { 
    display: flex; gap: 0.5rem; margin-bottom: 1rem; border-bottom: 2px solid #e2e8f0; 
}

.tab-btn { 
    padding: 0.5rem 1.25rem; 
    font-weight: 600; 
    text-decoration: none; 
    color: #64748b; 
    border-bottom: 3px solid transparent; 
}

.tab-btn.active { 
    color: #2563eb; 
    border-bottom-color: #2563eb; 
}

.filter-bar { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 1.25rem; 
    background: #f8fafc; 
    padding: 0.75rem 1rem;  
    border: 1px solid #e2e8f0; 
}

.badge-status { 
    padding: 0.25rem 0.6rem; 
    font-size: 0.8rem; 
    font-weight: 600; 
    border-radius: 4px; 
    display: inline-block; 
}

/* ==========================================
   CONSULTATION FORM LAYOUT (2-COLUMN GRID)
   ========================================== */
.consultation-grid-2col {
    display: flex;
    flex-direction: column;
    gap: 1.0rem;
    width: 100%;
}

@media (min-width: 992px) {
    .consultation-grid-2col {
        display: flex;
        flex-direction: row;
        align-items: stretch;
    }

    .consultation-col-left {
        width: 320px;
        min-width: 320px;
        display: flex;
        flex-direction: column;
        gap: 1.0rem;
    }

    .consultation-col-right {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 1.0rem;
    }

    .consultation-col-left .card-stretch,
    .consultation-col-right .card-stretch {
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    .consultation-col-left .card-stretch .form-group-fill,
    .consultation-col-right .card-stretch .form-group-fill {
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    .consultation-col-left .card-stretch textarea,
    .consultation-col-right .card-stretch textarea {
        flex: 1;
        min-height: 80px;
        resize: vertical;
    }
}

@media (max-width: 991px) {
    .consultation-grid-2col,
    .consultation-col-left,
    .consultation-col-right {
        width: 100% !important;
        min-width: 100% !important;
        box-sizing: border-box;
    }
    
    .consultation-col-left,
    .consultation-col-right {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
    }
}

.vitals-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.vitals-grid .form-group {
    margin-bottom: 0;
}

.vitals-grid label {
    font-size: 0.75rem;
    margin-bottom: 0.15rem;
    white-space: nowrap;
}

.vitals-grid input, 
.vitals-grid select {
    padding: 0.25rem 0.4rem;
    font-size: 0.8125rem;
    height: 32px;
}

/* Dynamic Autocomplete Dropdown */
.autocomplete-dropdown, #lab-autocomplete-dropdown {
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border-color, #cbd5e1);
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 9999 !important;
}

.autocomplete-dropdown div, #lab-autocomplete-dropdown div {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    color: var(--text-main, #0f172a);
}

.autocomplete-dropdown div:last-child, #lab-autocomplete-dropdown div:last-child {
    border-bottom: none;
}

.autocomplete-dropdown div:hover, #lab-autocomplete-dropdown div:hover {
    background-color: var(--bg-main, #f8fafc);
    color: var(--primary-color, #0284c7);
}

/* Global Modal Overlay */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 99999;
    justify-content: center;
    align-items: center;
}

.modal-card {
    width: 100%;
    max-width: 620px;
    margin: 0 1rem;
    padding: 1.5rem;
}

/* ==========================================
   SETTINGS GRID (CLINIC MANAGEMENT)
   ========================================== */
.settings-grid-2col {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    margin-top: 1.5rem;
}

@media (min-width: 992px) {
    .settings-grid-2col {
        flex-direction: row;
        align-items: stretch;
    }

    .settings-col-left {
        flex: 1;
        max-width: 500px;
        display: flex;
        flex-direction: column;
    }

    .settings-col-right {
        flex: 1;
        display: flex;
        flex-direction: column;
    }
}

@media (max-width: 991px) {
    .settings-grid-2col,
    .settings-col-left,
    .settings-col-right {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }
}

.card-stretch {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    margin-bottom: 0 !important;
}

.image-preview-box {
    background-color: var(--bg-main, #f8fafc);
    border: 1px dashed var(--border-color, #e2e8f0);
    border-radius: 4px;
    padding: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
    max-height: 100px;
}

.image-preview-box img {
    max-width: 100%;
    max-height: 80px;
    object-fit: contain;
}

.custom-file-input {
    width: 100%;
    padding: 0.5rem;
    font-size: 0.875rem;
    border: 1px solid var(--border-color, #cbd5e1);
    border-radius: 3px;
    background-color: var(--bg-card, #ffffff);
    cursor: pointer;
}

/* ==========================================
   PATIENT HISTORY - CARD WORKSPACE
   ========================================== */
.history-header-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.history-patient-profile {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.history-patient-item {
    display: flex;
    flex-direction: column;
}

.history-patient-item label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.15rem;
}

.history-patient-item span {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
}

/* Visit Cards Stack */
.visit-card-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.visit-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.visit-card:hover {
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.07), 0 4px 6px -4px rgb(0 0 0 / 0.07);
}

.visit-card-header {
    background: #f8fafc;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.visit-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.visit-date {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.visit-doctor {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: #e2e8f0;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-weight: 500;
}

.visit-card-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Section Cards Inside Card Body */
.visit-vitals-card {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.85rem 1rem;
}

.vitals-pills-container {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.vital-badge-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.875rem;
    color: var(--text-main);
}

.vital-badge-item strong {
    color: var(--primary-color);
}

.visit-section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.clinical-info-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1rem;
}

.clinical-info-card h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.clinical-info-card p {
    font-size: 0.9rem;
    color: var(--text-main);
    margin: 0;
    line-height: 1.4;
}

/* Rx Table Inside Card */
.rx-card-table {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    border-collapse: separate;
    border-spacing: 0;
}

.rx-card-table th {
    background: #f1f5f9;
    font-size: 0.75rem;
    padding: 0.6rem 0.85rem;
}

.rx-card-table td {
    padding: 0.65rem 0.85rem;
    font-size: 0.875rem;
}

/* Print Prescription Styles */
.meta-grid { 
    display: grid; 
    grid-template-columns: repeat(4, 1fr); 
    gap: 10px; 
    background: #f8fafc; 
    padding: 12px; 
    border-radius: 3px; 
    margin-bottom: 20px; 
    font-size: 13px; 
}

.meta-item label { 
    font-size: 11px; 
    text-transform: uppercase; 
    color: #64748b; 
    font-weight: bold; 
    display: block; 
}

.rx-section { 
    margin-bottom: 20px; 
}

.rx-title { 
    font-size: 16px; 
    font-weight: bold; 
    color: #0284c7; 
    border-bottom: 1px solid #e2e8f0; 
    padding-bottom: 5px; 
    margin-bottom: 10px; 
}

.med-table { 
    width: 100%; 
    border-collapse: collapse; 
    margin-bottom: 15px; 
}

.med-table th, .med-table td { 
    text-align: left; 
    padding: 8px; 
    border-bottom: 1px solid #e2e8f0; 
    font-size: 13px; 
}

.med-table th { 
    background: #f1f5f9; 
    text-transform: uppercase; 
    font-size: 11px; 
    color: #475569; 
}

/* Mobile Responsiveness */
@media screen and (max-width: 768px) {
    .container,
    .navbar-wrapper,
    .footer-wrapper {
        width: 94%;
    }
    
    .navbar-wrapper {
        flex-direction: column;
        gap: 0.75rem;
    }

    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }

    .history-header-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .history-patient-profile {
        gap: 1rem;
    }
}

/* Print Utilities */
@media print {
    @page {
        margin: 10mm;
    }
    body { margin: 0; }
    .no-print { display: none; }
    .prescription-wrapper { width: 100%; padding: 0; }
}

.prescription-wrapper { 
    width: 100%; 
    max-width: 800px; 
    margin: 0 auto; 
    box-sizing: border-box; 
}

.header-container { 
    width: 100%; 
    max-height: 120px; 
    overflow: hidden; 
    margin-bottom: 15px; 
    border-bottom: 2px solid #0284c7; 
}

.header-img { 
    width: 100%; 
    max-height: 120px; 
    object-fit: contain; 
    display: block; 
}

.footer-container { 
    width: 100%; 
    max-height: 100px; 
    overflow: hidden; 
    margin-top: 30px; 
    border-top: 1px solid #cbd5e1; 
}

.footer-img { 
    width: 100%; 
    max-height: 100px; 
    object-fit: contain; 
    display: block; 
}