/*
 * Overlays ขั้นสูง / Notifications / Navigation ขั้นสูง — component ใหม่ (ออกแบบเพิ่มให้ครบตาม
 * COMPONENT_REGISTRY ไม่ได้สกัดจากไฟล์ preview ต้นฉบับ) ใช้ token/pattern เดียวกับ components.css
 * ต้องโหลดหลัง tokens.css และ components.css
 */

/* ===== Tooltip ===== */
.oc-tooltip { position: relative; display: inline-flex; }
.oc-tooltip-bubble { position: absolute; z-index: 60; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%) translateY(4px); padding: 6px 10px; border-radius: 8px; background: var(--brand-900); color: #fff; font-size: 12px; font-weight: 700; white-space: nowrap; box-shadow: var(--shadow-md); opacity: 0; pointer-events: none; transition: opacity .12s ease, transform .12s ease; }
.oc-tooltip-bubble::after { content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 5px solid transparent; border-top-color: var(--brand-900); }
.oc-tooltip:hover .oc-tooltip-bubble, .oc-tooltip:focus-within .oc-tooltip-bubble { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Popover ===== */
.popover-wrap { position: relative; display: inline-flex; }
.popover-panel { position: absolute; z-index: 40; top: calc(100% + 8px); left: 0; width: 260px; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-md); display: none; }
.popover-panel.open { display: block; }
.popover-panel h4 { margin: 0 0 6px; font-size: 13px; }
.popover-panel p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }

/* ===== Context menu ===== */
.context-menu { position: fixed; z-index: 90; min-width: 190px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); display: none; }
.context-menu.open { display: block; }
.context-menu button { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border: 0; border-radius: 7px; background: transparent; text-align: left; font-size: 13px; color: var(--text); }
.context-menu button:hover { background: var(--surface-muted); }
.context-menu button.danger { color: var(--danger); }
.context-menu hr { margin: 5px 2px; border: 0; border-top: 1px solid var(--border); }

/* ===== Command palette ===== */
.command-palette-backdrop { position: fixed; inset: 0; z-index: 130; display: none; align-items: flex-start; justify-content: center; padding: 90px 18px 18px; background: rgba(5, 12, 22, .55); backdrop-filter: blur(3px); }
.command-palette-backdrop.open { display: flex; }
.command-palette { width: min(560px, 100%); max-height: 70vh; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; }
.command-palette-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.command-palette-input svg { color: var(--muted); flex: 0 0 auto; }
.command-palette-input input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 15px; color: var(--text); }
.command-palette-input kbd { padding: 2px 6px; border: 1px solid var(--border); border-radius: 5px; font-size: 11px; color: var(--muted); }
.command-palette-list { overflow: auto; padding: 8px; }
.command-palette-list .group-label { padding: 8px 10px 4px; font-size: 11px; font-weight: 800; letter-spacing: .04em; color: var(--muted); text-transform: uppercase; }
.command-palette-list button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; border: 0; border-radius: 9px; background: transparent; text-align: left; color: var(--text); font-size: 13px; }
.command-palette-list button:hover, .command-palette-list button.active { background: var(--primary-soft); color: var(--primary); }
.command-palette-list button[hidden] { display: none; }
.command-palette-list button i { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: var(--surface-muted); flex: 0 0 auto; }
.command-palette-list button small { margin-left: auto; color: var(--muted); }

/* ===== Notification center ===== */
.notif-bell { position: relative; }
.notif-bell .notif-dot { position: absolute; top: 6px; right: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); border: 2px solid var(--surface); }
.notif-panel { position: absolute; z-index: 40; top: calc(100% + 8px); right: 0; width: 340px; max-height: 420px; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); display: none; }
.notif-panel.open { display: flex; }
.notif-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 15px; border-bottom: 1px solid var(--border); }
.notif-panel-head strong { font-size: 14px; }
.notif-panel-head button { border: 0; background: transparent; color: var(--primary); font-size: 12px; font-weight: 700; }
.notif-list { overflow: auto; }
.notif-item { display: flex; gap: 11px; padding: 12px 15px; border-bottom: 1px solid var(--border); }
.notif-item:last-child { border-bottom: 0; }
.notif-item.unread { background: color-mix(in srgb, var(--primary-soft) 45%, transparent); }
.notif-item i { width: 34px; height: 34px; flex: 0 0 auto; border-radius: 50%; display: grid; place-items: center; background: var(--info-soft); color: var(--info); }
.notif-item i.success { background: var(--success-soft); color: var(--success); }
.notif-item i.warning { background: var(--warning-soft); color: var(--warning); }
.notif-item i.danger { background: var(--danger-soft); color: var(--danger); }
.notif-item div { min-width: 0; }
.notif-item strong { display: block; font-size: 13px; }
.notif-item p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.notif-item small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }

/* ===== In-app banner ===== */
.app-banner { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-radius: 10px; background: var(--info-soft); color: var(--info); font-size: 13px; }
.app-banner.warning { background: var(--warning-soft); color: var(--warning); }
.app-banner.danger { background: var(--danger-soft); color: var(--danger); }
.app-banner.success { background: var(--success-soft); color: var(--success); }
.app-banner strong { color: var(--text); }
.app-banner .banner-close { margin-left: auto; flex: 0 0 auto; border: 0; background: transparent; color: inherit; width: 24px; height: 24px; border-radius: 50%; opacity: .7; }
.app-banner .banner-close:hover { opacity: 1; background: rgba(0, 0, 0, .06); }

/* ===== Sidebar nav (reusable, ไม่ผูกกับ app shell เฉพาะหน้า) ===== */
.oc-sidebar-nav { display: grid; gap: 2px; }
.oc-sidebar-nav .nav-group-label { padding: 12px 10px 6px; font-size: 11px; font-weight: 800; letter-spacing: .05em; color: var(--muted); text-transform: uppercase; }
.oc-sidebar-nav a, .oc-sidebar-nav button.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; border-radius: 9px; background: transparent; color: var(--text-soft); font-weight: 700; font-size: 13px; text-decoration: none; }
.oc-sidebar-nav a:hover, .oc-sidebar-nav button.nav-link:hover { background: var(--surface-muted); color: var(--text); }
.oc-sidebar-nav a.active, .oc-sidebar-nav button.nav-link.active { background: var(--primary-soft); color: var(--primary); }
.oc-sidebar-nav svg { flex: 0 0 auto; width: 18px; height: 18px; }
.oc-sidebar-nav .nav-badge { margin-left: auto; }
.oc-sidebar-nav .nav-group { display: grid; gap: 2px; }
.oc-sidebar-nav .nav-group > button.nav-link svg.chevron { margin-left: auto; width: 14px; height: 14px; transition: transform .15s ease; }
.oc-sidebar-nav .nav-group.open > button.nav-link svg.chevron { transform: rotate(90deg); }
.oc-sidebar-nav .nav-subitems { display: none; padding-left: 30px; gap: 2px; }
.oc-sidebar-nav .nav-group.open .nav-subitems { display: grid; }
.oc-sidebar-nav .nav-subitems a { font-weight: 600; font-size: 12.5px; padding: 7px 10px; }

/* ===== Vertical stepper nav (สำหรับฟอร์มหลายขั้นตอน) ===== */
.stepper-nav { display: grid; gap: 0; }
.stepper-nav li { list-style: none; display: grid; grid-template-columns: auto 1fr; gap: 12px; position: relative; padding-bottom: 22px; }
.stepper-nav li:not(:last-child):after { content: ""; position: absolute; left: 15px; top: 34px; bottom: 2px; width: 2px; background: var(--border); }
.stepper-nav li.done:not(:last-child):after { background: var(--success); }
.stepper-nav li > i { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-muted); border: 2px solid var(--border); font-weight: 800; font-style: normal; font-size: 13px; z-index: 1; }
.stepper-nav li.done > i { background: var(--success); border-color: var(--success); color: #fff; }
.stepper-nav li.current > i { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 0 0 5px var(--primary-soft); }
.stepper-nav li button.step-label { border: 0; background: transparent; text-align: left; padding: 3px 0 0; }
.stepper-nav li strong { display: block; font-size: 13px; }
.stepper-nav li small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ===== Mega menu ===== */
.mega-menu-wrap { position: relative; }
.mega-menu-panel { position: absolute; z-index: 40; top: calc(100% + 10px); left: 0; width: min(620px, 90vw); padding: 20px; display: none; grid-template-columns: repeat(3, 1fr); gap: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); }
.mega-menu-panel.open { display: grid; }
.mega-menu-col h4 { margin: 0 0 10px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.mega-menu-col a { display: block; padding: 6px 0; color: var(--text-soft); text-decoration: none; font-size: 13px; }
.mega-menu-col a:hover { color: var(--primary); }

/* ===== Breadcrumb with dropdown ===== */
.breadcrumb-dropdown { position: relative; display: inline-flex; }
.breadcrumb-dropdown > button { border: 0; background: transparent; color: var(--muted); font-size: 13px; display: inline-flex; align-items: center; gap: 3px; }
.breadcrumb-dropdown > button:hover { color: var(--text); }
.breadcrumb-dropdown-list { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; min-width: 180px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-md); display: none; }
.breadcrumb-dropdown-list.open { display: block; }
.breadcrumb-dropdown-list a { display: block; padding: 7px 10px; border-radius: 7px; color: var(--text); font-size: 13px; text-decoration: none; }
.breadcrumb-dropdown-list a:hover { background: var(--surface-muted); }

@media (max-width: 500px) {
  .notif-panel { position: fixed; top: auto; bottom: 0; left: 0; right: 0; width: 100%; max-height: 80dvh; border-radius: 16px 16px 0 0; }
  .mega-menu-panel { grid-template-columns: 1fr; width: min(320px, 92vw); }
}
