/* goldi — warm, accessible dashboard for elderly people's families */

:root {
  /* Apollo palette: amber #D4A373, cream #FEFAE0, olive #606C38, dark #283618 */
  --gold-50: #fefae0;
  --gold-100: #faf0c8;
  --gold-200: #eedcaa;
  --gold-300: #e2c88d;
  --gold-400: #d4a373;
  --gold-500: #c48b5c;
  --gold-600: #a5714a;
  --gold-700: #85593b;
  --gold-800: #6b472f;
  --gold-900: #523624;

  --warm-50: #fefae0;
  --warm-100: #f7f0d8;
  --warm-200: #eedcaa;
  --warm-300: #d5c4a1;
  --warm-400: #b8a07e;
  --warm-500: #9a8565;
  --warm-600: #7c6a4f;

  --olive: #606c38;
  --olive-light: #7a8a4a;
  --olive-dark: #283618;

  --text: #283618;
  --text-light: #4a5a2c;
  --text-muted: #7c6a4f;

  --bg: #fefae0;
  --bg-card: #fffdf5;
  --bg-sidebar: #f7f0d8;

  --border: #eedcaa;
  --border-light: #f5ecd0;

  --green: #22c55e;
  --green-bg: #f0fdf4;
  --red: #ef4444;
  --red-bg: #fef2f2;
  --blue: #3b82f6;
  --blue-bg: #eff6ff;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.6;
  min-height: 100vh;
}

/* -- Layout -- */

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.sidebar-brand {
  padding: 0 24px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.sidebar-brand h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--olive-dark);
  letter-spacing: -0.5px;
}

.sidebar-brand .subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.sidebar nav {
  flex: 1;
  padding: 8px 12px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-light);
  text-decoration: none;
  font-size: 16px;
  font-weight: 500;
  transition: all 0.15s ease;
  cursor: pointer;
}

.nav-link:hover {
  background: var(--warm-200);
  color: var(--text);
}

.nav-link.active {
  background: #e8edc8;
  color: var(--olive-dark);
}

.nav-link .icon {
  font-size: 20px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

.main {
  flex: 1;
  margin-left: 260px;
  padding: 32px 40px;
  max-width: 1200px;
}

/* -- User selector -- */

.user-selector {
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.user-selector label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.user-selector select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
}

/* -- Page header -- */

.page-header {
  margin-bottom: 28px;
}

.page-header h2 {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
}

.page-header .page-desc {
  font-size: 15px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* -- Cards -- */

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

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

/* -- Stats grid -- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  text-align: center;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--olive);
  line-height: 1.1;
}

.stat-label {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* -- Grid layouts -- */

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

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

/* -- Sessions list -- */

.session-item {
  padding: 16px 0;
  border-bottom: 1px solid var(--border-light);
}

.session-item:last-child { border-bottom: none; }

.session-meta {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 6px;
}

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

.session-mood {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  padding: 2px 10px;
  border-radius: 20px;
  font-weight: 500;
}

.mood-happy { background: var(--green-bg); color: #16a34a; }
.mood-neutral { background: var(--gold-100); color: var(--gold-800); }
.mood-sad { background: var(--red-bg); color: #dc2626; }
.mood-mixed { background: var(--blue-bg); color: var(--blue); }

.session-summary {
  font-size: 15px;
  color: var(--text-light);
}

.session-turns {
  font-size: 13px;
  color: var(--text-muted);
}

/* -- Badges -- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-private { background: #f3f4f6; color: #6b7280; }
.badge-family { background: var(--gold-100); color: var(--gold-800); }
.badge-public { background: var(--green-bg); color: #16a34a; }

.badge-type {
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.type-story { background: #fef3c7; color: #92400e; }
.type-person { background: #dbeafe; color: #1e40af; }
.type-fact { background: #f0fdf4; color: #166534; }
.type-emotion { background: #fce7f3; color: #9d174d; }
.type-location { background: #e0e7ff; color: #3730a3; }
.type-topic { background: #f5f3ff; color: #5b21b6; }
.type-routine { background: #fff7ed; color: #9a3412; }
.type-preference { background: #ecfdf5; color: #065f46; }

/* -- Alert banners -- */

.alert {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-warning {
  background: #fff8e1;
  border: 1px solid var(--gold-300);
  color: var(--gold-800);
}

.alert-danger {
  background: var(--red-bg);
  border: 1px solid #fca5a5;
  color: #991b1b;
}

/* -- Search -- */

.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.search-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  background: var(--bg-card);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.search-input:focus {
  border-color: var(--olive-light);
}

.search-input::placeholder {
  color: var(--text-muted);
}

/* -- Filter pills -- */

.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filter-pill {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 14px;
  cursor: pointer;
  color: var(--text-light);
  transition: all 0.15s;
}

.filter-pill:hover { border-color: var(--olive-light); }
.filter-pill.active {
  background: #e8edc8;
  border-color: var(--olive-light);
  color: var(--olive-dark);
}

/* -- Node list -- */

.node-list {
  list-style: none;
}

.node-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.1s;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.node-item:hover { background: var(--warm-50); }

.node-item .node-info { flex: 1; }

.node-title {
  font-weight: 600;
  color: var(--text);
  font-size: 16px;
}

.node-content {
  font-size: 14px;
  color: var(--text-light);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 500px;
}

.node-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

/* -- Detail panel (slide-in) -- */

.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 20px rgba(0,0,0,0.08);
  z-index: 20;
  overflow-y: auto;
  padding: 24px;
  transform: translateX(100%);
  transition: transform 0.2s ease;
}

.detail-panel.open { transform: translateX(0); }

.detail-panel .close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 4px;
}

.detail-panel .close-btn:hover { background: var(--warm-100); }

.detail-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
  padding-right: 40px;
}

.detail-content {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-light);
  margin-bottom: 20px;
  white-space: pre-wrap;
}

.detail-section {
  margin-bottom: 20px;
}

.detail-section h4 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.edge-list {
  list-style: none;
}

.edge-item {
  padding: 8px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.1s;
}

.edge-item:hover { background: var(--warm-50); }

.edge-rel {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-right: 6px;
}

/* -- Life Book -- */

.lifebook-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 24px;
}

.era-section {
  margin-bottom: 32px;
}

.era-header {
  font-size: 20px;
  font-weight: 700;
  color: var(--olive-dark);
  margin-bottom: 4px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--gold-400);
}

.era-years {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 400;
}

.story-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold-400);
  border-radius: var(--radius);
  padding: 20px 20px 20px 24px;
  margin-top: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: box-shadow 0.15s, border-left-color 0.15s;
}

.story-card:hover {
  box-shadow: var(--shadow-md);
  border-left-color: var(--olive);
}

.story-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.story-narrative {
  font-size: 15px;
  color: var(--text-light);
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.story-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.story-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* -- People grid -- */

.people-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.person-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: box-shadow 0.15s;
  text-align: center;
}

.person-card:hover { box-shadow: var(--shadow-md); }

.person-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #e8edc8;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  font-size: 28px;
  color: var(--olive-dark);
  font-weight: 700;
}

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

.person-relation {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 2px;
}

.person-stories-count {
  font-size: 13px;
  color: var(--olive);
  margin-top: 8px;
}

/* -- Settings -- */

.settings-section {
  margin-bottom: 32px;
}

.settings-section h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.form-group input,
.form-group select {
  width: 100%;
  max-width: 400px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text);
  background: var(--bg-card);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--olive-light);
}

/* -- Buttons -- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--olive);
  color: #fff;
}
.btn-primary:hover { background: var(--olive-dark); }

.btn-secondary {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover { background: var(--warm-100); }

/* -- Loading -- */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--text-muted);
  font-size: 16px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--olive);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* -- Empty state -- */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 16px;
}

/* -- Mood chart -- */

.mood-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 80px;
  padding: 8px 0;
}

.mood-bar {
  flex: 1;
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.3s;
  position: relative;
}

.mood-bar .mood-tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: var(--text);
  color: #fff;
  font-size: 11px;
  border-radius: 4px;
  white-space: nowrap;
  margin-bottom: 4px;
}

.mood-bar:hover .mood-tooltip { display: block; }

/* -- People sidebar (Life Book) -- */

.people-sidebar .card { padding: 16px; }

.people-sidebar-list {
  list-style: none;
}

.people-sidebar-item {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 15px;
  transition: background 0.1s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.people-sidebar-item:hover { background: var(--warm-100); }

.people-sidebar-item.active {
  background: var(--gold-100);
  color: var(--gold-800);
}

.people-sidebar-count {
  font-size: 12px;
  background: var(--warm-200);
  padding: 2px 8px;
  border-radius: 10px;
  color: var(--text-muted);
}

/* -- Device list (Settings) -- */

.device-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}

.device-item:last-child { border-bottom: none; }

.device-name {
  font-weight: 600;
  font-size: 15px;
}

.device-status {
  font-size: 13px;
  color: var(--text-muted);
}

.device-online {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  margin-right: 6px;
}

.device-offline {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d1d5db;
  margin-right: 6px;
}

/* -- Chat -- */

.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 64px);
  max-height: calc(100vh - 64px);
}

.chat-header {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
  flex-shrink: 0;
}

.chat-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-header h2 {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
}

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

.engine-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.engine-selector label {
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 600;
}

.engine-selector select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.engine-selector select:focus {
  outline: none;
  border-color: var(--olive-light);
}

.chat-mute-btn {
  padding: 6px 10px !important;
  font-size: 18px !important;
  line-height: 1;
  min-width: 36px;
}

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

.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--text-muted);
  gap: 12px;
}

.chat-welcome-icon {
  font-size: 48px;
  opacity: 0.4;
}

.chat-welcome p {
  font-size: 16px;
}

.chat-bubble {
  max-width: 70%;
  padding: 12px 18px;
  border-radius: 18px;
  font-size: 16px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.chat-bubble-user {
  align-self: flex-end;
  background: var(--warm-200);
  color: var(--text);
  border-bottom-right-radius: 4px;
}

.chat-bubble-assistant {
  align-self: flex-start;
  background: var(--gold-400);
  color: var(--olive-dark);
  border-bottom-left-radius: 4px;
}

.chat-status {
  display: none;
  align-items: center;
  padding: 8px 16px;
  font-size: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.chat-status-thinking {
  color: var(--gold-600);
}

.chat-status-thinking::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold-400);
  margin-right: 8px;
  animation: chat-pulse 1s ease-in-out infinite;
}

@keyframes chat-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.chat-status-connecting {
  color: var(--text-muted);
}

.chat-status-connected {
  color: var(--olive);
}

.chat-status-error {
  color: var(--red);
}

.chat-offline {
  display: flex;
  align-items: center;
  background: var(--red-bg);
  border: 1px solid #fca5a5;
  border-radius: var(--radius-sm);
  color: #991b1b;
  padding: 10px 16px;
  font-size: 14px;
}

.chat-input-bar {
  display: flex;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 24px;
  font-size: 16px;
  background: var(--bg-card);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.chat-input:focus {
  border-color: var(--gold-400);
}

.chat-input::placeholder {
  color: var(--text-muted);
}

.chat-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-send-btn {
  border-radius: 24px;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 600;
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-mic-btn {
  border-radius: 24px;
  padding: 14px 18px;
  font-size: 18px;
  line-height: 1;
  background: var(--olive);
  color: #fff;
  transition: all 0.15s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.chat-mic-btn:hover {
  background: var(--olive-dark);
}

.chat-mic-btn.recording {
  background: var(--red);
  animation: mic-pulse 1s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 10px transparent; }
}

/* -- Responsive -- */

@media (max-width: 1024px) {
  .sidebar { width: 220px; }
  .main { margin-left: 220px; padding: 24px; }
  .lifebook-layout { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .detail-panel { width: 100%; }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    transform: translateX(-100%);
    transition: transform 0.2s;
    width: 260px;
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .people-grid { grid-template-columns: 1fr 1fr; }
}
