/*
 * css/components.css
 *
 * Visual component styles: cards, tables, badges, buttons,
 * form controls, modals, and utility classes.
 * Depends on tokens.css being loaded first.
 */

/* ---- Navigation items ---- */

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 10px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
  user-select: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover  { background: var(--bg-elevated); color: var(--text); }
.nav-item.active { background: var(--primary-dim); color: var(--primary); }
.nav-item svg    { flex-shrink: 0; }

.nav-badge {
  margin-left: auto;
  background: var(--badge-purple);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  min-width: 18px;
  text-align: center;
}

/* ---- Sidebar user footer ---- */

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
}

.sidebar-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary-dim);
  border: 1px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
}

.sidebar-user-info  { flex: 1; min-width: 0; }
.sidebar-user-name  { font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role  { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }

/* ---- Topbar live indicator ---- */

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
  animation: pulse 2s ease-in-out infinite;
}

.live-label {
  font-size: 12px;
  color: var(--success);
  font-weight: 600;
}

/* ---- Cards (app-style white cards with subtle shadow) ---- */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.card-title    { font-family: var(--font-head); font-size: 14px; font-weight: 600; color: var(--text); }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ---- Stat cards ---- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 18px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

/* Colored top-edge accent line per stat card variant */
.stat-card::before           { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; }
.stat-card.blue::before      { background: var(--primary); }
.stat-card.green::before     { background: var(--success); }
.stat-card.orange::before    { background: var(--outside); }
.stat-card.red::before       { background: var(--danger); }
.stat-card.cyan::before      { background: var(--accent); }

.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.7px; color: var(--text-muted); margin-bottom: 8px; }
.stat-value { font-family: var(--font-head); font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-sub   { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

/* ---- Tables ---- */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td        { border-bottom: none; }
tr.row-hover:hover td   { background: var(--bg-elevated); cursor: pointer; }

/* Monospace identifier cells (MAC addresses, timestamps) */
.mono { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }

/* ---- Badges ---- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}

/* Badges match app: admin=red pill, staff=gray pill, live=light blue */
.badge-green  { background: var(--success-dim); color: var(--success); }
.badge-orange { background: var(--outside-dim); color: var(--outside); }
.badge-red    { background: var(--admin-bg); color: #fff; }
.badge-blue   { background: #D6E8F6; color: var(--primary); }
.badge-gray   { background: var(--staff-bg); color: #fff; }
.badge-yellow { background: var(--warning-dim); color: var(--warning); }

/* ---- Tag chips (beacon tag display) ---- */

.tag-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid;
  margin-right: 4px;
  margin-bottom: 2px;
}

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  font-family: var(--font-ui);
  transition: opacity 0.15s, background 0.15s;
}

.btn:disabled { opacity: 0.5; cursor: default; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { opacity: 0.9; }

.btn-ghost   { background: var(--bg-elevated); color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled)   { color: var(--text); background: var(--bg-hover); }

/* Sign out style: white bg, red border (app pattern) */
.btn-danger  { background: #fff; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover:not(:disabled)  { background: var(--danger-dim); }

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

/* Icon-only button (no visible background) */
.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}

.btn-icon:hover { color: var(--text); }

/* ---- Form controls ---- */

.input, .select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--font-ui);
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}

.input:focus, .select:focus { border-color: var(--primary); }
.input::placeholder            { color: var(--text-faint); }

.form-group   { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-label   { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.form-row     { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---- Search bar ---- */

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
}

.search-bar input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-ui);
  min-width: 160px;
}

.search-bar input::placeholder { color: var(--text-faint); }

/* ---- Modal ---- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title  { font-family: var(--font-head); font-size: 15px; font-weight: 600; }
.modal-body   { padding: 20px; }

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---- Login card ---- */

.login-card {
  width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 36px;
  position: relative;
  z-index: 1;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.login-logo-area  { text-align: center; margin-bottom: 28px; }
.login-wordmark   { font-family: var(--font-head); font-size: 24px; font-weight: 700; color: var(--text); letter-spacing: -0.5px; }
.login-sub        { font-size: 12px; color: var(--primary); font-weight: 500; letter-spacing: 1px; text-transform: uppercase; margin-top: 3px; }
.login-divider    { width: 32px; height: 2px; background: var(--primary); border-radius: 1px; margin: 12px auto 0; }
.login-form-title { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 20px; }
.login-error      { background: var(--danger-dim); border: 1px solid var(--danger); border-radius: var(--radius); padding: 10px 12px; color: var(--danger); font-size: 12.5px; margin-bottom: 14px; }

/* ---- Map container ---- */

.map-container   { height: 480px; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow-card); }
.leaflet-container { background: #F8F8F8; }

/* ---- Empty and loading states ---- */

.empty-state      { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }
.empty-state-text { font-size: 14px; font-weight: 500; color: var(--text-muted); }
.empty-state-sub  { font-size: 12px; color: var(--text-faint); margin-top: 4px; }

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

/* ---- Detail rows (key / value pairs inside modals and cards) ---- */

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.detail-row:last-child { border-bottom: none; }
.detail-key  { font-size: 12px; color: var(--text-muted); }
.detail-val  { font-size: 12px; font-weight: 500; color: var(--text); text-align: right; max-width: 220px; word-break: break-all; }

/* ---- Error banner ---- */

.error-banner {
  background: var(--danger-dim);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 16px;
}

/* ---- Section actions row (search + buttons) ---- */

.section-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---- Map legend row ---- */

.map-legend {
  display: flex;
  gap: 16px;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.map-legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}

/* ---- Panel stack spacing ---- */

.panel-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
