/* Mzansi Connect App - Dashboard Styles
   SPDX-License-Identifier: Apache-2.0 */

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

:root {
  --sa-green: #007A4B;
  --sa-gold: #FFB612;
  --sa-red: #DE3831;
  --sa-blue: #002395;
  --black: #0A0A0A;
  --dark: #141414;
  --panel: #1B1B1B;
  --line: #2E2E2E;
  --text: #ECECEC;
  --muted: #9A9A9A;
}

body {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  background: var(--black);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 56px;
}

.flag-strip {
  display: flex;
  height: 8px;
}
.flag-strip span { flex: 1; }
.flag-strip span:nth-child(1) { background: var(--sa-red); }
.flag-strip span:nth-child(2) { background: var(--sa-blue); }
.flag-strip span:nth-child(3) { background: var(--sa-gold); }
.flag-strip span:nth-child(4) { background: var(--sa-green); }
.flag-strip span:nth-child(5) { background: var(--sa-blue); }
.flag-strip span:nth-child(6) { background: var(--sa-red); }

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 2px solid var(--line);
  background: var(--dark);
  position: sticky;
  top: 0;
  z-index: 50;
}

.app-logo { display: flex; align-items: center; gap: 12px; }

a.app-logo { text-decoration: none; color: inherit; }

.footer-home {
  color: var(--sa-gold);
  text-decoration: none;
  font-weight: 600;
}

.footer-home:hover { text-decoration: underline; }

.logo-img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border: 2px solid var(--sa-green);
  background: #fff;
  padding: 2px;
  flex-shrink: 0;
}

.header-actions { display: flex; align-items: center; gap: 10px; }

.download-btn {
  font-family: 'Archivo Black', sans-serif;
  font-size: 0.6rem;
  text-transform: uppercase;
  padding: 7px 12px;
  background: var(--sa-gold);
  color: var(--black);
  border: none;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.download-btn:active { transform: scale(0.96); }

.app-logo h1 { font-size: 1.05rem; font-family: 'Archivo Black', sans-serif; }
.app-logo p { font-size: 0.7rem; color: var(--muted); }

.conn-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--sa-red);
}
.conn-dot.connected { background: var(--sa-green); }

.demo-banner {
  background: var(--sa-gold);
  color: var(--black);
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
  padding: 6px 12px;
}

.tab-bar {
  display: flex;
  background: var(--dark);
  border-bottom: 2px solid var(--line);
  overflow-x: auto;
  position: sticky;
  top: 71px;
  z-index: 49;
}

.tab {
  flex: 1;
  min-width: 88px;
  padding: 12px 8px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-family: 'Archivo Black', sans-serif;
  font-size: 0.68rem;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}

.tab.active {
  color: var(--sa-gold);
  border-bottom-color: var(--sa-gold);
}

.tab-count {
  background: var(--sa-red);
  color: #fff;
  border-radius: 999px;
  font-size: 0.6rem;
  padding: 1px 6px;
  margin-left: 4px;
}

main { flex: 1; width: 100%; max-width: 560px; margin: 0 auto; padding: 18px 16px; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.tab-panel h2 {
  font-family: 'Archivo Black', sans-serif;
  font-size: 1.1rem;
  margin-bottom: 14px;
}

/* ─── Devices ─── */
.device-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.device-card {
  background: var(--panel);
  border: 2px solid var(--line);
  border-top: 4px solid var(--sa-green);
  padding: 12px;
  cursor: pointer;
  transition: transform 0.15s;
}
.device-card:active { transform: scale(0.97); }
.device-card.offline { border-top-color: var(--muted); }
.device-card.error { border-top-color: var(--sa-red); }

.device-card .d-icon { font-size: 1.6rem; }
.device-card h3 { font-size: 0.85rem; margin: 6px 0 2px; }
.device-card .d-type { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; }
.device-card .d-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 8px;
}

.d-status { font-weight: 700; }
.d-status.online { color: var(--sa-green); }
.d-status.offline { color: var(--muted); }
.d-status.low_battery { color: var(--sa-gold); }
.d-status.error { color: var(--sa-red); }

/* ─── Alerts ─── */
.alert-list { display: flex; flex-direction: column; gap: 10px; }

.alert-item {
  background: var(--panel);
  border: 2px solid var(--line);
  border-left: 5px solid var(--muted);
  padding: 12px;
}

.alert-item.warning { border-left-color: var(--sa-gold); }
.alert-item.critical { border-left-color: var(--sa-red); }
.alert-item.info { border-left-color: var(--sa-blue); }

.alert-item .a-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.alert-item h3 { font-size: 0.85rem; }
.alert-item .a-time { font-size: 0.65rem; color: var(--muted); white-space: nowrap; }
.alert-item p { font-size: 0.75rem; color: var(--muted); margin-top: 4px; }

.ack-btn {
  margin-top: 8px;
  padding: 6px 12px;
  font-family: 'Archivo Black', sans-serif;
  font-size: 0.6rem;
  text-transform: uppercase;
  background: var(--sa-green);
  color: #fff;
  border: none;
  cursor: pointer;
}

/* ─── Energy ─── */
.energy-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.energy-stat {
  background: var(--panel);
  border: 2px solid var(--line);
  padding: 12px;
  text-align: center;
}
.energy-stat strong { font-size: 1.3rem; font-family: 'Archivo Black', sans-serif; color: var(--sa-gold); display: block; }
.energy-stat span { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; }

#energyChart {
  width: 100%;
  background: var(--panel);
  border: 2px solid var(--line);
  display: block;
}
.chart-caption { text-align: center; font-size: 0.65rem; color: var(--muted); margin-top: 6px; }

/* ─── Security ─── */
.security-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.security-stats div {
  background: var(--panel);
  border: 2px solid var(--line);
  padding: 10px;
  text-align: center;
}
.security-stats strong { display: block; font-size: 1.1rem; }
.security-stats span { font-size: 0.6rem; color: var(--muted); text-transform: uppercase; }

.security-feed { display: flex; flex-direction: column; gap: 10px; }

.sec-item {
  background: var(--panel);
  border: 2px solid var(--line);
  padding: 12px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.sec-item .s-icon { font-size: 1.4rem; }
.sec-item h3 { font-size: 0.82rem; }
.sec-item p { font-size: 0.7rem; color: var(--muted); margin-top: 2px; }
.sec-item time { font-size: 0.62rem; color: var(--muted); }

/* ─── Subscriptions ─── */
.plan-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.plan-card {
  background: var(--panel);
  border: 2px solid var(--line);
  padding: 14px;
  position: relative;
}
.plan-card.featured {
  border-color: var(--sa-gold);
  border-width: 3px;
}
.plan-card h3 { font-size: 0.85rem; }
.plan-card .price { font-size: 1.5rem; font-family: 'Archivo Black', sans-serif; color: var(--sa-gold); margin: 4px 0; }
.plan-card .price small { font-size: 0.6rem; color: var(--muted); font-family: 'Space Grotesk', sans-serif; }
.plan-card ul { list-style: none; font-size: 0.68rem; color: var(--muted); margin-top: 6px; }
.plan-card li { padding: 2px 0; }
.plan-card li::before { content: '› '; color: var(--sa-green); font-weight: 900; }

.sub-list { display: flex; flex-direction: column; gap: 10px; }

.sub-item {
  background: var(--panel);
  border: 2px solid var(--line);
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.sub-item h3 { font-size: 0.85rem; }
.sub-item p { font-size: 0.68rem; color: var(--muted); }
.sub-status { font-size: 0.65rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.sub-status.active { background: rgba(0,122,75,0.2); color: var(--sa-green); }
.sub-status.past_due { background: rgba(222,56,49,0.2); color: var(--sa-red); }

.cancel-btn {
  padding: 6px 10px;
  font-family: 'Archivo Black', sans-serif;
  font-size: 0.58rem;
  text-transform: uppercase;
  background: none;
  color: var(--sa-red);
  border: 2px solid var(--sa-red);
  cursor: pointer;
}

/* ─── Footer ─── */
footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: var(--dark);
  border-top: 2px solid var(--line);
  font-size: 0.65rem;
  color: var(--muted);
}

/* ─── Empty states ─── */
.empty {
  background: var(--panel);
  border: 2px dashed var(--line);
  color: var(--muted);
  text-align: center;
  font-size: 0.8rem;
  padding: 28px 16px;
}

/* ─── Desktop tweaks ─── */
@media (min-width: 720px) {
  .device-grid { grid-template-columns: repeat(3, 1fr); }
  .plan-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 480px) {
  .download-btn { font-size: 0.55rem; padding: 6px 8px; }
  .app-logo p { display: none; }
}
