@import './tokens.css';
@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  html, body, #root {
    @apply h-full;
  }
  body {
    @apply antialiased;
    background-color: rgb(var(--bg));
    color: rgb(var(--text));
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  }
}

@layer components {
  /* ── Layout ── */
  .container {
    @apply max-w-5xl mx-auto px-4 sm:px-6 lg:px-8;
  }

  /* ── Cards ── */
  .card {
    @apply rounded-2xl border p-5 sm:p-6;
    background-color: rgb(var(--surface));
    border-color: rgb(var(--border));
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
  }
  .card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow), 0 0 0 1px rgb(var(--border));
  }

  /* ── Buttons ── */
  .btn {
    @apply inline-flex items-center justify-center rounded-xl px-5 py-2.5 font-semibold transition-all duration-200 focus:outline-none focus:ring-2 text-sm sm:text-base cursor-pointer select-none;
    min-height: 44px;
  }
  .btn-primary {
    background-color: rgb(var(--accent));
    color: rgb(var(--accent-contrast));
    box-shadow: 0 0 20px rgba(var(--glow) / 0.25);
  }
  .btn-primary:hover {
    background-color: rgb(var(--accent-hover));
    box-shadow: 0 0 30px rgba(var(--glow) / 0.4);
    transform: translateY(-1px);
  }
  .btn-primary:focus {
    --tw-ring-color: rgb(var(--ring) / 0.5);
  }
  .btn-ghost {
    color: rgb(var(--text));
    background-color: rgb(var(--surface));
    border: 1px solid rgb(var(--border));
  }
  .btn-ghost:hover {
    background-color: rgb(var(--border));
    transform: translateY(-1px);
  }
  .btn-ghost:focus {
    --tw-ring-color: rgb(var(--ring) / 0.5);
  }

  /* ── Inputs - CRUCIAAL: specifieke selectors om browser defaults te overriden ── */
  input[type="text"],
  input[type="password"],
  input[type="number"],
  input[type="email"],
  input[type="search"],
  input[type="tel"],
  input[type="url"],
  input:not([type]),
  select,
  textarea {
    @apply w-full rounded-xl px-4 py-3 transition-all duration-200 focus:outline-none;
    appearance: none;
    -webkit-appearance: none;
    background-color: rgb(var(--surface-input)) !important;
    border: 1px solid rgb(var(--border));
    color: rgb(var(--text-input)) !important;
    min-height: 48px;
    font-size: 16px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
  }
  input[type="text"]:focus,
  input[type="password"]:focus,
  input[type="number"]:focus,
  input[type="email"]:focus,
  input[type="search"]:focus,
  input[type="tel"]:focus,
  input[type="url"]:focus,
  input:not([type]):focus,
  select:focus,
  textarea:focus {
    border-color: rgb(var(--accent));
    box-shadow: 0 0 0 3px rgba(var(--ring) / 0.2), inset 0 1px 2px rgba(0, 0, 0, 0.06);
    outline: none;
  }
  input::placeholder, textarea::placeholder {
    color: rgb(var(--muted));
    opacity: 0.7;
  }
  select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
  }
  input[type="checkbox"] {
    @apply w-5 h-5 rounded;
    appearance: auto;
    -webkit-appearance: auto;
    accent-color: rgb(var(--accent));
    min-height: auto;
  }
  label {
    @apply block text-sm font-medium mb-1.5;
    color: rgb(var(--muted));
    letter-spacing: 0.01em;
  }

  /* ── Typography ── */
  .subtle {
    color: rgb(var(--muted));
  }

  /* ── Header ── */
  .header {
    @apply sticky top-0 z-30 border-b;
    background-color: rgba(var(--bg) / 0.8);
    border-color: rgb(var(--border));
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
  }
  .header-inner {
    @apply container flex items-center justify-between py-3 gap-3;
  }
  .header-title {
    @apply text-xs sm:text-sm font-semibold tracking-tight;
  }
  .header-logo {
    @apply h-8 sm:h-10 w-auto;
  }
  .header-right {
    @apply flex items-center gap-1.5 sm:gap-3 flex-shrink-0;
  }
  .header-stat {
    @apply hidden sm:flex items-center gap-1.5 text-sm;
    color: rgb(var(--muted));
  }
  .header-btn {
    @apply px-2.5 sm:px-3 py-1.5 text-xs flex items-center gap-1 rounded-lg;
    min-height: 36px;
    border: 1px solid rgb(var(--border));
    background-color: rgb(var(--surface));
    color: rgb(var(--text));
    transition: all 0.15s;
  }
  .header-btn:hover {
    background-color: rgb(var(--border));
  }

  /* ── Flag Selector ── */
  .flag-selector {
    @apply flex justify-center items-stretch gap-2 sm:gap-3 mb-5;
  }
  .flag-option {
    @apply flex flex-col items-center gap-1.5 sm:gap-2 rounded-xl px-3 sm:px-4 py-2.5 text-xs font-medium transition-all duration-200;
    color: rgb(var(--muted));
    background: rgb(var(--surface));
    border: 1px solid rgb(var(--border));
    cursor: pointer;
    flex: 1;
    max-width: 120px;
  }
  .flag-option img {
    @apply w-12 sm:w-16 rounded-md transition-transform duration-200;
  }
  .flag-option:hover {
    border-color: rgb(var(--muted));
    transform: translateY(-1px);
  }
  .flag-option:hover img {
    @apply scale-105;
  }
  .flag-option.selected {
    border-color: rgb(var(--accent));
    box-shadow: 0 0 16px rgba(var(--glow) / 0.2);
    color: rgb(var(--text));
    background: rgba(var(--accent) / 0.08);
  }

  /* ── Dashboard / Grid ── */
  .dashboard {
    @apply grid gap-4 sm:gap-6 mt-5 sm:mt-6 grid-cols-1;
    padding-bottom: 2rem;
  }
  .side-cards {
    @apply grid gap-4 sm:gap-5 grid-cols-1 md:grid-cols-3;
  }

  /* ── Misc Components ── */
  .preview-card {
    @apply rounded-2xl p-4 sm:p-8 text-center;
    background-color: rgba(var(--surface) / 0.6);
    backdrop-filter: blur(12px);
  }
  .toast {
    @apply fixed bottom-4 sm:bottom-6 left-1/2 -translate-x-1/2 px-5 py-3 rounded-xl shadow-lg z-50 text-sm font-medium;
    background-color: rgb(var(--accent));
    color: rgb(var(--accent-contrast));
    box-shadow: 0 8px 24px rgba(var(--glow) / 0.3);
  }
  .stat-card {
    @apply text-center;
  }
  .stat-value {
    @apply text-3xl font-bold text-accent;
  }
  .stat-label {
    @apply mt-1 text-sm;
    color: rgb(var(--muted));
  }
  .button-row {
    @apply flex gap-3 flex-wrap mt-5;
  }
  .plate-block {
    @apply mb-5 sm:mb-6 pb-5 sm:pb-6 border-b last:border-b-0 flex flex-col gap-5 md:flex-row md:gap-8;
    border-color: rgb(var(--border));
  }

  /* ── Spacing ── */
  .mt { @apply mt-4; }
  .mb { @apply mb-2; }
  .mb-lg { @apply mb-6; }
  .ml { @apply ml-2; }

  /* ── Forms ── */
  .form-row {
    @apply flex flex-col gap-1.5 mb-3;
  }
  .form-row.checkbox {
    @apply flex-row items-center gap-3;
  }

  /* ── Landing Page ── */
  .start-container {
    @apply flex items-center justify-center px-4;
    height: calc(100vh - 4rem);
    height: calc(100dvh - 4rem);
  }
  .start-card {
    @apply flex flex-col gap-4 w-full max-w-sm text-center;
  }

  /* ── Hero Background Pattern ── */
  .hero-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    background-color: rgb(var(--bg));
    background-image: radial-gradient(rgba(var(--border)) 1px, transparent 1px);
    background-size: 24px 24px;
  }

  /* ── Preview images ── */
  .plate-preview {
    @apply block mt-3 sm:mt-4 w-full h-auto rounded-lg;
    max-width: 100%;
  }
}
