/* ── Reset & Base ────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand:        #1a4d8f;   /* FBCCK blue */
  --brand-dark:   #123366;
  --brand-light:  #e8f0fb;
  --accent:       #c8a227;   /* gold */
  --bg:           #f4f6f9;
  --surface:      #ffffff;
  --text:         #1c1c1e;
  --text-muted:   #6b7280;
  --border:       #e5e7eb;
  --shadow:       0 2px 8px rgba(0,0,0,0.08);
  --shadow-hover: 0 6px 20px rgba(0,0,0,0.14);
  --radius:       14px;
  --radius-sm:    8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ──────────────────────────────────────────── */
header {
  background: var(--brand);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.church-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.church-logo { font-size: 28px; color: var(--accent); flex-shrink: 0; }
.church-name { font-size: 17px; font-weight: 700; white-space: nowrap; }
.church-subtitle { font-size: 12px; opacity: 0.8; margin-top: 1px; }

/* ── Tabs ────────────────────────────────────────────── */
.tab-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 57px;
  z-index: 90;
}

.tab-bar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.tab-bar-inner::-webkit-scrollbar { display: none; }

.tab-btn {
  flex-shrink: 0;
  padding: 14px 22px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}

.tab-btn.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.tab-btn:hover:not(.active) { color: var(--text); }

/* ── Main ────────────────────────────────────────────── */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

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

/* ── Metric Cards ────────────────────────────────────── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.metric-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.metric-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.metric-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  margin-bottom: 6px;
}

.metric-delta {
  font-size: 13px;
  font-weight: 600;
}

.metric-delta.positive { color: #16a34a; }
.metric-delta.negative { color: #dc2626; }
.metric-delta.neutral  { color: var(--text-muted); }

/* ── Charts ──────────────────────────────────────────── */
.chart-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 24px;
}

.chart-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 18px;
}

.chart-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.chart-canvas-wrap {
  position: relative;
  height: 260px;
}

/* ── Video Cards ─────────────────────────────────────── */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.video-card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.video-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
  background: var(--brand-light);
}

.video-info {
  padding: 12px 14px;
}

.video-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Social cards ────────────────────────────────────── */
.social-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.social-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.social-platform {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* ── Document list ───────────────────────────────────── */
.doc-list {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.doc-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.doc-row:last-child { border-bottom: none; }

.doc-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.doc-info {
  flex: 1;
  min-width: 0;
}

.doc-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

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

.doc-link {
  flex-shrink: 0;
  padding: 7px 14px;
  background: var(--brand-light);
  color: var(--brand);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}

.doc-link:hover { background: var(--brand); color: #fff; }

/* ── Warning badge ───────────────────────────────────── */
.warn-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #fef3c7;
  color: #92400e;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  margin-left: 8px;
}

/* ── Loading / Error ─────────────────────────────────── */
.loading-state {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 0;
  font-size: 15px;
}

.error-state {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  color: #dc2626;
  padding: 16px 20px;
  font-size: 14px;
  margin-bottom: 20px;
}

/* ── Section label ───────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin: 24px 0 12px;
}

/* ── Chat ────────────────────────────────────────────── */
.chat-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 160px);
  min-height: 400px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

/* Welcome state */
.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  padding: 40px 20px;
  gap: 10px;
}

.chat-welcome-icon {
  font-size: 36px;
  color: var(--brand);
  line-height: 1;
  margin-bottom: 4px;
}

.chat-welcome-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.chat-welcome-sub {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 380px;
  line-height: 1.5;
}

.chat-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  max-width: 600px;
}

.chat-chip {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--brand);
  cursor: pointer;
  transition: background .15s, border-color .15s;
  text-align: left;
}

.chat-chip:hover {
  background: var(--brand-light);
  border-color: var(--brand);
}

/* Message rows */
.chat-msg {
  display: flex;
  max-width: 100%;
}

.chat-msg-user {
  justify-content: flex-end;
}

.chat-msg-model,
.chat-msg-error {
  justify-content: flex-start;
}

.chat-bubble {
  max-width: min(680px, 80%);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

.chat-msg-user .chat-bubble {
  background: var(--brand);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg-model .chat-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.chat-bubble-error {
  background: #fef2f2 !important;
  border-color: #fecaca !important;
  color: #dc2626 !important;
}

/* Typing indicator */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px;
}

.chat-typing span {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: chatBounce 1.2s infinite ease-in-out;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40%           { transform: translateY(-6px); opacity: 1; }
}

/* Input bar */
.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 0 4px;
  border-top: 1px solid var(--border);
}

.chat-input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
  max-height: 160px;
  overflow-y: auto;
}

.chat-input:focus {
  outline: none;
  border-color: var(--brand);
}

.chat-send-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}

.chat-send-btn:hover:not(:disabled) { background: var(--brand-dark); }
.chat-send-btn:disabled { background: var(--border); cursor: not-allowed; }

/* ── Mobile ──────────────────────────────────────────── */
@media (max-width: 640px) {
  .chart-row { grid-template-columns: 1fr; }
  .social-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .tab-btn { padding: 12px 14px; font-size: 13px; }
  .chat-layout { height: calc(100vh - 140px); }
  .chat-bubble { max-width: 90%; }
}
