/* style.css — Chivato AI design tokens + components */

:root,
[data-theme='light'] {
  /* Surfaces */
  --color-bg: #f7f5f1;
  --color-surface: #ffffff;
  --color-surface-2: #f1eee7;
  --color-surface-offset: #ebe7de;
  --color-divider: #e2ddd2;
  --color-border: #d8d2c5;

  /* Text */
  --color-text: #201c15;
  --color-text-muted: #6e6a60;
  --color-text-faint: #a8a396;
  --color-text-inverse: #f9f7f2;

  /* Primary accent — amber (from logo) */
  --color-primary: #c8650f;
  --color-primary-hover: #a8530a;
  --color-primary-active: #8a4408;
  --color-primary-highlight: #f0dcc4;

  /* Severity colors */
  --color-critico: #b3352f;
  --color-critico-highlight: #f3d9d6;
  --color-atencion: #c8650f;
  --color-atencion-highlight: #f0dcc4;
  --color-informativo: #2c6a94;
  --color-informativo-highlight: #d3e2ea;
  --color-success: #3f7a34;
  --color-success-highlight: #d9e8d3;

  --radius-sm: 0.375rem;
  --radius-md: 0.625rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-full: 9999px;

  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  --shadow-sm: 0 1px 2px oklch(0.2 0.02 60 / 0.08);
  --shadow-md: 0 4px 16px oklch(0.2 0.02 60 / 0.10);
  --shadow-lg: 0 16px 40px oklch(0.2 0.02 60 / 0.16);

  --content-narrow: 480px;
  --content-default: 720px;

  --font-display: 'General Sans', 'Segoe UI', sans-serif;
  --font-body: 'Satoshi', 'Segoe UI', sans-serif;
}

[data-theme='dark'] {
  --color-bg: #0c1016;
  --color-surface: #131922;
  --color-surface-2: #182029;
  --color-surface-offset: #1c242f;
  --color-divider: #232b36;
  --color-border: #2b3542;

  --color-text: #e7e4dc;
  --color-text-muted: #9a968b;
  --color-text-faint: #666256;
  --color-text-inverse: #171310;

  --color-primary: #f5973a;
  --color-primary-hover: #ffb15c;
  --color-primary-active: #ffc888;
  --color-primary-highlight: #3a2c1c;

  --color-critico: #ef5b53;
  --color-critico-highlight: #3a2020;
  --color-atencion: #f5973a;
  --color-atencion-highlight: #3a2c1c;
  --color-informativo: #6ab0e6;
  --color-informativo-highlight: #1e2e3a;
  --color-success: #7ec36c;
  --color-success-highlight: #223420;

  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.3);
  --shadow-md: 0 4px 16px oklch(0 0 0 / 0.35);
  --shadow-lg: 0 16px 40px oklch(0 0 0 / 0.5);
}

/* Type scale */
:root {
  --text-xs: clamp(0.75rem, 0.72rem + 0.15vw, 0.8125rem);
  --text-sm: clamp(0.875rem, 0.84rem + 0.2vw, 0.9375rem);
  --text-base: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  --text-lg: clamp(1.125rem, 1.05rem + 0.4vw, 1.3rem);
  --text-xl: clamp(1.375rem, 1.2rem + 0.9vw, 1.75rem);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
}

/* ---------- Layout shell ---------- */
body {
  background: var(--color-bg);
}

.app-shell {
  max-width: var(--content-narrow);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--color-bg);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: color-mix(in oklab, var(--color-bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-divider);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.brand img {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-lg);
  letter-spacing: -0.01em;
}

.brand-name span {
  color: var(--color-primary);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text);
}
.icon-btn:hover {
  background: var(--color-surface-offset);
}
.icon-btn svg {
  width: 20px;
  height: 20px;
}

main {
  flex: 1;
  padding: var(--space-5) var(--space-5) var(--space-20);
}

.view {
  display: none;
  animation: fade-in 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
.view.is-active {
  display: block;
}

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

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  padding-bottom: max(var(--space-2), env(safe-area-inset-bottom));
  background: color-mix(in oklab, var(--color-bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--color-divider);
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  min-height: 44px;
}
.nav-btn svg {
  width: 22px;
  height: 22px;
}
.nav-btn.is-active {
  color: var(--color-primary);
  background: var(--color-primary-highlight);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--text-sm);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-full);
  min-height: 48px;
  width: 100%;
  border: 1px solid transparent;
}
.btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.btn-primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  background: var(--color-primary-hover);
}
.btn-primary:active {
  transform: scale(0.98);
}
.btn-secondary {
  background: var(--color-surface-2);
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn-secondary:hover {
  background: var(--color-surface-offset);
}
.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  width: auto;
  min-height: 40px;
  padding: var(--space-2) var(--space-4);
}
.btn-ghost:hover {
  color: var(--color-text);
}
.btn[disabled] {
  opacity: 0.5;
  pointer-events: none;
}

/* ---------- Scan view ---------- */
.hero-copy {
  text-align: center;
  margin-bottom: var(--space-6);
}
.hero-copy h1 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: var(--space-2);
  letter-spacing: -0.01em;
}
.hero-copy p {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  max-width: 40ch;
  margin-inline: auto;
}

.capture-zone {
  border: 1.5px dashed var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  background: var(--color-surface);
  margin-bottom: var(--space-4);
}

.capture-zone .capture-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--color-primary-highlight);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.capture-zone .capture-icon svg {
  width: 28px;
  height: 28px;
}

.capture-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
}

.preview-frame {
  position: relative;
  border-radius: var(--radius-xl);
  overflow: hidden;
  margin-bottom: var(--space-4);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
}
.preview-frame img {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
}
.preview-frame .remove-photo {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: color-mix(in oklab, black 55%, transparent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-frame .remove-photo svg {
  width: 18px;
  height: 18px;
}

.status-banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--color-surface-2);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2.5px solid var(--color-border);
  border-top-color: var(--color-primary);
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.error-banner {
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--color-critico-highlight);
  color: var(--color-critico);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
  line-height: 1.5;
}
.error-banner a {
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
}

/* ---------- Result cards ---------- */
.result-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.testigo-card {
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--sev-color, var(--color-border));
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.testigo-card[data-gravedad='critico'] {
  --sev-color: var(--color-critico);
}
.testigo-card[data-gravedad='atencion'] {
  --sev-color: var(--color-atencion);
}
.testigo-card[data-gravedad='informativo'] {
  --sev-color: var(--color-informativo);
}

.testigo-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.testigo-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-base);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  white-space: nowrap;
  background: color-mix(in oklab, var(--sev-color, var(--color-border)) 18%, var(--color-surface));
  color: var(--sev-color, var(--color-text));
}
.badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.testigo-card p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}
.testigo-card p:last-child {
  margin-bottom: 0;
}

.testigo-card .field-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-faint);
  margin-bottom: var(--space-1);
}

.testigo-card ul {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
  padding-left: var(--space-5);
  list-style: disc;
}

.action-line {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: color-mix(in oklab, var(--sev-color, var(--color-border)) 10%, var(--color-surface));
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

.cost-line {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-sm);
  padding-top: var(--space-3);
  margin-top: var(--space-3);
  border-top: 1px solid var(--color-divider);
}
.cost-line strong {
  font-family: var(--font-display);
}

/* ---------- Legal disclaimer ---------- */
.disclaimer {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--color-surface-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.5;
  margin-top: var(--space-6);
}
.disclaimer svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--color-text-faint);
  margin-top: 2px;
}

/* ---------- Empty states ---------- */
.empty-state {
  text-align: center;
  padding: var(--space-16) var(--space-5);
  color: var(--color-text-muted);
}
.empty-state svg {
  width: 40px;
  height: 40px;
  margin: 0 auto var(--space-4);
  color: var(--color-text-faint);
}
.empty-state p {
  font-size: var(--text-sm);
  max-width: 32ch;
  margin: 0 auto;
}

/* ---------- Guide (Guía) ---------- */
.search-input {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-4);
}
.search-input svg {
  width: 18px;
  height: 18px;
  color: var(--color-text-faint);
  flex-shrink: 0;
}
.search-input input {
  border: none;
  background: none;
  outline: none;
  width: 100%;
  font-size: var(--text-sm);
}

.guide-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--sev-color, var(--color-border));
  margin-bottom: var(--space-3);
  text-align: left;
  width: 100%;
}
.guide-item[data-gravedad='critico'] {
  --sev-color: var(--color-critico);
}
.guide-item[data-gravedad='atencion'] {
  --sev-color: var(--color-atencion);
}
.guide-item[data-gravedad='informativo'] {
  --sev-color: var(--color-informativo);
}
.guide-item .name {
  font-weight: 600;
  font-size: var(--text-sm);
}

/* Guide detail (inline expand) */
.guide-detail {
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--color-surface-2);
  margin: calc(var(--space-3) * -1) 0 var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ---------- History ---------- */
.history-item {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-3);
  width: 100%;
  text-align: left;
}
.history-thumb {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--color-surface-2);
}
.history-info {
  flex: 1;
  min-width: 0;
}
.history-info .name {
  font-weight: 600;
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-info .date {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

/* ---------- Settings ---------- */
.settings-section {
  margin-bottom: var(--space-8);
}
.settings-section h2 {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  margin-bottom: var(--space-3);
}
.field {
  margin-bottom: var(--space-4);
}
.field label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-faint);
  margin-bottom: var(--space-2);
}
.field input,
.field select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: var(--text-sm);
  min-height: 46px;
}
.field .hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-2);
  line-height: 1.5;
}
.field .hint a {
  color: var(--color-primary);
  font-weight: 600;
}

.provider-toggle {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.provider-toggle button {
  flex: 1;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
}
.provider-toggle button.is-active {
  background: var(--color-primary-highlight);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  background: var(--color-text);
  color: var(--color-text-inverse);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
}
.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(-8px);
}

.about-card {
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  text-align: center;
}
.about-card img {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-3);
  border-radius: var(--radius-md);
}
.about-card p {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

@media (min-width: 640px) {
  main {
    padding-inline: var(--space-8);
  }
}
