/* ==========================================================
   ESG AI prompty — self-contained styles (eap- prefix).
   Inherits theme design tokens where present; every var()
   carries a literal fallback so the tool renders correctly
   in any theme.
   ========================================================== */

/* Let the tool use full width inside the narrow .legal-content
   wrapper of the generic page template (progressive: without
   :has() support the layout simply collapses to one column). */
.legal-content:has(.eap-app) { max-width: 1200px; }

.eap-app { font-size: 1rem; line-height: 1.6; }

/* ── Intro: stats, steps, info box ─────────────────────── */
.eap-statsbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 2.5rem;
  background: var(--teal, #4A7366);
  color: #fff;
  border-radius: 12px;
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
}
.eap-statsbar span { font-size: 0.9rem; opacity: 0.92; }
.eap-statsbar strong { font-size: 1.25rem; margin-right: 0.35rem; }

.eap-steps { display: grid; gap: 1rem; margin-bottom: 1.5rem; }
.eap-step {
  display: flex;
  gap: 1rem;
  background: var(--light, #FFFFFF);
  border: 1px solid var(--border, #E5E7EB);
  border-radius: 12px;
  padding: 1.1rem 1.3rem;
}
.eap-step-num {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--orange, #E16839);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.eap-step h4 { margin: 0 0 0.3rem; font-size: 1rem; color: var(--dark, #1A1A1A); }
.eap-step p { margin: 0; font-size: 0.92rem; color: var(--gray, #6B7280); }

.eap-infobox {
  background: rgba(74, 115, 102, 0.08);
  border-left: 4px solid var(--teal, #4A7366);
  border-radius: 0 10px 10px 0;
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
}
.eap-infobox p { margin: 0; font-size: 0.92rem; color: var(--dark, #1A1A1A); }

/* ── Settings (year) ───────────────────────────────────── */
.eap-settings {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  background: var(--light, #FFFFFF);
  border: 1px solid var(--border, #E5E7EB);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
}
.eap-settings label { font-weight: 600; font-size: 0.95rem; color: var(--dark, #1A1A1A); }
.eap-settings input.eap-year {
  width: 90px;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border, #E5E7EB);
  border-radius: 8px;
  font: inherit;
  font-size: 0.95rem;
}
.eap-years-note { color: var(--gray, #6B7280); font-size: 0.88rem; }

/* ── Layout: TOC + list ────────────────────────────────── */
.eap-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 2.5rem;
  align-items: start;
}
.eap-toc {
  position: sticky;
  top: 96px;
  background: var(--light, #FFFFFF);
  border: 1px solid var(--border, #E5E7EB);
  border-radius: 12px;
  padding: 1rem 0.75rem;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}
.eap-toc h3 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray, #6B7280);
  letter-spacing: 0.03em;
  margin: 0;
  padding: 0.25rem 0.75rem 0.6rem;
}
.eap-toc a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  font-size: 0.88rem;
  color: var(--dark, #1A1A1A);
  text-decoration: none;
  transition: background 0.2s ease;
}
.eap-toc a:hover { background: var(--cream, #F8F6F3); }
.eap-count { margin-left: auto; font-size: 0.75rem; color: var(--gray, #6B7280); }

.eap-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.eap-dot-e { background: #3a7d57; }
.eap-dot-s { background: #2563a8; }
.eap-dot-g { background: #7c3aed; }
.eap-dot-0 { background: var(--orange, #E16839); }

/* ── Section cards ─────────────────────────────────────── */
.eap-section {
  background: var(--light, #FFFFFF);
  border: 1px solid var(--border, #E5E7EB);
  border-radius: 14px;
  margin-bottom: 1.75rem;
  overflow: hidden;
  scroll-margin-top: 100px;
}
.eap-section-head {
  padding: 1.4rem 1.6rem 1.2rem;
  border-bottom: 1px solid var(--border, #E5E7EB);
  border-top: 3px solid transparent;
}
.eap-ps-e .eap-section-head { border-top-color: #3a7d57; }
.eap-ps-s .eap-section-head { border-top-color: #2563a8; }
.eap-ps-g .eap-section-head { border-top-color: #7c3aed; }
.eap-ps-0 .eap-section-head { border-top-color: var(--orange, #E16839); }

.eap-badge {
  display: inline-block;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  margin-bottom: 0.6rem;
}
.eap-badge-e { background: #3a7d57; }
.eap-badge-s { background: #2563a8; }
.eap-badge-g { background: #7c3aed; }
.eap-badge-0 { background: var(--orange, #E16839); }

.eap-section-head h3 { font-size: 1.25rem; margin: 0 0 0.25rem; color: var(--dark, #1A1A1A); }
.eap-subtitle { color: var(--gray, #6B7280); font-size: 0.92rem; margin: 0; }
.eap-note {
  margin-top: 0.7rem;
  font-size: 0.86rem;
  color: var(--gray, #6B7280);
  background: var(--cream, #F8F6F3);
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
}

.eap-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }

/* ── Buttons ───────────────────────────────────────────── */
.eap-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: none;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 0.95rem;
  border-radius: 8px;
  transition: all 0.2s ease;
  text-decoration: none;
  line-height: 1.2;
}
.eap-btn svg { width: 14px; height: 14px; flex: 0 0 auto; }
.eap-btn-primary { background: var(--orange, #E16839); color: #fff; }
.eap-btn-primary:hover { background: #D15A2E; color: #fff; }
.eap-btn-outline {
  background: transparent;
  color: var(--dark, #1A1A1A);
  border: 1px solid var(--border, #E5E7EB);
}
.eap-btn-outline:hover { border-color: var(--orange, #E16839); color: var(--orange, #E16839); }
.eap-btn-ghost {
  background: transparent;
  color: var(--gray, #6B7280);
  border: 1px dashed var(--border, #E5E7EB);
}
.eap-btn-ghost:hover { color: var(--teal, #4A7366); border-color: var(--teal, #4A7366); }
.eap-btn-sm { font-size: 0.78rem; padding: 0.35rem 0.7rem; }

/* ── Questions ─────────────────────────────────────────── */
.eap-q { border-bottom: 1px solid var(--border, #E5E7EB); }
.eap-q:last-child { border-bottom: none; }
.eap-q summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  padding: 1rem 1.6rem;
  transition: background 0.15s ease;
}
.eap-q summary::-webkit-details-marker { display: none; }
.eap-q summary:hover { background: var(--cream, #F8F6F3); }
.eap-qcode {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--teal, #4A7366);
  background: rgba(74, 115, 102, 0.1);
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  white-space: nowrap;
}
.eap-qlabel { font-weight: 600; font-size: 0.95rem; flex: 1 1 auto; color: var(--dark, #1A1A1A); }
.eap-chevron { flex: 0 0 auto; align-self: center; color: var(--gray, #6B7280); transition: transform 0.2s ease; }
.eap-q[open] .eap-chevron { transform: rotate(180deg); }

.eap-qbody { padding: 0.25rem 1.6rem 1.4rem; }
.eap-quote {
  font-style: italic;
  color: var(--dark, #1A1A1A);
  background: var(--cream, #F8F6F3);
  border-left: 3px solid var(--teal, #4A7366);
  border-radius: 0 8px 8px 0;
  padding: 0.7rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.92rem;
  white-space: pre-line;
}
.eap-qbody h5 {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--teal, #4A7366);
  margin: 0.9rem 0 0.4rem;
}
.eap-qbody ul {
  list-style: disc;
  padding-left: 1.2rem;
  margin: 0;
  font-size: 0.9rem;
  color: var(--dark, #1A1A1A);
}
.eap-qbody li { margin-bottom: 0.25rem; }
.eap-format {
  font-size: 0.88rem;
  color: var(--dark, #1A1A1A);
  background: rgba(74, 115, 102, 0.06);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
}
.eap-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.eap-chip {
  font-size: 0.78rem;
  color: var(--dark, #1A1A1A);
  background: var(--cream, #F8F6F3);
  border: 1px solid var(--border, #E5E7EB);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
}

/* ── Documents checklist ───────────────────────────────── */
.eap-docs-head { margin: 2.5rem 0 1rem; }
.eap-docs-head h3 { font-size: 1.25rem; margin: 0 0 0.25rem; color: var(--dark, #1A1A1A); }
.eap-docs-head p { margin: 0; color: var(--gray, #6B7280); font-size: 0.92rem; }
.eap-docs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}
.eap-doc {
  background: var(--light, #FFFFFF);
  border: 1px solid var(--border, #E5E7EB);
  border-radius: 12px;
  padding: 1.25rem 1.4rem;
}
.eap-doc h4 { font-size: 0.98rem; margin: 0 0 0.6rem; color: var(--dark, #1A1A1A); }
.eap-doc ul { list-style: none; padding: 0; margin: 0; }
.eap-doc li {
  font-size: 0.88rem;
  color: var(--dark, #1A1A1A);
  padding: 0.28rem 0 0.28rem 1.4rem;
  position: relative;
}
.eap-doc li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.62rem;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--teal, #4A7366);
  opacity: 0.5;
}

/* ── Modal ─────────────────────────────────────────────── */
.eap-modal {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 26, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 99990;
  padding: 1.5rem;
}
.eap-modal.eap-open { display: flex; }
.eap-modal-box {
  background: var(--light, #FFFFFF);
  border-radius: 14px;
  max-width: 860px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
}
.eap-modal-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--border, #E5E7EB);
}
.eap-modal-head h4 { font-size: 1rem; flex: 1 1 auto; margin: 0; color: var(--dark, #1A1A1A); }
.eap-modal-close {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--gray, #6B7280);
  padding: 0.2rem 0.4rem;
}
.eap-modal-close:hover { color: var(--dark, #1A1A1A); }
.eap-modal pre {
  margin: 0;
  padding: 1.2rem 1.4rem;
  overflow: auto;
  font-family: Consolas, Menlo, monospace;
  font-size: 0.8rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--dark, #1A1A1A);
  background: var(--cream, #F8F6F3);
  flex: 1 1 auto;
}
.eap-modal-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 1rem 1.4rem;
  border-top: 1px solid var(--border, #E5E7EB);
}

/* ── Toast ─────────────────────────────────────────────── */
.eap-toast {
  position: fixed;
  left: 50%;
  bottom: 2rem;
  transform: translateX(-50%) translateY(20px);
  background: var(--dark, #1A1A1A);
  color: #fff;
  font-size: 0.9rem;
  padding: 0.7rem 1.3rem;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 99999;
  max-width: min(92vw, 560px);
  text-align: center;
}
.eap-toast.eap-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Responsive ────────────────────────────────────────── */
@media (min-width: 700px) {
  .eap-steps { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .eap-layout { grid-template-columns: 1fr; }
  .eap-toc {
    position: static;
    max-height: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
  }
  .eap-toc h3 { width: 100%; }
  .eap-toc a { padding: 0.35rem 0.6rem; }
  .eap-count { display: none; }
  .eap-q summary { flex-wrap: wrap; }
}
