
/* ──────────── MOBILE BOTTOM NAVIGATION ──────────── */
.admin-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--admin-bottomnav);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  z-index: 80;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.admin-bottom-nav-inner {
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  height: 100%;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px;
  flex: 1;
  color: var(--text-tertiary);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  transition: color 0.15s;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
  min-width: 0;
}
.bottom-nav-item .lucide { width: 20px; height: 20px; flex-shrink: 0; }
.bottom-nav-item span {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.bottom-nav-item:active { color: var(--text-secondary); }

.bottom-nav-item.active {
  color: var(--brand);
}
.bottom-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 28px; height: 2px;
  background: var(--brand);
  border-radius: 0 0 2px 2px;
}

.bottom-nav-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 16px);
  font-size: 0.52rem;
  font-weight: 800;
  background: var(--danger);
  color: white;
  min-width: 14px;
  height: 14px;
  padding: 0 4px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.bottom-nav-badge:empty { display: none; }


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

/* ── Large desktop ── */
@media (max-width: 1400px) {
  .admin-main { padding: 32px 36px 56px; }
}

/* ── Medium desktop ── */
@media (max-width: 1200px) {
  .admin-main { padding: 28px 28px 48px; }
  .admin-stats { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

/* ── Tablet landscape ── */
@media (max-width: 1024px) {
  .dash-stats-primary { grid-template-columns: repeat(2, 1fr) !important; }
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ── Dashboard overview stacks on smaller screens ── */
@media (max-width: 900px) {
  .dash-overview-grid { grid-template-columns: 1fr; }
  .dash-overview-group {
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 10px;
  }
  .dash-overview-group:last-child { border-bottom: none; }
}

/* ── Tablet portrait / large phone ── */
@media (max-width: 768px) {
  /* Show topbar + bottom nav */
  .admin-topbar { display: flex; }
  .admin-bottom-nav { display: block; }

  /* Hide old mobile toggle */
  .admin-mobile-toggle { display: none !important; }

  /* Show sidebar close button */
  .admin-sidebar-close { display: flex; }

  /* Sidebar becomes overlay */
  .admin-sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s var(--ease-out);
    width: 280px;
    box-shadow: none;
  }
  .admin-sidebar.open {
    transform: translateX(0);
    box-shadow: 16px 0 48px rgba(0,0,0,0.35);
  }

  .admin-layout { display: block; }
  .admin-main {
    margin-left: 0;
    padding: 20px 16px 100px;
    padding-top: calc(var(--admin-topbar) + 16px);
    padding-bottom: calc(var(--admin-bottomnav) + env(safe-area-inset-bottom, 0px) + 24px);
  }

  .admin-header h1 { font-size: 1.2rem; }
  .admin-header p { font-size: 0.82rem; }
  .admin-header { margin-bottom: 20px; }

  /* Stat cards */
  .admin-stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 16px; }
  .stat-card-value { font-size: 1.3rem; }
  .stat-card-icon { width: 34px; height: 34px; margin-bottom: 10px; }
  .stat-card-icon .lucide { width: 17px; height: 17px; }

  /* Panel header: toolbar wraps */
  .admin-panel-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px 16px;
  }

  /* Toolbar: horizontal scroll instead of stack */
  .admin-toolbar {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .admin-toolbar::-webkit-scrollbar { display: none; }
  .admin-toolbar > * { flex-shrink: 0; }
  .admin-search { min-width: 200px; }
  .admin-search input { width: 150px; }
  .admin-filter { min-width: fit-content; }
  .admin-btn { white-space: nowrap; }

  /* Table responsiveness */
  .admin-table { font-size: 0.8rem; min-width: 580px; }
  .admin-table th,
  .admin-table td { padding: 11px 14px; white-space: nowrap; }
  /* Sticky actions column */
  .admin-table th:last-child,
  .admin-table td:last-child {
    position: sticky;
    right: 0;
    background: var(--bg-card);
    box-shadow: -3px 0 6px rgba(0,0,0,0.04);
  }
  .admin-table tbody tr:hover td:last-child { background: var(--bg-card-hover); }

  .admin-pagination { padding: 12px; gap: 3px; }

  .admin-form .form-row { grid-template-columns: 1fr; }
  .admin-panel-row { grid-template-columns: 1fr !important; }

  /* Regular modals */
  .admin-modal {
    padding: 22px;
    width: 96%;
    border-radius: var(--r-lg);
    max-height: 85vh;
    max-height: 85dvh;
  }
  /* HS modals */
  .admin-modal.hs-modal {
    max-width: 100%;
    width: 96%;
    border-radius: var(--r-lg);
  }
  .hs-body {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .hs-main {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 16px 18px;
    max-height: none;
    overflow-y: visible;
  }
  .hs-sidebar {
    padding: 16px 18px;
    max-height: none;
    overflow-y: visible;
  }
  .hs-header { padding: 14px 18px; }
  .hs-form { padding: 14px 18px; }
  .hs-form .form-row { grid-template-columns: 1fr; }
  .hs-quick-stats { grid-template-columns: repeat(3, 1fr); gap: 6px; }

  /* Toast above bottom nav */
  .admin-toast {
    left: 16px; right: 16px;
    bottom: calc(var(--admin-bottomnav) + env(safe-area-inset-bottom, 0px) + 12px);
    font-size: 0.82rem;
    max-width: none;
  }

  /* Bulk action bar wraps on mobile */
  #bulk-action-bar {
    flex-wrap: wrap;
    margin: 10px 14px;
    gap: 8px;
    font-size: 0.8rem;
  }

  /* Inventory 5-col grid → stack on mobile */
  #panel-inventory .form-row[style*="grid-template-columns"] {
    grid-template-columns: 1fr 1fr !important;
  }
  #panel-inventory .form-row[style*="grid-template-columns"] > div:first-child {
    grid-column: 1 / -1;
  }

  /* Inventory overview cards stack */
  #inv-tab-overview [style*="display:flex"][style*="gap:24px"] {
    flex-direction: column !important;
    gap: 10px !important;
  }
}

/* ── Small phone ── */
@media (max-width: 480px) {
  .admin-main {
    padding: 16px 12px 100px;
    padding-top: calc(var(--admin-topbar) + 12px);
    padding-bottom: calc(var(--admin-bottomnav) + env(safe-area-inset-bottom, 0px) + 20px);
  }
  .admin-stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .dash-stats-primary { grid-template-columns: 1fr 1fr !important; }
  .stat-card { padding: 14px 12px; }
  .stat-card-value { font-size: 1.15rem; }
  .stat-card-label { font-size: 0.64rem; }
  .stat-card-icon { width: 32px; height: 32px; margin-bottom: 8px; }
  .stat-card-icon .lucide { width: 16px; height: 16px; }

  .admin-panel-header { padding: 14px 16px; }
  .admin-panel-title { font-size: 0.86rem; }
  .admin-table th,
  .admin-table td { padding: 10px 12px; }

  /* Bottom nav item text */
  .bottom-nav-item span { font-size: 0.55rem; }

  /* Full-screen modals on small phones */
  .admin-modal-overlay { padding: 0; align-items: flex-end; }
  .admin-modal {
    width: 100%;
    max-width: 100%;
    max-height: 95vh;
    max-height: 95dvh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    padding: 20px 16px;
    animation: modalSlideSheet 0.3s var(--ease-out);
  }
  @keyframes modalSlideSheet {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .admin-modal.hs-modal {
    width: 100%;
    max-width: 100%;
    max-height: 95vh;
    max-height: 95dvh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
  }
  .hs-header { padding: 14px 16px; }
  .hs-header-title { font-size: 1rem; }
  .hs-header-icon { width: 36px; height: 36px; }
  .hs-main { padding: 14px 16px; }
  .hs-sidebar { padding: 14px 16px; }
  .hs-form { padding: 12px 16px; }

  .admin-header h1 { font-size: 1.1rem; }
}

/* ── Very small phone ── */
@media (max-width: 360px) {
  .admin-main {
    padding: 12px 10px 96px;
    padding-top: calc(var(--admin-topbar) + 10px);
  }
  .admin-stats { grid-template-columns: 1fr; }
  .dash-stats-primary { grid-template-columns: 1fr !important; }
  .stat-card { padding: 12px; }

  .admin-header h1 { font-size: 1rem; }
  .admin-header p { font-size: 0.78rem; }

  .bottom-nav-item .lucide { width: 18px; height: 18px; }
  .bottom-nav-item span { font-size: 0.52rem; }
}

/* ══════════════════════════════════════════
   SETTINGS PAGE
   ══════════════════════════════════════════ */

.settings-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  align-items: start;
}

.settings-nav {
  position: sticky;
  top: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--r-md);
  transition: all 0.15s ease;
  white-space: nowrap;
}
.settings-nav-item i { width: 16px; height: 16px; flex-shrink: 0; }
.settings-nav-item:hover { color: var(--text-primary); background: var(--bg-input); }
.settings-nav-item.active {
  color: var(--yellow);
  background: rgba(240, 180, 41, 0.08);
  font-weight: 600;
}

.settings-content {
  min-width: 0;
}

.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: none;
}
.settings-card.active { display: block; }

.settings-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
}
.settings-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(240, 180, 41, 0.1);
  color: var(--yellow);
  flex-shrink: 0;
}
.settings-card-icon i { width: 20px; height: 20px; }
.settings-card-icon.blue { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.settings-card-icon.green { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.settings-card-icon.orange { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }
.settings-card-icon.purple { background: rgba(139, 92, 246, 0.1); color: #8b5cf6; }
.settings-card-icon.teal { background: rgba(20, 184, 166, 0.1); color: #14b8a6; }
.settings-card-icon.red { background: rgba(239, 68, 68, 0.1); color: #ef4444; }

.settings-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.settings-card-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.settings-card-body {
  padding: 24px;
}

.settings-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.settings-row:last-child { margin-bottom: 0; }

.settings-field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.settings-field input,
.settings-field textarea,
.settings-field select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: inherit;
  transition: border-color 0.15s ease;
}
.settings-field input:focus,
.settings-field textarea:focus {
  border-color: var(--yellow);
  outline: none;
  box-shadow: 0 0 0 3px rgba(240, 180, 41, 0.1);
}
.settings-field textarea { resize: vertical; }

.settings-group-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}
.settings-hint {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  margin-bottom: 14px;
  line-height: 1.5;
}
.settings-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 20px 0;
}

/* Toggle switch */
.settings-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
}
.settings-toggle-row + .settings-toggle-row {
  border-top: 1px solid var(--border-subtle);
}
.settings-toggle-info { flex: 1; min-width: 0; }
.settings-toggle-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}
.settings-toggle-desc {
  font-size: 0.76rem;
  color: var(--text-tertiary);
  margin-top: 2px;
  line-height: 1.4;
}

.settings-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}
.settings-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.settings-switch-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 12px;
  transition: all 0.2s ease;
}
.settings-switch-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.settings-switch input:checked + .settings-switch-slider {
  background: var(--yellow);
}
.settings-switch input:checked + .settings-switch-slider::before {
  transform: translateX(20px);
}
.settings-switch input:focus-visible + .settings-switch-slider {
  box-shadow: 0 0 0 3px rgba(240, 180, 41, 0.2);
}

/* Save bar */
.settings-save-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
  padding: 20px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  position: sticky;
  bottom: 0;
  z-index: 5;
}

/* Settings mobile */
@media (max-width: 768px) {
  .settings-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .settings-nav {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 6px;
    gap: 0;
  }
  .settings-nav-item {
    padding: 8px 12px;
    font-size: 0.76rem;
  }
  .settings-card-header { padding: 16px 18px; }
  .settings-card-body { padding: 18px; }
  .settings-row { grid-template-columns: 1fr; gap: 12px; }
  .settings-save-bar { padding: 14px 16px; }
}

@media (max-width: 480px) {
  .settings-nav-item span { display: none; }
  .settings-nav-item { padding: 8px 10px; }
}
