/* ==========================================================================
   ALPR Scanner — Production UI
   ========================================================================== */

:root {
  --color-bg: #0b0f17;
  --color-bg-elevated: #111827;
  --color-bg-panel: #151c2c;
  --color-bg-input: #0d1320;
  --color-border: rgba(255, 255, 255, 0.08);
  --color-border-strong: rgba(255, 255, 255, 0.14);
  --color-text: #e8edf5;
  --color-text-muted: #8b9bb4;
  --color-text-faint: #5c6b82;
  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --color-primary-glow: rgba(59, 130, 246, 0.25);
  --color-accent: #06b6d4;
  --color-success: #22c55e;
  --color-warning: #f59e0b;
  --color-error: #ef4444;
  --color-plate-bg: #f8fafc;
  --color-plate-text: #0f172a;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.45);
  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --header-height: 64px;
  --transition: 180ms ease;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(59, 130, 246, 0.15), transparent),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(6, 182, 212, 0.08), transparent);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--color-accent);
}

.container {
  width: min(1120px, calc(100% - 2rem));
  margin-inline: auto;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 9999;
  padding: 0.5rem 1rem;
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  top: 1rem;
}

.hidden {
  display: none !important;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.85em;
}

/* Header
   -------------------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: rgba(11, 15, 23, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--color-text);
  text-decoration: none;
}

.brand:hover {
  color: var(--color-text);
}

.brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  border-radius: var(--radius-md);
  color: #fff;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.brand-text strong {
  font-size: 1rem;
  font-weight: 600;
}

.brand-text small {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  font-weight: 400;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

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

.nav-link--external::after {
  content: " ↗";
  font-size: 0.75em;
  opacity: 0.6;
}

/* Hero
   -------------------------------------------------------------------------- */

.hero {
  padding: 3rem 0 2rem;
}

.hero-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: center;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-accent);
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.25);
  border-radius: 999px;
  margin-bottom: 1rem;
}

.hero h1 {
  margin: 0 0 1rem;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.hero-lead {
  margin: 0 0 1.75rem;
  font-size: 1.05rem;
  color: var(--color-text-muted);
  max-width: 32rem;
}

.hero-stats {
  display: flex;
  gap: 2rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.hero-stats li {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
}

.stat-label {
  font-size: 0.78rem;
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hero-visual {
  display: flex;
  justify-content: center;
}

.hero-card {
  padding: 2rem;
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  transform: rotate(2deg);
}

.hero-plate {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  padding: 0.75rem 1.5rem;
  background: var(--color-plate-bg);
  color: var(--color-plate-text);
  border: 3px solid #334155;
  border-radius: var(--radius-sm);
  text-align: center;
  margin-bottom: 1rem;
}

.hero-meta {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.pill {
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--color-text-muted);
}

.pill--success {
  background: rgba(34, 197, 94, 0.15);
  color: var(--color-success);
}

/* Flash messages
   -------------------------------------------------------------------------- */

.flash-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.flash {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  border: 1px solid transparent;
}

.flash--error {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.flash--warning {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.3);
  color: #fcd34d;
}

.flash--success,
.flash--info {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.3);
  color: #86efac;
}

.flash-icon {
  flex-shrink: 0;
  width: 1.25rem;
  text-align: center;
  font-weight: 700;
}

/* Upload section
   -------------------------------------------------------------------------- */

.upload-section {
  padding: 1rem 0 3rem;
}

.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

.panel {
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.panel-header h2 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  font-weight: 600;
}

.panel-header p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.results-meta {
  color: var(--color-accent) !important;
  font-family: var(--font-mono);
  font-size: 0.8rem !important;
}

/* Dropzone
   -------------------------------------------------------------------------- */

.dropzone {
  position: relative;
  margin: 1.25rem 0;
  min-height: 220px;
  border: 2px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  background: var(--color-bg-input);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
  overflow: hidden;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--color-primary);
  background: rgba(59, 130, 246, 0.04);
  outline: none;
}

.dropzone--dragover {
  border-color: var(--color-accent);
  background: rgba(6, 182, 212, 0.06);
  box-shadow: 0 0 0 4px var(--color-primary-glow);
}

.dropzone--has-file {
  border-style: solid;
  border-color: var(--color-border);
  cursor: default;
}

.file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.dropzone--has-file .file-input {
  pointer-events: none;
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  padding: 2rem;
  text-align: center;
  pointer-events: none;
}

.dropzone-icon {
  color: var(--color-text-faint);
  margin-bottom: 0.75rem;
}

.dropzone-title {
  margin: 0 0 0.25rem;
  font-weight: 600;
  color: var(--color-text);
}

.dropzone-hint {
  margin: 0;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.dropzone-hint .link {
  color: var(--color-primary);
  font-weight: 500;
}

.dropzone-formats {
  margin: 0.75rem 0 0;
  font-size: 0.75rem;
  color: var(--color-text-faint);
}

.dropzone-preview {
  position: relative;
  min-height: 220px;
}

.dropzone-preview img {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  background: #000;
}

.preview-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
}

.preview-filename {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.85);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Options
   -------------------------------------------------------------------------- */

.options-panel {
  margin-bottom: 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.options-panel summary {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
  user-select: none;
}

.options-panel summary:hover {
  background: rgba(255, 255, 255, 0.04);
}

.region-fieldset {
  border: none;
  margin: 0;
  padding: 0 1rem 1rem;
}

.region-fieldset legend {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.optional {
  font-weight: 400;
  color: var(--color-text-faint);
}

.field-help {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.region-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--color-text-muted);
  cursor: pointer;
}

.checkbox-label input {
  accent-color: var(--color-primary);
}

/* Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.4;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: linear-gradient(135deg, var(--color-primary), #1d4ed8);
  color: #fff;
  box-shadow: 0 4px 14px var(--color-primary-glow);
}

.btn--primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--color-primary-hover), #1e40af);
  box-shadow: 0 6px 20px var(--color-primary-glow);
}

.btn--primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn--full {
  width: 100%;
  padding: 0.85rem 1.5rem;
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-text);
  border: 1px solid var(--color-border-strong);
}

.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn--sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
}

.btn--icon {
  padding: 0.4rem;
  background: rgba(255, 255, 255, 0.06);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.btn--icon:hover {
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.1);
}

.btn--icon.copied {
  color: var(--color-success);
  border-color: rgba(34, 197, 94, 0.4);
}

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

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

.btn--loading .btn-label {
  opacity: 0.7;
}

.btn--loading .btn-spinner {
  display: inline-block;
}

/* Results
   -------------------------------------------------------------------------- */

.canvas-wrapper {
  margin: 1rem 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--color-border);
}

#detection-canvas {
  display: block;
  width: 100%;
  height: auto;
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.result-card {
  padding: 1.25rem;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.result-card-header {
  margin-bottom: 1rem;
}

.plate-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.plate-text {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  padding: 0.5rem 1rem;
  background: var(--color-plate-bg);
  color: var(--color-plate-text);
  border: 2px solid #475569;
  border-radius: var(--radius-sm);
}

.plate-text--muted {
  background: transparent;
  color: var(--color-text-muted);
  border-color: var(--color-border);
  font-size: 1rem;
  letter-spacing: normal;
}

.confidence-bar {
  position: relative;
  height: 28px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-success));
  border-radius: var(--radius-sm);
  transition: width 600ms ease;
}

.confidence-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.result-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1rem;
  margin: 0;
}

.detail-row {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.detail-row dt {
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-faint);
}

.detail-row dd {
  margin: 0;
  font-size: 0.875rem;
  color: var(--color-text);
}

.detail-score {
  font-size: 0.8em;
  color: var(--color-text-muted);
}

.candidates-panel {
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.candidates-panel summary {
  cursor: pointer;
  color: var(--color-text-muted);
}

.candidates-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
}

.candidates-list li {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--color-border);
}

.candidates-list li:last-child {
  border-bottom: none;
}

/* Empty state
   -------------------------------------------------------------------------- */

.empty-state {
  text-align: center;
  padding: 2.5rem 1.5rem;
}

.empty-icon {
  display: inline-flex;
  color: var(--color-text-faint);
  margin-bottom: 1rem;
}

.empty-state h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

.empty-state p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  max-width: 28rem;
  margin-inline: auto;
}

.empty-state--idle .empty-icon {
  color: var(--color-primary);
  opacity: 0.6;
}

/* Info sections
   -------------------------------------------------------------------------- */

.info-section {
  padding: 3rem 0;
  border-top: 1px solid var(--color-border);
}

.section-title {
  text-align: center;
  margin: 0 0 2rem;
  font-size: 1.5rem;
  font-weight: 700;
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.step-card {
  padding: 1.5rem;
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--color-primary);
  background: rgba(59, 130, 246, 0.12);
  border-radius: 50%;
}

.step-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.step-card p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.features-section {
  padding: 0 0 4rem;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.feature-card {
  padding: 1.25rem;
  border-left: 3px solid var(--color-primary);
  background: rgba(59, 130, 246, 0.04);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.feature-card h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
}

.feature-card p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* Footer
   -------------------------------------------------------------------------- */

.site-footer {
  padding: 2.5rem 0;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
}

.footer-inner {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2rem;
}

.footer-brand strong {
  display: block;
  margin-bottom: 0.35rem;
}

.footer-brand p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  max-width: 28rem;
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.footer-links a {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.footer-links a:hover {
  color: var(--color-text);
}

.footer-copy {
  grid-column: 1 / -1;
  margin: 1rem 0 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.78rem;
  color: var(--color-text-faint);
}

/* Toast
   -------------------------------------------------------------------------- */

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 0.75rem 1.25rem;
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  opacity: 0;
  transition: transform 300ms ease, opacity 300ms ease;
  pointer-events: none;
}

.toast--visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .hero-inner,
  .upload-grid,
  .steps-grid,
  .features-grid {
    grid-template-columns: 1fr;
  }

  .hero-visual {
    order: -1;
  }

  .hero-card {
    transform: none;
    width: 100%;
    max-width: 320px;
  }

  .header-nav {
    display: none;
  }

  .result-details {
    grid-template-columns: 1fr;
  }

  .footer-inner {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .region-grid {
    grid-template-columns: 1fr;
  }

  .hero-stats {
    gap: 1.25rem;
  }

  .plate-text {
    font-size: 1.15rem;
    letter-spacing: 0.08em;
  }
}
