/* ============================================================
   TheDivorceBot — style.css
   ============================================================ */

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f8fafc;
  color: #1e293b;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-weight: 600; line-height: 1.3; }

/* ── Disclaimer banner ────────────────────────────────────── */
.disclaimer-banner {
  background: #7c3aed;
  color: #fff;
  text-align: center;
  padding: 6px 16px;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
}

/* ── Navbar ───────────────────────────────────────────────── */
.navbar {
  background: #1e293b;
  color: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 52px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  letter-spacing: -0.01em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-links a {
  color: #94a3b8;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 0.875rem;
  transition: background 0.15s, color 0.15s;
}

.nav-links a:hover { background: #334155; color: #f1f5f9; text-decoration: none; }
.nav-links a.active { background: #2563eb; color: #fff; }
.nav-links a.nav-logout { color: #f87171; margin-left: 8px; }
.nav-links a.nav-logout:hover { background: #450a0a; color: #fca5a5; }

/* ── Main content ─────────────────────────────────────────── */
.main-content {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* ── Flash messages ───────────────────────────────────────── */
.flash-messages { margin-bottom: 16px; }

.flash {
  padding: 10px 16px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 0.875rem;
}

.flash-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.flash-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.flash-warning { background: #fef9c3; color: #854d0e; border: 1px solid #fde047; }
.flash-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: #0f172a;
}

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 4px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.9rem;
  color: #1e293b;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

textarea { resize: vertical; min-height: 80px; }

.form-hint {
  font-size: 0.78rem;
  color: #64748b;
  margin-top: 4px;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  font-family: inherit;
  text-decoration: none;
}

.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(0); }

.btn-primary   { background: #2563eb; color: #fff; }
.btn-primary:hover   { background: #1d4ed8; }

.btn-secondary { background: #e2e8f0; color: #1e293b; }
.btn-secondary:hover { background: #cbd5e1; }

.btn-danger    { background: #dc2626; color: #fff; }
.btn-danger:hover    { background: #b91c1c; }

.btn-success   { background: #16a34a; color: #fff; }
.btn-success:hover   { background: #15803d; }

.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th {
  background: #f1f5f9;
  font-weight: 600;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 2px solid #e2e8f0;
  color: #374151;
  white-space: nowrap;
}

td {
  padding: 9px 14px;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* ── Auth pages ───────────────────────────────────────────── */
.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 120px);
  padding: 20px;
}

.auth-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 36px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.auth-card h1 {
  font-size: 1.5rem;
  margin-bottom: 6px;
  color: #0f172a;
}

.auth-subtitle {
  font-size: 0.875rem;
  color: #64748b;
  margin-bottom: 24px;
}

/* ── Disclaimer acknowledgement box ──────────────────────── */
.disclaimer-box {
  background: #fefce8;
  border: 1px solid #fde047;
  border-radius: 6px;
  padding: 14px 16px;
  font-size: 0.85rem;
  color: #713f12;
  margin-bottom: 20px;
  line-height: 1.5;
}

.disclaimer-box strong { color: #92400e; }

/* ── Chat layout ──────────────────────────────────────────── */
.chat-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 1fr;
  gap: 16px;
  height: calc(100vh - 160px);
  min-height: 500px;
}

/* Sidebar */
.chat-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px 8px;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 600;
  font-size: 0.875rem;
  color: #374151;
}

.conversation-item {
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.1s, border-color 0.1s;
}

.conversation-item:hover { background: #f1f5f9; border-color: #e2e8f0; }
.conversation-item.active { background: #dbeafe; border-color: #93c5fd; }

.conversation-item .conv-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-item .conv-date {
  font-size: 0.7rem;
  color: #94a3b8;
  margin-top: 2px;
}

/* Chat main panel */
.chat-main {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.message {
  display: flex;
  gap: 10px;
  max-width: 90%;
}

.message.user-message { margin-left: auto; flex-direction: row-reverse; }

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  color: #64748b;
}

.user-message .message-avatar { background: #2563eb; color: #fff; }

.message-bubble {
  background: #f1f5f9;
  border-radius: 12px 12px 12px 4px;
  padding: 10px 14px;
  font-size: 0.9rem;
  line-height: 1.55;
  color: #1e293b;
}

.user-message .message-bubble {
  background: #2563eb;
  color: #fff;
  border-radius: 12px 12px 4px 12px;
}

.message-bubble p { margin-bottom: 6px; }
.message-bubble p:last-child { margin-bottom: 0; }

/* Streaming cursor */
.streaming-cursor::after {
  content: "▋";
  animation: blink 0.8s step-end infinite;
}

@keyframes blink { 50% { opacity: 0; } }

/* Chat input area */
.chat-input-area {
  padding: 14px 16px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chat-input-row textarea {
  flex: 1;
  min-height: 44px;
  max-height: 160px;
  padding: 10px 12px;
  resize: none;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.4;
}

.chat-send-btn {
  height: 44px;
  padding: 0 18px;
  white-space: nowrap;
  align-self: flex-end;
}

.chat-context-info {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 6px;
  text-align: right;
}

/* ── Asset totals grid ────────────────────────────────────── */
.totals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.total-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.total-card .total-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 4px;
}

.total-card .total-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: #0f172a;
}

.total-card.total-net .total-value { color: #16a34a; }
.total-card.total-net-negative .total-value { color: #dc2626; }

/* ── Page headers ─────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-header h1 { font-size: 1.5rem; }

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

/* ── Footer ───────────────────────────────────────────────── */
.site-footer {
  background: #f1f5f9;
  border-top: 1px solid #e2e8f0;
  padding: 10px 24px;
  font-size: 0.75rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

.footer-legal { font-style: italic; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-co { background: #dbeafe; color: #1e40af; }
.badge-mt { background: #dcfce7; color: #14532d; }
.badge-wy { background: #fef9c3; color: #713f12; }
.badge-admin { background: #fce7f3; color: #831843; }

/* ── Child support calc ───────────────────────────────────── */
.calc-section {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
  background: #fff;
}

.calc-section h3 {
  font-size: 1rem;
  margin-bottom: 14px;
  color: #374151;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 8px;
}

.calc-result {
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 8px;
  padding: 16px 20px;
  text-align: center;
}

.calc-result .result-amount {
  font-size: 2rem;
  font-weight: 700;
  color: #15803d;
}

.calc-result .result-label {
  font-size: 0.875rem;
  color: #166534;
  margin-top: 4px;
}

/* ── Admin section ────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: #1e293b;
}

.stat-card .stat-label {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 2px;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .main-content { padding: 16px 12px; }

  .chat-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
  }

  .chat-sidebar { max-height: 160px; overflow-y: auto; flex-direction: row; flex-wrap: nowrap; }
  .conversation-item { flex-shrink: 0; width: 180px; }

  .chat-main { min-height: 60vh; }

  .auth-card { padding: 24px 20px; }

  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }

  .navbar { padding: 0 12px; }
  .nav-links { gap: 0; overflow-x: auto; }
  .nav-links a { padding: 6px 8px; font-size: 0.8rem; }
}

@media (max-width: 480px) {
  .totals-grid { grid-template-columns: 1fr 1fr; }
  .stats-row   { grid-template-columns: 1fr 1fr; }
}

/* ── Chat message formatting ─────────────────────────────── */
.message-bubble p {
  margin: 0 0 10px 0;
}
.message-bubble p:last-child {
  margin-bottom: 0;
}
.message-bubble strong {
  color: #1e293b;
}
.user-message .message-bubble strong {
  color: #fff;
}
.message-bubble br + strong {
  display: inline-block;
  margin-top: 6px;
}

/* ── Statute side pane ───────────────────────────────────────────────────── */
.statute-pane {
  display: none;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}

.chat-layout.pane-open {
  grid-template-columns: 240px 1fr 320px;
}

.chat-layout.pane-open .statute-pane {
  display: flex;
}

.statute-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 600;
  font-size: 0.875rem;
  color: #374151;
  background: #f8fafc;
  flex-shrink: 0;
}

#statutePaneClose {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  color: #94a3b8;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
}
#statutePaneClose:hover { background: #f1f5f9; color: #475569; }

.statute-pane-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  font-size: 0.78rem;
  line-height: 1.65;
  white-space: pre-wrap;
  color: #374151;
  font-family: 'Georgia', serif;
}

/* ── Statute reference links ─────────────────────────────────────────────── */
.statute-ref {
  color: #2563eb;
  text-decoration: underline;
  text-decoration-style: dotted;
  cursor: pointer;
}
.statute-ref:hover { color: #1d4ed8; text-decoration-style: solid; }

/* ── Replay button ───────────────────────────────────────────────────────── */
.replay-btn {
  align-self: center;
  background: transparent;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 3px 7px;
  font-size: 0.8rem;
  color: #94a3b8;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.message.user-message:hover .replay-btn { opacity: 1; }
.replay-btn:hover { background: #f1f5f9; color: #475569; border-color: #94a3b8; }

/* ── Responsive: hide pane on small screens ──────────────────────────────── */
@media (max-width: 900px) {
  .chat-layout.pane-open {
    grid-template-columns: 240px 1fr;
  }
  .statute-pane { display: none !important; }
}

/* ── Statute pane override: fixed overlay instead of grid column ─────────── */
.statute-pane {
  position: fixed !important;
  top: 0;
  right: 0;
  bottom: 0;
  width: 400px;
  background: #fff;
  border-left: 2px solid #cbd5e1;
  box-shadow: -4px 0 24px rgba(0,0,0,0.13);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex !important;
  flex-direction: column;
  z-index: 300;
}
.statute-pane.open { transform: translateX(0); }

/* Cancel the old pane-open grid change */
.chat-layout.pane-open { grid-template-columns: 240px 1fr !important; }
