/* ═══════════════════════════════════════════════════
   KAPISH WEB — Responsive Layout
   ═══════════════════════════════════════════════════ */

#app-root {
  min-height: 100vh;
  background: var(--bg);
}

/* ── Auth ────────────────────────────────────────── */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

/* ── App layout ──────────────────────────────────── */
.app-layout {
  min-height: 100vh;
  display: flex;
}

/* ── Sidebar ─────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow: hidden;
  transition: width .2s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 18px var(--space-4);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  white-space: nowrap;
}
.logo-icon {
  width: 34px; height: 34px;
  background: var(--grad);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.logo-text {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 800;
  color: var(--text); letter-spacing: -.02em;
}
.logo-tag {
  font-size: 9px; font-weight: 800;
  background: var(--grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: .1em;
  margin-top: 3px;
}

.sidebar-biz-switcher {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-footer {
  padding: var(--space-3);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-logout-btn {
  width: 100%;
  display: flex; align-items: center; gap: var(--space-2);
  padding: 9px var(--space-3);
  border-radius: var(--radius-md);
  font-size: 13px; color: var(--text-3);
  transition: var(--transition);
}
.sidebar-logout-btn:hover { background: rgba(239,68,68,.1); color: #ef4444; }
.sidebar-theme-btn {
  width: 100%;
  display: flex; align-items: center; gap: var(--space-2);
  padding: 9px var(--space-3);
  border-radius: var(--radius-md);
  font-size: 13px; color: var(--text-3);
  transition: var(--transition);
  margin-bottom: 2px;
}
.sidebar-theme-btn:hover { background: var(--surface-2); color: var(--text-2); }

/* ── Nav items ───────────────────────────────────── */
.nav-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 9px var(--space-3);
  border-radius: var(--radius-md);
  font-size: 13px; font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  width: 100%;
  text-align: left;
  border: none; background: none;
}
.nav-item:hover { background: var(--surface-2); color: var(--text-2); }
.nav-item.active {
  background: rgba(138,100,255,.15);
  color: var(--violet);
  font-weight: 700;
}
.nav-icon { font-size: 16px; flex-shrink: 0; width: 22px; text-align: center; }
.nav-label { flex: 1; }

/* ── Main content ────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.page-container {
  flex: 1;
  padding: var(--space-6) var(--space-6);
  width: 100%;
}

/* ── Mobile header ───────────────────────────────── */
.mobile-header {
  display: none;
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--mobile-header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-3);
  z-index: 200;
}
.mobile-menu-btn {
  width: 36px; height: 36px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 5px;
  border-radius: var(--radius-md);
}
.mobile-menu-btn span {
  display: block; width: 20px; height: 2px;
  background: var(--text-2); border-radius: 1px;
  transition: var(--transition);
}
.mobile-biz-name {
  flex: 1;
  font-family: var(--font-display);
  font-size: 16px; font-weight: 800; color: var(--text);
}
.mobile-header-actions { display: flex; gap: 4px; }
.mobile-icon-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md); font-size: 16px;
  transition: var(--transition);
}
.mobile-icon-btn:hover { background: var(--surface-2); }

/* ── Mobile drawer ───────────────────────────────── */
.mobile-nav-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0);
  z-index: 300;
  transition: background .25s;
  pointer-events: none;
}
.mobile-nav-overlay.open { background: rgba(0,0,0,.65); pointer-events: all; }

.mobile-nav-drawer {
  position: fixed; top: 0; left: 0;
  width: 76vw; max-width: 300px; height: 100vh;
  background: linear-gradient(160deg, #13101f 0%, #0d0920 100%);
  border-right: 1px solid rgba(138,100,255,.15);
  z-index: 301;
  transform: translateX(-100%);
  transition: transform .3s cubic-bezier(.25,.8,.25,1);
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 4px 0 32px rgba(0,0,0,.6);
}
.mobile-nav-drawer.open { transform: translateX(0); }

.drawer-header {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 18px var(--space-4);
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
  background: rgba(138,100,255,.05);
}
.drawer-header .logo-icon {
  width: 36px; height: 36px; font-size: 18px;
  box-shadow: 0 0 16px rgba(138,100,255,.4);
}
.drawer-header .logo-text { font-size: 17px; }
.drawer-close {
  margin-left: auto;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  font-size: 14px; color: var(--text-3);
  transition: var(--transition);
}
.drawer-close:hover { background: rgba(239,68,68,.15); color: #ef4444; border-color: rgba(239,68,68,.2); }

.drawer-biz-switcher {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}

.drawer-nav {
  flex: 1; overflow-y: auto;
  padding: var(--space-3) var(--space-3);
  display: flex; flex-direction: column; gap: 3px;
}
.drawer-nav::-webkit-scrollbar { width: 3px; }
.drawer-nav::-webkit-scrollbar-thumb { background: rgba(138,100,255,.2); border-radius: 2px; }

/* Override nav-item inside drawer for better mobile look */
.drawer-nav .nav-item {
  padding: 12px var(--space-3);
  border-radius: var(--radius-md);
  font-size: 14px; font-weight: 500;
  gap: var(--space-3);
}
.drawer-nav .nav-item .nav-icon { font-size: 18px; width: 26px; }
.drawer-nav .nav-item.active {
  background: linear-gradient(135deg, rgba(138,100,255,.18), rgba(236,72,153,.08));
  border: 1px solid rgba(138,100,255,.2);
  color: var(--violet);
}
.drawer-nav .nav-item:not(.active):hover {
  background: rgba(255,255,255,.05);
  color: var(--text-2);
}

/* Drawer footer with account + logout */
.drawer-footer {
  padding: var(--space-3) var(--space-3);
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex; flex-direction: column; gap: 3px;
  flex-shrink: 0;
}
.drawer-footer-btn {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 11px var(--space-3);
  border-radius: var(--radius-md);
  font-size: 13px; font-weight: 500;
  border: none; background: none;
  color: var(--text-3);
  cursor: pointer; transition: var(--transition);
  width: 100%; text-align: left;
}
.drawer-footer-btn:hover { background: rgba(255,255,255,.05); color: var(--text-2); }
.drawer-footer-btn.danger:hover { background: rgba(239,68,68,.1); color: #ef4444; }
.drawer-footer-btn .nav-icon { font-size: 16px; width: 22px; }

/* ── Bottom nav ──────────────────────────────────── */
.bottom-nav-web {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  background: rgba(16,12,31,.96);
  border-top: 1px solid rgba(138,100,255,.12);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 200;
  align-items: stretch;
  /* scrollable row so ALL items are accessible */
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav-web::-webkit-scrollbar { display: none; }

/* Scroll indicator fade on right edge */
.bottom-nav-web::after {
  content: '';
  position: sticky; right: 0; top: 0;
  min-width: 20px; height: 100%;
  background: linear-gradient(to left, rgba(16,12,31,.9), transparent);
  pointer-events: none;
  flex-shrink: 0;
}

.bottom-nav-item {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  padding: 6px 0;
  border-radius: 0;
  cursor: pointer; transition: var(--transition);
  min-width: 62px;
  flex-shrink: 0;
  border: none; background: none;
  scroll-snap-align: start;
  position: relative;
}
.bottom-nav-item::before {
  content: '';
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 0; height: 2px;
  background: var(--grad);
  border-radius: 0 0 2px 2px;
  transition: width .2s ease;
}
.bottom-nav-item.active::before { width: 28px; }
.bottom-nav-item .bn-icon {
  font-size: 20px;
  transition: transform .2s ease;
}
.bottom-nav-item.active .bn-icon { transform: scale(1.15); }
.bottom-nav-item .bn-label {
  font-size: 9px; font-weight: 600;
  color: var(--text-3);
  letter-spacing: .02em;
  line-height: 1.1;
  text-align: center;
  max-width: 58px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bottom-nav-item.active .bn-label {
  color: var(--violet);
  font-weight: 700;
}

/* ── Toast ───────────────────────────────────────── */
.toast-root {
  position: fixed;
  top: var(--space-4); right: var(--space-4);
  z-index: 9999;
  display: flex; flex-direction: column; gap: var(--space-2);
  pointer-events: none;
}

/* ── Modal root ──────────────────────────────────── */
#modal-root {
  position: fixed; inset: 0;
  z-index: 1000;
  pointer-events: none;
}
#modal-root:not(:empty) { pointer-events: all; }

/* ══════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════ */

/* Collapsed sidebar at tablet */
@media (max-width: 1100px) {
  :root { --sidebar-width: 64px; }
  .sidebar-logo { justify-content: center; padding: 18px 0; }
  .logo-text, .logo-tag,
  .sidebar-biz-switcher,
  .nav-label,
  .sidebar-logout-btn span:last-child { display: none; }
  .sidebar-theme-btn span:last-child { display: none; }
  .sidebar-theme-btn { justify-content: center; }
  .nav-item { justify-content: center; padding: 10px 0; }
  .nav-icon { width: auto; }
  .sidebar-footer { padding: var(--space-2); }
  .sidebar-logout-btn { justify-content: center; }
}

/* Mobile */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .mobile-header { display: flex; }
  .mobile-nav-overlay { display: block; }
  .bottom-nav-web { display: flex; }
  .main-content {
    margin-left: 0;
    padding-top: var(--mobile-header-h);
    padding-bottom: var(--bottom-nav-h);
  }
  .page-container { padding: var(--space-4); }
  .toast-root {
    top: calc(var(--mobile-header-h) + var(--space-2));
    right: var(--space-3); left: var(--space-3);
  }
}

@media (max-width: 480px) {
  .page-container { padding: var(--space-3); }
}
