/* ==========================================================
   Patient Management System — custom styles
   ========================================================== */

:root {
    --brand:        #089d4c;
    --brand-dark:   #067a3c;
    --brand-light:  #d1fae5;
    --ink:          #0f172a;
    --muted:        #64748b;
    --line:         #e2e8f0;
    --bg-soft:      #f8fafc;
    --sidebar-bg:   #0f172a;
    --radius:       14px;
}

* { scrollbar-width: thin; }

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    color: var(--ink);
    background: var(--bg-soft);
}
body.lang-km,
body.lang-km .btn,
body.lang-km .form-control,
body.lang-km .form-select {
    font-family: 'Noto Sans Khmer', 'Inter', system-ui, sans-serif;
}
body.lang-km { line-height: 1.9; }

a { text-decoration: none; }

.btn-primary,
.btn-primary:focus {
    background-color: var(--brand);
    border-color: var(--brand);
}
.btn-primary:hover { background-color: var(--brand-dark); border-color: var(--brand-dark); }
.btn-outline-primary { color: var(--brand); border-color: var(--brand); }
.btn-outline-primary:hover { background-color: var(--brand); border-color: var(--brand); }
.text-brand { color: var(--brand) !important; }
.bg-brand-soft { background-color: var(--brand-light); }
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 .2rem rgba(8, 157, 76, .15);
}
.page-item.active .page-link { background-color: var(--brand); border-color: var(--brand); }
.page-link { color: var(--brand); }

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 36px; height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--brand), #22c55e);
    color: #fff;
    font-size: 1.1rem;
    flex: none;
}

.card { border: 1px solid var(--line); border-radius: var(--radius); }
.card-elevated { box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.06); border-color: transparent; }

/* ---------------- Front-end ---------------- */
.navbar .nav-link { font-weight: 500; color: #334155; }
.navbar .nav-link.active { color: var(--brand); }

.hero {
    background:
        radial-gradient(1200px 400px at 10% -10%, rgba(8,157,76,.18), transparent 60%),
        linear-gradient(180deg, #ffffff 0%, var(--bg-soft) 100%);
    padding: 5rem 0 4rem;
}
.hero h1 { font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.hero-art {
    border-radius: 24px;
    background: linear-gradient(135deg, var(--brand), #22c55e);
    aspect-ratio: 4/3;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 6rem;
    box-shadow: 0 24px 60px rgba(8,157,76,.35);
}

.stat-strip { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fff; }
.stat-strip .stat-value { font-size: 2rem; font-weight: 700; color: var(--brand); line-height: 1; }
.stat-strip .stat-label { color: var(--muted); font-size: .875rem; }

.feature-icon {
    width: 46px; height: 46px;
    border-radius: 12px;
    display: grid; place-items: center;
    background: var(--brand-light);
    color: var(--brand-dark);
    font-size: 1.25rem;
}

.product-card { transition: transform .18s ease, box-shadow .18s ease; height: 100%; overflow: hidden; }
.product-card:hover { transform: translateY(-4px); box-shadow: 0 14px 32px rgba(15,23,42,.10); }
.product-thumb {
    height: 170px;
    background: linear-gradient(135deg, #e2e8f0, #f1f5f9);
    display: grid; place-items: center;
    color: #94a3b8; font-size: 2.5rem;
    overflow: hidden;
}
.product-thumb img { width: 100%; height: 100%; object-fit: cover; }

.site-footer { background: var(--sidebar-bg); color: #fff; }
.footer-links li { margin-bottom: .5rem; color: rgba(255,255,255,.65); }
.footer-links a { color: rgba(255,255,255,.65); }
.footer-links a:hover { color: #fff; }
.social-btn {
    width: 38px; height: 38px; border-radius: 10px;
    display: grid; place-items: center;
    background: rgba(255,255,255,.1); color: #fff;
}
.social-btn:hover { background: var(--brand); color: #fff; }
.brand-mark-light { background: rgba(255,255,255,.15); }

.auth-card { max-width: 440px; margin: 3rem auto; }

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

.admin-sidebar {
    width: 260px; flex: none;
    background: var(--sidebar-bg);
    color: #cbd5e1;
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
    display: flex; align-items: center; gap: .6rem;
    padding: 1.1rem 1.15rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    color: #fff; font-weight: 600;
}
.sidebar-brand .brand-text { font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-nav { padding: .75rem; display: flex; flex-direction: column; gap: .15rem; overflow-y: auto; flex: 1; }
.sidebar-link {
    display: flex; align-items: center; gap: .7rem;
    padding: .6rem .75rem;
    border-radius: 10px;
    color: #cbd5e1; font-size: .925rem;
}
.sidebar-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-link.active { background: var(--brand); color: #fff; font-weight: 500; }
.sidebar-footer { padding: .75rem; border-top: 1px solid rgba(255,255,255,.08); }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-topbar {
    background: #fff;
    border-bottom: 1px solid var(--line);
    padding: .65rem 1.25rem;
    display: flex; align-items: center; gap: .5rem;
    position: sticky; top: 0; z-index: 20;
}
.admin-content { padding: 1.5rem; flex: 1; }

.avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--brand); color: #fff;
    display: inline-grid; place-items: center;
    font-size: .75rem; font-weight: 600;
}

/* ---------------- Tabs (no JS framework needed) ----------------
   Panels are visible by default, so every field stays reachable even
   if JavaScript never runs. app.js adds .js-ready, which switches the
   set into real tab behaviour.                                     */
.tabset .tab-nav {
    display: flex; flex-wrap: wrap; gap: .4rem;
    margin-bottom: 1rem;
    padding: 0; list-style: none;
}
.tabset .tab-nav button {
    display: inline-flex; align-items: center; gap: .4rem;
    border: 1px solid var(--line); background: #fff; color: #334155;
    padding: .45rem .95rem; border-radius: 10px;
    font-size: .9rem; font-weight: 500; line-height: 1.4;
    cursor: pointer;
}
.tabset .tab-nav button:hover { border-color: var(--brand); color: var(--brand-dark); }
.tabset .tab-nav button.is-active {
    background: var(--brand); border-color: var(--brand); color: #fff;
}
.tabset .tab-nav button .tab-count {
    background: rgba(15,23,42,.08); border-radius: 99px;
    padding: 0 .45rem; font-size: .75rem; font-weight: 600;
}
.tabset .tab-nav button.is-active .tab-count { background: rgba(255,255,255,.25); }
.tabset .tab-panel-heading {
    font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted); font-weight: 600; margin-bottom: .75rem;
}
.tabset .tab-panel + .tab-panel { margin-top: 1.75rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.tabset.js-ready .tab-panel { display: none; margin-top: 0; padding-top: 0; border-top: 0; }
.tabset.js-ready .tab-panel.is-active { display: block; }
.tabset.js-ready .tab-panel-heading { display: none; }

/* ---------------- Dropdowns built on <details> (no JS needed) ---------------- */
.dd { position: relative; }
.dd > summary {
    list-style: none; cursor: pointer;
    display: inline-flex; align-items: center; gap: .45rem;
    border: 1px solid var(--line); background: #fff; color: #334155;
    padding: .35rem .7rem; border-radius: 8px; font-size: .875rem;
}
.dd > summary::-webkit-details-marker { display: none; }
.dd > summary::after { content: '\25BE'; font-size: .7rem; opacity: .6; }
.dd > summary:hover { border-color: #cbd5e1; background: #f8fafc; }
.dd[open] > summary { border-color: var(--brand); color: var(--brand-dark); }
.dd-menu {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 1050;
    min-width: 210px; padding: .35rem;
    background: #fff; border: 1px solid var(--line); border-radius: 12px;
    box-shadow: 0 10px 30px rgba(15,23,42,.12);
}
.dd-menu.dd-menu-start { right: auto; left: 0; }
.dd-menu a, .dd-menu button {
    display: flex; align-items: center; gap: .55rem; width: 100%;
    padding: .5rem .6rem; border: 0; background: none; border-radius: 8px;
    color: var(--ink); font-size: .9rem; text-align: start; cursor: pointer;
}
.dd-menu a:hover, .dd-menu button:hover { background: #f1f5f9; }
.dd-menu a.is-active { background: var(--brand-light); color: var(--brand-dark); font-weight: 600; }
.dd-menu .dd-header { padding: .5rem .6rem; font-size: .8rem; color: var(--muted); }
.dd-menu .dd-divider { height: 1px; background: var(--line); margin: .3rem 0; }
.dd-menu .text-danger { color: #dc2626 !important; }

/* front-end navbar variant */
.navbar .dd > summary { border-color: transparent; background: transparent; }
.navbar .dd > summary:hover { background: #f1f5f9; }

/* mobile navbar toggle handled by app.js */
.nav-collapse.is-open { display: block !important; }

.page-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.45rem; font-weight: 700; margin: 0; }
.page-head p { color: var(--muted); margin: .15rem 0 0; font-size: .9rem; }

.stat-card { border-radius: var(--radius); padding: 1.1rem 1.2rem; background: #fff; border: 1px solid var(--line); display: flex; gap: 1rem; align-items: center; }
.stat-card .icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.2rem; flex: none; }
.stat-card .value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-card .label { color: var(--muted); font-size: .82rem; margin-top: .2rem; }

.table > :not(caption) > * > * { padding: .7rem .75rem; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--bg-soft); }
.table-hover tbody tr:hover { background: #f1f5f9; }

.filter-bar { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1.25rem; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .85rem; }
.media-tile { position: relative; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.media-tile img, .media-tile video { width: 100%; height: 130px; object-fit: cover; display: block; background: #0f172a; }
.media-tile .meta { padding: .5rem .6rem; font-size: .75rem; color: var(--muted); }
.media-tile .meta .fname { color: var(--ink); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-tile .remove {
    position: absolute; top: 6px; right: 6px;
    border: 0; border-radius: 8px;
    background: rgba(15,23,42,.75); color: #fff;
    width: 28px; height: 28px; display: grid; place-items: center;
}
.media-tile .remove:hover { background: #dc2626; }
.file-tile { display: flex; align-items: center; gap: .7rem; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.file-tile .fi { font-size: 1.5rem; color: var(--brand); }

.avatar-lg { width: 64px; height: 64px; border-radius: 16px; background: var(--brand-light); color: var(--brand-dark); display: grid; place-items: center; font-size: 1.4rem; font-weight: 700; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state i { font-size: 2.5rem; opacity: .35; display: block; margin-bottom: .75rem; }

.bar-track { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--brand); border-radius: 99px; }

@media (max-width: 991.98px) {
    .admin-sidebar {
        position: fixed; z-index: 1040; left: -280px;
        transition: left .22s ease;
        box-shadow: 0 0 40px rgba(0,0,0,.3);
    }
    .admin-sidebar.open { left: 0; }
    .sidebar-backdrop {
        position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 1030;
    }
    .admin-content { padding: 1rem; }
}

@media print {
    .admin-sidebar, .admin-topbar, .no-print { display: none !important; }
    .admin-content { padding: 0; }
}
