/* style.css — the look of the DieCast app. Kept simple and mobile-first. */

:root {
  --bg: #f2f3f5;
  --card: #ffffff;
  --ink: #1c1e21;
  --muted: #6b7280;
  --accent: #c62828;      /* Matchbox red */
  --accent-dark: #8e0000;
  --border: #e2e4e8;
  --error: #c62828;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  /* Respect the iPhone notch/safe areas when installed to the home screen. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* A "view" is a whole screen. .hidden removes it from view entirely. */
.view { min-height: 100vh; }
.hidden { display: none !important; }

/* Login view centers its card on the screen. */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  margin: 12px auto;
  max-width: 560px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

h1 { margin: 0; color: var(--accent); font-size: 2rem; }
h2 { margin: 0 0 12px; font-size: 1.2rem; }
.subtitle { margin: 4px 0 20px; color: var(--muted); }

/* Form fields */
input, textarea, button {
  width: 100%;
  font-size: 1rem;
  padding: 12px;
  margin: 6px 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-family: inherit;
}
textarea { min-height: 70px; resize: vertical; }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  font-weight: 600;
  cursor: pointer;
}
button:active { background: var(--accent-dark); }

.field-label { display: block; font-size: 0.8rem; color: var(--muted); margin: 8px 0 -2px; }

.error { color: var(--error); min-height: 1.2em; margin: 6px 0 0; font-size: 0.9rem; }
.muted { color: var(--muted); }

/* Top bar in the app view */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
}
.logo { font-weight: 700; color: var(--accent); }
.spacer { flex: 1; }
.user-email { color: var(--muted); font-size: 0.85rem; }

/* Nav tabs */
.nav { display: flex; gap: 4px; }
.nav-btn {
  width: auto; margin: 0; padding: 6px 12px; font-size: 0.9rem; font-weight: 600;
  background: transparent; color: var(--muted); border: none; border-radius: 8px;
}
.nav-btn.active { background: #fbeaea; color: var(--accent); }
.nav-btn:active { background: #fbeaea; }

/* Collection controls */
.controls { display: flex; flex-direction: column; gap: 8px; }
.controls-row { display: flex; gap: 8px; flex-wrap: wrap; }
.controls-row select { flex: 1; min-width: 120px; margin: 0; }
.controls input { margin: 0; }
.link-btn {
  width: auto;
  background: none;
  color: var(--accent);
  padding: 4px 8px;
  font-size: 0.9rem;
}
.link-btn:active { background: none; color: var(--accent-dark); }

/* Secondary / success styling */
button.secondary { background: #fff; color: var(--accent); border: 1px solid var(--accent); margin-top: 10px; }
button.secondary:active { background: #fbeaea; }
.success { color: #2e7d32; min-height: 1.2em; margin: 6px 0 0; font-size: 0.9rem; }

/* Photo preview + candidates */
.preview-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.preview-thumb { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; background: #fafafa; }
.ai-guess { font-weight: 600; margin: 10px 0 6px; }
.candidate-list { list-style: none; margin: 0; padding: 0; }
.candidate-list li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.candidate-list li:last-child { border-bottom: none; }
.candidate-name { font-weight: 600; }
.candidate-meta { color: var(--muted); font-size: 0.85rem; margin: 2px 0 6px; }
button.add-candidate { width: auto; padding: 6px 14px; font-size: 0.9rem; }

/* Collection list */
.car-list { list-style: none; margin: 0; padding: 0; }
.car-row { padding: 12px 0; border-bottom: 1px solid var(--border); }
.car-row:last-child { border-bottom: none; }
.car-summary { display: flex; gap: 12px; align-items: center; }
.car-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.car-info { min-width: 0; flex: 1; }
.car-name { font-weight: 600; }
.car-meta { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }

/* Edit panel */
.edit-panel { margin-top: 12px; padding: 12px; background: #fafbfc; border: 1px solid var(--border); border-radius: 10px; }
.edit-panel input, .edit-panel textarea, .edit-panel button { margin: 5px 0; }
.edit-panel .danger { background: #fff; color: var(--error); border: 1px solid var(--error); }
.edit-panel .danger:active { background: #fbeaea; }

/* Photo gallery in the edit panel */
.gallery { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.gallery-cell { width: 96px; }
.gallery-cell img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 2px solid transparent; }
.gallery-cell.is-primary img { border-color: var(--accent); }
.gallery-actions { display: flex; flex-direction: column; gap: 3px; margin-top: 3px; }
button.tiny { width: auto; padding: 3px 8px; font-size: 0.75rem; margin: 0; }
button.tiny.danger { background: #fff; color: var(--error); border: 1px solid var(--error); }
span.tiny { font-size: 0.75rem; text-align: center; }

/* Tag chips */
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: #eef0f3; color: #333;
  border-radius: 999px; padding: 3px 10px; font-size: 0.78rem;
}
.chip.removable { padding-right: 4px; }
.chip-x {
  width: auto; margin: 0; padding: 0 4px;
  background: none; color: var(--muted); font-size: 1rem; line-height: 1;
}
.chip-x:active { background: none; color: var(--error); }

/* In-app delete confirmation */
.confirm-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.confirm-msg { font-size: 0.9rem; color: var(--error); flex: 1 1 100%; }
