/* =========================================================
   NxR RDAP Frontend — NAITS .sy theme (Arabic RTL, dark emerald + gold)
   Interface in Arabic; RDAP data values render in English (LTR) via bidi.
   ========================================================= */
:root {
  --header:          #082018;
  --bg:              #0C342A;
  --surface:         #0F4536;
  --surface-2:       #0C3B2E;
  --raised:          #12503F;

  --text:            #EAF2EC;
  --text-secondary:  #B7CEC1;
  --text-muted:      #8FAFA2;

  --border:          #215243;
  --border-soft:     rgba(232,222,192,0.10);

  --gold:            #C9A24B;
  --gold-soft:       #DCC489;
  --gold-050:        rgba(201,162,75,0.14);
  --gold-line:       rgba(201,162,75,0.35);

  --shadow-sm:  0 1px 2px rgba(0,0,0,0.25);
  --shadow-md:  0 6px 20px rgba(0,0,0,0.30);
  --shadow-lg:  0 14px 40px rgba(0,0,0,0.35);

  --radius:     10px;
  --radius-lg:  12px;
  --radius-xl:  16px;

  --font-sans: 'Tajawal', system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, Menlo, monospace;

  --pattern:
    repeating-linear-gradient(45deg,  transparent 0 25px, rgba(232,222,192,0.022) 25px 26px),
    repeating-linear-gradient(-45deg, transparent 0 25px, rgba(232,222,192,0.022) 25px 26px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  direction: rtl;
  font-family: var(--font-sans);
  color: var(--text);
  background-color: var(--bg);
  background-image: var(--pattern);
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Technical / English data helper */
.mono, code, .ns-name, .entity-title { font-family: var(--font-mono); }

/* ── Header ─────────────────────────────────────────────── */
.header {
  background: var(--header);
  border-bottom: 1px solid var(--gold-line);
  padding: 0.9rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.logo-section { display: flex; align-items: center; gap: 0.9rem; }

/* Emblem placeholder (real logo can be dropped back in later) */
.logo-icon {
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gold-050);
  border: 1px solid var(--gold-line);
  border-radius: 12px;
  color: var(--gold);
  font-size: 1.35rem;
}
.footer-logo .logo-icon { font-size: 1.05rem; }
.logo-img { width: 100%; height: 100%; object-fit: contain; }
.gate-emblem {
  width: 64px; height: 64px;
  border-radius: 16px;
  background: var(--gold-050);
  border: 1px solid var(--gold-line);
  color: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.7rem;
}

.logo-text h1 {
  font-size: 1.16rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0;
  direction: ltr;        /* ".sy RDAP" is a latin brand — keep dot-first LTR order */
  text-align: right;     /* but stay right-aligned in the RTL header */
}
.logo-text h1 .accent { color: var(--gold); }

.site-subtitle { font-size: 0.8rem; color: var(--text-secondary); }

.header-links { display: flex; gap: 1.2rem; align-items: center; }

.header-link {
  color: #DCEAE1;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  opacity: 0.9;
  transition: color 0.15s, opacity 0.15s;
}
.header-link:hover { color: var(--gold-soft); opacity: 1; }
.header-link.active { color: var(--gold); }

/* ── Main content ───────────────────────────────────────── */
.main-content {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2.2rem 1.5rem 4rem;
}

/* ── Search card ────────────────────────────────────────── */
.search-section { margin-bottom: 0; }
.search-container { max-width: 760px; margin: 0 auto; }

.search-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
}
.search-card::before {
  content: "";
  position: absolute;
  inset-inline-start: 0; inset-block-start: 0;
  width: 4px; height: 100%;
  background: linear-gradient(var(--gold), transparent);
}

.search-header {
  padding: 1.5rem 2rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.search-header h3 {
  font-size: 1.18rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.search-header h3 i { color: var(--gold); }
.search-subtitle { font-size: 0.9rem; color: var(--text-secondary); }

.search-form { padding: 1.5rem 2rem; }
.form-group { margin-bottom: 1.25rem; }
.form-group:last-child { margin-bottom: 0; }

.form-group label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}
.form-group label i { color: var(--gold); font-size: 0.85rem; }

.form-select,
.form-input {
  width: 100%;
  padding: 0.72rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.98rem;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--surface-2);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input {
  font-family: var(--font-mono);
  direction: ltr;
  text-align: left;
}
.form-select:focus,
.form-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-050);
}

/* RTL select: dropdown arrow on the LEFT */
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%23C9A24B' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 0.95rem center;
  padding-left: 2.5rem;
  cursor: pointer;
}

.input-with-button { display: flex; gap: 0.5rem; }
.input-with-button .form-input { flex: 1; }

.btn-primary {
  background: var(--gold);
  color: #22160A;
  border: none;
  padding: 0.72rem 1.6rem;
  border-radius: var(--radius);
  font-size: 0.98rem;
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: filter 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn-primary:hover { filter: brightness(1.07); transform: translateY(-1px); }

.input-hint { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.5rem; }

/* ── Results section ────────────────────────────────────── */
.results-section { margin-top: 2rem; }
.results-container { max-width: 1000px; margin: 0 auto; }

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.9rem;
  border-bottom: 2px solid var(--border);
}
.results-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.results-header h3 i { color: var(--gold); }
.results-controls { display: flex; gap: 0.6rem; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius);
  font-size: 0.86rem;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: border-color 0.15s, color 0.15s;
}
.btn-ghost:hover { border-color: var(--gold-line); color: var(--gold-soft); }

.btn-small {
  background: rgba(232,222,192,0.10);
  border: 1px solid var(--gold-line);
  color: var(--gold-soft);
  padding: 0.32rem 0.8rem;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: background 0.15s;
}
.btn-small:hover { background: rgba(232,222,192,0.18); }

.results-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

/* ── Data sections ──────────────────────────────────────── */
.data-section { border-bottom: 1px solid var(--border); padding: 1.5rem; }
.data-section:last-child { border-bottom: none; }
.data-section h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gold-soft);
  letter-spacing: 0.02em;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.data-section h3 i { color: var(--gold); }
.data-section h4 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin: 0.9rem 0 0.5rem;
}

/* ── Key-Value rows (Arabic label right, English value beside it) ── */
.kv {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  align-items: start;
}
.kv:last-child { border-bottom: none; }
.kv .k {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: right;
}
.kv .v {
  font-size: 0.94rem;
  color: var(--text);
  word-break: break-word;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  justify-content: flex-start;   /* RTL: hug the right, next to the label */
  unicode-bidi: plaintext;        /* English data reads LTR, Arabic RTL */
}
.kv .v i { color: var(--gold); }
.kv .v a { color: var(--gold-soft); text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.kv .v a:hover { color: var(--gold); }
.kv.kv-highlight {
  background: var(--gold-050);
  padding: 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--gold-line);
  grid-template-columns: 1fr;
  margin-top: 0.5rem;
}
.kv.kv-highlight .k {
  font-size: 0.82rem;
  color: var(--gold-soft);
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ── Badges (RDAP data — English) ───────────────────────── */
.badge {
  display: inline-block;
  padding: 0.22rem 0.65rem;
  border-radius: 100px;
  font-size: 0.76rem;
  font-weight: 500;
  border: 1px solid;
  direction: ltr;
  unicode-bidi: isolate;
}
.badge-green,
.badge-success { background: rgba(99,214,157,0.14);  color: #7FE0B0; border-color: rgba(99,214,157,0.30); }
.badge-blue    { background: var(--gold-050);          color: var(--gold-soft); border-color: var(--gold-line); }
.badge-warning { background: rgba(230,180,92,0.15);   color: #ECC079; border-color: rgba(230,180,92,0.35); }
.badge-danger  { background: rgba(240,133,122,0.15);  color: #F3998F; border-color: rgba(240,133,122,0.35); }
.badge-gray    { background: var(--surface-2);         color: var(--text-muted); border-color: var(--border); }

/* ── Accordions ─────────────────────────────────────────── */
.accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.6rem;
  overflow: hidden;
  background: var(--surface-2);
}
.accordion summary {
  padding: 0.8rem 1rem;
  background: var(--raised);
  cursor: pointer;
  font-weight: 500;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--text);
  list-style: none;
}
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary:hover { background: #14574533; background: rgba(201,162,75,0.08); }
.accordion[open] summary { border-bottom: 1px solid var(--border); }
.acc-body { padding: 1rem; }
.ns-name, .entity-title { direction: ltr; unicode-bidi: isolate; color: var(--gold-soft); font-weight: 500; }
.ns-status, .entity-roles { display: inline-flex; gap: 0.35rem; flex-wrap: wrap; }

/* ── Notices ─────────────────────────────────────────────── */
.notice-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--gold);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}
.notice-card:last-child { margin-bottom: 0; }
.notice-card h4 { font-size: 0.88rem; font-weight: 700; color: var(--gold-soft); margin-bottom: 0.4rem; }
.notice-content { color: var(--text-secondary); }
.notice-links { margin-top: 0.5rem; }

.link-button {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.82rem;
  color: var(--gold-soft);
  text-decoration: none;
  padding: 0.28rem 0.7rem;
  background: transparent;
  border: 1px solid var(--gold-line);
  border-radius: var(--radius);
  transition: background 0.15s, color 0.15s;
}
.link-button:hover { background: var(--gold); color: #22160A; border-color: var(--gold); }

/* ── Link display ────────────────────────────────────────── */
.link-display {
  margin-top: 0.75rem;
  padding: 0.7rem 0.9rem;
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 0.9rem;
}
.link-display .link-label { font-weight: 500; color: var(--text-secondary); margin-inline-end: 0.4rem; }
.link-display a { color: var(--gold-soft); text-decoration: none; word-break: break-all; direction: ltr; unicode-bidi: isolate; display: inline-block; }
.link-display a:hover { text-decoration: underline; }

/* ── IP section ──────────────────────────────────────────── */
.ip-section {
  background: var(--surface-2);
  padding: 0.8rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-top: 0.75rem;
}
.ip-group { margin-bottom: 0.4rem; }
.ip-group:last-child { margin-bottom: 0; }
.ip-group code { direction: ltr; unicode-bidi: isolate; color: var(--text); }
.ip-label { font-weight: 500; color: var(--text-secondary); margin-inline-end: 0.4rem; font-size: 0.9rem; }

/* ── Raw JSON section ────────────────────────────────────── */
.raw-section {
  margin-top: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.raw-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1.25rem;
  background: var(--header);
  color: var(--gold-soft);
  border-bottom: 1px solid var(--gold-line);
}
.raw-header h4 { display: flex; align-items: center; gap: 0.5rem; font-size: 0.92rem; color: var(--gold-soft); }
.raw-json {
  padding: 1.25rem;
  background: #061A14;
  color: #BFE0CF;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.6;
  overflow-x: auto;
  max-height: 480px;
  margin: 0;
  direction: ltr;
  text-align: left;
}

/* ── States ──────────────────────────────────────────────── */
.loading-state { text-align: center; padding: 3rem 2rem; }
.spinner {
  border: 3px solid var(--border);
  border-top: 3px solid var(--gold);
  border-radius: 50%;
  width: 40px; height: 40px;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.loading-state p { color: var(--text-secondary); font-size: 0.92rem; }

.error-state { text-align: center; padding: 3rem 2rem; }
.error-icon { font-size: 2.5rem; color: #F3998F; margin-bottom: 1rem; }
.error-state h4 { color: var(--text); font-size: 1.15rem; margin-bottom: 0.5rem; }
.error-state p  { color: var(--text-secondary); margin-bottom: 1.5rem; }
.error-state pre { color: var(--text-secondary); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem; direction: ltr; text-align: left; }

.maintenance-state { text-align: center; padding: 3.5rem 2rem; }
.maintenance-icon { font-size: 3rem; color: var(--gold); margin-bottom: 1.25rem; opacity: 0.9; }
.maintenance-state h3 { color: var(--text); font-size: 1.4rem; margin-bottom: 0.75rem; }
.maintenance-state p  { color: var(--text-secondary); margin-bottom: 1rem; font-size: 0.96rem; }
.maintenance-state .status-code {
  display: inline-block;
  background: var(--gold-050);
  color: var(--gold-soft);
  padding: 0.4rem 1rem;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.86rem;
  border: 1px solid var(--gold-line);
  margin-top: 0.75rem;
  direction: ltr;
}

/* ── Footer ──────────────────────────────────────────────── */
.footer { background: var(--header); border-top: 1px solid var(--gold-line); padding: 1.6rem 0; }
.footer-container { max-width: 1000px; margin: 0 auto; padding: 0 1.5rem; }
.footer-content { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; gap: 1rem; }
.footer-logo { display: flex; align-items: center; gap: 0.8rem; }
.footer-logo .logo-icon { width: 38px; height: 38px; }
.footer-logo h4 { font-size: 0.92rem; font-weight: 700; color: var(--text); }
.footer-logo p  { font-size: 0.8rem; color: var(--text-secondary); }
.footer-links { display: flex; gap: 1.5rem; }
.footer-link { color: var(--text-secondary); text-decoration: none; font-size: 0.88rem; transition: color 0.15s; }
.footer-link:hover { color: var(--gold-soft); }
.footer-bottom {
  text-align: center;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
}
.footer-bottom .gold { color: var(--gold-soft); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .header-container { flex-direction: column; gap: 0.75rem; }
  .header-links { gap: 0.9rem; }
  .search-form, .search-header { padding: 1.25rem; }
  .input-with-button { flex-direction: column; }
  .kv { grid-template-columns: 1fr; gap: 0.25rem; }
  .kv .k { color: var(--text-muted); font-size: 0.82rem; }
  .kv .v { justify-content: flex-start; }
  .results-header { flex-direction: column; gap: 0.75rem; align-items: flex-start; }
  .footer-content { flex-direction: column; gap: 1rem; text-align: center; }
  .footer-links { justify-content: center; }
}

::selection { background: var(--gold-050); color: var(--gold-soft); }

/* ── mCaptcha full-page gate ──────────────────────────────────
   Covers the page until solved. The widget iframe is an external LTR
   control — its window/overlay use PHYSICAL right/left and must NOT flip. */
.mcaptcha-gate {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background-color: var(--bg); background-image: var(--pattern);
}
.mcaptcha-gate-box {
  max-width: 440px; width: 90%;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--gold);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.gate-brand { display: flex; flex-direction: column; align-items: center; gap: 0.45rem; margin-bottom: 1.4rem; padding-bottom: 1.2rem; border-bottom: 1px solid var(--border); }
.gate-brand img { width: 60px; height: 60px; object-fit: contain; }
.gate-org { font-size: 0.85rem; color: var(--text-secondary); font-weight: 500; }
.gate-svc { font-size: 1.02rem; color: var(--gold-soft); font-weight: 700; }
.mcaptcha-gate-box h2 { margin: 0 0 0.5rem; color: var(--text); font-size: 1.25rem; }
.mcaptcha-gate-sub { margin: 0 0 1.25rem; color: var(--text-secondary); font-size: 0.9rem; }
#mcaptcha-widget-holder { display: flex; justify-content: center; margin-bottom: 0.75rem; }

/* MCAPTCHA WIDGET WRAPPER — compact checkbox-only view (LTR, physical).
   The iframe keeps mCaptcha's natural 300x220; this wrapper shows only the
   65px checkbox row through an overflow window. */
.nxr-mcaptcha-wrap {
  direction: ltr;
  position: relative;
  width: 300px;
  height: 65px;
  overflow: hidden;
  border: 1px solid #d1d5db;
  border-left: 3px solid #0057B8;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  box-sizing: border-box;
  background: #f6f6f6;
}
.nxr-mcaptcha-wrap iframe { margin-top: -75px; }
.nxr-mcaptcha-wrap::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 100px; height: 100%;
  background: #f6f6f6;
  pointer-events: none;
}
.mcaptcha-gate-status { color: var(--text-muted); font-size: 0.85rem; margin: 0; }
.mcaptcha-gate-error  { color: #F3998F; font-size: 0.9rem; font-weight: 500; margin: 0; }
.btn-disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
