/* استوديو الذكاء — ai.alhajda.com (ذهب البيت، لا قشرة المراكز) */

:root {
  --bg: #050506;
  --panel: #0c0c0e;
  --panel-2: #121215;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --gold: #b39359;
  --gold-soft: rgba(179, 147, 89, 0.14);
  --text: #f3efe6;
  --muted: #8a8a92;
  --ok: #3d9a6a;
  --bad: #c45c5c;
  --font: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --display: 'Noto Naskh Arabic', serif;
}

* { box-sizing: border-box; }

body.studio-body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  line-height: 1.7;
  background:
    radial-gradient(ellipse 70% 45% at 100% 0%, rgba(179, 147, 89, 0.11), transparent 55%),
    radial-gradient(ellipse 55% 40% at 0% 90%, rgba(61, 154, 106, 0.06), transparent 50%),
    var(--bg);
}

.skip-link {
  position: absolute;
  top: -100px;
  right: 1rem;
  z-index: 10000;
  background: var(--gold);
  color: #1a140c;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus { top: 1rem; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.wrap {
  width: min(1180px, 94vw);
  margin: 0 auto;
  padding: 1.25rem 0 3.5rem;
}

.nav {
  display: flex;
  gap: 1.15rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: color 0.2s;
}
.nav a:hover { color: var(--gold); }

/* ===== الهيرو ===== */
.studio-hero { margin-bottom: 2.25rem; }

.page-kicker {
  display: block;
  margin: 0 0 0.45rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ok);
}

.studio-hero h1 {
  font-family: var(--display);
  font-size: clamp(2rem, 5vw, 2.9rem);
  color: var(--gold);
  margin: 0 0 0.55rem;
  line-height: 1.2;
}

.lead {
  color: var(--muted);
  max-width: 44rem;
  line-height: 1.8;
  margin: 0 0 1.15rem;
}

.studio-status {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  border: 1px solid rgba(61, 154, 106, 0.32);
  background: rgba(61, 154, 106, 0.08);
  font-size: 0.85rem;
}
.studio-status.is-off {
  border-color: rgba(196, 92, 92, 0.35);
  background: rgba(196, 92, 92, 0.08);
}
.studio-status .dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--ok);
  animation: studio-pulse 1.8s ease-out infinite;
}
.studio-status.is-off .dot { background: var(--bad); animation: none; }

@keyframes studio-pulse {
  0% { box-shadow: 0 0 0 0 rgba(61, 154, 106, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(61, 154, 106, 0); }
  100% { box-shadow: 0 0 0 0 rgba(61, 154, 106, 0); }
}

/* ===== مساحات العمل ===== */
.workspace-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.75rem;
}

.workspace-tab {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1.15rem 1.25rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: inherit;
  font-family: inherit;
  text-align: start;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.workspace-tab:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.workspace-tab.is-active {
  border-color: rgba(179, 147, 89, 0.55);
  background: linear-gradient(180deg, var(--gold-soft), var(--panel));
  box-shadow: 0 0 0 1px rgba(179, 147, 89, 0.15);
}
.workspace-tab__icon { font-size: 1.5rem; flex: 0 0 auto; }
.workspace-tab__body { display: flex; flex-direction: column; min-width: 0; gap: 0.15rem; }
.workspace-tab__body strong { font-family: var(--display); font-size: 1.08rem; }
.workspace-tab__body small { color: var(--muted); font-size: 0.81rem; }
.workspace-tab.is-active .workspace-tab__body strong { color: var(--gold); }

.workspace { display: none; }
.workspace.is-active { display: block; }

/* ===== بدايات جاهزة ===== */
.quick-start {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  align-items: center;
  margin-bottom: 1.15rem;
}
.quick-start__label { font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.quick-start__chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }

.quick-chip {
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px dashed var(--line-strong);
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.18s;
}
.quick-chip:hover {
  color: var(--gold);
  border-color: rgba(179, 147, 89, 0.55);
  border-style: solid;
  background: var(--gold-soft);
}

.revise-form + .revise-log { margin-top: 1rem; }
#revise-presets { margin-bottom: 0.75rem; }

/* ===== خطوات التوليد ===== */
.progress-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.4rem;
  margin: 0;
  padding: 0.9rem 1.15rem;
  list-style: none;
  counter-reset: step;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.progress-steps li {
  counter-increment: step;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.progress-steps li::before {
  content: counter(step);
  width: 1.45rem;
  height: 1.45rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  font-size: 0.72rem;
  font-weight: 700;
}
.progress-steps li.is-on { color: var(--text); }
.progress-steps li.is-on::before {
  border-color: var(--gold);
  color: var(--gold);
  animation: studio-pulse 1.6s ease-out infinite;
}
.progress-steps li.is-done::before {
  content: '✓';
  border-color: rgba(61, 154, 106, 0.6);
  color: var(--ok);
}

/* ===== تبويبات الخدمات ===== */
.service-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(212px, 1fr));
  gap: 0.85rem;
  margin-bottom: 2rem;
}

.service-tab {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1.05rem 1.15rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: inherit;
  font-family: inherit;
  text-align: start;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.service-tab:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.service-tab.is-active {
  border-color: rgba(179, 147, 89, 0.5);
  background: linear-gradient(180deg, var(--gold-soft), var(--panel));
}
.service-tab__icon { font-size: 1.35rem; flex: 0 0 auto; }
.service-tab__body { display: flex; flex-direction: column; min-width: 0; }
.service-tab__body strong { font-size: 0.98rem; }
.service-tab__body small { color: var(--muted); font-size: 0.79rem; }
.service-tab.is-active .service-tab__body strong { color: var(--gold); }

/* ===== اللوحات ===== */
.panel { display: none; }
.panel.is-active { display: block; }

.brief-form {
  display: grid;
  gap: 1.15rem;
}

.form-section {
  padding: 1.5rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.form-section h2 {
  font-family: var(--display);
  font-size: 1.16rem;
  margin: 0 0 0.35rem;
  color: var(--gold);
}
.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 1.15rem;
  max-width: 46rem;
}
.form-section h2 + .field-grid,
.form-section h2 + .field { margin-top: 1.1rem; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 0.9rem;
}

.field { display: block; }
.field + .field,
.field-grid + .field { margin-top: 0.9rem; }
.field > span {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.field > span b { color: var(--gold); }

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.72rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.94rem;
  transition: border-color 0.2s;
}
.field textarea { resize: vertical; min-height: 4.5rem; line-height: 1.65; }
.field input::placeholder,
.field textarea::placeholder { color: rgba(138, 138, 146, 0.65); }
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: rgba(179, 147, 89, 0.55); outline: none; }
.field input:user-invalid { border-color: rgba(196, 92, 92, 0.6); }

/* ===== شرائح الاختيار ===== */
.chip-set {
  border: 0;
  padding: 0;
  margin: 0 0 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.chip-set:last-child { margin-bottom: 0; }
.chip-set legend {
  float: inline-start;
  width: 100%;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.5rem;
  padding: 0;
}

.chip { position: relative; display: inline-flex; }
.chip input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.chip span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  transition: 0.18s;
}
.chip input:checked + span {
  border-color: rgba(179, 147, 89, 0.6);
  background: var(--gold-soft);
  color: var(--text);
}
.chip input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }

.chip .swatch {
  width: 0.78rem;
  height: 0.78rem;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
}

/* ===== الأزرار ===== */
.form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.form-note { color: var(--muted); font-size: 0.83rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.78rem 1.6rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.18s, filter 0.18s, opacity 0.18s;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.08); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-primary { background: var(--gold); color: #1a140c; }
.btn-ghost { border-color: var(--line-strong); background: transparent; color: var(--text); }

/* ===== النتيجة والمعاينة ===== */
.result { margin-top: 1.6rem; }

.result-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.device-toggle {
  display: inline-flex;
  gap: 0.3rem;
  padding: 0.28rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.device-toggle button {
  padding: 0.42rem 0.85rem;
  border-radius: 9px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.18s;
}
.device-toggle button.is-active { background: var(--gold-soft); color: var(--text); }

.result-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.result-actions .btn { padding: 0.6rem 1.15rem; font-size: 0.87rem; }

.preview-shell {
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #16161a;
  padding: 0.75rem;
  display: flex;
  justify-content: center;
  transition: padding 0.25s;
}
.preview-shell iframe {
  width: 100%;
  max-width: 100%;
  height: min(70vh, 780px);
  border: 0;
  border-radius: 10px;
  background: #fff;
  transition: max-width 0.28s ease, opacity 0.2s ease;
}
.preview-shell iframe.is-loading { opacity: 0.35; }
.preview-shell[data-device="tablet"] iframe { max-width: 820px; }
.preview-shell[data-device="mobile"] iframe { max-width: 400px; }

/* ===== التنقيح ===== */
.tune {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.15rem;
  margin-top: 1.15rem;
}
.tune-block {
  padding: 1.5rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.tune-block h3 {
  font-family: var(--display);
  font-size: 1.05rem;
  margin: 0 0 0.35rem;
  color: var(--gold);
}

.revise-form { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.revise-form input {
  flex: 1 1 12rem;
  padding: 0.72rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
}
.revise-form input:focus { border-color: rgba(179, 147, 89, 0.55); outline: none; }

.revise-log {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
  max-height: 11rem;
  overflow-y: auto;
}
.revise-log li {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0.5rem 0.75rem;
  border-radius: 9px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}
.revise-log li.is-bad { border-color: rgba(196, 92, 92, 0.35); color: #e2a3a3; }

/* ===== مخرجات الخدمات الأخرى ===== */
.output { margin-top: 1.3rem; display: grid; gap: 1rem; }

.out-card {
  padding: 1.4rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.out-card h3 {
  font-family: var(--display);
  font-size: 1rem;
  color: var(--gold);
  margin: 0 0 0.75rem;
}
.out-card ul { margin: 0; padding-inline-start: 1.15rem; display: grid; gap: 0.5rem; }
.out-card li { font-size: 0.93rem; }
.out-card p { margin: 0; font-size: 0.95rem; line-height: 1.8; }
.out-card .kv { color: var(--muted); font-size: 0.85rem; }

.copy-line {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  justify-content: space-between;
}
.copy-line button {
  flex: 0 0 auto;
  padding: 0.3rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.76rem;
  cursor: pointer;
}
.copy-line button:hover { color: var(--gold); border-color: rgba(179, 147, 89, 0.45); }

.alert {
  padding: 0.85rem 1.1rem;
  border-radius: 12px;
  font-size: 0.9rem;
  border: 1px solid rgba(196, 92, 92, 0.35);
  background: rgba(196, 92, 92, 0.08);
  color: #e9b6b6;
}
.alert.is-info {
  border-color: rgba(179, 147, 89, 0.35);
  background: var(--gold-soft);
  color: var(--text);
}

.skeleton {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(100deg, var(--panel) 30%, var(--panel-2) 50%, var(--panel) 70%);
  background-size: 220% 100%;
  animation: studio-shimmer 1.3s linear infinite;
  height: 9rem;
}
@keyframes studio-shimmer {
  to { background-position: -220% 0; }
}

.studio-foot {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
}
.studio-foot a { color: var(--gold); }

@media (max-width: 720px) {
  .result-bar { flex-direction: column; align-items: stretch; }
  .device-toggle { justify-content: center; }
  .result-actions .btn { flex: 1 1 auto; }
  .preview-shell { padding: 0.4rem; }
  .preview-shell iframe { height: 60vh; }
}

@media (prefers-reduced-motion: reduce) {
  .service-tab, .btn, .preview-shell iframe { transition: none; }
  .btn:hover:not(:disabled), .service-tab:hover { transform: none; }
  .studio-status .dot, .skeleton { animation: none; }
}
