/* ── Reset & tokens ─────────────────────────────────────────── */

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

:root {
  --kcc-orange:         #FF7E00;
  --kcc-orange-dark:    #e06e00;
  --kcc-orange-light:   #ff9a33;
  --kcc-orange-bg:      #fff7ed;
  --kcc-orange-border:  #fed7aa;
  --kcc-green:          #16a34a;
  --kcc-green-bg:       #f0fdf4;
  --kcc-green-border:   #bbf7d0;
  --kcc-red:            #dc2626;
  --kcc-red-bg:         #fef2f2;
  --kcc-red-border:     #fecaca;
  --kcc-text:           #111827;
  --kcc-text-muted:     #6b7280;
  --kcc-border:         #e5e7eb;
  --kcc-radius:         14px;
  --kcc-radius-sm:      8px;
  --kcc-shadow:         0 4px 32px rgba(255, 126, 0, 0.13);
  --font:               'Inter', system-ui, -apple-system, sans-serif;
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font);
  background: linear-gradient(145deg, #fff3e0 0%, #fff7ed 50%, #fef3c7 100%);
  background-attachment: fixed;
  color: var(--kcc-text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Page layout ────────────────────────────────────────────── */

.page-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  gap: 1rem;
}

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

.site-header {
  padding: 0.875rem 1.5rem;
  background: #fff;
  border-bottom: 2px solid var(--kcc-orange);
  box-shadow: 0 2px 8px rgba(255, 126, 0, 0.08);
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-logo {
  height: 40px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}

/* shown when logo image fails to load */
.brand-logo-fallback {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--kcc-orange);
  color: #fff;
  font-weight: 700;
  font-size: 1.2rem;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.brand-name {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--kcc-orange);
  letter-spacing: -0.01em;
}

.brand-tagline {
  font-size: 0.75rem;
  color: var(--kcc-text-muted);
  font-weight: 400;
}

/* ── Page title bar ─────────────────────────────────────────── */

.page-title-bar {
  background: var(--kcc-orange);
  padding: 0.75rem 1.5rem;
  text-align: center;
}

.page-title {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.01em;
}

.page-title-sub {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 400;
  margin-top: 0.125rem;
}

/* ── Search card ────────────────────────────────────────────── */

.search-card {
  background: #ffffff;
  border-radius: var(--kcc-radius);
  box-shadow: var(--kcc-shadow);
  padding: 2rem 2rem 1.75rem;
  width: 100%;
  max-width: 540px;
  border-top: 3px solid var(--kcc-orange);
}

.card-header {
  margin-bottom: 1.5rem;
  text-align: center;
}

.search-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--kcc-text);
  letter-spacing: -0.02em;
  margin-bottom: 0.375rem;
}

.search-subtitle {
  font-size: 0.875rem;
  color: var(--kcc-text-muted);
}

/* ── Input group ────────────────────────────────────────────── */

.input-group {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.serial-input {
  flex: 1;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: var(--font);
  border: 1.5px solid var(--kcc-border);
  border-radius: var(--kcc-radius-sm);
  outline: none;
  color: var(--kcc-text);
  background: #fafafa;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  min-width: 0;
}

.serial-input::placeholder {
  color: #c4c9d4;
}

.serial-input:focus {
  border-color: var(--kcc-orange-light);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 126, 0, 0.15);
}

.search-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 1.25rem;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: var(--font);
  color: #fff;
  background: var(--kcc-orange);
  border: none;
  border-radius: var(--kcc-radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}

.search-btn:hover {
  background: var(--kcc-orange-dark);
}

.search-btn:active {
  transform: scale(0.97);
}

.btn-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

/* ── HTMX spinner ───────────────────────────────────────────── */

.spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.htmx-request .spinner {
  display: inline-block;
}

.htmx-request #search-icon {
  display: none;
}

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

/* ── Result area ────────────────────────────────────────────── */

.result-area {
  margin-top: 1.25rem;
}

/* ── Found result ───────────────────────────────────────────── */

.result-found {
  border: 1.5px solid var(--kcc-green-border);
  border-left: 4px solid var(--kcc-green);
  border-radius: var(--kcc-radius-sm);
  background: var(--kcc-green-bg);
  padding: 1.125rem 1.25rem;
  animation: fadeSlideIn 0.2s ease;
}

/* ── Not found result ───────────────────────────────────────── */

.result-not-found {
  border: 1.5px solid var(--kcc-red-border);
  border-left: 4px solid var(--kcc-red);
  border-radius: var(--kcc-radius-sm);
  background: var(--kcc-red-bg);
  padding: 1.125rem 1.25rem;
  animation: fadeSlideIn 0.2s ease;
}

/* ── Error (rate limit / server error) ──────────────────────── */

.result-error {
  border: 1.5px solid var(--kcc-orange-border);
  border-left: 4px solid var(--kcc-orange);
  border-radius: var(--kcc-radius-sm);
  background: var(--kcc-orange-bg);
  padding: 1.125rem 1.25rem;
  animation: fadeSlideIn 0.2s ease;
  color: #9a3412;
  font-size: 0.9rem;
}

/* ── Badge ──────────────────────────────────────────────────── */

.result-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.875rem;
}

.found-badge {
  color: var(--kcc-green);
}

.not-found-badge {
  color: var(--kcc-red);
}

.badge-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ── Result table ───────────────────────────────────────────── */

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.result-table tbody tr {
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.result-table tbody tr:last-child {
  border-bottom: none;
}

.result-table th {
  text-align: left;
  font-weight: 500;
  color: var(--kcc-text-muted);
  padding: 0.45rem 0.75rem 0.45rem 0;
  width: 42%;
  vertical-align: top;
}

.result-table td {
  padding: 0.45rem 0;
  color: var(--kcc-text);
  vertical-align: top;
}

.serial-value {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.875rem;
  letter-spacing: 0.02em;
  word-break: break-all;
}

.warranty-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.875rem;
}

.status-active {
  color: var(--kcc-green);
}

.status-expired {
  color: var(--kcc-red);
}

.status-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.no-data {
  color: var(--kcc-text-muted);
}

/* ── Notes ──────────────────────────────────────────────────── */

.result-note {
  margin-top: 0.875rem;
  font-size: 0.8125rem;
  color: var(--kcc-text-muted);
}

.not-found-msg {
  font-size: 0.9rem;
  color: var(--kcc-text);
  margin-bottom: 0.5rem;
}

.serial-query {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.875rem;
  color: var(--kcc-red);
}

.not-found-hint {
  font-size: 0.8125rem;
  color: var(--kcc-text-muted);
}

/* ── Help text ──────────────────────────────────────────────── */

.help-text {
  font-size: 0.8125rem;
  color: rgba(180, 90, 0, 0.7);
  text-align: center;
}

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

.site-footer {
  padding: 1.25rem 1.5rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--kcc-text-muted);
  border-top: 1px solid var(--kcc-border);
  background: #fff;
}

.site-footer a {
  color: var(--kcc-orange);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

/* ── Animation ──────────────────────────────────────────────── */

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

/* ── Responsive ─────────────────────────────────────────────── */

@media (max-width: 480px) {
  .search-card {
    padding: 1.5rem 1.25rem 1.25rem;
    border-radius: var(--kcc-radius-sm);
  }

  .search-title {
    font-size: 1.25rem;
  }

  .input-group {
    flex-direction: column;
  }

  .search-btn {
    justify-content: center;
    padding: 0.75rem;
  }

  .result-table th {
    width: 38%;
  }

  .page-title {
    font-size: 0.9rem;
  }

  .page-title-sub {
    font-size: 0.7rem;
  }
}
