/* styles.css — Syzzle Status web app
   Visual language mirrors the iOS/macOS SwiftUI app (AppTheme.swift). */

:root {
  /* Status colors — identical to AppTheme.swift */
  --status-green: #16A34A;
  --status-amber: #D97706;
  --status-red:   #DC2626;
  --status-gray:  #6B7280;

  --accent: #C2410C;              /* brand accent — orange, matches the app logo */
  --identity-blue: #3B82F6;       /* fixed IMAP icon-chip color, independent of health */
  --splash-bg: #1C1C1E;

  /* Light theme surfaces */
  --page-bg: #FFFFFF;
  --card-bg: #FFFFFF;
  --card-border: rgba(0, 0, 0, 0.06);
  --text-primary: #1C1C1E;
  --text-secondary: #6B7280;
  --text-tertiary: #9CA3AF;
  --field-bg: #FFFFFF;
  --field-border: rgba(0, 0, 0, 0.12);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 8px 24px rgba(0, 0, 0, 0.04);

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --max-content: 560px;          /* .macContentFrame() equivalent */

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
          Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";

  /* Subtle U.S. patriotic page background: a sparse field of faint red and
     blue stars (Old Glory Red / Old Glory Blue) on a plain white page. Kept
     low-opacity so it reads as texture, not decoration — cards/text sit on
     their own opaque surfaces on top. */
  --patriot-stars: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cpath fill='%23B22234' fill-opacity='0.09' d='M24 4l3.5 10.6H38l-8.8 6.4 3.4 10.6L24 25.2l-8.6 6.4 3.4-10.6L10 14.6h10.5z'/%3E%3Cpath fill='%233C3B6E' fill-opacity='0.09' d='M154 100l2.7 8.2h8.6l-6.9 5 2.6 8.2-7-5-7 5 2.6-8.2-6.9-5h8.6z'/%3E%3Cpath fill='%233C3B6E' fill-opacity='0.08' d='M60 150l3 9.2h9.6l-7.8 5.7 3 9.2-7.8-5.7-7.8 5.7 3-9.2-7.8-5.7h9.6z'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #FB923C;             /* lighter orange for contrast against dark surfaces */
    --page-bg: #000000;
    --card-bg: #1C1C1E;
    --card-border: rgba(255, 255, 255, 0.08);
    --text-primary: #FFFFFF;
    --text-secondary: #9CA3AF;
    --text-tertiary: #6B7280;
    --field-bg: #2C2C2E;
    --field-border: rgba(255, 255, 255, 0.14);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);

    --patriot-stars: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cpath fill='%23E85A6D' fill-opacity='0.07' d='M24 4l3.5 10.6H38l-8.8 6.4 3.4 10.6L24 25.2l-8.6 6.4 3.4-10.6L10 14.6h10.5z'/%3E%3Cpath fill='%237B84D6' fill-opacity='0.08' d='M154 100l2.7 8.2h8.6l-6.9 5 2.6 8.2-7-5-7 5 2.6-8.2-6.9-5h8.6z'/%3E%3Cpath fill='%237B84D6' fill-opacity='0.07' d='M60 150l3 9.2h9.6l-7.8 5.7 3 9.2-7.8-5.7-7.8 5.7 3-9.2-7.8-5.7h9.6z'/%3E%3C/svg%3E");
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  background-color: var(--page-bg);
  background-image: var(--patriot-stars);
  background-repeat: repeat;
  background-size: 220px 220px;
  background-attachment: fixed;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

/* ── Views ──────────────────────────────────────────────────────────── */

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  animation: fade-in 0.25s ease;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.content {
  width: 100%;
  max-width: var(--max-content);
  margin: 0 auto;
  padding: clamp(20px, 5vw, 40px) 20px 48px;
  flex: 1;
}

/* Centered variant for auth screens */
.view--center {
  justify-content: center;
  align-items: center;
}
.view--center .content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex: 0;
}

/* ── Loading / splash ───────────────────────────────────────────────── */

.view--loading {
  background: var(--splash-bg);
  justify-content: center;
  align-items: center;
  gap: 28px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner--inline {
  width: 18px;
  height: 18px;
  border-width: 2px;
  border-color: rgba(255, 255, 255, 0.4);
  border-top-color: #FFFFFF;
  display: inline-block;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Brand mark / logo ──────────────────────────────────────────────── */

.brand-mark {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
}

.auth-logo {
  width: 64px;
  height: 64px;
  margin-bottom: 20px;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.18));
}

/* The Syzzle logo is a self-contained icon (transparent corners), so it just
   fills its container — no colored tile behind it. */
.logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* ── Typography ─────────────────────────────────────────────────────── */

h1 { font-size: 1.65rem; font-weight: 700; margin: 0 0 6px; letter-spacing: -0.02em; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.tagline { color: var(--text-secondary); font-size: 0.95rem; margin: 0 0 28px; }
.muted { color: var(--text-secondary); }
.tertiary { color: var(--text-tertiary); font-size: 0.8rem; }

/* ── Auth forms ─────────────────────────────────────────────────────── */

.auth-card {
  width: 100%;
  max-width: 380px;
}

.field {
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--field-bg);
  border: 1px solid var(--field-border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.btn {
  width: 100%;
  padding: 14px 20px;
  margin-top: 14px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  color: #FFFFFF;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: filter 0.15s ease, opacity 0.15s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.06); }
.btn:active:not(:disabled) { filter: brightness(0.94); }
.btn:disabled { opacity: 0.6; cursor: default; }

.btn--ghost {
  background: transparent;
  color: var(--accent);
  font-weight: 500;
  margin-top: 8px;
}
.btn--ghost:hover:not(:disabled) { filter: none; text-decoration: underline; }

.form-error {
  color: var(--status-red);
  font-size: 0.88rem;
  margin: 12px 0 0;
  min-height: 1.1em;
}

.signin-app-store { margin-top: 24px; }

.check-icon {
  font-size: 44px;
  margin-bottom: 16px;
}

/* ── Dashboard header ───────────────────────────────────────────────── */

.dash-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}
.dash-header .logo {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.dash-header .titles { flex: 1; min-width: 0; }
.dash-header .brand { font-size: 1.55rem; letter-spacing: -0.02em; }
.dash-header .brand .brand-light { font-weight: 400; }
.dash-header .brand .brand-bold { font-weight: 800; }
.dash-header .sub {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 3px;
}
.brand-rule {
  width: 3px;
  height: 12px;
  border-radius: 2px;
  background: var(--accent);
  flex-shrink: 0;
}
.brand-tagline {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.header-refresh {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(128, 128, 128, 0.12);
  color: var(--accent);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s ease;
}
.header-refresh:hover:not(:disabled) { background: rgba(128, 128, 128, 0.2); }
.header-refresh:disabled { opacity: 0.6; cursor: default; }
.header-refresh svg { width: 18px; height: 18px; }
.header-refresh.is-refreshing svg { animation: spin 0.8s linear infinite; }

.signout {
  background: transparent;
  border: 1px solid var(--field-border);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.signout:hover { color: var(--status-red); border-color: var(--status-red); }

/* ── Overall status banner ──────────────────────────────────────────── */

.banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.banner .dot { width: 16px; height: 16px; flex-shrink: 0; }
.banner .banner-text { flex: 1; }
.banner .banner-title { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.01em; }
.banner .banner-sub { font-size: 0.85rem; color: var(--text-secondary); margin-top: 2px; }

/* ── Status page: overall card ──────────────────────────────────────── */

.overall-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.overall-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.overall-icon svg { width: 26px; height: 26px; }
.overall-text { flex: 1; min-width: 0; }
.overall-title { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.01em; }
.overall-sub { font-size: 0.85rem; color: var(--text-secondary); margin-top: 2px; }
.overall-dot { width: 11px; height: 11px; flex-shrink: 0; }

/* ── Status page: SERVICES section ──────────────────────────────────── */

/* Compound selector (not just .section-label--caps) so this reliably beats
   .section-label's own text-transform:none regardless of source order. */
.section-label.section-label--caps {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.74rem;
  font-weight: 700;
}

.services-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.service-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
}
/* Inset divider: starts after the icon, aligned with the text column. */
.service-row-divider {
  height: 1px;
  background: var(--card-border);
  margin-left: 58px;
}
.svc-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.svc-icon svg { width: 20px; height: 20px; }
/* Fixed per-service identity colors — independent of health. */
.svc-icon-webmail { background: rgba(22, 163, 74, 0.14); color: var(--status-green); }
.svc-icon-imap    { background: rgba(59, 130, 246, 0.14); color: var(--identity-blue); }
.svc-icon-smtp    { background: rgba(217, 119, 6, 0.14); color: var(--status-amber); }

.svc-meta { flex: 1; min-width: 0; }
.svc-name { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; }
.svc-desc { font-size: 0.82rem; color: var(--text-secondary); margin-top: 1px; }

.svc-health {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.svc-health .dot { width: 8px; height: 8px; }

/* ── Status page: info footer card ──────────────────────────────────── */

.info-footer-card {
  margin-top: 24px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.info-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
}
.info-row-divider {
  height: 1px;
  background: var(--card-border);
  margin-left: 48px;
}
.info-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: var(--text-tertiary);
}
.info-icon svg { width: 18px; height: 18px; }
.info-label { flex: 1; min-width: 0; font-size: 0.9rem; color: var(--text-secondary); }
.info-value { font-size: 0.9rem; font-weight: 700; text-align: right; }

.dash-footer--center { justify-content: center; margin-top: 24px; }

.refresh-btn--icon-only {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  justify-content: center;
}
.refresh-btn--icon-only svg { width: 18px; height: 18px; }

/* Status → color mapping */
.dot { border-radius: 50%; display: inline-block; }

.s-operational { color: var(--status-green); }
.s-degraded    { color: var(--status-amber); }
.s-down        { color: var(--status-red); }
.s-unknown     { color: var(--status-gray); }

.bg-operational { background: rgba(22, 163, 74, 0.12); }
.bg-degraded    { background: rgba(217, 119, 6, 0.12); }
.bg-down        { background: rgba(220, 38, 38, 0.12); }
.bg-unknown     { background: rgba(107, 114, 128, 0.12); }

.dot.s-operational { background: var(--status-green); }
.dot.s-degraded    { background: var(--status-amber); }
.dot.s-down        { background: var(--status-red); }
.dot.s-unknown     { background: var(--status-gray); }

/* ── Footer / last-checked ──────────────────────────────────────────── */

.dash-footer {
  margin-top: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.last-checked { font-size: 0.82rem; color: var(--text-tertiary); }
.last-checked.is-stale { color: var(--status-amber); }

.refresh-btn {
  background: transparent;
  border: 1px solid var(--field-border);
  color: var(--accent);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.refresh-btn:disabled { opacity: 0.5; cursor: default; }
.refresh-btn svg { width: 14px; height: 14px; }
.refresh-btn.is-refreshing svg { animation: spin 0.8s linear infinite; }

.error-note {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: rgba(220, 38, 38, 0.1);
  color: var(--status-red);
  font-size: 0.85rem;
}

.skeleton {
  background: linear-gradient(90deg,
    rgba(128,128,128,0.10) 25%,
    rgba(128,128,128,0.18) 50%,
    rgba(128,128,128,0.10) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  border-radius: 6px;
  color: transparent !important;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Tabbed app shell (Home / Status / Account) ─────────────────────── */

.view--app {
  flex-direction: row;
  align-items: stretch;
}

.sidebar {
  flex-shrink: 0;
  width: 240px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 12px;
  border-right: 1px solid var(--card-border);
  background: var(--card-bg);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.98rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item:hover { background: rgba(128, 128, 128, 0.1); }
.nav-item.active { background: rgba(128, 128, 128, 0.16); font-weight: 600; }
.nav-icon { width: 22px; height: 22px; flex-shrink: 0; display: grid; place-items: center; }
.nav-icon svg { width: 20px; height: 20px; }
.nav-spacer { flex: 1; }
.nav-signout { color: var(--text-secondary); }
.nav-signout:hover { color: var(--status-red); }

.pane {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
}

/* ── Home tab ───────────────────────────────────────────────────────── */

.section-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: none;
  margin: 26px 4px 10px;
}

.home-banner {
  padding: 22px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--card-border);
  margin-bottom: 4px;
}
.home-banner.bg-unknown { background: var(--card-bg); }
.home-banner.bg-operational { border-color: rgba(22, 163, 74, 0.35); }
.home-banner.bg-degraded    { border-color: rgba(217, 119, 6, 0.35); }
.home-banner.bg-down        { border-color: rgba(220, 38, 38, 0.35); }

.home-banner-top { display: flex; align-items: center; gap: 16px; }
.shield {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.shield svg { width: 30px; height: 30px; }
.home-banner-text { flex: 1; min-width: 0; }
.home-banner-title { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; }
.home-banner-sub { font-size: 0.9rem; color: var(--text-secondary); margin-top: 2px; }

.service-pills { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.service-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  font-size: 0.86rem;
  font-weight: 500;
}
.service-pill .dot { width: 9px; height: 9px; }

/* ── About / key-value lists ────────────────────────────────────────── */

.about-list {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.about-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 20px;
  border-top: 1px solid var(--card-border);
}
.about-row:first-child { border-top: none; }
.about-label { font-size: 0.95rem; font-weight: 500; }
.about-value { font-size: 0.95rem; color: var(--text-secondary); text-align: right; }

/* ── Home editorial message card (Firestore `homepage` collection) ─────── */

.home-msg-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 20px 22px;
}
.home-msg-card.fade-in { animation: fade-in 0.35s ease; }

.home-msg-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}
.home-msg-body {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 18px;
  overflow-wrap: anywhere;
}
.home-msg-divider {
  height: 1px;
  background: var(--card-border);
  margin-bottom: 12px;
}
.home-msg-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-tertiary);
}

.app-store-card { margin-top: 20px; }
.app-store-badge-link {
  display: inline-block;
  line-height: 0;
  border-radius: 8px;
}
.app-store-badge-link img { display: block; width: 140px; height: 47px; }
.app-store-badge-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Account tab ────────────────────────────────────────────────────── */

.account-identity {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 600;
}
.identity-text { flex: 1; min-width: 0; }
.identity-name {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.identity-email {
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-card {
  padding: 18px 20px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.quota-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.quota-line { font-size: 0.95rem; font-weight: 500; }
.quota-pct { font-size: 0.95rem; font-weight: 700; }
.quota-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(128, 128, 128, 0.16);
  overflow: hidden;
}
.quota-fill { height: 100%; border-radius: 999px; transition: width 0.4s ease; }
.bg-fill-operational { background: var(--status-green); }
.bg-fill-degraded    { background: var(--status-amber); }
.bg-fill-down        { background: var(--status-red); }

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.stat-label { font-weight: 500; }
.stat-value { color: var(--text-secondary); }

.signout-btn {
  width: 100%;
  margin-top: 20px;
  padding: 14px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--status-red);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s ease;
}
.signout-btn:hover { background: rgba(220, 38, 38, 0.08); }

/* ── Responsive: bottom tab bar on narrow screens ───────────────────── */

@media (max-width: 640px) {
  .view--app { flex-direction: column; }
  .pane { order: 1; padding-bottom: 112px; }
  .sidebar {
    order: 2;
    position: fixed;
    bottom: calc(14px + env(safe-area-inset-bottom));
    left: 16px;
    right: 16px;
    width: auto;
    flex-direction: row;
    gap: 0;
    padding: 8px 8px;
    border: 1px solid var(--card-border);
    border-radius: 999px;
    background: var(--card-bg);
    box-shadow: var(--shadow);
    z-index: 10;
  }
  .nav-item {
    flex-direction: column;
    gap: 3px;
    padding: 6px 4px;
    font-size: 0.68rem;
    border-radius: 999px;
  }
  .nav-item.active { background: transparent; color: var(--accent); }
  .nav-spacer { display: none; }
  .nav-signout { display: none; }
}

/* ── Admin announcement banners (Firestore) ─────────────────────────── */

.message-banners {
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;      /* center cards; card caps at --max-content */
  gap: 10px;
}
.message-banners.has-messages { padding: 16px 20px 0; }

/* On desktop the dashboard has a 240px sidebar, so shift the banner right to
   line the cards up with the pane's content column (auth screens have no
   sidebar, so no offset there). */
@media (min-width: 641px) {
  body:has(.view--app) .message-banners { padding-left: calc(240px + 20px); }
}

.msg-card {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  width: 100%;
  /* Match the content cards' column: --max-content minus .content's 20px
     horizontal padding on each side, so the banner edges line up with them. */
  max-width: calc(var(--max-content) - 40px);
  box-sizing: border-box;
  padding: 14px 14px 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid;
  box-shadow: var(--shadow);
  animation: fade-in 0.2s ease;
}
.msg-icon {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
}
.msg-icon svg { width: 15px; height: 15px; }
.msg-content { flex: 1; min-width: 0; }
.msg-title { font-size: 0.95rem; font-weight: 700; letter-spacing: -0.01em; }
.msg-body { font-size: 0.88rem; margin-top: 3px; opacity: 0.9; overflow-wrap: anywhere; }

.msg-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
  font-size: 0.76rem;
  font-weight: 500;
  opacity: 0.72;
}
.msg-meta svg { width: 12px; height: 12px; flex-shrink: 0; }

.msg-dismiss {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: currentColor;
  opacity: 0.55;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.msg-dismiss:hover { opacity: 1; background: rgba(0, 0, 0, 0.06); }
.msg-dismiss svg { width: 16px; height: 16px; }

/* Type variants: info=blue, warning=amber, maintenance=indigo/purple */
.msg-info        { background: #EFF6FF; border-color: #BFDBFE; color: #1E3A8A; }
.msg-info .msg-icon { background: #2563EB; }
.msg-warning     { background: #FEF2F2; border-color: #FECACA; color: #991B1B; }
.msg-warning .msg-icon { background: #DC2626; }
.msg-maintenance { background: #EEF2FF; border-color: #C7D2FE; color: #3730A3; }
.msg-maintenance .msg-icon { background: #6366F1; }

/* Urgent: same red as warning, but a LIGHTER card background — the pulsing
   border/glow (not a heavy fill) is what signals severity. */
.msg-urgent      { background: #FFF5F5; border-color: #FECACA; color: #991B1B; }
.msg-urgent .msg-icon { background: #DC2626; }
.msg-urgent {
  /* ~1.6s each way (in and out) → 3.2s per full breathing cycle. */
  animation: urgent-pulse 3.2s ease-in-out infinite;
}

@keyframes urgent-pulse {
  0%, 100% {
    border-color: rgba(220, 38, 38, 0.30);
    box-shadow: var(--shadow), 0 0 4px rgba(220, 38, 38, 0.35);
    transform: scale(1);
  }
  50% {
    border-color: rgba(220, 38, 38, 1);
    box-shadow: var(--shadow), 0 0 20px rgba(220, 38, 38, 0.55);
    transform: scale(1.03);
  }
}

@media (prefers-reduced-motion: reduce) {
  .msg-urgent { animation: none; border-color: #FECACA; }
}

@media (prefers-color-scheme: dark) {
  .msg-info        { background: rgba(37, 99, 235, 0.16);  border-color: rgba(59, 130, 246, 0.4);  color: #BFDBFE; }
  .msg-warning     { background: rgba(220, 38, 38, 0.16);  border-color: rgba(248, 113, 113, 0.4); color: #FCA5A5; }
  .msg-maintenance { background: rgba(99, 102, 241, 0.16); border-color: rgba(129, 140, 248, 0.4); color: #C7D2FE; }
  .msg-urgent      { background: rgba(220, 38, 38, 0.10);  border-color: rgba(248, 113, 113, 0.4); color: #FCA5A5; }
  .msg-dismiss:hover { background: rgba(255, 255, 255, 0.12); }
}

@media (max-width: 640px) {
  .message-banners.has-messages { padding: 12px 14px 0; }
}
