/**
 * Alderity Plate Lookup - Frontend Styles
 * Version: 1.0.0
 */

.apl-app {
  --apl-bg: #0a0d14;
  --apl-bg-2: #11151f;
  --apl-bg-3: #1a1f2e;
  --apl-line: rgba(255, 255, 255, 0.08);
  --apl-line-strong: rgba(255, 255, 255, 0.18);
  --apl-text: #f5f5f7;
  --apl-mute: #8a92a3;
  --apl-mute-2: #5a6173;
  --apl-accent: #ffd84d;
  --apl-accent-glow: rgba(255, 216, 77, 0.4);
  --apl-success: #00d4a3;
  --apl-red: #ff4d6d;
  --apl-plate-yellow: #ffcb05;
  --apl-plate-black: #0a0a0a;
  --apl-ease: cubic-bezier(0.16, 1, 0.3, 1);

  font-family: 'Heebo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--apl-bg);
  color: var(--apl-text);
  border-radius: 20px;
  padding: 40px 32px;
  position: relative;
  overflow: hidden;
  margin: 24px auto;
  max-width: 1100px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.4);
  -webkit-font-smoothing: antialiased;
  font-weight: 400;
  direction: rtl;
}

.apl-app * {
  box-sizing: border-box;
}

.apl-app[data-theme="light"] {
  --apl-bg: #faf8f3;
  --apl-bg-2: #ffffff;
  --apl-bg-3: #f5f1e8;
  --apl-line: rgba(0, 0, 0, 0.08);
  --apl-line-strong: rgba(0, 0, 0, 0.18);
  --apl-text: #0a0d14;
  --apl-mute: #5a6173;
  --apl-mute-2: #8a92a3;
}

.apl-app::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 216, 77, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 0% 100%, rgba(0, 212, 163, 0.04) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.apl-app > * { position: relative; z-index: 1; }

/* ===== STATE: INITIAL ===== */
.apl-state-initial {
  text-align: center;
  padding: 20px 0;
}

.apl-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.3em;
  color: var(--apl-accent);
  text-transform: uppercase;
  margin-bottom: 24px;
}

.apl-eyebrow::before, .apl-eyebrow::after {
  content: '';
  width: 24px;
  height: 1px;
  background: var(--apl-accent);
  opacity: 0.5;
}

.apl-headline {
  font-family: 'Frank Ruhl Libre', 'Heebo', serif;
  font-size: clamp(28px, 4vw, 48px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 16px;
  color: var(--apl-text);
}

.apl-headline em {
  font-style: italic;
  color: var(--apl-accent);
  font-weight: 500;
}

.apl-subline {
  font-size: 16px;
  color: var(--apl-mute);
  max-width: 540px;
  margin: 0 auto 36px;
  line-height: 1.6;
}

/* License Plate Input */
.apl-plate-wrapper {
  max-width: 460px;
  margin: 0 auto 16px;
  position: relative;
}

.apl-plate-frame {
  background: var(--apl-plate-yellow);
  border: 4px solid var(--apl-plate-black);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow:
    0 16px 40px -10px rgba(0, 0, 0, 0.4),
    0 0 0 2px rgba(255, 203, 5, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: all 0.4s var(--apl-ease);
}

.apl-plate-frame:focus-within {
  box-shadow:
    0 20px 50px -10px rgba(0, 0, 0, 0.5),
    0 0 0 4px var(--apl-accent-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transform: translateY(-2px);
}

.apl-plate-il {
  background: #003db8;
  color: white;
  padding: 18px 6px;
  border-radius: 4px;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
  line-height: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 32px;
}

.apl-plate-il-star {
  font-size: 14px;
  color: #ffd700;
}

.apl-plate-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--apl-plate-black);
  font-family: 'DM Mono', monospace;
  font-size: clamp(24px, 5vw, 36px);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-align: center;
  width: 100%;
  direction: ltr;
  padding: 6px 0;
}

.apl-plate-input::placeholder {
  color: rgba(10, 10, 10, 0.3);
  letter-spacing: 0.15em;
}

.apl-plate-submit {
  background: var(--apl-plate-black);
  color: var(--apl-plate-yellow);
  border: none;
  width: 50px;
  height: 50px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s var(--apl-ease);
  flex-shrink: 0;
}

.apl-plate-submit:hover:not(:disabled) {
  background: #2a2a2a;
  transform: scale(1.05);
}

.apl-plate-submit:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.apl-plate-submit svg {
  transition: transform 0.3s var(--apl-ease);
}

.apl-plate-submit:hover:not(:disabled) svg {
  transform: translateX(-3px);
}

.apl-plate-hint {
  text-align: center;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--apl-mute);
  letter-spacing: 0.1em;
  margin-bottom: 24px;
}

/* Trust Signals */
.apl-trust-row {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 32px;
  flex-wrap: wrap;
}

.apl-trust-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--apl-mute);
}

.apl-trust-item::before {
  content: '✓';
  color: var(--apl-success);
  font-weight: 700;
}

/* ===== STATE: SCANNING ===== */
.apl-state-scanning {
  display: none;
  padding: 40px 0;
  text-align: center;
}

.apl-state-scanning.active { display: block; }

.apl-scanner {
  max-width: 460px;
  margin: 0 auto 24px;
  background: var(--apl-bg-2);
  border: 1px solid var(--apl-line);
  border-radius: 16px;
  padding: 32px;
  position: relative;
  overflow: hidden;
}

.apl-scanner-plate {
  font-family: 'DM Mono', monospace;
  font-size: 28px;
  font-weight: 700;
  background: var(--apl-plate-yellow);
  color: var(--apl-plate-black);
  padding: 14px 22px;
  border-radius: 8px;
  border: 3px solid var(--apl-plate-black);
  display: inline-block;
  margin-bottom: 24px;
  letter-spacing: 0.1em;
}

.apl-scanner-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--apl-accent), transparent);
  box-shadow: 0 0 12px var(--apl-accent-glow);
  animation: aplScanLine 2s linear infinite;
  top: 0;
}

@keyframes aplScanLine {
  0% { top: 0; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

.apl-scanner-status {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--apl-accent);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.apl-scanner-status::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--apl-accent);
  border-radius: 50%;
  margin-left: 8px;
  animation: aplPulse 1s ease-in-out infinite;
  box-shadow: 0 0 8px var(--apl-accent-glow);
}

@keyframes aplPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.apl-scanner-steps {
  margin-top: 28px;
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.apl-scanner-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--apl-mute);
  opacity: 0.3;
  transition: opacity 0.4s var(--apl-ease);
}

.apl-scanner-step.active { opacity: 1; color: var(--apl-accent); }
.apl-scanner-step.done { opacity: 1; color: var(--apl-success); }

.apl-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.apl-scanner-step.active .apl-dot {
  animation: aplPulse 0.8s ease-in-out infinite;
}

/* ===== STATE: RESULT ===== */
.apl-state-result {
  display: none;
  padding: 16px 0;
}

.apl-state-result.active {
  display: block;
  animation: aplFadeIn 0.6s var(--apl-ease);
}

@keyframes aplFadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.apl-result-banner {
  background: linear-gradient(135deg, rgba(0, 212, 163, 0.1), rgba(0, 212, 163, 0.02));
  border: 1px solid rgba(0, 212, 163, 0.3);
  border-radius: 12px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  font-size: 14px;
}

.apl-check {
  width: 28px;
  height: 28px;
  background: var(--apl-success);
  color: var(--apl-bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.apl-result-banner strong { color: var(--apl-success); }

/* Car Details Card */
.apl-car-card {
  background: linear-gradient(135deg, var(--apl-bg-2), var(--apl-bg-3));
  border: 1px solid var(--apl-line-strong);
  border-radius: 18px;
  padding: 28px;
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  align-items: center;
}

.apl-car-card::before {
  content: '';
  position: absolute;
  top: -100px;
  left: -100px;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(255, 216, 77, 0.08), transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.apl-car-info { position: relative; z-index: 1; }

.apl-car-plate-display {
  display: inline-block;
  background: var(--apl-plate-yellow);
  color: var(--apl-plate-black);
  font-family: 'DM Mono', monospace;
  font-size: 16px;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: 5px;
  border: 2px solid var(--apl-plate-black);
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}

.apl-car-name {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: clamp(24px, 3.5vw, 36px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
  color: var(--apl-text);
}

.apl-car-name em {
  font-style: italic;
  color: var(--apl-accent);
  font-weight: 500;
}

.apl-car-tagline {
  font-size: 13px;
  color: var(--apl-mute);
  margin-bottom: 20px;
}

.apl-car-specs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  padding-top: 18px;
  border-top: 1px solid var(--apl-line);
}

.apl-car-spec-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.apl-car-spec-label {
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--apl-mute);
}

.apl-car-spec-value {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--apl-text);
}

.apl-car-illustration {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.apl-car-illustration svg {
  width: 100%;
  max-width: 300px;
  height: auto;
  filter: drop-shadow(0 16px 32px rgba(0, 0, 0, 0.4));
}

/* Recommendations */
.apl-recommendations-head {
  margin-bottom: 20px;
}

.apl-recommendations-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--apl-accent);
  margin-bottom: 8px;
}

.apl-recommendations-eyebrow::before {
  content: '';
  width: 18px;
  height: 1px;
  background: var(--apl-accent);
}

.apl-recommendations-title {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 0;
  color: var(--apl-text);
}

.apl-recommendations-title em {
  font-style: italic;
  color: var(--apl-accent);
  font-weight: 500;
}

.apl-recommendations-sub {
  font-size: 13px;
  color: var(--apl-mute);
  margin: 6px 0 0;
}

.apl-products-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 20px 0 24px;
}

.apl-product-card {
  background: var(--apl-bg-2);
  border: 1px solid var(--apl-line);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.4s var(--apl-ease);
  position: relative;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: block;
}

.apl-product-card:hover {
  transform: translateY(-6px);
  border-color: var(--apl-accent);
  box-shadow: 0 16px 32px -16px rgba(255, 216, 77, 0.25);
}

.apl-product-match {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--apl-success);
  color: var(--apl-bg);
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  padding: 4px 7px;
  border-radius: 100px;
  letter-spacing: 0.1em;
  z-index: 2;
}

.apl-product-image {
  width: 100%;
  aspect-ratio: 1;
  background: linear-gradient(135deg, var(--apl-bg-3), var(--apl-bg));
  border-radius: 8px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.apl-product-image::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255, 216, 77, 0.08), transparent 60%);
}

.apl-product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: relative;
  z-index: 1;
}

.apl-product-image svg {
  width: 60%;
  height: 60%;
  position: relative;
  z-index: 1;
}

.apl-product-name {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 4px;
  line-height: 1.25;
  color: var(--apl-text);
}

.apl-product-meta {
  font-size: 11px;
  color: var(--apl-mute);
  margin-bottom: 10px;
  line-height: 1.4;
  min-height: 30px;
}

.apl-product-price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--apl-line);
}

.apl-product-price {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--apl-accent);
}

.apl-product-add {
  background: var(--apl-accent);
  color: var(--apl-bg);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s var(--apl-ease);
}

.apl-product-add:hover {
  transform: scale(1.1) rotate(-15deg);
  background: #ffe478;
}

/* Bundle CTA */
.apl-bundle-cta {
  background: linear-gradient(135deg, rgba(255, 216, 77, 0.1), rgba(255, 216, 77, 0.02));
  border: 1px solid rgba(255, 216, 77, 0.3);
  border-radius: 14px;
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 16px;
}

.apl-bundle-cta-text {
  font-size: 14px;
  line-height: 1.4;
  color: var(--apl-text);
}

.apl-bundle-cta-text strong { color: var(--apl-accent); font-size: 18px; }

.apl-bundle-cta-btn {
  background: var(--apl-accent);
  color: var(--apl-bg);
  font-family: 'Heebo', sans-serif;
  font-size: 13px;
  font-weight: 700;
  padding: 12px 24px;
  border: none;
  border-radius: 100px;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: all 0.3s var(--apl-ease);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.apl-bundle-cta-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px -8px var(--apl-accent-glow);
}

.apl-arrow {
  transition: transform 0.3s var(--apl-ease);
}

.apl-bundle-cta-btn:hover .apl-arrow {
  transform: translateX(-4px);
}

.apl-reset-btn {
  display: block;
  margin: 0 auto;
  background: transparent;
  border: 1px solid var(--apl-line);
  color: var(--apl-mute);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s var(--apl-ease);
}

.apl-reset-btn:hover {
  border-color: var(--apl-mute);
  color: var(--apl-text);
}

/* Error State */
.apl-error-state {
  display: none;
  text-align: center;
  padding: 28px;
  background: rgba(255, 77, 109, 0.08);
  border: 1px solid rgba(255, 77, 109, 0.3);
  border-radius: 12px;
  margin: 16px auto;
  max-width: 460px;
}

.apl-error-state.active { display: block; }

.apl-error-state h3 {
  color: var(--apl-red);
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 20px;
  margin: 0 0 8px;
}

.apl-error-state p {
  color: var(--apl-mute);
  font-size: 14px;
  margin: 0 0 16px;
}

.apl-error-state button {
  background: transparent;
  border: 1px solid var(--apl-mute);
  color: var(--apl-text);
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Heebo', sans-serif;
  font-size: 13px;
  transition: all 0.3s var(--apl-ease);
}

.apl-error-state button:hover {
  border-color: var(--apl-accent);
  color: var(--apl-accent);
}

/* Toast */
.apl-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--apl-success);
  color: var(--apl-bg);
  padding: 12px 20px;
  border-radius: 100px;
  font-weight: 600;
  font-size: 13px;
  box-shadow: 0 16px 40px -8px rgba(0, 212, 163, 0.4);
  z-index: 100000;
  transition: transform 0.5s var(--apl-ease);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.apl-toast.show {
  transform: translateX(-50%) translateY(0);
}

/* States visibility */
.apl-state-initial { display: block; }
.apl-state-scanning,
.apl-state-result,
.apl-error-state { display: none; }

.apl-state-scanning.active,
.apl-state-result.active,
.apl-error-state.active { display: block; }

.apl-app.apl-show-scanning .apl-state-initial,
.apl-app.apl-show-scanning .apl-state-result,
.apl-app.apl-show-scanning .apl-error-state { display: none !important; }

.apl-app.apl-show-result .apl-state-initial,
.apl-app.apl-show-result .apl-state-scanning,
.apl-app.apl-show-result .apl-error-state { display: none !important; }

.apl-app.apl-show-error .apl-state-initial,
.apl-app.apl-show-error .apl-state-scanning,
.apl-app.apl-show-error .apl-state-result { display: none !important; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .apl-app {
    padding: 24px 16px;
    border-radius: 12px;
    margin: 16px;
  }

  .apl-car-card {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 20px;
  }

  .apl-car-illustration svg { max-width: 240px; }

  .apl-products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .apl-bundle-cta {
    flex-direction: column;
    text-align: center;
    gap: 16px;
    padding: 18px;
  }
}

@media (max-width: 480px) {
  .apl-plate-frame {
    padding: 12px;
    gap: 8px;
  }

  .apl-plate-input { font-size: 22px; }

  .apl-plate-submit {
    width: 44px;
    height: 44px;
  }

  .apl-trust-row {
    gap: 12px;
    font-size: 11px;
  }

  .apl-car-specs {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .apl-scanner-steps {
    flex-direction: column;
    gap: 10px;
    align-items: center;
  }

  .apl-headline { font-size: 24px; }
  .apl-subline { font-size: 14px; }
}
