/* ─────────────────────────────────────────────────────────────
   Trademark Search — Frontend Stylesheet
   تصميم: RTL/LTR, glass dark theme, شفافية, gradient accents
───────────────────────────────────────────────────────────── */

:root {
  --bg-1: #0b1020;
  --bg-2: #131a33;
  --bg-3: #1c2547;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-strong: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);

  --text: #e7ecff;
  --text-dim: #9aa5d4;
  --text-muted: #6b75a3;

  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-3: #06b6d4;

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  --risk-high: #ef4444;
  --risk-mid: #f59e0b;
  --risk-low: #10b981;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;

  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --shadow-strong: 0 18px 40px rgba(0, 0, 0, 0.45);

  --font-ui: "Inter", "Cairo", "Segoe UI", Tahoma, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-ui);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(99, 102, 241, 0.20), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(6, 182, 212, 0.15), transparent 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Top Nav ─────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(11, 16, 32, 0.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.2px;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  font-size: 18px;
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}
.brand-sub {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
  margin-top: 2px;
}
.brand-block { display: flex; flex-direction: column; }

.api-badge {
  margin-inline-start: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.api-badge .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 12px var(--success);
}
.api-badge.offline .dot { background: var(--danger); box-shadow: 0 0 12px var(--danger); }

/* ── Layout ──────────────────────────────────────────── */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

/* ── Tabs ────────────────────────────────────────────── */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--surface);
  padding: 6px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 24px;
}
.tab {
  flex: 1 1 auto;
  min-width: 130px;
  padding: 10px 14px;
  background: transparent;
  color: var(--text-dim);
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: center;
}
.tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.3);
}

.tab-panels { position: relative; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Section / Cards ─────────────────────────────────── */
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  font-size: 20px;
  font-weight: 700;
}
.section-title .pill {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 999px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}
.card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-method {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 3px 8px;
  border-radius: 6px;
}
.method-post { color: #10b981; background: rgba(16, 185, 129, 0.12); }
.method-get { color: #3b82f6; background: rgba(59, 130, 246, 0.12); }
.method-delete { color: #ef4444; background: rgba(239, 68, 68, 0.12); }
.card-path {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}
.card-desc {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.55;
}

/* ── Form / Inputs ───────────────────────────────────── */
.form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 14px; }
.form .full { grid-column: 1 / -1; }
@media (max-width: 720px) { .form { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}
.field label .req { color: var(--danger); }
.field .hint { font-size: 11px; color: var(--text-muted); }

.input, .select, .textarea, .file-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  transition: all 0.15s ease;
}
.input:focus, .select:focus, .textarea:focus, .file-input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.textarea { min-height: 76px; resize: vertical; font-family: var(--font-mono); font-size: 13px; }
.input[type="number"] { font-family: var(--font-mono); }

/* checkbox */
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
.check input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* file input */
.file-input { padding: 8px 12px; cursor: pointer; }
.file-input::-webkit-file-upload-button {
  background: var(--surface-strong);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  margin-inline-end: 10px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}

/* معاينة الصورة المرفوعة (file input من نوع صورة) — جديد */
.file-preview { margin-top: 6px; }
.file-preview-img {
  display: block;
  max-width: 160px;
  max-height: 160px;
  width: auto;
  height: auto;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
}

/* buttons */
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.3);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(99, 102, 241, 0.4); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.secondary {
  background: var(--surface-strong);
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: none;
}
.btn.secondary:hover { background: rgba(255,255,255,0.10); }
.btn.danger {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  box-shadow: 0 6px 18px rgba(220, 38, 38, 0.3);
}
.btn.danger:hover { box-shadow: 0 10px 24px rgba(220, 38, 38, 0.4); }
.btn.ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  box-shadow: none;
}
.btn.small { padding: 6px 12px; font-size: 12px; }

/* ── Response Area ──────────────────────────────────── */
.response-block {
  margin-top: 14px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  overflow: hidden;
}
.response-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  flex-wrap: wrap;
}
.status-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}
.status-pill.ok { color: #10b981; background: rgba(16, 185, 129, 0.12); }
.status-pill.err { color: #ef4444; background: rgba(239, 68, 68, 0.12); }
.status-pill.loading { color: #f59e0b; background: rgba(245, 158, 11, 0.12); }
.elapsed { margin-inline-start: auto; font-family: var(--font-mono); color: var(--text-muted); }

.response-body {
  padding: 12px;
  max-height: 600px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}
.response-body.empty {
  color: var(--text-muted);
  text-align: center;
  padding: 28px 12px;
  font-family: var(--font-ui);
  font-size: 13px;
}

/* hide-raw: للـ endpoints اللي عايزين نخفي JSON الخام ونعرض cards/progress فقط */
.response-block.hide-raw .response-head,
.response-block.hide-raw .response-body {
  display: none;
}
.response-block.hide-raw {
  background: transparent;
  border: none;
}
.response-block.hide-raw .sse-log {
  margin-top: 14px;
}
.response-block.hide-raw .results-cards:empty {
  display: none;
}

/* mini loading indicator للـ hide-raw */
.mini-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.20);
  border-radius: var(--radius-sm);
  margin-top: 14px;
  color: var(--text-dim);
  font-size: 13px;
}
.mini-error {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-sm);
  margin-top: 14px;
  color: #fca5a5;
  font-size: 13px;
}
.mini-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 14px;
  color: var(--text-dim);
  font-size: 13px;
}

/* JSON syntax highlight */
.json-key { color: #93c5fd; }
.json-string { color: #86efac; }
.json-number { color: #fbbf24; }
.json-bool { color: #f472b6; }
.json-null { color: #94a3b8; }

/* ── Results Visual ──────────────────────────────────── */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.result-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.result-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
}
.result-img {
  width: 100%;
  aspect-ratio: 1.3 / 1;
  object-fit: contain;
  background:
    repeating-conic-gradient(rgba(255,255,255,0.025) 0 25%, transparent 0 50%) 0/16px 16px,
    rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border);
}
.result-img.placeholder {
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 32px;
}
.result-body { padding: 10px 12px; }
.result-brand {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  word-break: break-word;
}
.result-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  word-break: break-all;
}
.result-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  gap: 6px;
  flex-wrap: wrap;
}
.score {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.score-bar {
  position: relative;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}
.score-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-3));
  border-radius: 999px;
}

.risk-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.risk-high { color: var(--risk-high); background: rgba(239, 68, 68, 0.12); }
.risk-mid { color: var(--risk-mid); background: rgba(245, 158, 11, 0.12); }
.risk-low { color: var(--risk-low); background: rgba(16, 185, 129, 0.12); }

/* SSE Progress */
.sse-log {
  margin-top: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  max-height: 220px;
  overflow: auto;
}
.sse-line {
  padding: 3px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.04);
}
.sse-line:last-child { border-bottom: none; }
.sse-line.err { color: var(--danger); }
.sse-line.ok { color: var(--success); }
.sse-line.inf { color: var(--info); }

/* loader */
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast-stack {
  position: fixed;
  top: 80px;
  inset-inline-end: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  background: var(--surface-strong);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-strong);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-size: 13px;
  pointer-events: auto;
  animation: toastIn 0.25s ease;
}
.toast.ok { border-color: rgba(16, 185, 129, 0.4); }
.toast.err { border-color: rgba(239, 68, 68, 0.4); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* mini info icon */
.info-i {
  display: inline-grid;
  place-items: center;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1px solid var(--text-muted);
  color: var(--text-muted);
  font-size: 9px;
  font-style: italic;
  font-weight: 700;
  cursor: help;
}

/* scrollbar */
.response-body::-webkit-scrollbar,
.sse-log::-webkit-scrollbar { width: 8px; height: 8px; }
.response-body::-webkit-scrollbar-thumb,
.sse-log::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.10);
  border-radius: 999px;
}
.response-body::-webkit-scrollbar-thumb:hover,
.sse-log::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.18); }

/* dir helper */
[dir="rtl"] .api-badge { margin-inline-start: auto; margin-inline-end: 0; }
