/* =============================================
   VigilantDrive — Global Stylesheet
   ============================================= */

:root {
  --bg:        #0f0f0f;
  --surface:   #181818;
  --surface2:  #1f1f1f;
  --border:    #2a2a2a;
  --text:      #e8e8e8;
  --text-muted:#777;
  --orange:    #f97316;
  --green:     #22c55e;
  --yellow:    #eab308;
  --red:       #ef4444;
  --blue:      #3b82f6;
  --font-main: 'Syne', sans-serif;
  --font-mono: 'DM Mono', monospace;
  --radius:    12px;
  --radius-sm: 8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-main);
  min-height: 100vh;
  padding-bottom: 70px;
}

/* ── HEADER ─────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left { display: flex; align-items: center; gap: 32px; }
.header-right { display: flex; align-items: center; gap: 10px; }

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  white-space: nowrap;
}

.nav { display: flex; gap: 4px; }

.nav-link {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.15s;
}
.nav-link:hover { color: var(--text); background: var(--surface2); }
.nav-link.active { color: var(--text); background: var(--surface2); }

.btn-mute {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: var(--font-main);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-mute:hover { background: var(--surface2); }
.btn-mute.muted { border-color: var(--yellow); color: var(--yellow); }

.btn-emergency {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  border: none;
  background: var(--red);
  color: white;
  font-family: var(--font-main);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-emergency:hover { background: #dc2626; }

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
}

/* ── ALERT BANNER ───────────────────────────── */
.alert-banner {
  background: #1a0a0a;
  border-bottom: 1px solid #7f1d1d;
  padding: 10px 24px;
}
.alert-banner-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--red);
  font-size: 0.88rem;
  font-weight: 600;
  flex-wrap: wrap;
}
.alert-banner-inner span { color: #fca5a5; font-weight: 500; }
.alert-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.snooze-label { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-muted); }

.btn-find-rest {
  padding: 5px 12px;
  border-radius: 6px;
  background: var(--orange);
  color: white;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s;
}
.btn-find-rest:hover { background: #ea6c0a; }

.btn-dismiss {
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-dismiss:hover { background: var(--surface2); color: var(--text); }

/* ── MAIN ───────────────────────────────────── */
.main { padding: 24px; max-width: 1300px; margin: 0 auto; }

/* ── DASHBOARD GRID ─────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  gap: 20px;
  align-items: start;
}

/* ── SCORE CARD ─────────────────────────────── */
.score-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.score-ring-wrap {
  position: relative;
  width: 180px;
  height: 180px;
  background: #141a14;
  border-radius: 50%;
}
.score-ring { width: 180px; height: 180px; }
.score-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.score-value {
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}
.score-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--green);
  margin-top: 4px;
}
.score-label.warning { color: var(--yellow); }
.score-label.alert   { color: var(--red); }

.score-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}
.last-update {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

.btn-details {
  padding: 8px 20px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: var(--font-main);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
}
.btn-details:hover { background: var(--surface2); }

/* ── CENTER COLUMN ──────────────────────────── */
.center-col { display: flex; flex-direction: column; gap: 16px; }

.metrics-grid { display: flex; flex-direction: column; gap: 10px; }

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color 0.2s;
}
.metric-card:hover { border-color: #3a3a3a; }

.metric-icon {
  width: 38px; height: 38px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.metric-icon.green  { background: rgba(34,197,94,0.15); color: var(--green); }
.metric-icon.orange { background: rgba(249,115,22,0.15); color: var(--orange); }
.metric-icon.red    { background: rgba(239,68,68,0.15);  color: var(--red); }
.metric-icon.yellow { background: rgba(234,179,8,0.15);  color: var(--yellow); }

.metric-info { flex: 1; }
.metric-title { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }
.metric-value { font-size: 1.1rem; font-weight: 700; font-family: var(--font-mono); margin-top: 2px; }

.metric-badge {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
}

.action-row {
  display: flex;
  gap: 12px;
}

.btn-mute-lg {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-mute-lg:hover { background: var(--surface2); }
.btn-mute-lg.muted { border-color: var(--yellow); color: var(--yellow); }

.btn-emergency-lg {
  flex: 2;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--red);
  color: white;
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-emergency-lg:hover { background: #dc2626; }

/* ── EVENTS CARD ────────────────────────────── */
.events-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.events-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.events-header h2 { font-size: 1rem; font-weight: 700; }

.system-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.events-list { display: flex; flex-direction: column; gap: 8px; flex: 1; }

.event-item {
  padding: 10px 12px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--border);
}
.event-item.warning { border-left-color: var(--yellow); }
.event-item.alert   { border-left-color: var(--red); }
.event-item.ok      { border-left-color: var(--green); }
.event-item.info    { border-left-color: var(--blue); }

.event-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.event-name { font-size: 0.82rem; font-weight: 600; }
.event-tag {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  white-space: nowrap;
}
.event-tag.warning { background: rgba(234,179,8,0.15);  color: var(--yellow); }
.event-tag.alert   { background: rgba(239,68,68,0.15);  color: var(--red); }
.event-tag.ok      { background: rgba(34,197,94,0.15);  color: var(--green); }
.event-tag.info    { background: rgba(59,130,246,0.15); color: var(--blue); }

.event-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 3px; font-family: var(--font-mono); }
.event-empty { color: var(--text-muted); font-size: 0.82rem; text-align: center; padding: 20px 0; }

.system-status { font-size: 0.75rem; color: var(--text-muted); }
.status-active { color: var(--green); font-weight: 600; }

/* ── ANALYTICS PAGE ─────────────────────────── */
.analytics-wrap { max-width: 1000px; }

.page-title { margin-bottom: 24px; }
.page-title h1 { font-size: 1.6rem; font-weight: 800; }
.page-title p  { color: var(--text-muted); font-size: 0.85rem; margin-top: 4px; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
  text-align: center;
}
.stat-val { font-size: 1.8rem; font-weight: 800; font-family: var(--font-mono); }
.stat-lbl { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.warning-text { color: var(--yellow); }
.alert-text   { color: var(--red); }

.chart-card, .table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.chart-header { margin-bottom: 16px; }
.chart-header h2 { font-size: 1rem; font-weight: 700; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.data-table td {
  padding: 10px 12px;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface2); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
}
.badge.warning { background: rgba(234,179,8,0.15);  color: var(--yellow); }
.badge.critical { background: rgba(239,68,68,0.15); color: var(--red); }
.badge.ok, .badge.ras { background: rgba(34,197,94,0.15); color: var(--green); }

/* ── SMART ASSISTANCE PAGE ──────────────────── */
.assist-wrap { max-width: 1000px; }

.assist-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.assist-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}

.assist-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.assist-card-header h2 { font-size: 1rem; font-weight: 700; }

.assist-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 20px 0;
}

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.assist-error {
  color: var(--red);
  font-size: 0.85rem;
  padding: 16px 0;
}

/* Weather */
.weather-main {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
.weather-icon { font-size: 3rem; }
.weather-temp { font-size: 2rem; font-weight: 800; font-family: var(--font-mono); }
.weather-desc { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; text-transform: capitalize; }
.weather-loc  { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

.weather-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.weather-detail {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.wd-label { display: block; font-size: 0.7rem; color: var(--text-muted); margin-bottom: 2px; text-transform: uppercase; letter-spacing: 0.05em; }
.wd-val   { font-size: 0.9rem; font-weight: 600; font-family: var(--font-mono); }

.risk-box {
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  border-left: 3px solid var(--green);
  background: rgba(34,197,94,0.05);
}
.risk-box.risk-medium { border-left-color: var(--yellow); background: rgba(234,179,8,0.05); }
.risk-box.risk-high   { border-left-color: var(--red);   background: rgba(239,68,68,0.05); }
.risk-title { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.risk-level { font-size: 1rem; font-weight: 700; margin: 4px 0; color: var(--green); }
.risk-box.risk-medium .risk-level { color: var(--yellow); }
.risk-box.risk-high   .risk-level { color: var(--red); }
.risk-desc  { font-size: 0.8rem; color: var(--text-muted); }

/* Rest areas */
.rest-list { display: flex; flex-direction: column; gap: 10px; }

.rest-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.rest-item:hover {
  border-color: var(--orange);
  background: rgba(249,115,22,0.06);
}
.rest-directions {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--orange);
  white-space: nowrap;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.rest-item:hover .rest-directions { opacity: 1; }
.rest-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: rgba(249,115,22,0.15);
  color: var(--orange);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.rest-info { flex: 1; }
.rest-name { font-size: 0.88rem; font-weight: 600; }
.rest-dist { font-size: 0.75rem; color: var(--text-muted); font-family: var(--font-mono); margin-top: 2px; }
.rest-type { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

/* ── BOTTOM NAV ─────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 62px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 600;
  transition: color 0.15s;
}
.bottom-nav-item:hover, .bottom-nav-item.active { color: var(--orange); }

/* ── RESPONSIVE ─────────────────────────────── */
@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .score-card { flex-direction: row; flex-wrap: wrap; }
  .nav { display: none; }
  .assist-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2,1fr); }
}
