/* ==========================================================================
   RxCare — Doctor Prescription Management System
   Professional medical UI: clean, dense, fast. No decorative animation.
   ========================================================================== */

:root {
    --rx-primary:      #0d6f6b;
    --rx-primary-dark: #095551;
    --rx-primary-soft: #e6f2f1;
    --rx-accent:       #1f6feb;
    --rx-sidebar:      #10222b;
    --rx-sidebar-2:    #0b1920;
    --rx-body:         #f4f6f8;
    --rx-border:       #e2e6ea;
    --rx-text:         #1d2b32;
    --rx-muted:        #6b7b85;
    --rx-danger:       #c62828;
    --rx-warning:      #b26a00;
    --sidebar-w:       252px;
    --topbar-h:        58px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body.app-body,
body.auth-body {
    margin: 0;
    background: var(--rx-body);
    color: var(--rx-text);
    font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14.5px;
    -webkit-text-size-adjust: 100%;
}

body.lang-bn,
body.lang-bn .form-control,
body.lang-bn .form-select,
body.lang-bn .btn {
    font-family: "Hind Siliguri", "Noto Sans Bengali", "Nirmala UI", "SolaimanLipi",
                 "Segoe UI", Roboto, Arial, sans-serif;
}

a { color: var(--rx-primary-dark); }
a:hover { color: var(--rx-primary); }

/* ---------------------------------------------------------------- shell */
.app-shell { display: flex; min-height: 100vh; }

.app-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    margin-left: var(--sidebar-w);
}

.app-content { flex: 1 1 auto; padding: 18px 20px 28px; }

.app-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--rx-border);
    background: #fff;
    font-size: 12.5px;
    color: var(--rx-muted);
}

/* ---------------------------------------------------------------- sidebar */
.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--rx-sidebar) 0%, var(--rx-sidebar-2) 100%);
    color: #cfdbe2;
    display: flex;
    flex-direction: column;
    z-index: 1040;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    border-radius: 9px;
    background: var(--rx-primary);
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    flex: 0 0 auto;
}
.brand-mark.lg { width: 52px; height: 52px; font-size: 22px; border-radius: 14px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { color: #fff; font-size: 15px; }
.brand-text small { color: #8fa5b1; font-size: 10.5px; }

.sidebar-nav { flex: 1 1 auto; overflow-y: auto; padding: 8px 0 14px; }

.sidebar-nav .nav-heading {
    padding: 14px 18px 6px;
    font-size: 10.5px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #6f8592;
}

.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 18px;
    color: #c3d2da;
    text-decoration: none;
    font-size: 14px;
    border-left: 3px solid transparent;
}
.sidebar-nav .nav-item i { font-size: 16px; width: 18px; text-align: center; }
.sidebar-nav .nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav .nav-item.active {
    background: rgba(13,111,107,.28);
    border-left-color: var(--rx-primary);
    color: #fff;
    font-weight: 600;
}

.sidebar-note {
    padding: 10px 16px;
    font-size: 11px;
    line-height: 1.5;
    color: #93a6b1;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex;
    gap: 8px;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(6,15,20,.5);
    z-index: 1035;
}
.sidebar-backdrop.show { display: block; }

/* ---------------------------------------------------------------- topbar */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    background: #fff;
    border-bottom: 1px solid var(--rx-border);
}

.btn-icon {
    border: 1px solid var(--rx-border);
    background: #fff;
    border-radius: 8px;
    width: 36px; height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.global-search { position: relative; flex: 1 1 auto; max-width: 520px; }
.global-search > i {
    position: absolute; top: 50%; left: 11px; transform: translateY(-50%);
    color: var(--rx-muted); font-size: 14px; pointer-events: none;
}
.global-search .form-control {
    padding-left: 32px;
    height: 36px;
    font-size: 13.5px;
    background: #f7f9fa;
}
.search-results {
    position: absolute;
    top: 42px; left: 0; right: 0;
    background: #fff;
    border: 1px solid var(--rx-border);
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(16,34,43,.14);
    max-height: 420px;
    overflow-y: auto;
    z-index: 1050;
}
.search-results .sr-group { padding: 6px 12px 2px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--rx-muted); }
.search-results a { display: block; padding: 7px 12px; text-decoration: none; color: var(--rx-text); border-top: 1px solid #f1f4f6; }
.search-results a:hover { background: var(--rx-primary-soft); }
.search-results a small { display: block; color: var(--rx-muted); font-size: 11.5px; }
.search-results .sr-empty { padding: 14px; text-align: center; color: var(--rx-muted); font-size: 13px; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.avatar-sm {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: var(--rx-primary);
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700;
    text-transform: uppercase;
}

/* ---------------------------------------------------------------- page */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.page-title { font-size: 21px; font-weight: 700; margin: 0; }
.page-subtitle { margin: 3px 0 0; color: var(--rx-muted); font-size: 13px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.card {
    border: 1px solid var(--rx-border);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(16,34,43,.04);
}
.card-header {
    background: #fff;
    border-bottom: 1px solid var(--rx-border);
    font-weight: 600;
    padding: 12px 16px;
    border-radius: 12px 12px 0 0 !important;
}
.card-body { padding: 16px; }

/* ---------------------------------------------------------------- stats */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}
.stat-card {
    background: #fff;
    border: 1px solid var(--rx-border);
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}
.stat-card:hover { border-color: var(--rx-primary); color: inherit; }
.stat-icon {
    width: 42px; height: 42px;
    border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 19px;
    background: var(--rx-primary-soft);
    color: var(--rx-primary-dark);
    flex: 0 0 auto;
}
.stat-icon.blue   { background: #e7f0fe; color: #1553b6; }
.stat-icon.amber  { background: #fdf1dd; color: #a56600; }
.stat-icon.red    { background: #fdeaea; color: #b02222; }
.stat-icon.violet { background: #efeafd; color: #5a34b8; }
.stat-value { font-size: 21px; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 12.5px; color: var(--rx-muted); }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
.table { font-size: 13.5px; margin-bottom: 0; }
.table > thead > tr > th {
    background: #f7f9fa;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--rx-muted);
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 1px solid var(--rx-border);
}
.table > tbody > tr > td { vertical-align: middle; }
.table-hover > tbody > tr:hover > * { background: #f6fbfa; }
.table .actions-cell { white-space: nowrap; text-align: end; }

.filter-bar {
    background: #fff;
    border: 1px solid var(--rx-border);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 14px;
}

.empty-state { padding: 34px 16px; text-align: center; color: var(--rx-muted); }
.empty-state i { font-size: 30px; display: block; margin-bottom: 8px; opacity: .5; }

/* ---------------------------------------------------------------- forms */
.form-label { font-weight: 600; font-size: 12.8px; margin-bottom: 4px; color: #33454f; }
.form-control, .form-select { font-size: 14px; }
.form-control:focus, .form-select:focus {
    border-color: var(--rx-primary);
    box-shadow: 0 0 0 .18rem rgba(13,111,107,.15);
}
.required::after { content: " *"; color: var(--rx-danger); }
.form-section-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--rx-muted);
    font-weight: 700;
    margin: 4px 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--rx-border);
}

.btn-primary {
    background: var(--rx-primary);
    border-color: var(--rx-primary);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--rx-primary-dark);
    border-color: var(--rx-primary-dark);
}
.btn-outline-primary { color: var(--rx-primary-dark); border-color: var(--rx-primary); }
.btn-outline-primary:hover { background: var(--rx-primary); border-color: var(--rx-primary); }

.check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
    gap: 4px 14px;
    max-height: 300px;
    overflow-y: auto;
    padding: 10px;
    border: 1px solid var(--rx-border);
    border-radius: 10px;
    background: #fbfcfd;
}
.check-grid .form-check { margin-bottom: 0; }
.check-grid .form-check-label { font-size: 13.4px; }

/* ---------------------------------------------------------------- disclaimer */
.medical-disclaimer {
    background: #fff8e6;
    border: 1px solid #f0dca8;
    border-left: 4px solid #d99b00;
    border-radius: 10px;
    padding: 11px 14px;
    font-size: 12.7px;
    line-height: 1.55;
    margin-bottom: 16px;
    color: #5c4400;
}
.medical-disclaimer i { font-size: 16px; color: #b57d00; }
.medical-disclaimer p { margin-top: 3px; }

.reference-note {
    background: var(--rx-primary-soft);
    border: 1px solid #bfdedb;
    border-radius: 9px;
    padding: 9px 12px;
    font-size: 12.6px;
    color: #0a4b48;
}

.alert-allergy {
    background: #fdeaea;
    border: 1px solid #f2b8b8;
    border-left: 4px solid var(--rx-danger);
    border-radius: 9px;
    padding: 9px 12px;
    font-size: 13px;
    color: #7d1a1a;
}

/* ---------------------------------------------------------------- builder */
.rx-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}
.rx-step {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 13px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--rx-border);
    font-size: 12.6px;
    color: var(--rx-muted);
    text-decoration: none;
    cursor: pointer;
}
.rx-step .num {
    width: 20px; height: 20px;
    border-radius: 50%;
    background: #e8edf0;
    color: #5c6f7a;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
}
.rx-step.active { border-color: var(--rx-primary); background: var(--rx-primary-soft); color: var(--rx-primary-dark); font-weight: 600; }
.rx-step.active .num { background: var(--rx-primary); color: #fff; }
.rx-step.done .num { background: #2e7d32; color: #fff; }

.builder-panel { display: none; }
.builder-panel.active { display: block; }

.patient-chip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 18px;
    background: #fff;
    border: 1px solid var(--rx-border);
    border-left: 4px solid var(--rx-primary);
    border-radius: 10px;
    padding: 11px 14px;
}
.patient-chip .pc-name { display: block; font-weight: 700; font-size: 15px; line-height: 1.3; }
.patient-chip .pc-meta { display: block; font-size: 12.6px; color: var(--rx-muted); }
.patient-chip .pc-item strong { display: block; font-size: 11px; color: var(--rx-muted); text-transform: uppercase; letter-spacing: .04em; }

.pick-list { max-height: 300px; overflow-y: auto; border: 1px solid var(--rx-border); border-radius: 10px; }
.pick-list .pick-row {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 8px 12px; border-bottom: 1px solid #eef1f3; cursor: pointer;
}
.pick-list .pick-row:last-child { border-bottom: 0; }
.pick-list .pick-row:hover { background: var(--rx-primary-soft); }
.pick-list .pick-row .pk-title { font-weight: 600; font-size: 13.6px; }
.pick-list .pick-row .pk-sub { font-size: 11.8px; color: var(--rx-muted); }

.ref-med-card {
    border: 1px solid var(--rx-border);
    border-radius: 10px;
    padding: 10px 12px;
    background: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.ref-med-card .rm-name { font-weight: 600; font-size: 13.8px; }
.ref-med-card .rm-sub { font-size: 11.8px; color: var(--rx-muted); }

.question-card {
    border: 1px solid var(--rx-border);
    border-radius: 10px;
    padding: 12px 14px;
    background: #fff;
    margin-bottom: 10px;
}
.question-card .q-text { font-weight: 600; font-size: 13.8px; margin-bottom: 8px; }
.question-card .opt-row { display: flex; flex-wrap: wrap; gap: 6px; }
.opt-chip {
    border: 1px solid var(--rx-border);
    border-radius: 999px;
    padding: 5px 13px;
    font-size: 13px;
    cursor: pointer;
    background: #fff;
    user-select: none;
}
.opt-chip.selected { background: var(--rx-primary); border-color: var(--rx-primary); color: #fff; font-weight: 600; }

.med-table { font-size: 13px; }
.med-table td { padding: 6px 5px; vertical-align: top; }
.med-table .form-control, .med-table .form-select { font-size: 13px; padding: 5px 8px; }
.med-row-name { font-weight: 600; }
.dose-ref-box {
    background: #f3f9f8;
    border: 1px dashed #a9cfcb;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12.2px;
    color: #0b4c49;
    margin: 0 0 4px;
}
.dose-ref-box table { width: 100%; font-size: 12px; margin-bottom: 4px; }
.dose-ref-box td { padding: 2px 6px 2px 0; border: 0; }
.med-table tr.med-ref-row > td { padding-top: 0; border-bottom: 1px solid #e6ebee; }

.autosave-badge {
    font-size: 11.5px;
    color: var(--rx-muted);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.sticky-actions {
    position: sticky;
    bottom: 0;
    background: #fff;
    border-top: 1px solid var(--rx-border);
    padding: 10px 14px;
    margin: 16px -20px -28px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: space-between;
    align-items: center;
    z-index: 900;
}

/* ---------------------------------------------------------------- auth */
.auth-body { display: flex; align-items: center; justify-content: center; padding: 24px 14px; background: #eef2f5; }
.auth-wrap { width: 100%; max-width: 420px; }
.auth-card {
    background: #fff;
    border: 1px solid var(--rx-border);
    border-radius: 16px;
    padding: 26px 24px 20px;
    box-shadow: 0 14px 40px rgba(16,34,43,.10);
}
.auth-head { text-align: center; margin-bottom: 18px; }
.auth-head h1 { font-size: 19px; font-weight: 700; margin: 12px 0 2px; }
.auth-head p { color: var(--rx-muted); font-size: 12.8px; margin: 0; }
.auth-lang { text-align: center; margin-top: 14px; font-size: 12.6px; }
.auth-disclaimer {
    margin: 16px 0 0;
    font-size: 11.6px;
    line-height: 1.6;
    color: #5b6d78;
    text-align: justify;
}

/* ---------------------------------------------------------------- print page */
.print-toolbar {
    background: #fff;
    border-bottom: 1px solid var(--rx-border);
    padding: 10px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* ---------------------------------------------------------------- helpers */
.text-muted-sm { font-size: 12px; color: var(--rx-muted); }
.badge-soft { background: var(--rx-primary-soft); color: var(--rx-primary-dark); font-weight: 600; }
.cursor-pointer { cursor: pointer; }
.w-90 { width: 90px; }
.w-110 { width: 110px; }
.w-130 { width: 130px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 991.98px) {
    .app-main { margin-left: 0; }
    .app-sidebar { transform: translateX(-100%); transition: transform .18s ease-out; }
    .app-sidebar.open { transform: translateX(0); }
    .app-content { padding: 14px 12px 24px; }
    .sticky-actions { margin: 14px -12px -24px; }
}

@media (max-width: 575.98px) {
    body.app-body { font-size: 14px; }
    .page-title { font-size: 18px; }
    .stat-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .btn { padding: .45rem .8rem; }
    .app-topbar { gap: 8px; padding: 0 10px; }
    .global-search .form-control { font-size: 13px; }
    .table { font-size: 12.8px; }
}

@media print {
    .app-sidebar, .app-topbar, .app-footer, .sticky-actions, .print-toolbar, .no-print { display: none !important; }
    .app-main { margin-left: 0; }
    .app-content { padding: 0; }
    body { background: #fff; }
}
