/* ==========================================================================
   result.css — خاص بصفحة التقرير التفصيلي، الرسوم البيانية، المساعد الذكي، والطباعة PDF
   ========================================================================== */

[hidden] { display: none !important; }

[data-group="analysts"]  { --group-color: var(--lav); }
[data-group="diplomats"] { --group-color: var(--green); }
[data-group="sentinels"] { --group-color: var(--blue); }
[data-group="explorers"] { --group-color: var(--pink); }

.result-mt { margin-block-start: var(--gap); }
.result-mt-sm { margin-block-start: 10px; }

/* ---------- حالات التحميل والفراغ ---------- */
.result-state {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 14px;
  padding: clamp(32px, 5vw, 64px);
}

.result-state__title { font-size: clamp(1.5rem, 3vw, 2.2rem); }
.result-state__actions { display: flex; flex-wrap: wrap; gap: 12px; margin-block-start: 8px; }

.result-state__spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--track);
  border-inline-end-color: var(--pink);
  animation: tessera-spin 0.8s linear infinite;
}

/* ---------- شريط الأدوات العلوي ---------- */
.result-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-block-end: 20px;
}

.result-bar__meta,
.result-bar__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.result-bar__time { font-size: 0.84rem; font-weight: 600; padding-inline: 4px; }
.result-action-btn { padding: 10px 18px; font-size: 0.86rem; }

/* ---------- هيرو النتيجة ---------- */
.result-hero {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gap);
  align-items: stretch;
}

.result-hero__main {
  grid-column: span 7;
  padding: clamp(24px, 3.4vw, 42px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.result-hero__top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.group-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  border-radius: var(--r-pill);
  background: var(--group-color, var(--pink));
  color: var(--on-color);
  font-size: 0.82rem;
  font-weight: 700;
}

.result-hero__title { font-size: clamp(1.9rem, 4vw, 3rem); line-height: 1.15; }
.result-hero__tagline { font-size: 1.08rem; font-weight: 700; }
.result-hero__overview { font-size: 0.96rem; color: var(--muted); line-height: 1.75; }

.result-hero__actions {
  margin-block-start: auto;
  padding-block-start: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.result-hero__side {
  --d: 100ms;
  grid-column: span 5;
  padding: clamp(24px, 3vw, 36px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.result-side__eyebrow { font-size: 0.8rem; font-weight: 600; color: var(--on-dark-muted); }

/* الأحرف الأربعة */
.type-letters { direction: ltr; display: flex; gap: 10px; }
.type-letter {
  flex: 1;
  aspect-ratio: 1;
  max-width: 78px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  font-family: var(--font-latin);
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 800;
  color: var(--on-color);
}
.type-letter:nth-child(1) { background: var(--pink); }
.type-letter:nth-child(2) { background: var(--blue); }
.type-letter:nth-child(3) { background: var(--lav); }
.type-letter:nth-child(4) { background: var(--green); }

/* حلقة المؤشر */
.res-ring-row {
  display: flex;
  align-items: center;
  gap: 20px;
}

.res-ring { position: relative; width: 120px; aspect-ratio: 1; flex: none; }
.res-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.res-ring circle { fill: none; stroke-width: 9; stroke-linecap: round; }
.res-ring__track { stroke: rgba(255, 255, 255, 0.12); }
.res-ring__fill {
  stroke: var(--pink);
  stroke-dasharray: var(--v, 0) 100;
  transition: stroke-dasharray 1.2s var(--ease-ios);
}
.res-ring__label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.res-ring__label b { font-size: 1.45rem; line-height: 1.1; }
.res-ring__label small { font-size: 0.72rem; color: var(--on-dark-muted); }

.res-quick-stats { flex: 1; display: grid; gap: 10px; min-width: 0; }
.res-stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  padding-block-end: 8px;
  border-block-end: 1px solid rgba(255, 255, 255, 0.1);
}
.res-stat-item:last-child { border-block-end: 0; padding-block-end: 0; }
.res-stat-item span { color: var(--on-dark-muted); }

.res-stack-wrap { display: grid; gap: 10px; margin-block-start: auto; }
.res-stack { direction: ltr; display: flex; flex-wrap: wrap; gap: 8px; }
.res-stack .chip:first-child { background: var(--pink); color: var(--on-color); }

/* ---------- شبكة الأبعاد الأربعة ---------- */
.dims-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
}

.dim-card { display: grid; gap: 12px; }
.dim-card__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.dim-card__poles {
  direction: ltr;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  font-weight: 700;
}

.dim-card__pole { display: inline-flex; align-items: center; gap: 6px; opacity: 0.52; }
.dim-card__pole.is-win { opacity: 1; }
.dim-card__pole b { font-family: var(--font-latin); font-size: 1.1rem; }

.dim-bar {
  direction: ltr;
  display: flex;
  height: 14px;
  border-radius: var(--r-pill);
  background: var(--track);
  overflow: hidden;
  padding: 2px;
}

.dim-bar__fill {
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--dim-c, var(--pink));
  transition: width 1s var(--spring-smooth);
}

.dim-bar--right { justify-content: flex-end; }
.dim-card__note { font-size: 0.85rem; color: var(--muted); }

/* ---------- الوظائف المعرفية والمنحنى ---------- */
.fn-layout {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: var(--gap);
  align-items: stretch;
}

.curve-card { display: flex; flex-direction: column; }
.curve-card__head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.curve-card__head .card__title { margin: 0; }
.tag-dark {
  display: inline-block;
  background: #111;
  color: #fff;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  font-size: 0.75rem;
  font-weight: 600;
}

.curve { direction: ltr; margin-block: auto; padding-block-start: 10px; }
.curve svg { width: 100%; height: auto; overflow: visible; }
.curve__grid { stroke: rgba(0, 0, 0, 0.14); stroke-width: 1; }
.curve__line {
  fill: none;
  stroke: #111;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 1.8s var(--ease-ios);
}
.is-in .curve__line { stroke-dashoffset: 0; }
.curve__peak { fill: #111; }
.curve__labels {
  direction: ltr;
  display: flex;
  justify-content: space-between;
  font-family: var(--font-latin);
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(17, 17, 17, 0.72);
  margin-block-start: 8px;
}

.fn-bars { display: grid; gap: 12px; margin-block-start: 10px; }
.fn-bar-row {
  display: grid;
  grid-template-columns: 138px 1fr 44px;
  align-items: center;
  gap: 10px;
}
.fn-bar-row__name { display: flex; align-items: center; gap: 8px; font-size: 0.84rem; }
.fn-bar-row__name b { font-family: var(--font-latin); font-size: 0.94rem; min-width: 24px; }
.fn-bar-row__name span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fn-bar-row__track { height: 10px; border-radius: var(--r-pill); background: var(--track); overflow: hidden; }
.fn-bar-row__fill {
  height: 100%;
  border-radius: inherit;
  background: var(--ink);
  transition: width 1s var(--spring-smooth);
}
.fn-bar-row:first-child .fn-bar-row__fill { background: var(--pink); }
.fn-bar-row__val { font-size: 0.84rem; font-weight: 700; text-align: end; }

/* ---------- بطاقات الضغط وBig Five ---------- */
.stress-res-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
}

.stress-advice { margin-block-start: var(--gap); display: grid; gap: 8px; }

.big5-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
}

.trait-meter-card { display: grid; gap: 10px; }
.trait-meter-card__top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.trait-meter-card__val { font-size: 1.4rem; font-weight: 800; }

/* ---------- التفصيل السلوكي للنمط ---------- */
.dual-grid,
.stress-grid,
.growth-grid {
  display: grid;
  gap: var(--gap);
}
.dual-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stress-grid,
.growth-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.dual-grid__title { font-size: 1.25rem; margin-block-end: 14px; }
.trait-list { display: grid; gap: 12px; }
.trait-list li {
  display: grid;
  gap: 3px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.42);
}
.trait-list b { font-size: 0.95rem; }
.trait-list span { font-size: 0.86rem; color: rgba(17, 17, 17, 0.78); line-height: 1.55; }

.bullet-list { display: grid; gap: 10px; margin-block-start: 6px; }
.bullet-list li { display: flex; align-items: flex-start; gap: 10px; font-size: 0.9rem; color: var(--on-dark-muted); }
.bullet-list li::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  margin-block-start: 0.55em;
  border-radius: 50%;
  background: var(--pink);
}

.res-recovery { font-size: 0.9rem; font-weight: 700; }
.sub-label { font-size: 0.92rem; margin-block-end: 6px; }
.career-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-block-start: 8px; }

.growth-step__num {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: var(--dark);
  color: var(--on-dark);
  margin-block-end: 12px;
}

/* ---------- المساعد الذكي ---------- */
.ai-card {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  display: grid;
  gap: 18px;
  padding: clamp(24px, 3.6vw, 42px);
}

.ai-card::before {
  content: "";
  position: absolute;
  z-index: -1;
  width: 300px;
  height: 300px;
  inset-block-start: -130px;
  inset-inline-end: -80px;
  border-radius: 50%;
  background: var(--pink);
  filter: blur(75px);
  opacity: 0.25;
}

.ai-card__head { display: grid; gap: 8px; }
.ai-card__head .chip { width: fit-content; }
.ai-card__title { font-size: clamp(1.35rem, 2.8vw, 1.95rem); }

.ai-prompts { display: flex; flex-wrap: wrap; gap: 8px; }

.ai-prompt {
  padding: 8px 16px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.1);
  color: var(--on-dark);
  font-size: 0.84rem;
  font-weight: 600;
  transition: background var(--t-fast), scale var(--dur-slow) var(--spring-bouncy);
}
.ai-prompt:hover { background: rgba(228, 184, 230, 0.25); }
.ai-prompt:active { scale: 0.95; }

.ai-messages {
  display: grid;
  gap: 12px;
  max-height: 360px;
  overflow-y: auto;
}
.ai-messages:empty { display: none; }

.ai-msg {
  padding: 14px 18px;
  border-radius: var(--r-md);
  font-size: 0.94rem;
  line-height: 1.65;
  max-width: 68ch;
  white-space: pre-wrap;
}
.ai-msg--user {
  justify-self: start;
  background: var(--pink);
  color: var(--on-color);
  font-weight: 600;
}
.ai-msg--bot {
  justify-self: end;
  background: rgba(255, 255, 255, 0.08);
  color: var(--on-dark);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.ai-msg--err {
  background: color-mix(in srgb, var(--err) 20%, transparent);
  border: 1px solid var(--err);
  color: var(--on-dark);
}

.ai-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.ai-input {
  flex: 1;
  min-width: 0;
  min-height: 52px;
  padding: 12px 18px;
  border-radius: var(--r-pill);
  border: 1.5px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: var(--on-dark);
  outline: none;
  font-size: 0.95rem;
}
.ai-input:focus { border-color: var(--pink); }
.ai-input::placeholder { color: var(--on-dark-muted); }

/* ---------- الاستجابة ---------- */
@media (max-width: 1000px) {
  .result-hero__main,
  .result-hero__side { grid-column: 1 / -1; }
  .fn-layout,
  .dims-grid,
  .dual-grid,
  .stress-grid,
  .growth-grid,
  .stress-res-grid,
  .big5-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .res-ring-row { flex-direction: column; align-items: flex-start; }
  .fn-bar-row { grid-template-columns: 112px 1fr 40px; }
  .ai-form { flex-direction: column; align-items: stretch; }
  .result-action-btn { flex: 1; }
}

/* ---------- تنسيق الطباعة وتصدير PDF ---------- */
@media print {
  body { background: #fff !important; color: #111 !important; }
  .app-frame { width: 100%; margin: 0; padding: 0; background: #fff; border-radius: 0; }
  [data-shell="header"],
  [data-shell="footer"],
  .topbar,
  .footer,
  .result-bar__actions,
  .result-hero__actions,
  #aiSection,
  .skip-link { display: none !important; }
  .card { break-inside: avoid; border: 1px solid #ddd; box-shadow: none !important; }
  .card--dark { background: #18181b !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .card--pink, .card--blue, .card--lav, .type-letter, .dim-bar__fill {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .reveal { opacity: 1 !important; transform: none !important; }
}