/* UI-U1: โครง layout (sidebar ซ้ายสีครีมอุ่น + topbar บาง) ใช้ตัวแปร --nv-* จาก theme.css; ไม่มีทรัพยากรภายนอก · ธีม Dew Ledger (ขั้น 1) */
:root { --nv-side-w: 248px; --nv-side-w-mini: 68px; --nv-top-h: 58px; }

.nv-body { margin: 0; background: var(--nv-bg); color: var(--nv-ink); font-family: var(--nv-font); }
.nv-shell { min-height: 100vh; }
.nv-ico { flex: none; }

.nv-sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--nv-side-w); z-index: 1040;
    background: var(--nv-card); border-right: 1px solid var(--nv-line);
    display: flex; flex-direction: column; padding: 14px 12px; overflow-y: auto;
    transition: width .15s ease, transform .2s ease;
}
.nv-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; color: var(--nv-green-800); font-weight: 700; text-decoration: none; }
.nv-logo { display: inline-flex; width: 36px; height: 36px; align-items: center; justify-content: center; border-radius: 12px; background: var(--nv-green-800); color: var(--nv-orange-500); flex: none; }
.nv-group-title { font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--nv-muted); padding: 14px 10px 6px; }
.nv-link {
    display: flex; align-items: center; gap: 10px; padding: 9px 10px; margin-bottom: 2px; min-height: 44px;
    border-radius: var(--nv-radius); color: var(--nv-ink); text-decoration: none;
}
.nv-link:hover { background: var(--nv-green-100); color: var(--nv-green-800); }
.nv-link.active { background: var(--nv-green-100); color: var(--nv-green-800); font-weight: 650; box-shadow: inset 3px 0 0 var(--nv-orange-500); }
.nv-link:focus-visible, .nv-collapse:focus-visible, .nv-burger:focus-visible { outline: 3px solid var(--nv-orange-500); outline-offset: 2px; }
.nv-badge { margin-left: auto; background: var(--nv-orange-100); color: var(--nv-gold-ink); font-size: .75rem; font-weight: 700; border-radius: 999px; padding: 1px 9px; }
.nv-collapse {
    margin-top: auto; display: flex; align-items: center; gap: 10px; background: none; border: 0;
    color: var(--nv-muted); padding: 9px 10px; border-radius: var(--nv-radius); cursor: pointer;
}
.nv-collapse:hover { background: var(--nv-green-100); }
.nv-collapse .nv-ico { transition: transform .15s; }

.nv-main { margin-left: var(--nv-side-w); min-height: 100vh; display: flex; flex-direction: column; transition: margin-left .15s ease; }
.nv-topbar {
    position: sticky; top: 0; z-index: 1030; height: var(--nv-top-h); display: flex; align-items: center; gap: 12px;
    padding: 0 20px; background: rgba(251, 248, 240, .86); backdrop-filter: blur(6px); border-bottom: 1px solid var(--nv-line);
}
.nv-title { font-weight: 600; font-size: 1.05rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nv-top-actions { display: flex; align-items: center; gap: 8px; }
.nv-top-actions .btn { display: inline-flex; align-items: center; gap: 6px; }
.nv-problems { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.nv-content { flex: 1; padding: 22px 24px; min-width: 0; }
.nv-footer { padding: 14px 24px; color: var(--nv-muted); font-size: .85rem; }
.nv-burger { display: none; background: none; border: 0; padding: 6px; border-radius: 10px; color: var(--nv-green-800); }
.nv-backdrop { display: none; }

/* ยุบเป็นไอคอน (เดสก์ท็อป) */
.nv-shell.nv-mini .nv-sidebar { width: var(--nv-side-w-mini); }
.nv-shell.nv-mini .nv-main { margin-left: var(--nv-side-w-mini); }
.nv-shell.nv-mini .nv-label, .nv-shell.nv-mini .nv-badge { display: none; }
.nv-shell.nv-mini .nv-link, .nv-shell.nv-mini .nv-collapse, .nv-shell.nv-mini .nv-brand { justify-content: center; }
.nv-shell.nv-mini .nv-collapse .nv-ico { transform: rotate(180deg); }

@media (max-width: 991.98px) {
    .nv-sidebar { transform: translateX(-100%); width: min(280px, 82vw); box-shadow: var(--nv-shadow); }
    .nv-shell.nv-open .nv-sidebar { transform: none; }
    .nv-shell.nv-open .nv-backdrop { display: block; position: fixed; inset: 0; background: rgba(20, 45, 30, .35); z-index: 1035; }
    .nv-main, .nv-shell.nv-mini .nv-main { margin-left: 0; }
    .nv-shell.nv-mini .nv-sidebar { width: min(280px, 82vw); }
    .nv-shell.nv-mini .nv-label { display: inline; }
    .nv-shell.nv-mini .nv-badge { display: inline; }
    .nv-shell.nv-mini .nv-link, .nv-shell.nv-mini .nv-brand { justify-content: flex-start; }
    .nv-collapse { display: none; }
    .nv-burger { display: inline-flex; }
    .nv-content { padding: 16px 14px; }
    .nv-topbar { padding: 0 12px; }
}
@media (max-width: 575.98px) {
    .nv-hide-sm { display: none; }
    .nv-user { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .nv-sidebar, .nv-main { transition: none; }
}

/* UI-U2: หัวหน้า/หัวข้อย่อยในหน้า admin (ชื่อหน้าอยู่ใน topbar แล้ว h1 จึงเล็กลง) */
.nv-content h1 { font-size: 1.35rem; font-weight: 700; color: var(--nv-green-800); margin-bottom: .75rem; }
.nv-content h2.h5 { font-weight: 600; margin: 1.25rem 0 .6rem; color: var(--nv-ink); }
.nv-content .breadcrumb { font-size: .85rem; margin-bottom: .6rem; }

/* UI-U3: หน้า login / 2FA (layouts/auth.php) แบ่งสองฝั่ง; มือถือเหลือฝั่งฟอร์มพร้อมแถบแบรนด์บางๆ */
.nv-auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.nv-auth-hero {
    display: flex; flex-direction: column; justify-content: center; padding: 48px 56px;
    background: linear-gradient(160deg, var(--nv-card) 0%, var(--nv-green-200) 55%, var(--nv-green-500) 135%);
    color: var(--nv-green-900);
}
.nv-auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; margin-bottom: 28px; }
.nv-auth-brand .nv-logo { background: var(--nv-green-800); }
.nv-auth-hero h2 { font-size: 2rem; font-weight: 700; margin: 0 0 12px; }
.nv-auth-hero p { margin: 0; color: var(--nv-green-800); }
.nv-auth-panel { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.nv-auth-card { width: 100%; max-width: 440px; padding: 8px 10px; }
.nv-auth-card h1 { font-size: 1.3rem; font-weight: 700; color: var(--nv-green-800); margin-bottom: .6rem; }
.nv-auth-card .row { margin: 0; }
/* view เดิมใส่ col-lg-N ไว้ในฟอร์ม/แถว: ในการ์ดแคบให้เต็มความกว้าง */
.nv-auth-card [class*="col-lg-"]:not(.form-control):not(.form-select) { flex: 0 0 100%; width: 100%; max-width: 100%; padding-left: 0; padding-right: 0; }
.nv-auth-card form.card { border: 0; box-shadow: none; padding: 0; }
.nv-auth-card .col-form-label { padding-left: 0; }
/* ช่องกรอกในการ์ด login/2FA: เว้นขอบในให้ตัวอักษรไม่ชิดกรอบ (กฎ col-lg-* ข้างบนเคยทับ padding ของ .form-control) */
.nv-auth-card .form-control { padding: .7rem .95rem; }
.nv-auth-card .form-control::placeholder { color: var(--nv-muted); }
@media (max-width: 767.98px) {
    .nv-auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    .nv-auth-hero { padding: 22px 20px; }
    .nv-auth-hero h2 { font-size: 1.2rem; }
    .nv-auth-brand { margin-bottom: 10px; }
}

/* UI-U4: หน้า portal (เมล่อน/องุ่น/สตรอว์เบอร์รี) เปลี่ยนแค่ภายนอก — view ข้างในไม่ถูกแก้ ใช้ CSS ห่อ .portal-default-index เป็นการ์ด */
.portal-default-index {
    background: var(--nv-card); border: 1px solid var(--nv-line); border-radius: var(--nv-radius-lg);
    box-shadow: var(--nv-shadow); padding: 18px 20px; min-width: 0;
}
.portal-default-index > h1 { margin-bottom: 1rem; }
/* กล่องสถานะ/สวิตช์ในแถว: view เดิมใช้ .container (กว้างสุดตาม breakpoint) ใน layout ใหม่ให้เต็มคอลัมน์และเป็นการ์ดย่อย */
.portal-default-index .row > [class*="col-"] > .container {
    max-width: none; background: var(--nv-green-50); border: 1px solid var(--nv-line);
    border-radius: var(--nv-radius); padding: 12px 14px;
}
.portal-default-index .form-check-input:checked { background-color: var(--nv-btn); border-color: var(--nv-btn); }
.portal-default-index .form-switch .form-check-input { cursor: pointer; }
@media (max-width: 575.98px) {
    .portal-default-index { padding: 14px 12px; border-radius: var(--nv-radius); }
}
