/* ════════════════════════════════════════════════════════════
   Componentes rescatados de la versión anterior (index(1).html)
   y adaptados a los tokens del tema para que funcionen en
   modo claro y oscuro.
   ════════════════════════════════════════════════════════════ */

/* ── Selector de idioma flotante ── */
.lang-selector { position: relative; }

.lang-menu {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 190px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  padding: 8px;
  z-index: 120;
}

.lang-selector.open .lang-menu { display: block; }

.lang-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 0.88rem;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.lang-menu a:hover { background: var(--accent-glow); color: var(--primary); }
.lang-menu a.lang-active { background: var(--accent-glow); font-weight: 600; color: var(--primary); }
.lang-flag { font-size: 1.1rem; line-height: 1; }

.lang-float {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 90;
  display: none;
}

.lang-float-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 99px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.lang-float-btn svg { width: 16px; height: 16px; }
.lang-float .lang-menu { left: 0; right: auto; bottom: calc(100% + 10px); top: auto; }
@media (max-width: 900px) { .lang-float { display: block; } }

/* ── Calculadora de honorarios ── */
.calc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: var(--shadow-sm);
  max-width: 900px;
  margin: 0 auto;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

.calc-field { display: flex; flex-direction: column; gap: 6px; }

.calc-field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.calc-field select,
.calc-field input {
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  font-size: 0.92rem;
  font-family: inherit;
  background: var(--surface2);
  color: var(--text);
}

.calc-field select:focus,
.calc-field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.calc-disclaimer { font-size: 0.8rem; color: var(--text-muted); line-height: 1.6; }

/* ── Checklist de documentación ── */
.checklist-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: var(--shadow-sm);
}

.checklist-progress { margin-bottom: 32px; }

.progress-bar-wrap {
  height: 10px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 99px;
  transition: width 0.4s ease;
}

.progress-label { font-size: 0.85rem; color: var(--text-muted); margin: 0; }

.check-groups {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
  margin-bottom: 32px;
}

.check-group h4 {
  font-family: 'Outfit', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin: 0 0 14px;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 0;
}

.check-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 2px;
  accent-color: var(--primary);
  cursor: pointer;
}

.check-item label {
  font-size: 0.88rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1.5;
  margin: 0;
}

.check-item.checked label { text-decoration: line-through; color: var(--accent); opacity: 0.85; }

/* ── Monitor de boletines ── */
#boletin { background: var(--surface2); }

.boletin-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  box-shadow: var(--shadow-sm);
  max-width: 860px;
  margin: 0 auto;
}

.boletin-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 16px;
}

.boletin-field { display: flex; flex-direction: column; gap: 6px; }

.boletin-field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.boletin-field input,
.boletin-field select {
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--surface2);
  color: var(--text);
}

.boletin-field input:focus,
.boletin-field select:focus { outline: 2px solid var(--accent); border-color: transparent; }

.bol-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

.bol-empty { text-align: center; color: var(--text-muted); padding: 40px 0; font-size: 0.95rem; }

.bol-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 22px;
  margin-bottom: 14px;
  display: flex;
  gap: 18px;
  align-items: flex-start;
  transition: transform 0.2s, box-shadow 0.2s;
}

.bol-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.bol-flag { font-size: 1.6rem; flex-shrink: 0; line-height: 1; padding-top: 2px; }
.bol-body { flex: 1; min-width: 0; }
.bol-meta { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 4px; }
.bol-title { font-weight: 600; font-size: 0.95rem; margin-bottom: 6px; line-height: 1.4; }
.bol-snippet { font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; margin-bottom: 8px; }

.bol-link { font-size: 0.82rem; font-weight: 600; color: var(--accent); text-decoration: none; }
.bol-link:hover { text-decoration: underline; }

.bol-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  margin-right: 8px;
}

.bol-badge-boe  { background: rgba(196, 30, 58, 0.14);  color: #d94868; }
.bol-badge-bora { background: rgba(116, 192, 90, 0.18); color: #4f9c36; }
.bol-badge-uy   { background: rgba(0, 90, 200, 0.14);   color: #3b8fd4; }
.bol-count { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 20px; }

/* ── Biblioteca jurídica ── */
#biblioteca { background: var(--surface2); }

.lib-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 28px;
}

.lib-tab {
  padding: 9px 18px;
  border: 1px solid var(--border-strong);
  border-radius: 99px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.83rem;
  font-weight: 500;
  cursor: pointer;
  transition: 0.2s;
}

.lib-tab:hover { border-color: var(--primary); color: var(--primary); }

.lib-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--accent-soft);
  font-weight: 600;
}

.lib-search-wrap { text-align: center; margin-bottom: 28px; }

.lib-search {
  width: min(420px, 100%);
  padding: 12px 18px;
  border: 1px solid var(--border-strong);
  border-radius: 99px;
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
}

.lib-search:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--accent-glow); }

.lib-panels { min-height: 300px; }
.lib-panel { display: none; }
.lib-panel.active { display: block; animation: fadeIn 0.35s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.lib-loading { text-align: center; color: var(--text-muted); padding: 40px 0; font-size: 0.92rem; }
.lib-error { text-align: center; color: var(--text-muted); padding: 40px 0; font-size: 0.92rem; }
.lib-content { max-width: 900px; margin: 0 auto; }

.lib-content h3 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.45rem;
  color: var(--primary);
  margin: 28px 0 12px;
}

.lib-content h4 {
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
  margin: 20px 0 8px;
}

.lib-content p { font-size: 0.92rem; color: var(--text-muted); margin-bottom: 10px; line-height: 1.75; }
.lib-content ul, .lib-content ol { padding-left: 1.4rem; }
.lib-content li { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 6px; }
.lib-content strong { color: var(--primary); font-weight: 600; }
.lib-content em { color: var(--accent); font-style: italic; }
.lib-content a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

.lib-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.86rem;
}

.lib-content th {
  text-align: left;
  padding: 10px 12px;
  background: var(--surface2);
  color: var(--primary);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.lib-content td { padding: 10px 12px; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.lib-content tr:last-child td { border-bottom: none; }
.lib-content tr:nth-child(even) td { background: var(--accent-glow); }

.lib-content blockquote {
  border-left: 3px solid var(--accent);
  background: var(--accent-glow);
  padding: 12px 18px;
  border-radius: 0 10px 10px 0;
  margin: 16px 0;
}

.lib-content blockquote p { color: var(--text-muted); font-size: 0.85rem; margin: 0; }
.lib-highlight { background: rgba(148, 114, 24, 0.28); border-radius: 3px; padding: 0 2px; }

/* ── Módulos temáticos (acordeón) ── */
.module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  margin-bottom: 14px;
  overflow: hidden;
  transition: box-shadow 0.3s, background 0.3s;
}

.module-card[open] { box-shadow: var(--shadow-md); }

.module-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.module-summary::-webkit-details-marker { display: none; }
.module-summary::marker { display: none; }

.module-num {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  background: var(--primary);
  color: var(--accent-soft);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cormorant Garamond', serif;
  font-size: 1rem;
  font-weight: 600;
  transition: background 0.3s;
}

.module-card[open] .module-num { background: var(--accent); color: #fff; }

.module-title-text {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--primary);
  flex: 1;
}

.module-toggle {
  font-size: 1.5rem;
  font-weight: 300;
  color: var(--text-muted);
  line-height: 1;
  transition: transform 0.3s;
}

.module-card[open] .module-toggle { transform: rotate(45deg); color: var(--accent); }

.module-body { padding: 4px 24px 28px; border-top: 1px solid var(--border); }
.module-body.lib-content h3 { margin-top: 20px; font-size: 1.1rem; }
.module-body.lib-content p { font-size: 0.91rem; }
.module-body.lib-content li { font-size: 0.9rem; }

/* ── Toasts (reemplazo de alert) ── */
.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 96px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--primary-dk);
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.85rem;
  box-shadow: var(--shadow-lg);
  max-width: 340px;
  animation: toastIn 0.25s ease;
}

.toast-error { background: #7a1f2b; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Utilidades ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ── Responsive de componentes ── */
@media (max-width: 900px) {
  .calc-grid { grid-template-columns: 1fr; }
  .check-groups { grid-template-columns: 1fr; gap: 24px; }
  .calc-card, .checklist-card { padding: 28px 20px; }
  .boletin-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 700px) {
  .boletin-grid { grid-template-columns: 1fr; }
  .boletin-form { padding: 24px 18px; }
  .toast-stack { right: 12px; left: 12px; bottom: 84px; }
  .toast { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  .progress-bar-fill, .lib-panel.active, .toast { animation: none; transition: none; }
}

@media print {
  header, footer, .wa-float, #progress, #chatBtn, #chatWin,
  .hero, .stats-band, #servicios, #proceso, #asistente,
  #honorarios, #calculadora, #boletin, #biblioteca, #faq,
  #contacto, .lang-float, .theme-btn, .no-print { display: none !important; }

  #documentos { display: block !important; padding: 20px; background: #fff; color: #000; }
  .checklist-card { box-shadow: none; border: 1px solid #ccc; }
  .check-item label { color: #000; }
}

/* ── Acabado visual compartido ── */
.svc-icon svg,
.cp-icon svg,
.bp-avatar svg,
.cw-avatar svg,
#chatBtn .ico-open svg,
.theme-icon {
  display: block;
  width: 22px;
  height: 22px;
}

.cp-icon {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(154,117,70,.24);
  border-radius: 14px;
  color: var(--primary);
}

.bp-avatar svg,
.cw-avatar svg { width: 20px; height: 20px; }
.bp-avatar,
.cw-avatar { color: var(--accent-soft); }

:root[data-theme="dark"] .bp-avatar,
:root[data-theme="dark"] .cw-avatar { color: var(--accent); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .bp-avatar,
  :root:not([data-theme="light"]) .cw-avatar { color: var(--accent); }
}

#chatBtn .ico-open { display: flex; align-items: center; justify-content: center; }
#chatBtn .ico-open svg { width: 24px; height: 24px; }

.theme-btn {
  width: 42px;
  height: 42px;
  border-color: var(--border-strong);
}

.theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-icon-moon { display: none; }
:root[data-theme="dark"] .theme-icon-sun { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-icon-moon { display: none; }
  :root:not([data-theme="light"]) .theme-icon-sun { display: block; }
}

.contact-grid > .reveal {
  padding: clamp(24px, 4vw, 40px);
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.inp,
.calc-field select,
.calc-field input,
.boletin-field input,
.boletin-field select,
.lib-search {
  border-radius: 12px;
  min-height: 48px;
}

.inp:focus,
.calc-field select:focus,
.calc-field input:focus,
.boletin-field input:focus,
.boletin-field select:focus,
.lib-search:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.calc-card,
.boletin-form {
  border-radius: 22px;
  box-shadow: var(--shadow-md);
}

.lib-tab {
  padding: 10px 18px;
  border-radius: 12px;
}

.lib-tab.active { color: #fff; }

.module-card { border-radius: 16px; }
.module-card[open] { border-color: var(--border-strong); }

.wa-btn {
  box-shadow: 0 8px 22px rgba(37,211,102,.24);
}

@media (max-width: 600px) {
  .contact-grid > .reveal { padding: 22px 18px; }
  .theme-btn { top: calc(env(safe-area-inset-top,0px) + 72px); }
  .lang-float { bottom: calc(92px + env(safe-area-inset-bottom,0px)); }
}
