/* WAPP — Layout: Staff (mobile-first) + Manager (desktop sidebar) */

/* ─── Staff layout — mobile bottom-nav ──────────────── */
.staff-layout {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  min-height: 100vh;
  background: var(--cream);
}

.staff-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--cream);
  border-bottom: 1px solid rgba(26,26,26,.08);
  padding: var(--sp-4) var(--sp-5);
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  min-height: calc(72px + env(safe-area-inset-top, 0px));
  box-sizing: border-box;
}

.staff-header .header-title {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.staff-header .header-logo {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
}

.staff-header .header-logo span { color: var(--gold); }

.staff-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-5) var(--sp-4);
  padding-bottom: calc(var(--sp-4) + 70px);
}

.staff-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--white);
  border-top: 1px solid rgba(26,26,26,.08);
  display: flex;
  height: 70px;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 20px rgba(26,26,26,.06);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--ink-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  transition: color var(--dur) var(--ease);
  position: relative;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.nav-item svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: all var(--dur) var(--ease);
}

.nav-item.active { 
  color: var(--gold); 
}

.nav-item.active svg {
  stroke: var(--gold);
  stroke-width: 2.2;
}

/* ─── Manager layout — desktop sidebar ──────────────── */
.manager-layout {
  display: flex;
  min-height: 100dvh;
  min-height: 100vh;
  background: var(--cream);
}

/* Sidebar */
.manager-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--ink);
  color: var(--cream);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100dvh;
  height: 100vh;
  overflow-y: auto;
  z-index: 50;
}

.sidebar-logo {
  padding: var(--sp-6) var(--sp-6) var(--sp-5);
  border-bottom: 1px solid rgba(245,240,232,.08);
}

.sidebar-logo .app-name {
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sidebar-logo .app-name span { color: var(--gold); }

.sidebar-logo .app-sub {
  font-size: 11px;
  color: rgba(245,240,232,.45);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: var(--sp-4) 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(245,240,232,.35);
  padding: var(--sp-4) var(--sp-5) var(--sp-2);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px var(--sp-5);
  font-size: 14px;
  font-weight: 500;
  color: rgba(245,240,232,.7);
  transition: all var(--dur) var(--ease);
  cursor: pointer;
  border-radius: 0;
  margin: 0 var(--sp-3);
  border-radius: var(--r-md);
}

.sidebar-link svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-link:hover {
  background: rgba(245,240,232,.08);
  color: var(--cream);
}

.sidebar-link.active {
  background: rgba(201, 168, 76, 0.15);
  color: var(--cream);
  font-weight: 600;
  border-left: 3px solid var(--gold);
  margin-left: calc(var(--sp-3) - 3px);
}

.sidebar-link.active svg { 
  opacity: 1;
  stroke: var(--gold);
}

.sidebar-link .link-badge {
  margin-left: auto;
  background: var(--rust);
  color: var(--white);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--r-full);
  min-width: 20px;
  text-align: center;
}

.sidebar-link.active .link-badge {
  background: var(--ink);
  color: var(--cream);
}

.sidebar-footer {
  padding: var(--sp-5) var(--sp-5);
  border-top: 1px solid rgba(245,240,232,.08);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name { font-size: 14px; font-weight: 600; color: var(--cream); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-role { font-size: 11px; color: rgba(245,240,232,.45); }

/* Main content area */
.manager-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.manager-topbar {
  background: var(--cream);
  border-bottom: 1px solid rgba(26,26,26,.08);
  padding: 0 var(--sp-8);
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
}

.manager-page-title {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 700;
}

.manager-content {
  flex: 1;
  padding: var(--sp-8);
  overflow-y: auto;
}

/* ─── Manager layout on mobile — hamburger mode ──────── */

/* Mobile hamburger button */
.mobile-menu-btn {
  display: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--cream);
  border: none;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: calc(16px + env(safe-area-inset-top, 0px));
  left: calc(16px + env(safe-area-inset-left, 0px));
  z-index: 210;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
  -webkit-tap-highlight-color: transparent;
}

.mobile-menu-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
}

@media (max-width: 900px) {
  .mobile-menu-btn {
    display: flex;
  }

  .manager-sidebar {
    position: fixed;
    left: -260px;
    transition: left 300ms var(--ease);
    z-index: 200;
    padding-top: env(safe-area-inset-top, 0px);
  }

  .manager-sidebar.open { left: 0; }

  .manager-topbar { 
    padding: 0 var(--sp-4);
    padding-left: calc(80px + env(safe-area-inset-left, 0px)); /* Space for hamburger */
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(64px + env(safe-area-inset-top, 0px));
  }

  .manager-content { 
    padding: var(--sp-4); 
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26,26,26,.5);
    z-index: 190;
    display: none;
  }

  .sidebar-overlay.visible { display: block; }
}

/* ─── Page sections ──────────────────────────────────── */
.page-section {
  margin-bottom: var(--sp-8);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
}

.section-title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
}

/* ─── Dashboard grid ─────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--sp-4);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--sp-4);
}

/* ─── Table ──────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--r-lg);
  border: 1px solid rgba(26,26,26,.08);
  background: var(--white);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead {
  background: rgba(26,26,26,.03);
  border-bottom: 1px solid rgba(26,26,26,.08);
}

th {
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid rgba(26,26,26,.05);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(201,168,76,.04); }

/* ─── Loading overlay ────────────────────────────────── */
.page-loader {
  position: fixed;
  inset: 0;
  background: var(--cream);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: var(--sp-4);
  transition: opacity 300ms var(--ease);
}

.page-loader.hidden {
  opacity: 0;
  pointer-events: none;
}

.page-loader .loader-logo {
  font-family: var(--font-heading);
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.page-loader .loader-logo span { color: var(--gold); }

/* ─── Manager Switch Button (for managers viewing staff pages) ─── */
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.btn-gold {
  background: var(--gold);
  color: var(--ink);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-gold:hover {
  background: #b89843;
}

.sidebar-link-accent {
  background: rgba(201, 168, 76, 0.12) !important;
  color: var(--gold) !important;
  border-left: 3px solid var(--gold);
  margin-left: calc(var(--sp-3) - 3px);
}

.sidebar-link-accent:hover {
  background: rgba(201, 168, 76, 0.2) !important;
}

.sidebar-link-accent svg {
  stroke: var(--gold) !important;
  opacity: 1 !important;
}

/* ─── PWA Install Banner ─────────────────────────────── */
.pwa-install-banner {
  position: fixed;
  bottom: 80px; /* Above bottom nav */
  left: var(--sp-4);
  right: var(--sp-4);
  background: var(--ink);
  color: var(--cream);
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  display: none;
  align-items: center;
  gap: var(--sp-4);
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
  z-index: 150;
  animation: slideUp 300ms var(--ease);
}

/* Ensure visibility on mobile */
@media (max-width: 900px) {
  .pwa-install-banner {
    bottom: 85px;
    left: var(--sp-3);
    right: var(--sp-3);
  }
}

.pwa-install-banner.show {
  display: flex;
}

.pwa-install-banner .pwa-icon {
  width: 48px;
  height: 48px;
  background: var(--gold);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pwa-install-banner .pwa-icon svg {
  width: 24px;
  height: 24px;
  stroke: var(--ink);
}

.pwa-install-banner .pwa-text {
  flex: 1;
}

.pwa-install-banner .pwa-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 2px;
}

.pwa-install-banner .pwa-desc {
  font-size: 12px;
  opacity: 0.8;
}

.pwa-install-banner .pwa-actions {
  display: flex;
  gap: var(--sp-2);
}

.pwa-install-banner .btn-install {
  background: var(--gold);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: var(--r-full);
  font-weight: 700;
  font-size: 13px;
  border: none;
  cursor: pointer;
}

.pwa-install-banner .btn-close {
  background: transparent;
  color: var(--cream);
  padding: 10px;
  border: none;
  cursor: pointer;
  opacity: 0.6;
}

.pwa-install-banner .btn-close:hover {
  opacity: 1;
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ─── Enhanced Responsive Styles ─────────────────────── */

/* Mobile-first improvements */
@media (max-width: 480px) {
  :root {
    --sp-1: 3px;
    --sp-2: 6px;
    --sp-3: 10px;
    --sp-4: 14px;
    --sp-5: 18px;
  }

  .staff-header {
    padding: var(--sp-3) var(--sp-4);
  }

  .staff-content {
    padding: var(--sp-4);
    padding-bottom: 100px;
  }

  .section-title {
    font-size: 16px;
  }

  .card {
    padding: var(--sp-4);
  }

  .btn {
    padding: 10px 16px;
    font-size: 13px;
  }

  .btn-sm {
    padding: 6px 12px;
    font-size: 12px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-3);
  }

  .cards-grid {
    grid-template-columns: 1fr;
    gap: var(--sp-3);
  }

  table {
    font-size: 12px;
  }

  th, td {
    padding: var(--sp-2) var(--sp-3);
  }

  /* Hide some columns on very small screens */
  .hide-mobile {
    display: none;
  }
  
  .pwa-install-banner {
    flex-direction: column;
    text-align: center;
  }
  
  .pwa-install-banner .pwa-actions {
    width: 100%;
    justify-content: center;
  }
}

/* Tablet */
@media (min-width: 481px) and (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Desktop improvements */
@media (min-width: 1200px) {
  .manager-content {
    max-width: 1400px;
    margin: 0 auto;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .cards-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
  .btn, .nav-item, .sidebar-link, .card {
    min-height: 44px; /* Apple's recommended touch target */
  }

  .nav-item {
    min-width: 44px;
  }
}

/* Safe area insets for notched phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .staff-bottom-nav {
    padding-bottom: calc(var(--sp-2) + env(safe-area-inset-bottom));
  }

  .pwa-install-banner {
    bottom: calc(80px + env(safe-area-inset-bottom));
  }
}
