:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #e0e7ff;
  --secondary: #f3f4f6;
  --danger: #ef4444;
  --success: #16a34a;
  --success-light: #dcfce7;
  --danger-light: #fee2e2;
  --bg: #f9fafb;
  --panel-bg: #ffffff;
  --text: #111827;
  --text-light: #6b7280;
  --border: #e5e7eb;
  --ring: rgba(79, 70, 229, 0.2);
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

html[dir="rtl"] body { direction: rtl; }

header {
  background-color: var(--panel-bg);
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}

header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.language-picker {
  padding: 0.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background-color: white;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
}
.language-picker:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }

main {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

.hero { text-align: center; margin-bottom: 2rem; }
.hero h2 {
  font-size: 1.875rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
}
.hero p { color: var(--text-light); font-size: 1rem; }

#search-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.75rem;
}
#q {
  flex: 1;
  padding: 0.875rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-family: inherit;
  background-color: white;
  transition: all 0.2s;
}
#q:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }

button {
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}
button:active { transform: scale(0.98); }
.primary-btn {
  background-color: var(--primary);
  color: white;
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}
.primary-btn:hover { background-color: var(--primary-hover); box-shadow: var(--shadow-md); }
.primary-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.search-hint {
  margin-top: 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-light);
  text-align: center;
}

/* Results */
#results { margin-top: 2rem; display: flex; flex-direction: column; gap: 1rem; }
#results:focus { outline: none; }
#results:focus-visible { outline: 2px solid var(--primary); outline-offset: 4px; border-radius: var(--radius-lg); }

.results-count { font-size: 0.875rem; color: var(--text-light); font-weight: 500; }

.cert-card {
  background-color: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.cert-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: #fcfcfd;
}
.cert-card-header .cert-title { font-weight: 700; font-size: 1.0625rem; }

.status-badge {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}
/* Darker text colors meet WCAG AA (>=4.5:1) against the light badge backgrounds. */
.status-badge.valid { color: #15803d; background: var(--success-light); }
.status-badge.revoked { color: #b91c1c; background: var(--danger-light); }
.status-badge.unknown { color: #374151; background: #e5e7eb; }

.cert-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.875rem 1.5rem;
  padding: 1.25rem;
}
.cert-field { display: flex; flex-direction: column; gap: 0.2rem; }
.cert-field .field-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  font-weight: 700;
}
.cert-field .field-value { font-size: 0.9375rem; font-weight: 500; word-break: break-word; }

/* Empty / error / loading states */
.state-box {
  text-align: center;
  padding: 2.5rem 1.5rem;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.state-box .state-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.state-box h3 { font-size: 1.125rem; font-weight: 700; margin-bottom: 0.375rem; }
.state-box p { color: var(--text-light); font-size: 0.9375rem; max-width: 32rem; margin: 0 auto; }
.state-box.error h3 { color: var(--danger); }

.spinner {
  width: 1.75rem; height: 1.75rem;
  border: 3px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 0.75rem;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-light);
  font-size: 0.8125rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 560px) {
  #search-form { flex-direction: column; }
  .cert-fields { grid-template-columns: 1fr; }
  .hero h2 { font-size: 1.5rem; }
}
