/* ── v6 Additions: Component classes used by rewritten JS modules ────────── */

/* ── Community row ─────────────────────────────────────────────────────── */
.community-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: border-color 0.18s, background 0.18s;
}
.community-row:hover {
  border-color: var(--accent-border);
  background: var(--bg-raised);
}
.community-row-avatar {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-bright);
  flex-shrink: 0;
}
.community-row-info {
  flex: 1;
  min-width: 0;
}
.community-row-name {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.community-row-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 2px;
  letter-spacing: 0.5px;
}

/* ── Action cards ──────────────────────────────────────────────────────── */
.action-card {
  padding: 24px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, transform 0.12s;
  text-align: center;
}
.action-card:hover {
  transform: translateY(-2px);
}
.action-card:active {
  transform: scale(0.98);
}
.action-card-red:hover  { border-color: var(--accent-border); background: var(--accent-dim); }
.action-card-blue:hover { border-color: var(--blue-border);   background: var(--blue-dim); }
.action-card-dim:hover  { border-color: rgba(255,255,255,0.15); background: var(--bg-raised); }
.action-card-icon {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 10px;
  line-height: 1;
}
.action-card-red  .action-card-icon { color: var(--accent); }
.action-card-blue .action-card-icon { color: var(--blue); }
.action-card-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}
.action-card-desc {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Page header additions ─────────────────────────────────────────────── */
.page-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}
.section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ── Empty state ───────────────────────────────────────────────────────── */
.empty-state-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.empty-state-desc {
  font-size: 12px;
  color: var(--text-dim);
}

/* ── List item (replaces inline border-bottom dividers) ─────────────────── */
.list-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child {
  border-bottom: none;
}

/* ── Unit callsign display ─────────────────────────────────────────────── */
.unit-callsign {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 1px;
}
.unit-card.status-108available { border-top-color: var(--success); }
.unit-card.status-107offduty   { border-top-color: var(--text-dim); }
.unit-card.status-106busy      { border-top-color: var(--warning); }
.unit-card.status-1097onscene  { border-top-color: var(--blue); }
.unit-card.status-1015prisoner { border-top-color: var(--danger); }
.unit-card.status-1010offduty  { border-top-color: var(--text-dim); }

/* ── Select element base style ─────────────────────────────────────────── */
.select {
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 6px 10px;
  outline: none;
  transition: border-color 0.18s;
  cursor: pointer;
}
.select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

/* ── btn-sm modifier ───────────────────────────────────────────────────── */
.btn-sm {
  padding: 5px 12px !important;
  font-size: 11px !important;
}

/* ── PWA / Responsive Layer ──────────────────────────────────────────────── */

/* Safe area insets for notched devices (iOS/Android) */
:root {
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
}

/* Standalone PWA: add top padding for status bar */
.pwa-standalone #topbar,
.pwa-standalone .topbar {
  padding-top: calc(8px + var(--safe-top));
}
.pwa-standalone #sidebar,
.pwa-standalone .sidebar {
  padding-top: var(--safe-top);
}
.pwa-standalone #main-content,
.pwa-standalone .main-content {
  padding-bottom: var(--safe-bottom);
}

/* ── Mobile layout (< 768px) ─────────────────────────────────────────────── */
@media (max-width: 767px) {
  /* Sidebar becomes a full-screen overlay on mobile */
  #sidebar, .sidebar {
    position: fixed !important;
    left: -260px;
    top: 0;
    bottom: 0;
    z-index: 1000;
    width: 260px !important;
    transition: left 0.25s cubic-bezier(0.23,1,0.32,1);
    box-shadow: 4px 0 24px rgba(0,0,0,0.6);
  }
  /* JS adds class 'open' to slide the sidebar in */
  #sidebar.open, .sidebar.open {
    left: 0;
  }
  /* Overlay backdrop — JS adds class 'open' */
  #sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 999;
    backdrop-filter: blur(2px);
  }
  #sidebar-overlay.open {
    display: block;
  }
  /* Main content takes full width */
  #main-content, .main-content {
    margin-left: 0 !important;
    width: 100% !important;
  }
  /* Hide topbar entirely on mobile — bottom nav handles navigation */
  .topbar, #mobile-topbar {
    display: none !important;
  }
  /* Hamburger no longer needed */
  .topbar-hamburger {
    display: none !important;
  }
  /* Content fills from top since topbar is gone */
  #content, .page-content {
    padding-top: 0 !important;
  }
  /* Reduce card padding on mobile */
  .card, .form-card {
    padding: 14px !important;
  }
  /* Stack grid columns */
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr !important;
  }
  .grid-auto {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
  }
  /* Full-width buttons on mobile */
  .btn-mobile-full {
    width: 100%;
  }
  /* Stat cards: 2 per row on mobile */
  .stat-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  /* Page title smaller on mobile */
  .page-title {
    font-size: 22px !important;
  }
  /* Table: horizontal scroll */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table {
    min-width: 600px;
  }
  /* Bottom nav visible on mobile */
  .bottom-nav {
    display: flex !important;
    padding-bottom: var(--safe-bottom);
  }
  /* Hide desktop-only elements */
  .desktop-only {
    display: none !important;
  }
}

/* ── Tablet layout (768px – 1023px) ─────────────────────────────────────── */
@media (min-width: 768px) and (max-width: 1023px) {
  /* Sidebar collapses to icon-only mode */
  #sidebar, .sidebar {
    width: 60px !important;
    overflow: hidden;
  }
  #sidebar .nav-label,
  .sidebar .nav-label,
  #sidebar .sidebar-brand-text,
  .sidebar .sidebar-brand-text,
  #sidebar .nav-section-title,
  .sidebar .nav-section-title,
  #sidebar .sidebar-section,
  .sidebar .sidebar-section,
  #sidebar .sidebar-server,
  .sidebar .sidebar-server,
  #sidebar .sidebar-logo-mark,
  .sidebar .sidebar-logo-mark,
  #sidebar .user-chip-info,
  .sidebar .user-chip-info,
  #sidebar .user-name,
  .sidebar .user-name,
  #sidebar .user-role,
  .sidebar .user-role {
    display: none !important;
  }
  #sidebar .nav-item,
  .sidebar .nav-item {
    justify-content: center;
    padding: 10px 0;
  }
  #sidebar .nav-icon,
  .sidebar .nav-icon {
    margin: 0;
  }
  #main-content, .main-content {
    /* No margin-left needed — sidebar is a flex item, not fixed positioned */
    margin-left: 0 !important;
  }
  /* 2-column grids on tablet */
  .grid-3, .grid-4 {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  /* Topbar hamburger hidden on tablet (sidebar still visible) */
  .topbar-hamburger {
    display: none !important;
  }
  .tablet-only {
    display: block !important;
  }
  .mobile-only {
    display: none !important;
  }
}

/* ── Desktop layout (>= 1024px) ─────────────────────────────────────────── */
@media (min-width: 1024px) {
  .topbar-hamburger {
    display: none !important;
  }
  .bottom-nav {
    display: none !important;
  }
  .mobile-only {
    display: none !important;
  }
  /* Sidebar is part of the flex flow on desktop — never a fixed overlay */
  #sidebar, .sidebar {
    position: relative !important;
    left: 0 !important;
    top: auto !important;
    bottom: auto !important;
    transform: none !important;
    width: 220px !important;
    min-width: 220px !important;
    height: 100vh !important;
    box-shadow: none !important;
    transition: width var(--transition-normal) !important;
  }
  /* Overlay never visible on desktop */
  #sidebar-overlay {
    display: none !important;
    pointer-events: none !important;
  }
  /* Content area fills remaining width */
  #content, .main-content {
    flex: 1 !important;
    min-width: 0 !important;
    overflow-y: auto !important;
    height: 100vh !important;
  }
}

/* ── Topbar hamburger button (hidden by default, shown on mobile) ─────────── */
.topbar-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 18px;
  margin-right: 10px;
  transition: border-color 0.15s, color 0.15s;
}
.topbar-hamburger:hover {
  border-color: var(--accent-border);
  color: var(--accent);
}

/* ── Bottom navigation bar (mobile) ─────────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 900;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 6px 0 calc(6px + var(--safe-bottom));
  justify-content: space-around;
  align-items: center;
}
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 12px;
  cursor: pointer;
  color: var(--text-dim);
  transition: color 0.15s;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-radius: 6px;
}
.bottom-nav-item.active,
.bottom-nav-item:hover {
  color: var(--accent);
}
.bottom-nav-icon {
  font-size: 20px;
  line-height: 1;
}

/* ── iOS-specific tweaks ─────────────────────────────────────────────────── */
.device-ios input,
.device-ios select,
.device-ios textarea {
  font-size: 16px !important; /* Prevents iOS auto-zoom on focus */
}
.device-ios .bottom-nav {
  padding-bottom: calc(10px + var(--safe-bottom));
}

/* ── Touch-friendly tap targets ──────────────────────────────────────────── */
@media (hover: none) and (pointer: coarse) {
  .btn, button {
    min-height: 40px;
  }
  .nav-item {
    min-height: 44px;
  }
  .bottom-nav-item {
    min-width: 56px;
  }
  input, select, textarea {
    min-height: 40px;
  }
}

/* ── Landscape mobile ────────────────────────────────────────────────────── */
@media (max-width: 767px) and (orientation: landscape) {
  #sidebar, .sidebar {
    width: 220px !important;
  }
  .grid-2 {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}
