/* theme.css */

/* LIGHT THEME (default) */
:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --text: #222;
  --muted: #666;
  --border: #ddd;

  /* base accent (will be overridden by theme.js/localStorage) */
  --accent: #2b7fff;

  /* anything still using --primary will now follow accent */
  --primary: var(--accent);

  --panel-shadow: 0 2px 6px rgba(0,0,0,0.05);
  --danger: #c62828;
  /* zebra stripe derived from current accent (light theme) */
  --table-stripe: color-mix(in srgb, var(--accent) 32%, var(--surface) 68%);

}

/* Ensure chat layout background matches panels so there's no stray bar */
.chat-layout {
  background: var(--bg);
}

/* DARK THEME */
body.dark {
  --bg: #121212;
  --surface: #1e1e1e;
  --text: #f5f5f5;
  --muted: #aaa;
  --border: #333;

  /* dark accent */
  --accent: #7aa8ff;
  --primary: var(--accent);

  --panel-shadow: 0 2px 10px rgba(0,0,0,0.35);
  --danger: #ef5350;
  /* zebra stripe derived from current accent (dark theme) */
  --table-stripe: color-mix(in srgb, var(--accent) 35%, var(--surface) 65%);
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* top bar */
.topbar {
  background: var(--surface);
  border-bottom: 2px solid var(--accent);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .5rem 1rem;
}

.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--text);
  margin-left: 10px;
}

/* generic panel */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: var(--panel-shadow);
}

/* accent panels (theme-aware) */
/* Softer accent panel for primary sections */
.panel-accent {
  background: var(--surface);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface) 90%);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--surface) 65%);
}

/* Very subtle accent for helper/tool strips */
.panel-accent-subtle {
  background: var(--surface);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface) 94%);
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--surface) 76%);
}

/* panel headings get accent */
.panel h2,
.panel h3 {
  color: var(--accent);
  margin-top: 0;
}

/* links – use accent everywhere */
a,
a:visited,
a:hover,
a:active {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  opacity: 0.85;
  text-decoration: underline;
}

/* optional accent button */
.btn-accent {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
}

/* dark-mode visited fix */
body.dark a:visited {
  color: var(--accent);
}

/* Stronger zebra striping for data tables */
table tbody tr:nth-child(even) {
  background: var(--table-stripe);
}

/* App header and navigation */
.app-header {
  background: var(--surface);
  color: var(--text);
  border-bottom: 2px solid var(--accent);
  box-shadow: var(--panel-shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  height: 40px;
  width: auto;
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.brand-title {
  font-size: 1.2rem;
  font-weight: 600;
}

.brand-subtitle {
  font-size: 0.8rem;
  color: var(--muted);
}

.top-links {
  display: flex;
  align-items: center;
  gap: 14px;
}

.top-links a,
.top-links span.nav-current {
  font-size: 0.9rem;
}

.top-links span.nav-current {
  font-weight: 600;
}

.hamburger-button {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 1.1rem;
  margin-left: auto;
}

/* Mobile header layout: wrap and right-align nav links under the brand row */
@media (max-width: 700px) {
  .app-header {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .hamburger-button {
    display: inline-flex;
  }

  .top-links {
    /* Hide mobile nav links by default, and push the container to the right
       so the dropdown panel hugs the right edge under the hamburger. */
    display: none;
    margin-left: auto;
    margin-right: 0;
  }

  /* When nav is open, show links, stack vertically and right-align */
  .app-header.nav-open .top-links {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    width: 100%;
    justify-content: flex-start;
    margin-top: 0.35rem;
  }

  .app-header.nav-open .top-links a,
  .app-header.nav-open .top-links span.nav-current {
    display: flex;
    justify-content: flex-end;
    text-align: right;
    width: 100%;
  }
}

/* --------------------------------------------------
   Chat / Notes / Homework / Intake / Tools tab bar
   -------------------------------------------------- */
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  color: var(--text);
  font-size: 0.9rem;
}

.tab-btn.active {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface) 88%);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--surface) 60%);
  color: var(--text);
}

.tab-icon {
  font-size: 1rem;
  line-height: 1;
}

.tab-label {
  font-size: 0.9rem;
}

/* Slight tightening on mobile */
@media (max-width: 600px) {
  .tab-btn {
    padding: 5px 8px;
    font-size: 0.85rem;
  }
  .tab-icon {
    font-size: 0.95rem;
  }
  .tab-label {
    font-size: 0.85rem;
  }
}

/* Alert styles */
.alert {
  padding: 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.alert.error {
  background: #ef5350;
  color: #fff;
}

.alert.success {
  background: #4caf50;
  color: #000;
}

/* Ensure success/notice banners use dark text for readability */
.alert-success,
.notice-success,
.status-success,
.flash-success {
  color: #000 !important;
}
/* Force dark text on success / notice banners so they stay readable */
.alert-success,
.notice-success,
.status-success,
.flash-success,
.status-message,
.status-message.success,
.notice,
.notice.success,
.ca-status-banner,
.ca-status-banner.success {
  color: #000 !important;
}

.alert-success a,
.notice-success a,
.status-success a,
.flash-success a,
.status-message a,
.notice a,
.ca-status-banner a {
  color: #000 !important;
  text-decoration: underline;
}

/* --------------------------------------------------
   Organization pills (shared across CA)
   -------------------------------------------------- */
.org-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  white-space: nowrap;
}
.org-pill.org-millsmemorial {
  background:#e8f1ff;
  color:#1b3d6d;
  border-color:#bcd3f5;
}
.org-pill.org-restoredcounsel {
  background:#f3e9dd;
  color:#7a5a3a;
  border-color:#e2cbb3;
}

/* --------------------------------------------------
   Payments Summary Grid — Clean Modern Responsive Layout
   -------------------------------------------------- */

.payments-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-top: 1rem;
}

/* Each stat card */
.payments-summary-grid .panel,
.payments-summary-grid .panel-accent-subtle {
  padding: 0.65rem 0.9rem !important;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 6%, var(--surface) 94%);
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--surface) 76%);
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  min-height: 60px;
}

/* Label text */
.payments-summary-grid .summary-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.3px;
}

/* Value text */
.payments-summary-grid .summary-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}

/* Mobile tightening */
@media (max-width: 480px) {
  .payments-summary-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .payments-summary-grid .panel {
    padding: 0.55rem 0.75rem !important;
  }
}
/* Force date filter to stay inline in Payments */
.filters-row label {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

/* Prevent filter bar from wrapping — enable horizontal scroll */
.filters-scroll {
    overflow-x: auto;
    white-space: nowrap;
    width: 100%;
}
/* Ensure filter form never wraps and scrolls horizontally */
.filters-scroll form {
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  align-items: center;
  width: 100%;
  overflow-x: auto;
}
.filters-scroll select,
.filters-scroll input[type="date"],
.filters-scroll input[type="text"],
.filters-scroll button {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* Hard‑lock Payments filters into a single non‑wrapping row */
.payments-filters-bar {
  display: flex !important;
  flex-wrap: nowrap !important;
  align-items: center;
  gap: 10px;
  white-space: nowrap !important;
  overflow-x: auto;
}