/* =====================================================================
   E-Askep 3S - Design System
   ===================================================================== */

:root {
    --brand: #006b3f;
    --brand-600: #00854d;
    --brand-700: #006b3f;
    --brand-900: #0b3d27;
    --gold: #b8964a;
    --gold-soft: #f5eeda;
    --ink: #17201b;
    --muted: #5f6b65;
    --line: #e3e8e5;
    --bg: #f5f7f6;
    --sidebar-w: 268px;
    --radius: 14px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 20, .04);
    --shadow-md: 0 6px 18px rgba(16, 24, 20, .07);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: .925rem;
    -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; }

a { text-decoration: none; }

/* ---------------------------------------------------------------------
   Sidebar
   --------------------------------------------------------------------- */
.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: #0e2a1f;
    border-right: 1px solid #1a3a2b;
    color: #c3d2c9;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform .25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.35rem 1.25rem 1.1rem;
    color: #fff;
}

.sidebar-brand .brand-logo {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    background: #006b3f;
    border: 1px solid #23734f;
    display: grid;
    place-items: center;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .03em;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-brand .brand-name {
    font-weight: 700;
    font-size: 1.08rem;
    letter-spacing: -.02em;
    line-height: 1.15;
}

.sidebar-brand .brand-sub {
    font-size: .63rem;
    line-height: 1.3;
    color: #a9bfb2;
    font-weight: 500;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: .5rem .8rem 1rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.18) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 99px; }

.nav-section {
    font-size: .66rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: #82998c;
    font-weight: 600;
    padding: 1rem .85rem .45rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .62rem .85rem;
    border-radius: 8px;
    color: #c3d2c9;
    font-weight: 500;
    font-size: .875rem;
    margin-bottom: 2px;
    transition: background .16s ease, color .16s ease;
    position: relative;
}

.sidebar-nav .nav-link i {
    font-size: 1.05rem;
    width: 1.35rem;
    text-align: center;
    color: #93a99c;
    transition: color .16s ease;
}

.sidebar-nav .nav-link:hover {
    background: rgba(255, 255, 255, .06);
    color: #fff;
}

.sidebar-nav .nav-link:hover i { color: #d9c58c; }

.sidebar-nav .nav-link.active {
    background: rgba(184, 150, 74, .12);
    color: #fff;
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--gold);
}

.sidebar-nav .nav-link.active i { color: #d9c58c; }

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: .78rem;
    background: #e7f0eb;
    color: #006b3f;
    flex-shrink: 0;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .5);
    backdrop-filter: blur(2px);
    z-index: 1035;
    opacity: 0;
    visibility: hidden;
    transition: all .25s ease;
}

/* ---------------------------------------------------------------------
   Main layout
   --------------------------------------------------------------------- */
.app-main {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .8rem 1.6rem;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.topbar-title { font-weight: 700; font-size: .96rem; letter-spacing: -.01em; }
.topbar-breadcrumb { font-size: .76rem; color: var(--muted); }

.topbar-logout {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    border: 1px solid var(--line);
    background: #fff;
    color: #4f5b55;
    font-size: .78rem;
    font-weight: 600;
    padding: .32rem .7rem;
    border-radius: 7px;
    line-height: 1.4;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.topbar-logout:hover { background: #eef4f0; border-color: #b9d3c6; color: var(--brand-700); }
.topbar-logout i { font-size: .95rem; }

.btn-sidebar-toggle {
    display: none;
    border: 1px solid var(--line);
    background: #fff;
    width: 40px;
    height: 40px;
    border-radius: 11px;
    color: var(--ink);
    font-size: 1.15rem;
}

.app-content {
    padding: 1.6rem;
    flex: 1;
    max-width: 1500px;
    width: 100%;
}

/* ---------------------------------------------------------------------
   Headings & cards
   --------------------------------------------------------------------- */
.page-heading { margin-bottom: 1.4rem; }
.page-heading h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -.03em;
    margin-bottom: .2rem;
}
.page-heading p { color: var(--muted); margin: 0; font-size: .875rem; }

.card-app {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card-app .card-app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.05rem 1.25rem;
    border-bottom: 1px solid var(--line);
}

.card-app .card-app-header h2,
.card-app .card-app-header h3 {
    font-size: .95rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -.01em;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.card-app .card-app-header i { color: var(--brand-600); }

.card-app .card-app-body { padding: 1.25rem; }

/* Stat cards */
.stat-card {
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: #fff;
    padding: 1.15rem 1.25rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 100%;
    transition: transform .18s ease, box-shadow .18s ease;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}

.stat-icon.teal { background: #e7f0eb; color: #006b3f; }
.stat-icon.blue { background: #e8eef2; color: #33566b; }
.stat-icon.amber { background: #f5eeda; color: #8a6d2f; }
.stat-icon.rose { background: #f3e6e4; color: #9c4a3f; }

.stat-value { font-size: 1.65rem; font-weight: 800; line-height: 1; letter-spacing: -.03em; }
.stat-label { color: var(--muted); font-size: .78rem; font-weight: 600; margin-top: .3rem; }

/* ---------------------------------------------------------------------
   Buttons & badges
   --------------------------------------------------------------------- */
.btn { border-radius: 10px; font-weight: 600; font-size: .85rem; padding: .5rem .95rem; }
.btn-lg { padding: .72rem 1.3rem; font-size: .95rem; border-radius: 12px; }
.btn-sm { padding: .32rem .65rem; font-size: .78rem; border-radius: 8px; }
.btn-primary {
    --bs-btn-bg: var(--brand-700);
    --bs-btn-border-color: var(--brand-700);
    --bs-btn-hover-bg: var(--brand-600);
    --bs-btn-hover-border-color: var(--brand-600);
    --bs-btn-active-bg: var(--brand-900);
    --bs-btn-active-border-color: var(--brand-900);
}
.btn-outline-primary {
    --bs-btn-color: var(--brand-700);
    --bs-btn-border-color: #b9d3c6;
    --bs-btn-hover-bg: var(--brand-700);
    --bs-btn-hover-border-color: var(--brand-700);
    --bs-btn-active-bg: var(--brand-900);
}
.btn-light-primary { background: #eef4f0; color: #006b3f; border: 1px solid #d5e4db; }
.btn-light-primary:hover { background: #dfebe4; color: #0b3d27; border-color: #b9d3c6; }

.badge { font-weight: 600; padding: .35em .6em; border-radius: 7px; font-size: .72rem; }
.badge-mayor { background: #f3e6e4; color: #9c4a3f; }
.badge-minor { background: #e8eef2; color: #33566b; }
.badge-ds { background: #ece9f1; color: #57477a; }
.badge-do { background: #e7f0eb; color: #0b5c39; }
.badge-soft { background: #eef1ef; color: #4f5b55; }
.badge-pending { background: #f5eeda; color: #7a5f22; }
.badge-done { background: #e7f0eb; color: #0b5c39; }

/* ---------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------- */
.form-label { font-weight: 600; font-size: .8rem; color: #33403a; margin-bottom: .35rem; }
.form-control, .form-select {
    border-radius: 8px;
    border-color: #d6ded9;
    font-size: .875rem;
    padding: .55rem .8rem;
}
.form-control:focus, .form-select:focus {
    border-color: #8fb9a3;
    box-shadow: 0 0 0 .18rem rgba(0, 107, 63, .1);
}
.form-text { font-size: .75rem; }
.input-group-text { border-radius: 8px; background: #f5f7f6; border-color: #d6ded9; color: var(--muted); }

/* ---------------------------------------------------------------------
   Symptom picker
   --------------------------------------------------------------------- */
.symptom-box {
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.symptom-box-head {
    padding: .8rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    border-bottom: 1px solid var(--line);
    background: #f5f7f6;
}

.symptom-box-head .title { font-weight: 700; font-size: .86rem; display: flex; align-items: center; gap: .45rem; }

.symptom-search { padding: .7rem .8rem; border-bottom: 1px solid var(--line); position: relative; }
.symptom-search i {
    position: absolute;
    left: 1.45rem;
    top: 50%;
    transform: translateY(-50%);
    color: #8d9992;
    font-size: .9rem;
}
.symptom-search input {
    padding-left: 2.2rem;
    background: #f5f7f6;
    border-color: #e1e7e3;
}

.symptom-list {
    overflow-y: auto;
    max-height: 380px;
    padding: .55rem;
    flex: 1;
    scrollbar-width: thin;
}

.symptom-item {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .5rem .65rem;
    border-radius: 7px;
    cursor: pointer;
    margin-bottom: 1px;
    font-size: .82rem;
    line-height: 1.35;
    transition: background .12s ease;
    border: 1px solid transparent;
}

.symptom-item:hover { background: #f5f7f6; }

.symptom-item input {
    margin-top: .15rem;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--brand-600);
}

.symptom-item.checked { background: #eef4f0; border-color: #d5e4db; }
.symptom-item.checked span { color: #006b3f; font-weight: 600; }

.symptom-empty { text-align: center; color: var(--muted); padding: 1.5rem; font-size: .82rem; }

.symptom-counter { font-size: .72rem; font-weight: 700; background: #e7f0eb; color: #006b3f; padding: .2rem .5rem; border-radius: 5px; }

/* Relation mapping (Mayor/Minor) */
.relation-row {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .4rem .55rem;
    border-radius: 9px;
    font-size: .8rem;
    border: 1px solid transparent;
    margin-bottom: 2px;
    transition: background .12s ease;
}
.relation-row:hover { background: #f5f7f6; }
.relation-row .label { flex: 1; line-height: 1.35; }
.relation-row .sifat-select {
    width: 108px;
    flex-shrink: 0;
    font-size: .74rem;
    font-weight: 600;
    padding: .22rem .45rem;
}
.relation-row.row-mayor { background: #f7f1e2; border-color: #e6d7ae; }
.relation-row.row-minor { background: #eef2f5; border-color: #d3dee5; }
.relation-row.row-mayor .sifat-select { border-color: #dcc78f; color: #7a5f22; }
.relation-row.row-minor .sifat-select { border-color: #b9cbd6; color: #33566b; }
.relation-list { max-height: 470px; overflow-y: auto; padding: .55rem; }

/* Vital signs */
.vital-box {
    display: block;
    background: #f5f7f6;
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: .65rem .85rem .6rem;
    cursor: text;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
    margin-bottom: 0;
}
.vital-box:hover { border-color: #c9d6ce; }
.vital-box:focus-within {
    background: #fff;
    border-color: #8fb9a3;
    box-shadow: 0 0 0 .18rem rgba(0, 107, 63, .1);
}
.vital-box .vital-label {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    margin-bottom: .25rem;
    display: block;
    cursor: text;
}
.vital-box input {
    display: block;
    width: 100%;
    border: 0;
    background: transparent;
    padding: .1rem 0;
    min-height: 1.6rem;
    font-weight: 700;
    font-size: .95rem;
    color: var(--ink);
    cursor: text;
}
.vital-box input:focus { box-shadow: none; background: transparent; outline: 0; }
.vital-box input::placeholder { color: #9aa59f; font-weight: 500; opacity: 1; }

/* Tabs */
.nav-pills .nav-link {
    border: 1px solid var(--line);
    background: #fff;
    color: #4f5b55;
    font-weight: 600;
    border-radius: 7px;
    padding: .45rem .9rem;
}
.nav-pills .nav-link:hover { background: #eef4f0; color: var(--brand-700); border-color: #d5e4db; }
.nav-pills .nav-link.active {
    background: var(--brand-700);
    border-color: var(--brand-700);
    color: #fff;
}
.auth-card .text-primary { color: var(--brand-700) !important; }

/* ---------------------------------------------------------------------
   Diagnosis cards
   --------------------------------------------------------------------- */
.diag-card {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1.15rem 1.25rem;
    background: #fff;
    box-shadow: var(--shadow-sm);
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: border-color .18s ease, box-shadow .18s ease;
    position: relative;
    overflow: hidden;
}

.diag-card:hover { border-color: #b9d3c6; box-shadow: var(--shadow-md); }

.diag-card.rank-1 { border-color: #c9b378; background: #fdfbf5; }

.diag-card .rank-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 30px;
    height: 30px;
    border-radius: 7px;
    background: #eef1ef;
    color: #4f5b55;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: .78rem;
}

.diag-card.rank-1 .rank-badge { background: #f5eeda; color: #7a5f22; }

.diag-code { font-size: .72rem; font-weight: 800; letter-spacing: .04em; color: var(--brand-600); }
.diag-name { font-size: 1rem; font-weight: 700; letter-spacing: -.01em; margin: .1rem 0 .2rem; }
.diag-kategori { font-size: .75rem; color: var(--muted); }

.diag-match-list {
    font-size: .78rem;
    background: #f5f7f6;
    border-radius: 8px;
    padding: .6rem .75rem;
    margin: .7rem 0;
    max-height: 120px;
    overflow-y: auto;
    color: #4f5b55;
    line-height: 1.7;
}
.diag-match-list::-webkit-scrollbar { width: 4px; }
.diag-match-list::-webkit-scrollbar-thumb { background: #c3cdc7; border-radius: 99px; }

.match-bar { height: 6px; border-radius: 99px; background: #e3e8e5; overflow: hidden; }
.match-bar > div { height: 100%; border-radius: 99px; background: var(--brand-600); }

/* ---------------------------------------------------------------------
   Askep detail
   --------------------------------------------------------------------- */
.askep-section {
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
    margin-bottom: 1rem;
    overflow: hidden;
}
.askep-section-head {
    padding: .8rem 1.1rem;
    background: #f5f7f6;
    border-bottom: 1px solid var(--line);
    font-weight: 700;
    font-size: .88rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.askep-section-head i { color: var(--brand-600); }
.askep-section-body { padding: 1.05rem 1.15rem; }

.list-tindakan { padding-left: 1.1rem; margin: 0; font-size: .86rem; line-height: 1.75; color: #33403a; }
.list-tindakan li { margin-bottom: .15rem; }
.list-tindakan li::marker { color: var(--brand-600); }

.detail-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; margin-bottom: .2rem; }
.detail-value { font-size: .88rem; font-weight: 600; color: var(--ink); }

.biodata-item { padding: .45rem 0; border-bottom: 1px dashed #eef1ef; }
.biodata-item:last-child { border-bottom: 0; }

/* ---------------------------------------------------------------------
   Tables
   --------------------------------------------------------------------- */
.table { font-size: .85rem; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .75rem .8rem; vertical-align: middle; }
.table thead th {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    font-weight: 700;
    border-bottom: 1px solid var(--line);
    background: #f5f7f6;
    white-space: nowrap;
}
.table tbody tr { border-color: #eef1ef; }
.table-hover tbody tr:hover { background: #f5f7f6; }

div.dataTables_wrapper .row:first-child { padding: .75rem 0; }
.dataTables_filter input { border-radius: 8px; border: 1px solid #d6ded9; padding: .4rem .7rem; font-size: .82rem; }
.dataTables_length select { border-radius: 7px; border: 1px solid #d6ded9; padding: .3rem 1.8rem .3rem .6rem; font-size: .82rem; }
.page-link { border-radius: 6px !important; margin: 0 2px; border-color: var(--line); color: var(--brand-700); font-size: .8rem; }
.active > .page-link, .page-link.active { background: var(--brand-700); border-color: var(--brand-700); }
.dt-info, .dt-length, .dt-search { font-size: .8rem; color: var(--muted); }

/* ---------------------------------------------------------------------
   Auth / login
   --------------------------------------------------------------------- */
.auth-page {
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 2.5rem 1.25rem;
}

.auth-panel { width: 100%; display: flex; align-items: center; justify-content: center; padding: 0; }
.auth-card {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 2.25rem 2rem;
    box-shadow: var(--shadow-md);
}
.auth-card h2 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; }
.auth-card p.sub { color: var(--muted); font-size: .87rem; margin-bottom: 1.6rem; }

.auth-footer-note { text-align: center; color: var(--muted); font-size: .74rem; margin-top: 2rem; line-height: 1.6; }
.auth-footer-note a { color: var(--brand-700); font-weight: 600; }
.auth-footer-note a:hover { color: var(--brand-900); text-decoration: underline; }
.auth-footer-note .made-heart { color: var(--gold); vertical-align: -1px; margin: 0 1px; }

/* ---------------------------------------------------------------------
   Misc
   --------------------------------------------------------------------- */
.empty-state { text-align: center; padding: 2.5rem 1rem; }
.empty-state .ic {
    width: 60px; height: 60px; border-radius: 10px; background: #e7f0eb; color: #006b3f;
    display: grid; place-items: center; font-size: 1.5rem; margin: 0 auto 1rem;
}
.empty-state h4 { font-size: .95rem; font-weight: 700; }
.empty-state p { color: var(--muted); font-size: .82rem; margin-bottom: 1rem; }

.swal2-popup { border-radius: 12px !important; font-family: 'Inter', sans-serif; }
.swal2-title { font-size: 1.15rem !important; font-weight: 700 !important; }

.select2-container--bootstrap-5 .select2-selection { border-radius: 8px; min-height: 40px; border-color: #d6ded9; }
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered { line-height: 38px; font-size: .875rem; }
.select2-container--bootstrap-5 .select2-selection--single { padding: .05rem .4rem; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c3cdc7; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #a3b0a9; }

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.show { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .btn-sidebar-toggle { display: inline-grid; place-items: center; }
    .sidebar-overlay.show { opacity: 1; visibility: visible; }
    .app-content { padding: 1.1rem; }
    .auth-page { padding: 1.5rem 1rem; }
    .auth-card { padding: 1.75rem 1.35rem; }
    .topbar-date { display: none; }
}

@media (max-width: 575.98px) {
    .app-topbar { padding: .7rem .9rem; }
    .app-content { padding: .9rem; }
    .page-heading h1 { font-size: 1.25rem; }
    .stat-card { padding: .9rem 1rem; }
    .stat-value { font-size: 1.35rem; }
    .stat-icon { width: 44px; height: 44px; font-size: 1.15rem; }
}
