/* ============================================================
   BMZ: Primary Eye Care Referral & Aggregation System
   Application CSS — LEH Portal Design Language System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary-color:   #0d9488; /* Medical Teal 600 */
    --primary-dark:    #0f766e; /* Teal 700 */
    --secondary-color: #0284c7; /* Sky 600 */
    --bg-color:        #f8fafc; /* Slate 50 */
    --sidebar-bg:      #1e293b; /* Slate 800 */
    --sidebar-width:   260px;
    --header-height:   64px;

    /* Semantic Status Tokens */
    --c-amber:         #d97706;
    --c-amber-bg:      #fffbeb;
    --c-amber-border:  #fde68a;
    --c-green:         #15803d;
    --c-green-bg:      #f0fdf4;
    --c-green-border:  #bbf7d0;
    --c-rose:          #be123c;
    --c-rose-bg:       #fff1f2;
    --c-rose-border:   #fecdd3;
    --c-blue:          #1d4ed8;
    --c-blue-bg:       #eff6ff;
    --c-blue-border:   #bfdbfe;
    --c-purple:        #7e22ce;
    --c-purple-bg:     #faf5ff;
    --c-purple-border: #e9d5ff;

    --radius-sm:       0.5rem;
    --radius-md:       0.75rem;
    --radius-lg:       1rem;
    --radius-xl:       1.25rem;
    --transition:      200ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Reset & Baseline ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: #0f172a;
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
}

/* ── Typography & Tabular Numbers ────────────────────────────── */
.font-mono, .mono {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

/* ── Micro-Animations ────────────────────────────────────────── */
@keyframes slideFadeUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.view-section {
    animation: slideFadeUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ── Sidebar Component ────────────────────────────────────────── */
#sidebar {
    width: var(--sidebar-width);
}

#sidebar.open {
    transform: translateX(0) !important;
}

#sidebar-overlay.open {
    display: block !important;
}

.nav-section-label {
    padding: 0.75rem 0.75rem 0.35rem 0.75rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.625rem 0.875rem;
    margin-bottom: 0.25rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    font-weight: 500;
    font-size: 0.875rem;
    color: #94a3b8;
    background: transparent;
    border: none;
    text-align: left;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.06);
    color: #f1f5f9;
}

.nav-item.active {
    background-color: var(--primary-color);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 4px 12px -1px rgba(13, 148, 136, 0.35);
}

.nav-item i {
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* ── Cards & Containers ──────────────────────────────────────── */
.card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04);
    overflow: hidden;
    transition: box-shadow var(--transition), border-color var(--transition);
}

.card:hover {
    box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.06);
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #ffffff;
}

.card-header h2, .card-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.card-header h2 i, .card-header h3 i {
    font-size: 1.2rem;
    color: var(--primary-color);
}

.card-body {
    padding: 1.25rem;
}

/* ── KPI Stat Cards ──────────────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    border: 1px solid #e2e8f0;
    padding: 1.25rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04);
    transition: transform var(--transition), box-shadow var(--transition);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.08);
}

.stat-card-icon {
    height: 2.75rem;
    width: 2.75rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
}

.stat-card-val {
    font-size: 1.875rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.stat-card-lbl {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-top: 0.35rem;
}

.stat-card-desc {
    font-size: 0.72rem;
    color: #94a3b8;
    margin-top: 0.25rem;
}

/* ── Modern Tables ───────────────────────────────────────────── */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid #e2e8f0;
    background: #ffffff;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    text-align: left;
}

.table thead th {
    background-color: #f8fafc;
    padding: 0.75rem 1rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}

.table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    vertical-align: middle;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover td {
    background-color: rgba(248, 250, 252, 0.8);
}

/* ── Form Controls & Inputs ──────────────────────────────────── */
.form-group {
    margin-bottom: 0.875rem;
}

.form-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 0.35rem;
}

.form-control {
    width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid #cbd5e1;
    background-color: #f8fafc;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #0f172a;
    transition: all var(--transition);
}

.form-control:focus {
    background-color: #ffffff;
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.55rem 0.95rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary-color);
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(13, 148, 136, 0.2);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(13, 148, 136, 0.25);
}

.btn-ghost {
    background-color: #f1f5f9;
    color: #334155;
    border-color: #e2e8f0;
}

.btn-ghost:hover {
    background-color: #e2e8f0;
    color: #0f172a;
}

.btn-sm {
    padding: 0.38rem 0.65rem;
    font-size: 0.78rem;
    border-radius: var(--radius-sm);
}

.btn-danger {
    background-color: #fff1f2;
    color: #be123c;
    border-color: #fecdd3;
}

.btn-danger:hover {
    background-color: #ffe4e6;
}

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.badge-teal   { background: #f0fdfa; color: #0f766e; border: 1px solid #99f6e4; }
.badge-green  { background: var(--c-green-bg); color: var(--c-green); border: 1px solid var(--c-green-border); }
.badge-amber  { background: var(--c-amber-bg); color: var(--c-amber); border: 1px solid var(--c-amber-border); }
.badge-rose   { background: var(--c-rose-bg); color: var(--c-rose); border: 1px solid var(--c-rose-border); }
.badge-blue   { background: var(--c-blue-bg); color: var(--c-blue); border: 1px solid var(--c-blue-border); }
.badge-purple { background: var(--c-purple-bg); color: var(--c-purple); border: 1px solid var(--c-purple-border); }
.badge-slate  { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }

/* ── Alerts & Banners ───────────────────────────────────────── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
}

.alert i {
    font-size: 1.15rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.alert-info    { background: var(--c-blue-bg); color: #1e3a8a; border: 1px solid var(--c-blue-border); }
.alert-success { background: var(--c-green-bg); color: #14532d; border: 1px solid var(--c-green-border); }
.alert-warning { background: var(--c-amber-bg); color: #92400e; border: 1px solid var(--c-amber-border); }
.alert-error   { background: var(--c-rose-bg); color: #881337; border: 1px solid var(--c-rose-border); }

/* ── Modals & Drawers ───────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    z-index: 50;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.open {
    display: flex;
}

.modal-box {
    background: #ffffff;
    border-radius: var(--radius-xl);
    border: 1px solid #e2e8f0;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 540px;
    overflow: hidden;
    animation: slideFadeUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #fafbfc;
}

.modal-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: #0f172a;
    background: #f1f5f9;
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    padding: 0.875rem 1.25rem;
    border-top: 1px solid #f1f5f9;
    display: flex;
    justify-content: flex-end;
    gap: 0.65rem;
    background-color: #fafbfc;
}

/* ── Toast Notifications ────────────────────────────────────── */
.toast {
    background: #1e293b;
    color: #ffffff;
    border-radius: var(--radius-lg);
    padding: 0.75rem 1.1rem;
    font-size: 0.82rem;
    font-weight: 500;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 240px;
    max-width: 360px;
    pointer-events: auto;
    border: 1px solid rgba(255, 255, 255, 0.08);
    animation: slideFadeUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.success { background: #0f766e; }
.toast.error   { background: #9f1239; }
.toast.warning { background: #b45309; }

.toast i {
    font-size: 1.15rem;
    flex-shrink: 0;
}

/* ── Daily Log High-Speed Entry Table ────────────────────────── */
.log-table {
    border-collapse: collapse;
    width: 100%;
}

.log-table th {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    padding: 0.6rem 0.75rem;
    border-bottom: 2px solid #e2e8f0;
    text-align: center;
    white-space: nowrap;
    background-color: #f8fafc;
}

.log-table th:first-child {
    text-align: left;
    width: 3rem;
}

.log-table td {
    padding: 0.4rem 0.55rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.log-table tbody tr:hover td {
    background-color: #f8fafc;
}

.log-table tbody tr:focus-within td {
    background-color: #f0fdf4;
}

/* Toggle button group */
.toggle-group {
    display: inline-flex;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
}

.toggle-btn {
    padding: 0.3rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 600;
    background: none;
    border: none;
    cursor: pointer;
    color: #64748b;
    transition: all var(--transition);
    white-space: nowrap;
}

.toggle-btn.active {
    background: var(--primary-color);
    color: #ffffff;
}

.toggle-btn:not(.active):hover {
    background: #e2e8f0;
}

/* Referred toggle */
.ref-toggle {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: none;
    border: 2px solid #cbd5e1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    margin: auto;
    flex-shrink: 0;
    color: white;
}

.ref-toggle.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.ref-toggle i {
    display: none;
    font-size: 0.75rem;
    font-weight: bold;
}

.ref-toggle.active i {
    display: block;
}

.referral-detail-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    align-items: center;
    background-color: #f0fdfa;
    border-radius: var(--radius-md);
    padding: 0.65rem 0.85rem;
    border: 1px solid #ccfbf1;
    margin: 0.25rem 0;
}

.ref-field-group {
    display: flex;
    flex-direction: column;
    min-width: 140px;
}

.ref-field-group label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #0f766e;
    margin-bottom: 0.25rem;
}

/* ── Spinner ─────────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.65s linear infinite;
}

/* ── Keyboard shortcut hint ───────────────────────────────────── */
.kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 0.35rem;
    padding: 0.15rem 0.4rem;
    font-size: 0.68rem;
    font-weight: 700;
    color: #475569;
    letter-spacing: 0.02em;
    box-shadow: 0 1px 0 #cbd5e1;
}

/* ── Empty State ─────────────────────────────────────────────── */
.empty-state {
    padding: 3.5rem 1rem;
    text-align: center;
    color: #94a3b8;
}

.empty-state i {
    font-size: 2.75rem;
    color: #cbd5e1;
    margin-bottom: 0.75rem;
    display: block;
}

.empty-state p {
    font-size: 0.875rem;
    color: #64748b;
    font-weight: 500;
}

/* ── Report Print Styles ──────────────────────────────────────── */
.report-section {
    margin-bottom: 1.5rem;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.report-table th, .report-table td {
    border: 1px solid #cbd5e1;
    padding: 0.5rem 0.75rem;
    text-align: right;
}

.report-table th:first-child, .report-table td:first-child {
    text-align: left;
    font-weight: 600;
}

.report-table thead th {
    background: #f8fafc;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}

.report-table .total-row td {
    background: #f1f5f9;
    font-weight: 700;
    color: #0f172a;
}

.report-header {
    background: #1e293b;
    color: #ffffff;
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.report-header h2 {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
}

.report-header p {
    font-size: 0.78rem;
    color: #94a3b8;
}

@media print {
    .sidebar, .topbar, .btn, .no-print, .sidebar-overlay, header {
        display: none !important;
    }
    .content-wrapper {
        margin-left: 0 !important;
        padding-left: 0 !important;
    }
    .page-content {
        padding: 0 !important;
        max-width: none !important;
    }
    .card {
        box-shadow: none !important;
        border-radius: 0 !important;
        border: none !important;
        border-top: 1px solid #ccc !important;
    }
    .report-header {
        background: #1e293b !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    body {
        font-size: 11pt;
        background: #ffffff !important;
    }
}
