/* ═══════════════════════════════════════════════════════════════════
   Hearts of Patriots CRM — Stylesheet
   Brand-aligned with heartsofpatriots.org
   ═══════════════════════════════════════════════════════════════════ */

:root {
  /* ── Brand colors (from heartsofpatriots.org) ── */
  --hop-navy: #0B5394;
  --hop-navy-dark: #063A7F;
  --hop-navy-light: #98C1E8;
  --hop-red: #9E221A;
  --hop-red-hover: #7E1A14;
  --hop-cream: #F7F3EC;

  /* ── Neutrals ── */
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --border: #E5E7EB;
  --border-strong: #CBD5E1;
  --text: #1F2937;
  --text-muted: #6B7280;
  --text-soft: #9CA3AF;

  /* ── Semantic ── */
  --success: #047857;
  --warning: #B45309;
  --danger: #B91C1C;
  --info: var(--hop-navy);

  /* ── Layout ── */
  --header-h: 68px;
  --sidebar-w: 260px;
  --radius: 6px;
  --radius-lg: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.10);

  /* ── Typography ── */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "Open Sans", Roboto, sans-serif;
}

/* Material Symbols base styling */
.mi {
  font-family: 'Material Symbols Rounded';
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
}
.mi-sm { font-size: 16px; }
.mi-lg { font-size: 24px; }

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

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--hop-navy); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ═══════════════════════════════════════════════════════════
   App shell
   ═══════════════════════════════════════════════════════════ */
.app { display: flex; flex-direction: column; min-height: 100vh; }

/* Header ─────────────────────────────────────────────────── */
.header {
  height: var(--header-h);
  background: var(--hop-navy);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 20px;
  color: white;
  box-shadow: var(--shadow-sm);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  text-decoration: none;
}

.header-brand img {
  height: 44px;
  width: auto;
  display: block;
}

.header-spacer { flex: 1; }

.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.header-user .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 12px;
}

.header-btn {
  background: var(--hop-red);
  color: white;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.header-btn:hover { background: var(--hop-red-hover); }

.header-btn--ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
}
.header-btn--ghost:hover { background: rgba(255, 255, 255, 0.1); }

/* Body layout ─────────────────────────────────────────────── */
.body {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 0 24px;
  flex-shrink: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-group {
  margin-bottom: 18px;
}

.sidebar-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
  padding: 0 20px;
  margin-bottom: 6px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--text);
  font-size: 15px;
  border-left: 3px solid transparent;
  transition: background 0.12s;
  cursor: pointer;
}
.sidebar-link:hover { background: var(--bg); text-decoration: none; }
.sidebar-link.active {
  background: rgba(11, 83, 148, 0.06);
  border-left-color: var(--hop-navy);
  color: var(--hop-navy);
  font-weight: 600;
}

.sidebar-link .mi {
  color: var(--text-muted);
  font-size: 20px;
}
.sidebar-link.active .mi { color: var(--hop-navy); }

/* Quick Actions card in sidebar */
.sidebar-actions {
  margin: 0 16px 20px;
  background: linear-gradient(180deg, var(--hop-navy) 0%, var(--hop-navy-dark) 100%);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: 0 4px 12px rgba(11, 83, 148, 0.18);
}
.sidebar-actions-label {
  color: rgba(255, 255, 255, 0.85);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.sidebar-action {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: white;
  background: rgba(255, 255, 255, 0.10);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  transition: background 0.15s;
  text-decoration: none;
}
.sidebar-action:last-child { margin-bottom: 0; }
.sidebar-action:hover { background: rgba(255, 255, 255, 0.18); text-decoration: none; color: white; }
.sidebar-action .mi {
  font-size: 18px;
  color: var(--hop-navy-light);
}
.sidebar-action--red {
  background: var(--hop-red);
}
.sidebar-action--red:hover { background: var(--hop-red-hover); }
.sidebar-action--red .mi { color: white; }

/* Main content ────────────────────────────────────────────── */
.main {
  flex: 1;
  padding: 28px 36px 60px;
  overflow-y: auto;
  min-width: 0;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--border);
}

.page-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--hop-navy);
  letter-spacing: -0.01em;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

.page-actions {
  display: flex;
  gap: 10px;
}

/* ═══════════════════════════════════════════════════════════
   Cards
   ═══════════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--hop-navy);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-title-accent {
  width: 3px;
  height: 18px;
  background: var(--hop-navy);
  border-radius: 2px;
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Stat cards (dashboard tiles) */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.stat-card .label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-soft);
}
.stat-card .value {
  font-size: 30px;
  font-weight: 700;
  color: var(--hop-navy);
  margin-top: 6px;
  letter-spacing: -0.01em;
}
.stat-card .delta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Quick action grid (Home page) */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.quick-action {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--hop-navy);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s;
  cursor: pointer;
}
.quick-action:hover {
  border-color: var(--hop-navy);
  background: rgba(11, 83, 148, 0.04);
  text-decoration: none;
}
.quick-action::before {
  content: "+";
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--hop-navy);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

/* ═══════════════════════════════════════════════════════════
   Tables
   ═══════════════════════════════════════════════════════════ */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  background: #F8FAFC;
  padding: 12px 16px;
  text-align: left;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}

td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

tr:hover td { background: rgba(11, 83, 148, 0.03); }
tr:last-child td { border-bottom: none; }

/* Clickable rows */
tr.row-link { cursor: pointer; transition: background 0.12s; }
tr.row-link:hover td { background: rgba(11, 83, 148, 0.06); }
tr.row-link:hover td:first-child { box-shadow: inset 3px 0 0 var(--hop-navy); }

.td-amount { font-variant-numeric: tabular-nums; font-weight: 600; }
.td-date { color: var(--text-muted); white-space: nowrap; }
.td-actions { text-align: right; white-space: nowrap; }

/* Status / type pills */
.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.pill-received { background: rgba(4, 120, 87, 0.12); color: var(--success); }
.pill-paid { background: rgba(185, 28, 28, 0.10); color: var(--danger); }
.pill-open { background: rgba(11, 83, 148, 0.10); color: var(--hop-navy); }
.pill-progress { background: rgba(180, 83, 9, 0.12); color: var(--warning); }
.pill-done { background: rgba(107, 114, 128, 0.12); color: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════
   Buttons
   ═══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--hop-navy);
  color: white;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--hop-navy);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
}
.btn:hover { background: var(--hop-navy-dark); border-color: var(--hop-navy-dark); text-decoration: none; }

.btn--secondary {
  background: white;
  color: var(--hop-navy);
}
.btn--secondary:hover { background: var(--bg); }

.btn--red {
  background: var(--hop-red);
  border-color: var(--hop-red);
}
.btn--red:hover { background: var(--hop-red-hover); border-color: var(--hop-red-hover); }

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border-strong);
}
.btn--ghost:hover { background: var(--bg); color: var(--text); }

.btn--sm { padding: 5px 11px; font-size: 12px; }
.btn--icon { padding: 6px 10px; }

/* ═══════════════════════════════════════════════════════════
   Forms
   ═══════════════════════════════════════════════════════════ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.form-row-full { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}
.field-required::after { content: " *"; color: var(--hop-red); }
.field-hint { font-size: 11px; color: var(--text-muted); }

.field input,
.field select,
.field textarea {
  font-family: var(--font);
  font-size: 13.5px;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: white;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--hop-navy);
  box-shadow: 0 0 0 3px rgba(11, 83, 148, 0.12);
}
.field textarea { resize: vertical; min-height: 80px; font-family: inherit; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════════
   Login screen
   ═══════════════════════════════════════════════════════════ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--hop-navy);
  background-image:
    linear-gradient(135deg, var(--hop-navy) 0%, var(--hop-navy-dark) 100%);
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.login-brand .shield {
  width: 56px; height: 56px;
  background: var(--hop-navy);
  color: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 22px;
}

.login-brand h1 {
  font-size: 18px;
  color: var(--hop-navy);
  letter-spacing: 0.04em;
  font-weight: 800;
}
.login-brand p {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.login-card .field { margin-bottom: 16px; }
.login-card .btn { width: 100%; justify-content: center; padding: 11px; }

.login-error {
  background: rgba(185, 28, 28, 0.08);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 12.5px;
  margin-bottom: 16px;
  border-left: 3px solid var(--danger);
}

.login-info {
  background: rgba(11, 83, 148, 0.06);
  color: var(--hop-navy);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 12.5px;
  margin-bottom: 16px;
  border-left: 3px solid var(--hop-navy);
}

/* ═══════════════════════════════════════════════════════════
   Utility
   ═══════════════════════════════════════════════════════════ */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 13px;
}

.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; }
.text-muted { color: var(--text-muted); }
.text-small { font-size: 12px; }
.text-right { text-align: right; }
.font-mono { font-variant-numeric: tabular-nums; }

.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}
.loading::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--hop-navy);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 10px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════════════════
   Modal — used by Quick Add (person / organization) on the
   conversation and to-do forms
   ═══════════════════════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 100;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 620px;
  margin: auto;
}
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}
.modal-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-soft);
  font-size: 22px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: var(--radius);
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 22px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Label row with a Quick Add link on the right */
.field-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.quick-add-link {
  font-size: 12px;
  font-weight: 500;
  color: var(--hop-navy);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}
.quick-add-link:hover { text-decoration: underline; }
