/*
 * Dashboard styles — native Rails port of the anava-web React reference.
 * Plain hand-written CSS (no Tailwind/asset pipeline), approximating the
 * original shadcn/ui light theme. Served statically from public/.
 */

:root {
  --background: #ffffff;
  --foreground: #0f172a;
  --muted: #f1f5f9;
  --muted-foreground: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-foreground: #ffffff;
  --secondary: #f1f5f9;
  --destructive: #dc2626;
  --card: #ffffff;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 1rem;
  padding-bottom: 1rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.4rem;
  font-weight: 700;
}
.brand .icon { color: var(--primary); }
.header-controls {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}
.health {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted-foreground);
}
.health-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #eab308; /* checking */
}
.health-dot.connected { background: #22c55e; }
.health-dot.disconnected { background: var(--destructive); }

/* Form controls */
label.field-label {
  font-size: 0.85rem;
  color: var(--muted-foreground);
  white-space: nowrap;
}
select.select {
  appearance: none;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 2rem 0.4rem 0.7rem;
  font-size: 0.9rem;
  color: var(--foreground);
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.55rem center;
}
select.select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  border-radius: 8px;
  padding: 0.45rem 0.8rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.12s ease;
}
.btn:hover:not(:disabled) { background: var(--muted); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-icon { padding: 0.4rem; width: 2.1rem; height: 2.1rem; }
.btn-primary { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary); }
.btn-primary:hover:not(:disabled) { background: #1d4ed8; }
.btn-block { width: 100%; }

/* Main */
main.container { padding-top: 2rem; padding-bottom: 3rem; }

/* Tabs */
.tabs {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
  background: var(--muted);
  border-radius: 10px;
  padding: 0.25rem;
  max-width: 28rem;
  width: 100%;
  margin-bottom: 1.5rem;
}
.tab-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  background: transparent;
  color: var(--muted-foreground);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}
.tab-trigger.active {
  background: var(--background);
  color: var(--foreground);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.tab-panel[hidden] { display: none; }

/* Cards */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}
.card + .card { margin-top: 1rem; }
.card-header { padding: 1.1rem 1.25rem 0.5rem; }
.card-title { font-size: 1.1rem; font-weight: 600; margin: 0; }
.card-title.sm { font-size: 0.85rem; font-weight: 500; }
.card-description { color: var(--muted-foreground); font-size: 0.85rem; margin: 0.25rem 0 0; }
.card-content { padding: 1rem 1.25rem 1.25rem; }

/* Filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.filters .group { display: flex; align-items: center; gap: 0.5rem; }
.filters .total { margin-left: auto; color: var(--muted-foreground); font-size: 0.85rem; }

/* Recordings list */
.day-card { margin-top: 1rem; }
.day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  cursor: pointer;
  user-select: none;
}
.day-header-left { display: flex; align-items: center; gap: 0.5rem; }
.day-title { font-size: 1.05rem; font-weight: 600; }
.day-meta { display: flex; align-items: center; gap: 1rem; color: var(--muted-foreground); font-size: 0.85rem; }
.day-meta span { display: inline-flex; align-items: center; gap: 0.3rem; }
.chevron { transition: transform 0.15s ease; color: var(--muted-foreground); }
.day-header[aria-expanded="true"] .chevron { transform: rotate(90deg); }
.day-body { padding: 0 1.25rem 1rem; display: flex; flex-direction: column; gap: 0.65rem; }
.day-body[hidden] { display: none; }

.rec-row {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  background: rgba(241, 245, 249, 0.6);
  cursor: pointer;
  transition: background 0.12s ease;
}
.rec-row:hover { background: rgba(241, 245, 249, 1); }
.rec-main { flex: 1; display: flex; flex-direction: column; gap: 0.4rem; }
.rec-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.rec-slot { font-weight: 600; }
.rec-time { color: var(--muted-foreground); font-size: 0.85rem; }
.rec-sub { display: flex; align-items: center; gap: 1rem; color: var(--muted-foreground); font-size: 0.85rem; }
.rec-sub span { display: inline-flex; align-items: center; gap: 0.3rem; }

/* Empty / loading / error states */
.state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted-foreground);
}
.state .icon { color: var(--muted-foreground); margin-bottom: 0.75rem; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 1rem;
}
.pagination .pages { color: var(--muted-foreground); font-size: 0.85rem; }
.pagination .controls { display: flex; align-items: center; gap: 0.25rem; }

/* Analytics grid */
.grid { display: grid; gap: 1rem; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 820px) {
  .grid-3, .grid-2, .grid-4 { grid-template-columns: 1fr; }
}
.stat-card .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.35rem;
}
.stat-value { font-size: 1.75rem; font-weight: 700; }
.stat-sub { font-size: 0.78rem; color: var(--muted-foreground); }
.stat-block .stat-label { font-size: 0.85rem; color: var(--muted-foreground); }
.stat-block .stat-num { font-size: 1.25rem; font-weight: 600; }
.muted-icon { color: var(--muted-foreground); }

.chart-wrap { position: relative; width: 100%; }

/* Recording detail modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2.5rem 1rem;
  z-index: 50;
  overflow-y: auto;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--background);
  border-radius: 12px;
  width: 100%;
  max-width: 42rem;
  padding: 1.5rem;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.modal-title { font-size: 1.15rem; font-weight: 600; }
.modal-close {
  border: none;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted-foreground);
}
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; font-size: 0.9rem; }
.info-grid .full { grid-column: 1 / -1; }
.info-grid .label { color: var(--muted-foreground); margin: 0 0 0.1rem; }
.info-grid .value { font-weight: 600; margin: 0; word-break: break-all; }
.modal section { margin-top: 1.25rem; }
.modal section .section-label { font-size: 0.85rem; color: var(--muted-foreground); margin-bottom: 0.4rem; display: flex; align-items: center; gap: 0.3rem; }
.modal iframe.map { width: 100%; height: 12rem; border: 1px solid var(--border); border-radius: 8px; }

.icon-inline { vertical-align: -0.15em; }
