/* === St Simeon Donation Dashboard === */
/* Color palette inspired by the church icon:
   - Gold (halo)        #C8A04A
   - Deep red (frame)   #A63A2A
   - Dark olive (robes) #3E3528
   - Cream warm bg      #F5EDD8
   - Off-white surface  #FBF7EE
   - Charcoal text      #1A1612
*/

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;500;600;700&family=Source+Sans+3:wght@400;500;600;700&display=swap');

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

:root {
  --gold: #C8A04A;
  --gold-light: #D4B86A;
  --gold-dark: #A8842F;
  --red: #A63A2A;
  --red-dark: #82281C;
  --olive: #3E3528;
  --cream: #F5EDD8;
  --surface: #FBF7EE;
  --text: #1A1612;
  --muted: #6B5F4A;
  --border: #E0D5BC;
  --shadow: 0 2px 12px rgba(62,53,40,0.08);
}

html, body {
  font-family: 'Source Sans 3', sans-serif;
  background: var(--cream);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

h1, h2, h3, h4 {
  font-family: 'Cormorant Garamond', serif;
  color: var(--olive);
  font-weight: 600;
  letter-spacing: 0.01em;
}

a { color: var(--red); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--red-dark); text-decoration: underline; }

/* === Layout === */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--olive);
  color: var(--cream);
  padding: 1.5rem 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-header {
  text-align: center;
  padding: 0 1.5rem 1.5rem;
  border-bottom: 1px solid rgba(200,160,74,0.2);
}

.sidebar-header img {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  border: 3px solid var(--gold);
  background: white;
  margin-bottom: 0.75rem;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.sidebar-header .church-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 0.25rem;
  line-height: 1.2;
}

.sidebar-header .church-loc {
  font-size: 0.8rem;
  color: rgba(245,237,216,0.7);
}

.sidebar-nav { padding: 1rem 0.5rem; flex: 1; }

.sidebar-nav a {
  display: block;
  padding: 0.7rem 1rem;
  color: var(--cream);
  border-radius: 6px;
  margin-bottom: 0.25rem;
  font-size: 0.95rem;
  font-weight: 500;
}

.sidebar-nav a:hover {
  background: rgba(200,160,74,0.15);
  color: var(--gold);
  text-decoration: none;
}

.sidebar-nav a.active {
  background: var(--gold);
  color: var(--olive);
  font-weight: 600;
}

.sidebar-nav a.active:hover { color: var(--olive); }

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(200,160,74,0.2);
  font-size: 0.85rem;
}

.sidebar-footer .user-name { color: var(--gold); margin-bottom: 0.25rem; font-weight: 600; }
.sidebar-footer a { color: rgba(245,237,216,0.7); }
.sidebar-footer a:hover { color: var(--gold); }

.main {
  flex: 1;
  margin-left: 240px;
  padding: 2.5rem 3rem;
  max-width: 1400px;
}

.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--gold);
}

.page-header h1 {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.page-header .subtitle {
  color: var(--muted);
  font-size: 0.95rem;
}

/* === Stats grid === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--gold);
}

.stat-card.red { border-top-color: var(--red); }
.stat-card.olive { border-top-color: var(--olive); }

.stat-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.stat-value {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2.25rem;
  font-weight: 600;
  color: var(--olive);
  line-height: 1;
}

.stat-sub {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

/* === Cards === */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem 1.75rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

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

.card-header h2 {
  font-size: 1.4rem;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 1100px) { .card-grid { grid-template-columns: 1fr; } }

/* === Tables === */
table.data {
  width: 100%;
  border-collapse: collapse;
}

table.data th {
  text-align: left;
  padding: 0.75rem 0.5rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 2px solid var(--gold);
  font-weight: 600;
}

table.data td {
  padding: 0.85rem 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

table.data tr:last-child td { border-bottom: none; }

table.data tr:hover td { background: rgba(200,160,74,0.05); }

table.data .num { text-align: right; font-variant-numeric: tabular-nums; }

table.data .money {
  text-align: right;
  font-weight: 600;
  color: var(--olive);
  font-variant-numeric: tabular-nums;
}

/* === Bars (for monthly chart) === */
.bar-row {
  display: grid;
  grid-template-columns: 80px 1fr 100px;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0;
}

.bar-label { font-size: 0.9rem; color: var(--muted); font-weight: 500; }

.bar-bg {
  height: 24px;
  background: var(--cream);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold) 0%, var(--gold-dark) 100%);
  display: flex;
  align-items: center;
  padding: 0 0.5rem;
  color: white;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  border-radius: 0 4px 4px 0;
}

.bar-value {
  font-weight: 600;
  color: var(--olive);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* === Filter bar === */
.filter-bar {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  align-items: center;
}

.filter-bar input, .filter-bar select {
  padding: 0.6rem 0.85rem;
  font-family: inherit;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.filter-bar input:focus, .filter-bar select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200,160,74,0.2);
}

.filter-bar input[type=search] { width: 280px; }

/* === Buttons === */
.btn {
  display: inline-block;
  padding: 0.65rem 1.25rem;
  background: var(--gold);
  color: var(--olive);
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn:hover { background: var(--gold-dark); color: white; text-decoration: none; }

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-secondary:hover { background: var(--cream); color: var(--olive); }

/* === Badges === */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-eft { background: rgba(200,160,74,0.2); color: var(--gold-dark); }
.badge-square { background: rgba(166,58,42,0.15); color: var(--red); }
.badge-recurring { background: rgba(62,53,40,0.15); color: var(--olive); }

.fund-pill {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.8rem;
  margin-right: 0.25rem;
  color: var(--olive);
}

.fund-pill .amt { font-weight: 600; color: var(--gold-dark); margin-left: 0.25rem; }

/* === Login page === */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--cream) 0%, #EDE0BE 100%);
}

.login-card {
  background: var(--surface);
  padding: 3rem 2.5rem;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(62,53,40,0.15);
  width: 100%;
  max-width: 420px;
  text-align: center;
  border-top: 6px solid var(--gold);
}

.login-card img {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  border: 4px solid var(--gold);
  margin: 0 auto 1rem;
  display: block;
  background: white;
}

.login-card h1 {
  font-size: 1.6rem;
  margin-bottom: 0.25rem;
}

.login-card .subtitle {
  color: var(--muted);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

.login-card form { text-align: left; }

.form-group { margin-bottom: 1.25rem; }

.form-group label {
  display: block;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.form-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  background: white;
}

.form-group input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200,160,74,0.2);
}

.btn-block { width: 100%; padding: 0.85rem; font-size: 1rem; }

.flash {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.flash-error { background: rgba(166,58,42,0.1); color: var(--red-dark); border: 1px solid rgba(166,58,42,0.3); }

/* === Donor detail === */
.donor-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.donor-meta .item label {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
  font-weight: 600;
}

.donor-meta .item .value { font-size: 1rem; color: var(--text); }

.empty {
  text-align: center;
  padding: 3rem;
  color: var(--muted);
  font-style: italic;
}


/* --- donor detail / filters / extras --- */
.back-link { color: var(--red); text-decoration: none; font-size: 0.9rem; display: inline-block; margin-bottom: 0.5rem; }
.back-link:hover { text-decoration: underline; }

.card-grid.two-col { grid-template-columns: 1fr 1fr; }

dl.kv { display: grid; grid-template-columns: 140px 1fr; gap: 0.6rem 1rem; margin: 0; padding: 1rem 1.25rem; }
dl.kv dt { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; }
dl.kv dd { margin: 0; color: var(--ink); }

.big-number { font-family: 'Cormorant Garamond', serif; font-size: 3.2rem; font-weight: 600; color: var(--red); padding: 1.5rem 1.25rem 0.25rem; line-height: 1; }
.big-sub { color: var(--muted); padding: 0 1.25rem 1.5rem; }

.fund-line { display: flex; justify-content: space-between; gap: 0.75rem; font-size: 0.9rem; padding: 1px 0; }
.fund-line .fund-name { color: var(--ink); }
.fund-line .fund-amt { color: var(--muted); font-variant-numeric: tabular-nums; }

.filter-bar { display: flex; gap: 1rem; align-items: end; padding: 1rem 1.25rem; background: var(--cream); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 1.5rem; flex-wrap: wrap; }
.filter-bar label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.filter-bar select { padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 6px; background: white; font-size: 0.95rem; min-width: 180px; }
.filter-bar button { padding: 0.55rem 1.25rem; border: 0; background: var(--red); color: white; border-radius: 6px; font-size: 0.95rem; cursor: pointer; font-weight: 500; }
.filter-bar button:hover { background: var(--red-dark); }
.filter-bar .btn-clear { padding: 0.55rem 1rem; color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.filter-bar .btn-clear:hover { color: var(--red); }

.badge-mail { background: rgba(200,160,74,0.15); color: var(--gold-dark); border: 1px solid rgba(200,160,74,0.4); }

table.data tfoot td { font-weight: 600; background: var(--cream); border-top: 2px solid var(--border); }

/* --- year tabs --- */

/* --- year tabs (refined Byzantine-style pills) --- */
.year-tabs {
  display: flex;
  gap: 0.5rem;
  margin: 0 0 1.75rem;
  padding: 0.5rem;
  background: linear-gradient(180deg, #FBF6E6 0%, var(--cream) 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  flex-wrap: wrap;
  box-shadow: 0 1px 2px rgba(62,53,40,0.04);
}
.year-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  color: var(--muted);
  text-decoration: none;
  font-family: 'Cormorant Garamond', serif;
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  transition: all 0.18s ease;
}
.year-tab:hover {
  color: var(--ink);
  background: rgba(255,255,255,0.65);
  text-decoration: none;
}
.year-tab.active {
  color: white;
  background: linear-gradient(180deg, var(--red) 0%, var(--red-dark) 100%);
  border-color: var(--red-dark);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.25) inset,
    0 2px 6px rgba(166,58,42,0.35);
}
.year-tab.active::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 2px rgba(200,160,74,0.25);
}
.year-tab[data-label="All"] { font-style: italic; }


/* ========================================================
   Mobile / responsive (added 2026-04-30)
   ======================================================== */

/* Tablet & below: collapse sidebar to top bar */
@media (max-width: 900px) {
  .app-shell { flex-direction: column; }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    padding: 0.75rem 1rem;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    overflow-x: auto;
    overflow-y: hidden;
    border-bottom: 3px solid var(--gold);
  }

  .sidebar-header {
    padding: 0;
    border-bottom: none;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
  }

  .sidebar-header img {
    width: 44px; height: 44px;
    border-width: 2px;
    margin: 0;
  }

  .sidebar-header .church-name {
    font-size: 0.95rem;
    margin: 0;
    white-space: nowrap;
  }

  .sidebar-header .church-loc { display: none; }

  .sidebar-nav {
    padding: 0;
    flex: 1;
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar-nav a {
    padding: 0.45rem 0.85rem;
    margin: 0;
    font-size: 0.9rem;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .sidebar-footer {
    padding: 0;
    border-top: none;
    flex-shrink: 0;
    text-align: right;
  }

  .sidebar-footer .user-name { display: none; }
  .sidebar-footer a { font-size: 0.85rem; }

  .main {
    margin-left: 0;
    padding: 1.25rem 1rem 2rem;
    max-width: 100%;
  }

  .page-header { margin-bottom: 1.25rem; padding-bottom: 0.75rem; }
  .page-header h1 { font-size: 1.5rem; }
  .page-header .subtitle { font-size: 0.85rem; }
}

/* Phone-specific tweaks */
@media (max-width: 600px) {
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
  }

  .stat-card { padding: 1rem 1.1rem; }
  .stat-value { font-size: 1.75rem; }
  .stat-label { font-size: 0.7rem; }

  .card { padding: 1rem 1.1rem; margin-bottom: 1rem; }
  .card-header h2 { font-size: 1.15rem; }

  /* Tables become horizontally scrollable on phones */
  .card, .main > table.data {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table.data {
    min-width: 480px;
    font-size: 0.88rem;
  }
  table.data th, table.data td {
    padding: 0.55rem 0.4rem;
    font-size: 0.85rem;
  }

  /* Wrap any direct-child table in a scroll container effectively */
  .main > table.data {
    display: block;
    width: 100%;
  }

  /* Bar-row chart: compact label/value columns */
  .bar-row {
    grid-template-columns: 50px 1fr 75px;
    gap: 0.5rem;
    padding: 0.4rem 0;
  }
  .bar-label { font-size: 0.8rem; }
  .bar-fill { font-size: 0.7rem; padding: 0 0.3rem; }
  .bar-value { font-size: 0.85rem; }

  /* Filter bar — stack form controls full-width */
  .filter-bar {
    padding: 0.85rem 1rem;
    gap: 0.6rem;
    flex-direction: column;
    align-items: stretch;
  }
  .filter-bar label { width: 100%; }
  .filter-bar select, .filter-bar input { width: 100%; min-width: 0; }
  .filter-bar input[type=search] { width: 100%; }
  .filter-bar button, .filter-bar .btn-clear { width: 100%; text-align: center; }

  /* Year tabs scroll horizontally rather than wrapping into many rows */
  .year-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1.25rem;
  }
  .year-tab {
    flex-shrink: 0;
    padding: 0.4rem 0.85rem;
    font-size: 0.95rem;
  }

  /* Donor detail: kv-list stacks instead of two columns */
  dl.kv {
    grid-template-columns: 1fr;
    gap: 0.15rem 0;
    padding: 0.85rem 1rem;
  }
  dl.kv dt { margin-top: 0.35rem; }
  dl.kv dt:first-child { margin-top: 0; }

  .big-number { font-size: 2.4rem; padding: 1rem 1rem 0.25rem; }
  .big-sub { padding: 0 1rem 1rem; font-size: 0.85rem; }

  .card-grid.two-col, .card-grid { grid-template-columns: 1fr; gap: 1rem; }

  .donor-meta { gap: 0.6rem; }

  /* Login card on small phones */
  .login-card { padding: 2rem 1.5rem; max-width: 100%; }
  .login-card img { width: 90px; height: 90px; }
  .login-card h1 { font-size: 1.35rem; }

  /* Pills/badges stay readable */
  .fund-pill { font-size: 0.75rem; padding: 0.1rem 0.45rem; }
  .badge { font-size: 0.7rem; padding: 0.15rem 0.5rem; }
}

/* Very narrow (small phones) */
@media (max-width: 380px) {
  .sidebar-header .church-name { display: none; }
  .stat-value { font-size: 1.55rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
