/* Arishma POS — Layout Shell */

/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

main {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--page-gutter) var(--page-gutter) var(--sp-12);
  width: 100%;
}
.app-main main:has(.pos-page) { max-width: none; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width var(--ease-slow), min-width var(--ease-slow);
  z-index: 20;
  overflow: hidden;
}

/* Brand header */
.sidebar-brand {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  padding: var(--sp-5) var(--sp-4);
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.sidebar-logo {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: var(--r-md);
  background: var(--teal);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: var(--fw-extrabold);
  flex-shrink: 0;
}
.sidebar-brand-text { min-width: 0; overflow: hidden; }
.sidebar-brand strong { display: block; font-size: var(--text-sm); white-space: nowrap; }
.sidebar-brand span { font-size: var(--text-xs); color: var(--faint); white-space: nowrap; }

.sidebar-toggle {
  margin-left: auto;
  width: 28px;
  height: 28px;
  min-height: 28px;
  min-width: 28px;
  padding: 0;
  background: rgba(255,255,255,.08);
  border: none;
  border-radius: var(--r-sm);
  color: var(--faint);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--ease-fast), color var(--ease-fast);
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: rgba(255,255,255,.15); color: #fff; }
.sidebar-toggle svg { width: 16px; height: 16px; transition: transform var(--ease-base); }

/* Navigation */
.sidebar-nav {
  padding: var(--sp-3) var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
}

/* Nav sections */
.nav-group { margin-bottom: var(--sp-1); }
.nav-group:first-child .nav-group-btn { padding-top: var(--sp-2); }

.nav-group-btn {
  width: 100%;
  background: none;
  border: none;
  color: var(--faint);
  font-size: var(--text-xs);
  font-weight: var(--fw-extrabold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: var(--sp-4) var(--sp-3) var(--sp-1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  border-radius: var(--r-sm);
  transition: color var(--ease-fast);
  white-space: nowrap;
  overflow: hidden;
  font-family: inherit;
}
.nav-group-btn:hover { color: rgba(255,255,255,.7); }

.nav-group-chevron {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--ease-base);
  flex-shrink: 0;
}
.nav-group-btn[aria-expanded="false"] .nav-group-chevron { transform: rotate(-90deg); }
.nav-group-items { overflow: hidden; transition: max-height var(--ease-slow); }

/* Nav items */
.nav-ic {
  width: 18px;
  height: 18px;
  min-width: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.sidebar-nav a {
  color: rgba(255,255,255,.65);
  text-decoration: none;
  border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-3);
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  transition: background var(--ease-fast), color var(--ease-fast);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-nav a:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
  text-decoration: none;
}
.sidebar-nav a.active {
  background: rgba(255,255,255,.12);
  color: #fff;
  font-weight: var(--fw-semibold);
}
.sidebar-nav a.active::before {
  content: "";
  width: 3px;
  height: 20px;
  min-width: 3px;
  border-radius: 2px;
  background: var(--teal-bright);
  margin-right: var(--sp-1);
  margin-left: calc(-1 * var(--sp-1));
  flex-shrink: 0;
}

.nav-label { overflow: hidden; text-overflow: ellipsis; }

/* Sidebar footer */
.sidebar-foot {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: var(--text-sm);
  color: var(--faint);
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
}

/* Sidebar card (CTA) */
.sidebar-card {
  margin: var(--sp-3);
  padding: var(--sp-4);
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--r-lg);
  font-size: var(--text-sm);
  line-height: var(--lh-normal);
  flex-shrink: 0;
  overflow: hidden;
}
.sidebar-card b { display: block; margin-bottom: var(--sp-1); }
.sidebar-card p { color: rgba(255,255,255,.5); margin: 0 0 var(--sp-3); }

/* ============================================================
   COLLAPSED SIDEBAR
   ============================================================ */
.sidebar[data-collapsed="true"] {
  width: var(--sidebar-collapsed-w);
  min-width: var(--sidebar-collapsed-w);
}
.sidebar[data-collapsed="true"] .sidebar-brand-text,
.sidebar[data-collapsed="true"] .nav-label,
.sidebar[data-collapsed="true"] .nav-group-btn,
.sidebar[data-collapsed="true"] .sidebar-card,
.sidebar[data-collapsed="true"] .sidebar-foot > span,
.sidebar[data-collapsed="true"] .sidebar-foot .btn { display: none; }
.sidebar[data-collapsed="true"] .nav-group-items { max-height: none !important; }

.sidebar[data-collapsed="true"] .sidebar-brand {
  justify-content: center;
  padding: var(--sp-4) var(--sp-2);
}
.sidebar[data-collapsed="true"] .sidebar-toggle {
  margin-left: 0;
}
.sidebar[data-collapsed="true"] .sidebar-toggle svg { transform: rotate(180deg); }

.sidebar[data-collapsed="true"] .sidebar-nav {
  padding: var(--sp-2);
  align-items: center;
}
.sidebar[data-collapsed="true"] .sidebar-nav a {
  justify-content: center;
  padding: var(--sp-2);
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  gap: 0;
}
.sidebar[data-collapsed="true"] .sidebar-nav a .nav-ic { margin: 0; }
.sidebar[data-collapsed="true"] .sidebar-nav a.active::before { display: none; }
.sidebar[data-collapsed="true"] .sidebar-nav a.active {
  background: var(--teal);
  color: #fff;
}

.sidebar[data-collapsed="true"] .sidebar-foot {
  padding: var(--sp-2);
  text-align: center;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  background: rgba(255,255,255,.97);
  border-bottom: 1px solid var(--border);
  padding: var(--sp-3) var(--page-gutter);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-4);
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: var(--topbar-h);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.topbar-hosted { flex-wrap: wrap; }

:root[data-theme="dark"] .topbar {
  background: rgba(26,35,50,.97);
  border-bottom-color: var(--border);
}

.topbar-left { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.breadcrumb { font-size: var(--text-xs); color: var(--faint); display: block; }
.topbar-title { font-size: var(--text-lg); margin: 1px 0 0; font-weight: var(--fw-bold); }

.topbar-centre { flex: 1; text-align: center; min-width: 0; }
.tenant-badge {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-pill);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}
.tenant-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.topbar-right { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }

/* Icon buttons in topbar */
.topbar-icon-btn {
  width: 36px;
  height: 36px;
  min-height: 36px;
  min-width: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--muted);
  cursor: pointer;
  transition: background var(--ease-fast), color var(--ease-fast), border-color var(--ease-fast);
  position: relative;
}
.topbar-icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--muted);
}

.topbar-btn {
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  text-decoration: none;
  font-weight: var(--fw-semibold);
  font-size: var(--text-sm);
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  transition: background var(--ease-fast), color var(--ease-fast);
}

/* Alert bell */
.alert-bell-wrap { position: relative; display: inline-block; }
.alert-bell {
  width: 36px;
  height: 36px;
  min-height: 36px;
  min-width: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--muted);
  cursor: pointer;
  transition: background var(--ease-fast), color var(--ease-fast);
  position: relative;
}
.alert-bell:hover { background: var(--surface-2); color: var(--ink); }
.alert-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.alert-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  min-width: 260px;
  z-index: 100;
  padding: var(--sp-4);
}
.alert-dropdown.open { display: block; }
.alert-dropdown h4 {
  font-size: var(--text-sm);
  font-weight: var(--fw-bold);
  color: var(--ink);
  margin: 0 0 var(--sp-2);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border-light);
}
.alert-row { display: flex; justify-content: space-between; padding: var(--sp-1) 0; font-size: var(--text-sm); }
.alert-row b { color: var(--danger); }
.alert-link {
  display: block;
  margin-top: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border-light);
  font-size: var(--text-xs);
  color: var(--teal);
}
.alert-link:hover { text-decoration: underline; }

/* Dark mode toggle */
.dark-toggle {
  width: 36px;
  height: 36px;
  min-height: 36px;
  min-width: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  transition: background var(--ease-fast), color var(--ease-fast);
}
.dark-toggle:hover { background: var(--surface-2); color: var(--ink); }

/* User chip + dropdown */
.user-chip {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3) var(--sp-1) var(--sp-1);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  cursor: pointer;
  background: var(--surface);
  transition: background var(--ease-fast), border-color var(--ease-fast);
  min-height: 36px;
}
.user-chip:hover { background: var(--surface-2); border-color: var(--muted); }

.user-avatar {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--fw-extrabold);
  font-size: var(--text-xs);
}
.user-chip strong { font-size: var(--text-sm); font-weight: var(--fw-semibold); }
.user-chip small { color: var(--muted); font-size: var(--text-xs); display: block; }

.user-menu, .user-chip-wrap { position: relative; }
.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  z-index: 100;
  overflow: hidden;
}
.user-dropdown.open { display: block; }
.user-dropdown-header {
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border-light);
}
.user-dropdown-header strong { display: block; font-size: var(--text-base); }
.user-dropdown-header small { color: var(--muted); font-size: var(--text-sm); }
.user-dropdown a {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-sm);
  color: var(--ink);
  transition: background var(--ease-fast);
}
.user-dropdown a:hover { background: var(--surface-2); text-decoration: none; }
.user-dropdown hr { border: none; border-top: 1px solid var(--border-light); margin: 0; }

/* Hamburger (mobile only) */
.hamburger {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink);
  padding: 0;
}

/* Mobile overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,32,64,.5);
  z-index: 19;
  backdrop-filter: blur(4px);
}
.sidebar-overlay.active { display: block; }

/* ============================================================
   LOGIN LAYOUT
   ============================================================ */
.login-main { margin: 0; padding: 0; max-width: none; }
.login-split { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100vh; }
.login-left { background: linear-gradient(135deg, var(--navy) 0%, #162e52 60%, #1e3a5f 100%); color: #fff; padding: var(--sp-16) var(--sp-16) var(--sp-10); }
.login-left h1 { font-size: var(--text-3xl); line-height: 1.05; letter-spacing: -0.02em; margin: var(--sp-8) 0 var(--sp-4); }
.teal-text { color: var(--teal); }
.login-left-sub { color: #cbd5e1; font-size: var(--text-md); line-height: var(--lh-relaxed); max-width: 520px; }
.login-brand { display: flex; gap: var(--sp-3); align-items: center; }
.login-brand strong { display: block; font-size: var(--text-lg); }
.login-brand span { font-size: var(--text-sm); color: #cbd5e1; }
.login-check { display: flex; gap: var(--sp-3); margin: var(--sp-5) 0; max-width: 540px; }
.login-check .check { width: 32px; height: 32px; min-width: 32px; border-radius: 50%; background: var(--teal); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: var(--fw-extrabold); }
.login-check span { color: #cbd5e1; font-size: var(--text-base); line-height: var(--lh-normal); }
.login-right { background: var(--bg); display: flex; align-items: center; justify-content: center; padding: var(--sp-8); }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  padding: var(--sp-8);
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-lg);
}
.login-card h2 { font-size: var(--text-2xl); margin: 0 0 var(--sp-2); font-weight: var(--fw-extrabold); letter-spacing: var(--tracking-tight); }
.login-note { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-4); font-size: var(--text-sm); color: var(--muted); line-height: var(--lh-normal); margin-top: var(--sp-4); }
.login-footer { font-size: var(--text-xs); color: var(--muted); margin-top: var(--sp-4); }
.login-wrap { max-width: 440px; margin: var(--sp-16) auto; background: var(--surface); border-radius: var(--r-xl); padding: var(--sp-8); box-shadow: var(--shadow-lg); }

:root[data-theme="dark"] .login-card { background: var(--surface); border-color: var(--border); }

@media (max-width: 900px) {
  .login-split { grid-template-columns: 1fr; }
  .login-left { padding: var(--sp-8) var(--sp-6); }
  .login-left h1 { font-size: var(--text-2xl); }
  .login-right { order: 1; }
  .login-left { order: 2; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .sidebar { width: 220px; min-width: 220px; }
  .sidebar-brand strong { white-space: normal; font-size: var(--text-xs); }
  .topbar-centre { text-align: left; }
}

@media (max-width: 640px) {
  :root { --page-gutter: 16px; }

  .hamburger { display: inline-flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 280px;
    min-width: 280px;
    transform: translateX(-100%);
    transition: transform var(--ease-slow);
    z-index: 30;
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar[data-collapsed="true"] { width: 280px; min-width: 280px; }
  .sidebar[data-collapsed="true"] .sidebar-brand-text,
  .sidebar[data-collapsed="true"] .nav-label,
  .sidebar[data-collapsed="true"] .nav-group-btn,
  .sidebar[data-collapsed="true"] .sidebar-card,
  .sidebar[data-collapsed="true"] .sidebar-foot > span,
  .sidebar[data-collapsed="true"] .sidebar-foot .btn { display: revert; }
  .sidebar[data-collapsed="true"] .nav-group-items { max-height: none !important; }
  .sidebar[data-collapsed="true"] .sidebar-brand { justify-content: flex-start; padding: var(--sp-5) var(--sp-4); }
  .sidebar[data-collapsed="true"] .sidebar-nav { padding: var(--sp-3); align-items: stretch; }
  .sidebar[data-collapsed="true"] .sidebar-nav a { justify-content: flex-start; padding: var(--sp-2) var(--sp-3); width: auto; height: auto; gap: var(--sp-3); }

  .sidebar-toggle { display: none; }

  .breadcrumb { display: none; }
  .topbar { padding: var(--sp-2) var(--sp-3); min-height: 48px; }
  .topbar-title { font-size: var(--text-md); }

  main { padding: var(--sp-4) var(--page-gutter) var(--sp-10); }
}
