/* ============================================================
   Hotel Wood Stone ERP — Navigation Shell CSS
   Phase 19 | v4.37.0 | nav-shell.css

   Sections
   ─────────
   1. CSS Custom Properties (shell tokens)
   2. App layout grid
   3. Sidebar
   4. Header
   5. Footer
   6. Apple glassmorphism user menu
   7. Search modal
   8. Page transitions
   9. Responsive breakpoints
   ============================================================ */

/* ── 1. Shell tokens ─────────────────────────────────────── */
:root {
  /* Sidebar */
  --shell-sidebar-w:          240px;
  --shell-sidebar-collapsed:  64px;
  --shell-sidebar-bg:         rgba(14, 14, 22, 0.97);
  --shell-sidebar-border:     rgba(255, 255, 255, 0.06);
  --shell-sidebar-item-h:     40px;
  --shell-sidebar-radius:     8px;
  --shell-sidebar-active-bg:  rgba(139, 92, 246, 0.18);
  --shell-sidebar-active-bar: #8b5cf6;
  --shell-sidebar-hover-bg:   rgba(255, 255, 255, 0.05);
  --shell-sidebar-text:       rgba(255, 255, 255, 0.65);
  --shell-sidebar-text-active:rgba(255, 255, 255, 0.95);
  --shell-sidebar-icon-size:  18px;

  /* Header */
  --shell-header-h:           58px;
  --shell-header-bg:          rgba(16, 16, 26, 0.92);
  --shell-header-border:      rgba(255, 255, 255, 0.07);
  --shell-header-blur:        backdrop-filter: blur(20px) saturate(180%);

  /* Footer */
  --shell-footer-h:           38px;
  --shell-footer-bg:          rgba(12, 12, 20, 0.95);
  --shell-footer-border:      rgba(255, 255, 255, 0.06);
  --shell-footer-text:        rgba(255, 255, 255, 0.35);
  --shell-footer-text-hi:     rgba(255, 255, 255, 0.6);

  /* User menu */
  --um-w:        288px;
  --um-bg:       rgba(22, 22, 34, 0.96);
  --um-border:   rgba(255, 255, 255, 0.10);
  --um-blur:     blur(24px) saturate(180%);
  --um-radius:   14px;
  --um-shadow:   0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255,255,255,0.06);
  --um-item-h:   40px;
  --um-item-radius: 8px;
}

/* ── 2. App layout grid ──────────────────────────────────── */
body {
  display: grid;
  grid-template-columns: var(--shell-sidebar-w) 1fr;
  grid-template-rows: var(--shell-header-h) 1fr var(--shell-footer-h);
  grid-template-areas:
    "sidebar  header"
    "sidebar  main"
    "sidebar  footer";
  min-height: 100vh;
  transition: grid-template-columns 0.25s ease;
}

body.sidebar-collapsed {
  grid-template-columns: var(--shell-sidebar-collapsed) 1fr;
}

/* Pages that use no sidebar (login, access-denied) */
body.no-shell {
  display: block;
}

/* app-main wrapper injected by process_category_c */
.app-main {
  grid-area: main;
  overflow-y: auto;
  padding: 24px;
}

/* ── 3. Sidebar ──────────────────────────────────────────── */
#appSidebar,
.app-sidebar {
  grid-area: sidebar;
  position: sticky;
  top: 0;
  height: 100vh;
  width: var(--shell-sidebar-w);
  background: var(--shell-sidebar-bg);
  border-right: 1px solid var(--shell-sidebar-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  z-index: 200;
  transition: width 0.25s ease;
}
#appSidebar::-webkit-scrollbar { display: none; }

body.sidebar-collapsed #appSidebar {
  width: var(--shell-sidebar-collapsed);
}

/* Sidebar brand / logo */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 12px;
  text-decoration: none;
  flex-shrink: 0;
}
.sidebar-brand-text {
  font-size: 15px;
  font-weight: 700;
  color: rgba(255,255,255,0.92);
  letter-spacing: -0.02em;
  white-space: nowrap;
  transition: opacity 0.2s;
}
body.sidebar-collapsed .sidebar-brand-text { opacity: 0; pointer-events: none; }

/* Nav sections */
.sidebar-section-label {
  padding: 12px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.28);
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s;
}
body.sidebar-collapsed .sidebar-section-label { opacity: 0; }

/* Nav items */
.sidebar-nav,
#sidebarNav {
  flex: 1;
  padding: 0 8px;
  list-style: none;
  margin: 0;
}
.sidebar-nav a,
#sidebarNav a {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--shell-sidebar-item-h);
  padding: 0 10px;
  border-radius: var(--shell-sidebar-radius);
  color: var(--shell-sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 450;
  white-space: nowrap;
  overflow: hidden;
  transition: background 0.15s, color 0.15s;
  position: relative;
}
.sidebar-nav a:hover,
#sidebarNav a:hover {
  background: var(--shell-sidebar-hover-bg);
  color: var(--shell-sidebar-text-active);
}
.sidebar-nav a.active,
#sidebarNav a.active {
  background: var(--shell-sidebar-active-bg);
  color: var(--shell-sidebar-text-active);
  font-weight: 600;
}
.sidebar-nav a.active::before,
#sidebarNav a.active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--shell-sidebar-active-bar);
  border-radius: 0 2px 2px 0;
}
.sidebar-nav a .nav-icon,
#sidebarNav a .nav-icon {
  width: var(--shell-sidebar-icon-size);
  height: var(--shell-sidebar-icon-size);
  flex-shrink: 0;
  opacity: 0.7;
}
.sidebar-nav a.active .nav-icon,
#sidebarNav a.active .nav-icon { opacity: 1; }

/* Sidebar overlay (mobile) */
#sidebarOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
  backdrop-filter: blur(2px);
}
#sidebarOverlay.visible { display: block; }

/* ── 4. Header ───────────────────────────────────────────── */
#appHeader,
.app-header {
  grid-area: header;
  position: sticky;
  top: 0;
  height: var(--shell-header-h);
  background: var(--shell-header-bg);
  backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--shell-header-border);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px 0 16px;
  z-index: 150;
}

/* Breadcrumb */
.header-breadcrumb {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: rgba(255,255,255,0.45);
  min-width: 0;
}
.header-breadcrumb-page {
  color: rgba(255,255,255,0.85);
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Header controls */
.header-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}
.header-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.55);
  transition: background 0.15s, color 0.15s;
}
.header-icon-btn:hover {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.9);
}

/* Profile avatar button */
#headerProfileBtn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  border: 2px solid rgba(255,255,255,0.12);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  position: relative;
  transition: transform 0.15s;
  margin-left: 4px;
}
#headerProfileBtn:hover { transform: scale(1.05); }

/* Shift badge on profile */
#headerShiftBadge {
  position: absolute;
  bottom: -3px; right: -3px;
  padding: 1px 5px;
  border-radius: 10px;
  font-size: 8px;
  font-weight: 700;
  background: rgba(34,197,94,0.85);
  color: #fff;
  display: none;
  white-space: nowrap;
}

/* ── 5. Footer ───────────────────────────────────────────── */
.app-footer {
  grid-area: footer;
  height: var(--shell-footer-h);
  background: var(--shell-footer-bg);
  border-top: 1px solid var(--shell-footer-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 16px;
  font-size: 11px;
  color: var(--shell-footer-text);
  z-index: 100;
}

.footer-left, .footer-center, .footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}
.footer-center { justify-content: center; }
.footer-right  { justify-content: flex-end; }

.footer-item { display: flex; align-items: center; gap: 4px; }
.footer-label { color: rgba(255,255,255,0.2); }
.footer-value { color: var(--shell-footer-text-hi); font-variant-numeric: tabular-nums; }
.footer-sep   { color: rgba(255,255,255,0.15); }

/* Status dot */
.footer-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34,197,94,0.6);
  display: inline-block;
}
.footer-dot.dot--dev { background: #f59e0b; box-shadow: 0 0 6px rgba(245,158,11,0.6); }

/* Environment badge */
.footer-env-badge {
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(34,197,94,0.15);
  color: #22c55e;
  border: 1px solid rgba(34,197,94,0.25);
}
.footer-env-badge[data-env="development"] {
  background: rgba(245,158,11,0.15);
  color: #f59e0b;
  border-color: rgba(245,158,11,0.25);
}

/* Sync icon */
.footer-sync-icon {
  width: 12px; height: 12px;
  stroke: currentColor; fill: none;
  stroke-width: 1.5;
}
.footer-user-icon {
  width: 12px; height: 12px;
  stroke: currentColor; fill: none;
  stroke-width: 1.5;
}

/* ── 6. Apple glassmorphism user menu ────────────────────── */
#user-menu-dropdown,
.user-menu-dropdown {
  position: absolute;
  top: calc(var(--shell-header-h) + 6px);
  right: 16px;
  width: var(--um-w);
  background: var(--um-bg);
  backdrop-filter: var(--um-blur);
  -webkit-backdrop-filter: var(--um-blur);
  border: 1px solid var(--um-border);
  border-radius: var(--um-radius);
  box-shadow: var(--um-shadow);
  overflow: hidden;
  z-index: 1000;
  opacity: 0;
  transform: translateY(-8px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
#user-menu-dropdown.open,
.user-menu-dropdown.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* User identity block */
.um-identity {
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.um-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.um-name { font-size: 14px; font-weight: 600; color: rgba(255,255,255,0.92); }
.um-designation { font-size: 11px; color: rgba(255,255,255,0.4); margin-top: 1px; }

/* Shift row */
.um-shift-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 12px;
  color: rgba(255,255,255,0.5);
}
.um-shift-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}
.um-shift-label { color: rgba(255,255,255,0.7); font-weight: 500; }
.um-shift-time  { margin-left: auto; font-size: 11px; font-variant-numeric: tabular-nums; }

/* Menu groups */
.um-group {
  padding: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.um-group:last-of-type { border-bottom: none; }

/* Menu items */
.um-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--um-item-h);
  padding: 0 10px;
  border-radius: var(--um-item-radius);
  cursor: pointer;
  font-size: 13.5px;
  color: rgba(255,255,255,0.75);
  transition: background 0.12s, color 0.12s;
  user-select: none;
  -webkit-user-select: none;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
}
.um-item:hover {
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.95);
}
.um-item-icon {
  width: 16px; height: 16px;
  flex-shrink: 0;
  opacity: 0.65;
}
.um-item:hover .um-item-icon { opacity: 1; }
.um-item-label { flex: 1; }

/* Accent colors */
.um-item--red:hover     { background: rgba(239,68,68,0.12);  color: #f87171; }
.um-item--gold:hover    { background: rgba(234,179,8,0.12);  color: #fbbf24; }
.um-item--blue:hover    { background: rgba(59,130,246,0.12); color: #60a5fa; }
.um-item--green:hover   { background: rgba(34,197,94,0.12);  color: #4ade80; }
.um-item--purple:hover  { background: rgba(139,92,246,0.12); color: #a78bfa; }
.um-item--orange:hover  { background: rgba(249,115,22,0.12); color: #fb923c; }
.um-item--teal:hover    { background: rgba(20,184,166,0.12); color: #2dd4bf; }

/* Theme toggle row */
.um-item--toggle {
  justify-content: space-between;
}
.um-toggle-track {
  width: 32px; height: 18px;
  border-radius: 9px;
  background: rgba(255,255,255,0.12);
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
}
.um-item[aria-checked="true"] .um-toggle-track {
  background: #8b5cf6;
}
.um-toggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.um-item[aria-checked="true"] .um-toggle-thumb {
  transform: translateX(14px);
}

/* Version watermark */
.um-version {
  display: block;
  text-align: center;
  padding: 8px 16px;
  font-size: 10px;
  color: rgba(255,255,255,0.18);
}

/* ── 7. Search modal ─────────────────────────────────────── */
#searchModal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
}
#searchModal.open { display: flex; }

.search-modal-box {
  width: 100%;
  max-width: 560px;
  background: rgba(22,22,34,0.96);
  backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.7);
  overflow: hidden;
  animation: searchIn 0.18s ease;
}
@keyframes searchIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.search-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.search-input-row input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 16px;
  color: rgba(255,255,255,0.9);
  caret-color: #8b5cf6;
}
.search-input-row input::placeholder { color: rgba(255,255,255,0.3); }

/* ── 8. Page transitions ─────────────────────────────────── */
@keyframes hwsPageEnter {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes hwsPageExit {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-6px); }
}
body.page-enter .app-main,
body.page-enter main {
  animation: hwsPageEnter 0.22s ease forwards;
}
body.page-exit .app-main,
body.page-exit main {
  animation: hwsPageExit 0.18s ease forwards;
}

/* Hide legacy standalone topbars replaced by shell header */
[data-nav-replaced="true"] { display: none !important; }

/* ── 9. Responsive ───────────────────────────────────────── */
@media (max-width: 1024px) {
  body {
    grid-template-columns: 0 1fr;
    grid-template-areas:
      "header  header"
      "main    main"
      "footer  footer";
  }
  body.sidebar-collapsed {
    grid-template-columns: 0 1fr;
  }

  #appSidebar, .app-sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--shell-sidebar-w);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 300;
  }
  #appSidebar.open, .app-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0,0,0,0.5);
  }

  #appHeader, .app-header {
    grid-column: 1 / -1;
  }

  .app-main {
    grid-column: 1 / -1;
    padding: 16px;
  }

  .app-footer {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  :root {
    --shell-header-h: 52px;
    --shell-footer-h: 34px;
  }

  .app-main { padding: 12px; }

  .footer-center { display: none; }

  #headerProfileBtn { width: 30px; height: 30px; font-size: 10px; }

  #user-menu-dropdown, .user-menu-dropdown {
    right: 8px;
    left: 8px;
    width: auto;
    max-width: 100%;
  }
}

@media (max-width: 400px) {
  .app-main { padding: 10px 8px; }
  .footer-right .footer-copy { display: none; }
}

/* ── Print ───────────────────────────────────────────────── */
@media print {
  #appSidebar, .app-sidebar,
  #appHeader,  .app-header,
  .app-footer  { display: none !important; }
  body {
    display: block;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }
  .app-main { padding: 0; }
}
