/*
 * Layout (app shell) / Typography / Page Templates — component ใหม่ (ออกแบบเพิ่มให้ครบตาม
 * COMPONENT_REGISTRY ไม่ได้สกัดจากไฟล์ preview ต้นฉบับ) ต้องโหลดหลัง tokens.css และ components.css
 * (ส่วน Charts/Gauges ย้ายไป css/charts.css แล้ว — เป็นของสกัดจริงจากไฟล์ต้นฉบับ ไม่ใช่ของออกแบบใหม่)
 */

/* ===== Typography scale (utility classes ใช้ซ้ำได้) ===== */
.text-display { font-size: clamp(30px, 4vw, 44px); font-weight: 800; letter-spacing: -.03em; line-height: 1.1; margin: 0; }
.text-h1 { font-size: clamp(24px, 3vw, 30px); font-weight: 800; letter-spacing: -.02em; line-height: 1.2; margin: 0; }
.text-h2 { font-size: clamp(19px, 2.4vw, 22px); font-weight: 750; letter-spacing: -.015em; line-height: 1.3; margin: 0; }
.text-h3 { font-size: 16px; font-weight: 700; line-height: 1.35; margin: 0; }
.text-body { font-size: 15px; line-height: 1.6; color: var(--text); margin: 0; }
.text-body-sm { font-size: 13px; line-height: 1.55; color: var(--text-soft); margin: 0; }
.text-caption { font-size: 12px; line-height: 1.5; color: var(--muted); margin: 0; }
.text-overline { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0; }
.text-link { color: var(--primary); text-decoration: none; font-weight: 700; }
.text-link:hover { text-decoration: underline; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ===== App shell (Layout) — reusable, ไม่ผูกกับหน้าใดหน้าหนึ่ง ===== */
.oc-app-shell { display: grid; grid-template-columns: var(--sidebar-width) 1fr; min-height: 100vh; background: var(--canvas); }
.oc-app-sidebar { padding: 18px 14px; background: var(--brand-950); border-right: 1px solid rgba(255, 255, 255, .06); display: flex; flex-direction: column; gap: 18px; }
.oc-app-sidebar .shell-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; color: #fff; font-weight: 800; font-size: 15px; }
.oc-app-sidebar .shell-brand i { width: 32px; height: 32px; border-radius: 9px; background: var(--primary); display: grid; place-items: center; flex: 0 0 auto; }
.oc-app-sidebar .oc-sidebar-nav a, .oc-app-sidebar .oc-sidebar-nav button.nav-link { color: #b9c7d7; }
.oc-app-sidebar .oc-sidebar-nav a:hover, .oc-app-sidebar .oc-sidebar-nav button.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.oc-app-sidebar .oc-sidebar-nav a.active { background: rgba(117, 167, 255, .16); color: #fff; }
.oc-app-sidebar .nav-group-label { color: #6b8299; }
.oc-app-main { min-width: 0; display: flex; flex-direction: column; }
.oc-app-topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 22px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.oc-app-content { flex: 1; padding: 22px; }

@media (max-width: 1024px) {
  .oc-app-shell { grid-template-columns: 1fr; }
  .oc-app-sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width); z-index: 60; transform: translateX(-100%); transition: transform .2s ease; }
  .oc-app-sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  body:not(.itdl-no-sidebar) .oc-app-topbar,
  body:not(.itdl-no-sidebar) .itdl-global-navbar,
  .oc-app-topbar.is-logged-in {
    background: var(--brand-950) !important;
    border-bottom-color: color-mix(in srgb, #fff 10%, transparent) !important;
  }
}

/* ===== Page templates ===== */
.page-template-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-template-head .component-row { gap: 8px; }
.page-list-template { display: grid; gap: 14px; }
.page-detail-template { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; }
.page-dashboard-template { display: grid; gap: 14px; }
.page-dashboard-template .dash-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.page-settings-template { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; }
.page-settings-nav { display: grid; gap: 2px; }
.page-settings-nav a { display: block; padding: 8px 10px; border-radius: 9px; color: var(--text-soft); font-size: 13px; font-weight: 700; text-decoration: none; }
.page-settings-nav a:hover { background: var(--surface-muted); }
.page-settings-nav a.active { background: var(--primary-soft); color: var(--primary); }
.page-settings-section { padding-bottom: 22px; margin-bottom: 22px; border-bottom: 1px solid var(--border); }
.page-settings-section:last-child { border-bottom: 0; margin-bottom: 0; }
.page-settings-section h3 { margin: 0 0 4px; font-size: 15px; }
.page-settings-section p { margin: 0 0 14px; color: var(--muted); font-size: 12.5px; }

@media (max-width: 820px) {
  .page-detail-template, .page-settings-template { grid-template-columns: 1fr; }
}
