/* styles.css – Mobile-first responsive styles for Book Scanner */

/* ─── Reset & base ─────────────────────────────────────────────────────── */

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

:root {
  --clr-primary: #2563eb;
  --clr-primary-dark: #1d4ed8;
  --clr-danger: #dc2626;
  --clr-danger-dark: #b91c1c;
  --clr-success-bg: #dcfce7;
  --clr-success-text: #166534;
  --clr-error-bg: #fee2e2;
  --clr-error-text: #991b1b;
  --clr-info-bg: #dbeafe;
  --clr-info-text: #1e40af;
  --clr-border: #e5e7eb;
  --clr-bg: #f9fafb;
  --clr-surface: #ffffff;
  --clr-text: #111827;
  --clr-text-muted: #6b7280;
  --radius: 0.75rem;
  --shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
}

html {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  color: var(--clr-text);
  background: var(--clr-bg);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ─── Header ────────────────────────────────────────────────────────────── */

header {
  background: var(--clr-primary);
  color: #fff;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: var(--shadow);
}

header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

header .header-icon {
  font-size: 1.5rem;
}

/* ─── Main layout ───────────────────────────────────────────────────────── */

main {
  flex: 1;
  padding: 1rem;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ─── Buttons ───────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.1rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  opacity: 0.85;
}

.btn-primary {
  background: var(--clr-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--clr-primary-dark);
}

.btn-secondary {
  background: var(--clr-surface);
  color: var(--clr-text);
  border: 1.5px solid var(--clr-border);
}

.btn-secondary:hover {
  background: #f3f4f6;
}

.btn-danger {
  background: var(--clr-danger);
  color: #fff;
}

.btn-danger:hover {
  background: var(--clr-danger-dark);
}

/* ─── Action bar ────────────────────────────────────────────────────────── */

.action-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.action-bar .btn {
  flex: 1 1 auto;
}

/* ─── Messages ──────────────────────────────────────────────────────────── */

.message {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
}

.message.success {
  background: var(--clr-success-bg);
  color: var(--clr-success-text);
}

.message.error {
  background: var(--clr-error-bg);
  color: var(--clr-error-text);
}

.message.info {
  background: var(--clr-info-bg);
  color: var(--clr-info-text);
}

/* ─── Scanner section ───────────────────────────────────────────────────── */

#scanner-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.scanner-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}

#scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scanner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.scanner-reticle {
  width: 65%;
  aspect-ratio: 3 / 1;
  border: 3px solid rgba(255,255,255,0.85);
  border-radius: 0.5rem;
  box-shadow: 0 0 0 2000px rgba(0,0,0,0.45);
}

.scanner-hint {
  margin-top: 0.75rem;
  color: rgba(255,255,255,0.9);
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
}

/* ─── Loading overlay ───────────────────────────────────────────────────── */

#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 5px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ─── Confirm dialog ────────────────────────────────────────────────────── */

#confirm-dialog {
  background: var(--clr-surface);
  border: 1.5px solid var(--clr-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#confirm-dialog h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.confirm-book {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

#confirm-cover {
  width: 80px;
  min-width: 80px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 0.4rem;
  background: #e5e7eb;
}

.confirm-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.confirm-details .book-title {
  font-weight: 700;
  font-size: 1rem;
}

.confirm-details .book-meta {
  font-size: 0.85rem;
  color: var(--clr-text-muted);
}

.confirm-actions {
  display: flex;
  gap: 0.5rem;
}

.confirm-actions .btn {
  flex: 1;
}

/* ─── Book list ─────────────────────────────────────────────────────────── */

#book-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.book-item {
  background: var(--clr-surface);
  border: 1.5px solid var(--clr-border);
  border-radius: var(--radius);
  padding: 0.75rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  box-shadow: var(--shadow);
}

.book-cover {
  width: 60px;
  min-width: 60px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 0.35rem;
  background: #e5e7eb;
}

.book-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  overflow: hidden;
}

.book-title {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-meta {
  font-size: 0.82rem;
  color: var(--clr-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-meta.isbn {
  font-size: 0.78rem;
  font-family: monospace;
}

.btn-delete {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--clr-text-muted);
  font-size: 1rem;
  padding: 0.25rem;
  border-radius: 0.35rem;
  line-height: 1;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-delete:hover {
  color: var(--clr-danger);
}

.empty-state {
  color: var(--clr-text-muted);
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.95rem;
}

/* ─── Section headings ──────────────────────────────────────────────────── */

.section-heading {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--clr-text-muted);
}

/* ─── Utilities ─────────────────────────────────────────────────────────── */

[hidden] {
  display: none !important;
}

/* ─── Footer ────────────────────────────────────────────────────────────── */

footer {
  text-align: center;
  padding: 0.75rem;
  font-size: 0.78rem;
  color: var(--clr-text-muted);
}
