/* Avin Web Client — Mobile-first styles
 * Dark-mode friendly via prefers-color-scheme.
 * Uses CSS custom properties for easy theming.
 */

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

:root {
  --bg:        #0f1117;
  --surface:   #1c1f2e;
  --surface2:  #252840;
  --border:    #333655;
  --text:      #e8eaf6;
  --text-dim:  #9097b8;
  --primary:   #6c8aff;
  --primary-h: #8ba4ff;
  --danger:    #ff5c72;
  --success:   #4caf82;
  --warning:   #ffb347;
  --rec:       #ff3b3b;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 4px 24px rgba(0,0,0,0.4);
  --font:      -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Light mode override */
@media (prefers-color-scheme: light) {
  :root {
    --bg:        #f0f2f8;
    --surface:   #ffffff;
    --surface2:  #eef0f8;
    --border:    #d0d4e8;
    --text:      #1a1d2e;
    --text-dim:  #5a6080;
    --primary:   #3d5afc;
    --primary-h: #2a44e0;
    --shadow:    0 4px 24px rgba(0,0,0,0.1);
  }
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.5;
  padding-bottom: env(safe-area-inset-bottom, 16px);
}

/* ── Layout ───────────────────────────────────────────────────────────────── */
.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 32px;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.header h1 span {
  color: var(--primary);
}

/* ── Settings panel ───────────────────────────────────────────────────────── */
.settings-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 6px 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.settings-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.settings-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  display: none;
}

.settings-panel.open {
  display: block;
}

.settings-panel h2 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}

.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 5px;
}

.field input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.field input:focus {
  border-color: var(--primary);
}

.field input::placeholder {
  color: var(--text-dim);
  opacity: 0.6;
}

.btn-save {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 20px;
  cursor: pointer;
  width: 100%;
  margin-top: 4px;
  transition: background 0.15s;
}

.btn-save:hover {
  background: var(--primary-h);
}

/* ── Record section ───────────────────────────────────────────────────────── */
.record-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 28px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.btn-record {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 3px solid var(--primary);
  background: var(--surface2);
  color: var(--primary);
  font-size: 2.4rem;
  cursor: pointer;
  transition: transform 0.1s, background 0.2s, border-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn-record:hover {
  transform: scale(1.05);
  background: var(--surface);
}

.btn-record:active {
  transform: scale(0.96);
}

.btn-record.recording {
  border-color: var(--rec);
  color: var(--rec);
  animation: pulse 1.5s infinite;
}

.btn-record.recording .icon-mic::before { content: "⏹"; }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0   rgba(255, 59, 59, 0.5); }
  70%  { box-shadow: 0 0 0 14px rgba(255, 59, 59, 0);   }
  100% { box-shadow: 0 0 0 0   rgba(255, 59, 59, 0);   }
}

.icon-mic::before { content: "🎙"; font-style: normal; }

.status-line {
  font-size: 0.95rem;
  color: var(--text-dim);
  text-align: center;
  min-height: 1.4em;
  transition: color 0.2s;
}

.status-line.error   { color: var(--danger); }
.status-line.active  { color: var(--success); }
.status-line.warning { color: var(--warning); }

/* ── Action bar (History button) ──────────────────────────────────────────── */
.action-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.btn-secondary {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 11px 16px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-secondary:hover {
  border-color: var(--primary);
  background: var(--surface2);
}

/* ── Feed ─────────────────────────────────────────────────────────────────── */
.feed-header {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feed-empty {
  color: var(--text-dim);
  font-size: 0.9rem;
  text-align: center;
  padding: 32px 0;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  animation: slide-in 0.2s ease-out;
}

@keyframes slide-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-type {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}

.card.transcript .card-type { color: var(--primary); }
.card.note       .card-type { color: var(--success);  }
.card.action     .card-type { color: var(--warning);  }
.card.error-card .card-type { color: var(--danger);   }
.card.history    .card-type { color: var(--text-dim); }

.card-body {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
}

.card-body .details {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 4px;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  word-break: break-all;
}

/* ── Action card confirmation buttons ────────────────────────────────────── */
.action-btns {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.btn-confirm,
.btn-dismiss {
  flex: 1;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 9px 14px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.btn-confirm {
  background: var(--success);
  color: #fff;
}

.btn-dismiss {
  background: var(--surface2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.btn-confirm:hover { opacity: 0.88; }
.btn-dismiss:hover { opacity: 0.75; }
.btn-confirm:active,
.btn-dismiss:active { transform: scale(0.97); }

.btn-confirm:disabled,
.btn-dismiss:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.action-status-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  margin-top: 8px;
}

.action-status-badge.confirmed {
  background: rgba(76, 175, 130, 0.18);
  color: var(--success);
}

.action-status-badge.dismissed {
  background: rgba(144, 151, 184, 0.15);
  color: var(--text-dim);
}

/* ── Note timestamp (for history) ─────────────────────────────────────────── */
.card-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 6px;
}

/* ── Spinner ──────────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

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