/* ─────────────────────────────────────────────
   FAMILY UPDATE DASHBOARD — Design System
   Overrides Pico CSS v2 variables + custom CSS
   ───────────────────────────────────────────── */

/* ── Google Font ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── Design Tokens ── */
:root {
  /* Brand */
  --brand:          #b45309;
  --brand-light:    #fef3c7;
  --brand-mid:      #f59e0b;
  --brand-dark:     #92400e;

  /* Neutrals */
  --surface-page:   #f8f7f5;
  --surface-card:   #ffffff;
  --surface-hover:  #f9f8f6;
  --border:         #e8e4df;
  --border-focus:   #b45309;

  /* Text */
  --text-primary:   #1a1614;
  --text-secondary: #6b7280;
  --text-muted:     #9ca3af;

  /* Shadows */
  --shadow-sm:  0 1px 3px 0 rgba(0,0,0,.06), 0 1px 2px -1px rgba(0,0,0,.04);
  --shadow-md:  0 4px 12px 0 rgba(0,0,0,.08), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg:  0 10px 30px -5px rgba(0,0,0,.10), 0 4px 10px -5px rgba(0,0,0,.06);

  /* Pico overrides */
  --pico-font-family:              'Inter', system-ui, sans-serif;
  --pico-font-size:                15px;
  --pico-line-height:              1.6;
  --pico-background-color:         var(--surface-page);
  --pico-color:                    var(--text-primary);
  --pico-muted-color:              var(--text-secondary);
  --pico-primary:                  var(--brand);
  --pico-primary-hover:            var(--brand-dark);
  --pico-primary-focus:            rgba(180,83,9,.25);
  --pico-border-color:             var(--border);
  --pico-card-background-color:    var(--surface-card);
  --pico-card-border-color:        var(--border);
  --pico-card-box-shadow:          var(--shadow-sm);
  --pico-border-radius:            10px;
  --pico-nav-background-color:     var(--surface-card);
  --pico-table-border-color:       var(--border);
  --pico-table-row-stripped-background-color: var(--surface-page);
  --pico-form-element-border-color: var(--border);
  --pico-form-element-focus-color: var(--brand);
}

/* ─────────────────────────────────────────────
   BASE
   ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  background: var(--surface-page);
  color: var(--text-primary);
  font-family: var(--pico-font-family);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  letter-spacing: -0.025em;
  font-weight: 700;
  color: var(--text-primary);
}

hgroup h1, hgroup h2 { margin-bottom: 0.1em; }
hgroup p {
  color: var(--text-secondary);
  font-size: 0.9em;
  margin-top: 0;
}

a { color: var(--brand); }
a:hover { color: var(--brand-dark); }

small, .meta { color: var(--text-secondary); }

/* ─────────────────────────────────────────────
   NAV
   ───────────────────────────────────────────── */
body > nav,
nav.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 0 1.5rem;
}

nav.container {
  display: flex;
  align-items: center;
  min-height: 56px;
  padding-top: 0;
  padding-bottom: 0;
}

nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

nav ul:first-child { flex: 1; }

nav ul li a,
nav ul li summary {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.75rem;
  border-radius: 7px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

nav ul li a:hover,
nav ul li summary:hover {
  background: var(--surface-page);
  color: var(--text-primary);
}

/* Active nav tab */
nav ul li a[aria-current="page"],
nav ul li summary[aria-current="page"] {
  color: var(--brand);
  background: var(--brand-light);
  font-weight: 600;
  text-decoration: none;
}

.app-brand {
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary) !important;
  text-decoration: none;
  margin-right: 1rem;
}

/* Dropdown */
details.dropdown > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.45rem 0.75rem;
  border-radius: 7px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}
details.dropdown > summary::after {
  content: ' ▾';
  font-size: 0.7em;
  opacity: 0.7;
}
details.dropdown[open] > summary {
  background: var(--surface-page);
  color: var(--text-primary);
}
details.dropdown ul {
  position: absolute;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  flex-direction: column;
  padding: 0.35rem;
  min-width: 160px;
  z-index: 200;
}
details.dropdown ul li a {
  width: 100%;
  border-radius: 6px;
  padding: 0.4rem 0.7rem;
}

/* ─────────────────────────────────────────────
   MAIN + FOOTER
   ───────────────────────────────────────────── */
main.container {
  padding-top: 2rem;
  padding-bottom: 3rem;
  max-width: 1100px;
}

footer.container {
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
}
footer small { color: var(--text-muted); font-size: 0.8em; }

/* ─────────────────────────────────────────────
   BADGES / PILLS
   ───────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.22em 0.65em;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.badge-green  { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.badge-yellow { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.badge-red    { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.badge-blue   { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.badge-gray   { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }

/* ─────────────────────────────────────────────
   STATS
   ───────────────────────────────────────────── */
.stats-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  align-items: end;
  gap: 0.75rem;
  min-height: 13rem;
}

.stats-chart-day {
  display: grid;
  grid-template-rows: auto 8rem auto auto;
  justify-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.stats-chart-day strong {
  font-size: 0.95rem;
}

.stats-chart-day span {
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 700;
}

.stats-chart-day small {
  color: var(--text-muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.stats-chart-track {
  display: flex;
  align-items: flex-end;
  width: 100%;
  max-width: 2.4rem;
  min-height: 8rem;
  overflow: hidden;
  border-radius: 7px;
  background: var(--surface-page);
  border: 1px solid var(--border);
}

.stats-chart-bar {
  width: 100%;
  min-height: 0.25rem;
  border-radius: inherit;
  background: var(--brand-mid);
}

.stats-chart-day.is-today .stats-chart-track {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(180,83,9,.12);
}

.stats-chart-day.is-today .stats-chart-bar {
  background: var(--brand);
}

@media (max-width: 640px) {
  .stats-chart {
    gap: 0.45rem;
  }

  .stats-chart-day {
    grid-template-rows: auto 6.5rem auto auto;
  }

  .stats-chart-track {
    min-height: 6.5rem;
  }

  .stats-chart-day small {
    display: none;
  }
}

/* ─────────────────────────────────────────────
   TABLES
   ───────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
}

thead tr {
  border-bottom: 2px solid var(--border);
}

thead th {
  padding: 0.6rem 0.85rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-hover); }

tbody td {
  padding: 0.75rem 0.85rem;
  vertical-align: middle;
  color: var(--text-primary);
}

/* Right-align numeric/action cols */
thead th:last-child,
tbody td:last-child { text-align: right; }

/* ── Next-track / highlighted row ── */
.next-track {
  background: #fffbeb !important;
  border-left: 3px solid var(--brand-mid);
}
.next-track:hover { background: #fef3c7 !important; }

/* ─────────────────────────────────────────────
   CARDS / ARTICLES
   ───────────────────────────────────────────── */
article {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--pico-border-radius);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.5rem;
}

article header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.6rem;
  margin-bottom: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}

article footer {
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  margin-top: 0.85rem;
}

/* ─────────────────────────────────────────────
   BUTTONS
   ───────────────────────────────────────────── */
[role="button"], button, input[type="submit"] {
  font-weight: 500;
  font-size: 0.875rem;
  border-radius: 8px;
  transition: all 0.15s;
}

button.outline, [role="button"].outline, a.outline {
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-primary);
}
button.outline:hover, [role="button"].outline:hover, a.outline:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-light);
}

button.secondary.outline, [role="button"].secondary.outline, a.secondary.outline {
  border-color: var(--border);
  color: var(--text-secondary);
}
button.secondary.outline:hover, a.secondary.outline:hover {
  border-color: #d1d5db;
  color: var(--text-primary);
  background: var(--surface-page);
}

/* Small action buttons inside tables */
[role="group"] a[role="button"],
[role="group"] button {
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  margin-bottom: 0 !important;
}

/* ─────────────────────────────────────────────
   FORM ELEMENTS
   ───────────────────────────────────────────── */
input, select, textarea {
  border-radius: 8px !important;
  border: 1.5px solid var(--border) !important;
  font-family: var(--pico-font-family) !important;
  font-size: 0.875rem !important;
  transition: border-color 0.15s, box-shadow 0.15s !important;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand) !important;
  box-shadow: 0 0 0 3px rgba(180,83,9,.12) !important;
  outline: none !important;
}

details > summary[role="button"].outline {
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.55rem 1rem;
  transition: all 0.15s;
}
details > summary[role="button"].outline:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-light);
}

/* ─────────────────────────────────────────────
   EMPTY STATE
   ───────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3.5rem 2rem;
  text-align: center;
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  margin: 1rem 0;
  background: var(--surface-card);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  margin-bottom: 1rem;
  opacity: 0.6;
}

.empty-state h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 0.35rem;
}

.empty-state p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0 0 1.25rem;
  max-width: 320px;
}

/* ─────────────────────────────────────────────
   STATUS INDICATORS
   ───────────────────────────────────────────── */
.status-pending {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  color: #854d0e;
  font-weight: 600;
  font-size: 0.8rem;
}
.status-pending::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #f59e0b;
}

.status-used {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.status-used::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #d1d5db;
}

/* ─────────────────────────────────────────────
   SEGMENT CHIPS (feed list, segment list)
   ───────────────────────────────────────────── */
.segment-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.segment-list li {
  list-style: none;
  list-style-type: none;
  padding: 0.18em 0.6em;
  background: var(--surface-page);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.segment-list li::marker,
.segment-list li::before {
  content: none;
  display: none;
}

/* ─────────────────────────────────────────────
   AUDIO PLAYER
   ───────────────────────────────────────────── */
.audio-wrap {
  display: flex;
  align-items: center;
}
.audio-wrap audio {
  /* No height cap — lets scrubber render naturally (~36px) */
  width: 220px;
  opacity: 0.8;
  transition: opacity 0.15s;
  accent-color: var(--brand);
}
.audio-wrap audio:hover { opacity: 1; }

/* ─────────────────────────────────────────────
   TIMELINE  (index.html)
   ───────────────────────────────────────────── */
.timeline {
  position: relative;
  padding-left: 2.25rem;
  margin: 1.5rem 0;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 0.7rem;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 2px;
  background: var(--border);
  border-radius: 2px;
}

.timeline-item {
  position: relative;
  margin-bottom: 1.25rem;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.7rem;
  top: 1rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d1d5db;
  border: 2px solid var(--surface-card);
  box-shadow: 0 0 0 2px var(--border);
  transition: background 0.15s;
}

.timeline-item.dynamic::before {
  background: var(--brand-mid);
  box-shadow: 0 0 0 2px #fef3c7;
}

.timeline-item article {
  transition: box-shadow 0.15s, transform 0.15s;
}
.timeline-item article:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.seg-type {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.meta-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.3em 1.25rem;
  font-size: 0.875rem;
  align-items: baseline;
}

.meta-label {
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.feed-list {
  list-style: none;
  list-style-type: none;
  padding: 0;
  margin: 0.4em 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.feed-list li {
  list-style: none;
  list-style-type: none;
  padding: 0.15em 0.55em;
  background: var(--surface-page);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.77rem;
  color: var(--text-secondary);
}

/* Pico v2 sets ::marker on li inside article — kill it */
.feed-list li::marker,
.feed-list li::before {
  content: none;
  display: none;
}

.feed-list li a {
  color: inherit;
  text-decoration: none;
}
.feed-list li a:hover { color: var(--brand); }

/* Shoutout chip */
.shoutout-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4em;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  padding: 0.18em 0.6em;
  font-size: 0.85em;
}
.shoutout-chip .chip-event { font-weight: 600; color: var(--text-primary); }
.shoutout-chip .chip-date  { color: var(--brand); font-size: 0.88em; }

/* ─────────────────────────────────────────────
   PAGINATION
   ───────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
}
.pagination .page-info {
  color: var(--text-muted);
  font-size: 0.85em;
}

/* ─────────────────────────────────────────────
   FILTER BUTTON GROUP
   ───────────────────────────────────────────── */
.filter-group {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.filter-group a[role="button"],
.filter-group button {
  padding: 0.35rem 0.9rem;
  font-size: 0.82rem;
  border-radius: 999px;
}
/* Stronger border so outline pills read clearly on off-white background */
.filter-group a[role="button"].outline,
.filter-group button.outline {
  border-color: #c9c4bd;
  color: var(--text-secondary);
}
.filter-group a[role="button"].outline:hover,
.filter-group button.outline:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-light);
}

/* ─────────────────────────────────────────────
   VOICE NOTE RECORDER PANEL
   ───────────────────────────────────────────── */
.recorder-panel {
  max-width: 600px;
}

.recorder-section {
  margin-bottom: 1.25rem;
}

.recorder-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

.recorder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.recorder-actions button {
  width: auto;
  margin: 0;
  padding: 0.45rem 1rem;
  font-size: 0.875rem;
}

/* Primary record button — most prominent */
.recorder-actions button#start-recording {
  padding: 0.45rem 1.25rem;
}

.recording-status-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.85rem;
  min-height: 1.5rem;
}

.recording-dot {
  display: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #dc2626;
  animation: pulse-dot 1s infinite;
  flex-shrink: 0;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.recording-state {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
}

.recording-state[data-active="true"] {
  color: #dc2626;
  font-weight: 600;
}

.recording-state[data-active="true"] ~ .recording-dot,
.recording-dot.visible {
  display: block;
}

.preview-wrap {
  margin-top: 0.75rem;
}

.preview-wrap audio {
  width: 100%;
  accent-color: var(--brand);
}

/* ─────────────────────────────────────────────
   ADD FORM PANEL (senders, shoutouts)
   ───────────────────────────────────────────── */
.add-form-panel {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

/* ─────────────────────────────────────────────
   HTMX loading indicator
   ───────────────────────────────────────────── */
.htmx-indicator {
  opacity: 0;
  transition: opacity 0.2s;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

/* ─────────────────────────────────────────────
   TOAST NOTIFICATIONS
   ───────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: #1f2937;
  color: #ffffff;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-width: 280px;
  font-size: 0.875rem;
  font-weight: 500;
  animation: toast-in 0.3s ease forwards;
}

.toast-success { background: #065f46; border-left: 4px solid #34d399; }
.toast-error   { background: #991b1b; border-left: 4px solid #f87171; }
.toast-info    { background: #1e3a8a; border-left: 4px solid #60a5fa; }

.toast-close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
  transition: color 0.15s;
  margin: 0;
  width: auto;
}

.toast-close:hover {
  color: #ffffff;
  background: transparent;
}

@keyframes toast-in {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ─────────────────────────────────────────────
   MODAL OVERRIDES
   ───────────────────────────────────────────── */
dialog article {
  max-width: 500px;
  width: 100%;
}
dialog article footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}
dialog article .close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  padding: 0.5rem;
  line-height: 1;
}
