:root { color-scheme: light dark; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  margin: 0;
  line-height: 1.4;
}

.sticky-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: white;
  padding: 10px 24px 10px;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sticky-header h1 { margin: 0; font-size: 1.4rem; }
.sticky-header .meta { margin: 0; font-size: 0.85rem; color: #64748b; white-space: nowrap; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.member-id {
  font-size: 0.75em;
  font-weight: 500;
  color: #64748b;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 2px 8px;
  vertical-align: middle;
  margin-left: 8px;
}

.filter-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #475569;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.filter-icon-btn:hover { background: #e2e8f0; color: #1e293b; border-color: #94a3b8; }
.filter-icon-btn.panel-open { background: #1e293b; color: #f8fafc; border-color: #1e293b; }

/* Floating filter panel */
.filter-panel {
  position: fixed;
  top: 70px;
  right: 24px;
  z-index: 200;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  padding: 16px 18px;
  min-width: 280px;
}

.filter-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.filter-panel-title { font-weight: 700; font-size: 0.95rem; color: #1e293b; }
.filter-panel-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  font-size: 1rem;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
}
.filter-panel-close:hover { background: #f1f5f9; color: #475569; }

.filter-section { margin-bottom: 14px; }
.filter-section:last-child { margin-bottom: 0; }
.filter-section-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
  margin-bottom: 8px;
}

.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  padding: 5px 13px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid;
  transition: transform 0.1s, box-shadow 0.15s;
}
.chip:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.chip.active { box-shadow: 0 0 0 3px rgba(0,0,0,0.15) inset; transform: none; }

.chip-all      { background: #f1f5f9;   color: #475569; border-color: #cbd5e1; }
.chip-call     { background: #ede9fe;   color: #6d28d9; border-color: #ddd6fe; }
.chip-kit      { background: #fef3c7;   color: #92400e; border-color: #fde68a; }
.chip-milestone{ background: #fce7f3;   color: #be185d; border-color: #fbcfe8; }
.chip-sms      { background: #fef08a;   color: #854d0e; border-color: #fde047; }
.chip-chat     { background: #e0f2fe;   color: #0369a1; border-color: #bae6fd; }
.chip-session  { background: #dcfce7;   color: #15803d; border-color: #bbf7d0; }
.chip-email    { background: #fdf2f8;   color: #9d174d; border-color: #fbcfe8; }
.chip-push     { background: #eff6ff;   color: #1e40af; border-color: #bfdbfe; }

/* inactive (not selected) chips are slightly faded */
.chip:not(.active) { opacity: 0.6; }
.chip:not(.active):hover { opacity: 0.85; }

.filter-panel-footer {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #e2e8f0;
}

.btn-reset-all {
  flex: 1;
  padding: 8px;
  border-radius: 9px;
  border: 1.5px solid #cbd5e1;
  background: #f1f5f9;
  color: #475569;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-reset-all:hover { background: #e2e8f0; }

.btn-apply {
  flex: 1.5;
  padding: 8px;
  border-radius: 9px;
  border: none;
  background: #475569;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-apply:hover { background: #334155; }

.date-inputs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.date-inputs label {
  font-size: 0.82rem;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 8px;
}
.date-inputs input[type="date"] {
  flex: 1;
  padding: 4px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  font-size: 0.82rem;
  color: #1e293b;
  background: #f8fafc;
}

@media (prefers-color-scheme: dark) {
  .sticky-header { background: #0f172a; border-bottom-color: #1e293b; }
  .filter-icon-btn { background: #1e293b; color: #94a3b8; border-color: #334155; }
  .filter-icon-btn:hover { background: #334155; color: #e2e8f0; }
  .filter-icon-btn.panel-open { background: #f8fafc; color: #0f172a; }
  .filter-panel { background: #1e293b; border-color: #334155; }
  .filter-panel-title { color: #e2e8f0; }
  .filter-panel-footer { border-top-color: #334155; }
  .btn-reset-all { background: #334155; color: #94a3b8; border-color: #475569; }
  .btn-reset-all:hover { background: #475569; }
  .btn-apply { background: #64748b; }
  .btn-apply:hover { background: #475569; }
  .date-inputs input[type="date"] { background: #0f172a; color: #e2e8f0; border-color: #334155; }
  .chip-all { background: #334155; color: #94a3b8; border-color: #475569; }
}

.content { padding: 0 24px; }

.day {
  position: relative;
  margin: 20px 0;
  padding: 12px 14px;
  border: 1px solid #ddd;
  border-radius: 10px;
}

.day h2 {
  margin: 0 0 10px 0;
  font-size: 1.05rem;
  padding-right: 36px; /* room for pin button */
}

/* Pin button */
.pin-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 7px;
  color: #cbd5e1;
  font-size: 1.05rem;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}
.pin-btn:hover { background: #f1f5f9; color: #64748b; }
.pin-btn.pinned { color: #f59e0b; }

/* PDF button */
.pdf-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 13px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  background: #f1f5f9;
  color: #334155;
  border: 1.5px solid #cbd5e1;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.pdf-btn:hover { background: #e2e8f0; border-color: #94a3b8; }

@media print {
  .sticky-header, .filter-panel, .pin-btn { display: none !important; }
  .content { padding: 0; }
  body { padding-top: 0 !important; }
}

@media (prefers-color-scheme: dark) {
  .pdf-btn { background: #1e293b; color: #94a3b8; border-color: #334155; }
  .pdf-btn:hover { background: #334155; color: #e2e8f0; }
}

/* Pinned nav button in header */
.pinned-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 13px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  background: #fffbeb;
  color: #92400e;
  border: 1.5px solid #fde68a;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.pinned-nav-btn:hover { background: #fef3c7; }

.pin-count-badge {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  background: #f59e0b;
  color: white;
  border-radius: 9px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0 4px;
}
.pin-count-badge.has-pins { display: inline-flex; }

/* Pinned page */
.pinned-page-title { font-size: 1.3rem; }
.back-btn {
  background: #f1f5f9;
  color: #475569;
  border-color: #cbd5e1;
}
.back-btn:hover { background: #e2e8f0; }
.empty-pins {
  text-align: center;
  color: #94a3b8;
  padding: 60px 24px;
  font-size: 1rem;
}

ul {
  margin: 0;
  padding-left: 0;
  list-style-type: none;
}

li {
  margin: 6px 0;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px;
  border-radius: 6px;
}

li:hover { background-color: rgba(0, 0, 0, 0.03); }

.time {
  color: #64748b;
  font-family: monospace;
  font-size: 0.9em;
  flex-shrink: 0;
}

.badge {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.85em;
  font-weight: 600;
  flex-shrink: 0;
  text-transform: uppercase;
}

.summary { flex-grow: 1; display: flex; flex-direction: column; gap: 2px; }

.msg-sender {
  font-weight: 600;
  font-size: 0.9em;
  color: #475569;
}

.msg-content {
  color: #1e293b;
}

.call-metadata {
  display: flex;
  gap: 16px;
  margin-top: 4px;
  font-size: 0.95rem;
  color: #1e293b;
  font-weight: 500;
}

.call-feat {
  display: flex;
  align-items: center;
  gap: 6px;
}

@media (prefers-color-scheme: dark) {
  .msg-sender { color: #94a3b8; }
  .msg-content { color: #e2e8f0; }
  .call-metadata { color: #e2e8f0; }
}

.type-milestone      { background-color: #fce7f3; color: #be185d; border: 1px solid #fbcfe8; }
.type-milestone-call { background-color: #ede9fe; color: #6d28d9; border: 1px solid #ddd6fe; }
.type-milestone-kit  { background-color: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.type-chat-message   { background-color: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.type-sms            { background-color: #fef08a; color: #854d0e; border: 1px solid #fde047; }
.type-session        { background-color: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.type-email           { background-color: #fdf2f8; color: #9d174d; border: 1px solid #fbcfe8; }
.type-push-notification { background-color: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

.session-line {
  margin: 2px 0;
  font-size: 0.9em;
  color: #1e293b;
}
.session-line:first-child { font-weight: 600; }

/* PT messages: medium grey; patient messages: light warm grey */
.from-pt      { border-left: 4px solid #64748b; background-color: #e2e8f0; }
.from-patient { border-left: 4px solid #94a3b8; background-color: #f1f5f9; }

@media (prefers-color-scheme: dark) {
  .from-pt      { border-left-color: #94a3b8; background-color: #1e293b; }
  .from-patient { border-left-color: #475569; background-color: #0f172a; }
}

.milestone-enrolled { color: #e11d48; font-weight: bold; }
.milestone-ob       { color: #2563eb; font-weight: bold; }
.summary.struck     { text-decoration: line-through; color: #94a3b8; }

@media (prefers-color-scheme: dark) {
  .day { border-color: #333; }
  li:hover { background-color: rgba(255, 255, 255, 0.05); }
  .type-milestone      { background-color: #831843; color: #fbcfe8; border-color: #be185d; }
  .type-milestone-call { background-color: #4c1d95; color: #ddd6fe; border-color: #6d28d9; }
  .type-milestone-kit  { background-color: #78350f; color: #fde68a; border-color: #92400e; }
  .type-chat-message   { background-color: #0c4a6e; color: #bae6fd; border-color: #0369a1; }
  .type-sms            { background-color: #713f12; color: #fef08a; border-color: #a16207; }
  .type-session        { background-color: #14532d; color: #bbf7d0; border-color: #15803d; }
  .type-email          { background-color: #831843; color: #fbcfe8; border-color: #be185d; }
  .type-push-notification { background-color: #1e3a8a; color: #bfdbfe; border-color: #3b82f6; }
  .session-line        { color: #e2e8f0; }
  .milestone-enrolled { color: #fb7185; }
  .milestone-ob       { color: #60a5fa; }
}

/* ── Member-ID as button ─────────────────────────────────────────────── */
.member-id {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid #e2e8f0;
  background: #f1f5f9;
}
.member-id:hover { background: #e2e8f0; }

.chevron-icon {
  font-size: 0.6em;
  opacity: 0.65;
}

/* ── Member ID dropdown ──────────────────────────────────────────────── */
.member-id-wrapper {
  position: relative;
  display: inline-flex;
  vertical-align: middle;
  margin-left: 8px;
}

.id-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 300;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.10);
  padding: 6px;
  min-width: 200px;
}

.id-dropdown-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 10px;
  border-radius: 7px;
  text-decoration: none;
  color: #334155;
  transition: background 0.12s;
}
.id-dropdown-item:hover { background: #f1f5f9; }
.id-dropdown-item.active { background: #e2e8f0; }

.id-item-id { font-size: 0.85rem; font-weight: 600; color: #1e293b; }
.id-item-name { font-size: 0.73rem; color: #64748b; }

/* ── PDF dropdown ────────────────────────────────────────────────────── */
.pdf-btn-wrapper {
  position: relative;
  display: inline-flex;
}

.pdf-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 300;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.10);
  padding: 6px;
  min-width: 230px;
  white-space: nowrap;
}

.pdf-option {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border-radius: 7px;
  border: none;
  background: none;
  text-decoration: none;
  color: #334155;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}
.pdf-option:hover { background: #f1f5f9; }

/* dark mode for new dropdowns */
@media (prefers-color-scheme: dark) {
  .member-id { background: #1e293b; border-color: #334155; color: #94a3b8; }
  .member-id:hover { background: #334155; }
  .id-dropdown, .pdf-dropdown { background: #1e293b; border-color: #334155; }
  .id-dropdown-item { color: #e2e8f0; }
  .id-dropdown-item:hover { background: #334155; }
  .id-dropdown-item.active { background: #475569; }
  .id-item-id { color: #e2e8f0; }
  .id-item-name { color: #94a3b8; }
  .pdf-option { color: #e2e8f0; }
  .pdf-option:hover { background: #334155; }
}
