/* ================================================
   CONSULTOR IA — MODAL STUDIO FLOTANTE
   ================================================ */

/* Fondo backdrop con desenfoque elegante y progresivo */
.ia-modal-backdrop,
.ia-panel-wrapper {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  background: rgba(15, 23, 42, 0) !important;
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  z-index: 2500 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 24px !important;
  box-sizing: border-box !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.65s cubic-bezier(0.2, 0.8, 0.25, 1),
              visibility 0.65s cubic-bezier(0.2, 0.8, 0.25, 1),
              background 0.65s cubic-bezier(0.2, 0.8, 0.25, 1),
              backdrop-filter 0.65s cubic-bezier(0.2, 0.8, 0.25, 1),
              -webkit-backdrop-filter 0.65s cubic-bezier(0.2, 0.8, 0.25, 1) !important;
  transform: none !important;
  font-size: var(--font-reading, 1.18rem);
}

.ia-modal-backdrop.ia-open,
.ia-panel-wrapper.ia-open {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  background: rgba(15, 23, 42, 0.5) !important;
  backdrop-filter: blur(16px) !important;
  -webkit-backdrop-filter: blur(16px) !important;
}

/* Tarjeta Modal Flotante */
.ia-modal-card {
  width: 100%;
  max-width: 860px;
  height: 86vh;
  max-height: 880px;
  background: var(--bg-container, #ffffff);
  border: 1px solid var(--border, rgba(0, 0, 0, 0.1));
  border-radius: 20px;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: scale(0.95) translateY(16px);
  filter: blur(12px);
  transition: opacity 0.68s cubic-bezier(0.2, 0.8, 0.25, 1),
              transform 0.68s cubic-bezier(0.2, 0.8, 0.25, 1),
              filter 0.68s cubic-bezier(0.2, 0.8, 0.25, 1);
  will-change: opacity, transform, filter;
}

.ia-modal-backdrop.ia-open .ia-modal-card,
.ia-panel-wrapper.ia-open .ia-modal-card {
  opacity: 1;
  transform: scale(1) translateY(0);
  filter: blur(0px);
}

/* En móvil se expande a pantalla completa sin márgenes */
@media (max-width: 680px) {
  .ia-modal-backdrop,
  .ia-panel-wrapper {
    padding: 0 !important;
  }

  .ia-modal-card {
    width: 100% !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
    transform: translateY(20px);
    opacity: 0;
    filter: blur(8px);
  }

  .ia-modal-backdrop.ia-open .ia-modal-card,
  .ia-panel-wrapper.ia-open .ia-modal-card {
    transform: translateY(0) !important;
    opacity: 1 !important;
    filter: blur(0px) !important;
  }
}

/* Ocultar bottom nav cuando el panel IA está abierto en mobile/tablet */
body.ia-panel-open .mode-tabs {
  display: none !important;
}

/* ── Barra superior moderna del Consultor IA ── */
.ia-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--bg-container, #ffffff);
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  gap: 12px;
  flex-shrink: 0;
  z-index: 10;
}

.ia-top-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text-main, #0f172a);
  letter-spacing: -0.01em;
}

.ia-badge-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(37, 99, 235, 0.1);
  color: #2563eb;
}

.ia-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ia-modal-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.1));
  background: var(--bg-card, rgba(0, 0, 0, 0.03));
  color: var(--text-muted, #64748b);
  cursor: pointer;
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.ia-modal-close-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.25);
  transform: scale(1.05);
}

/* Ocultar trigger bar antiguo */
.ia-trigger-bar {
  display: none !important;
}

/* ── Barra trigger ── */
.ia-trigger-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 7px 14px;
  background: var(--bg-filters);
  border-top: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  min-height: 35px;
}

.ia-trigger-bar:hover {
  background: var(--card-hover);
}

.ia-trigger-text {
  font-size: 0.62em;
  font-style: italic;
  color: var(--text-muted);
  opacity: 0.5;
}

.ia-trigger-bar:hover .ia-trigger-text {
  opacity: 0.85;
}

.ia-trigger-arrow {
  background: none;
  border: none;
  padding: 2px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  transition: transform 0.6s ease, color 0.3s;
}

.ia-panel-wrapper.ia-open .ia-trigger-arrow {
  transform: rotate(180deg);
  color: #c8a000;
}

.ia-panel {
  flex: 1;
  overflow: hidden;
  background: var(--bg-body, #f8fafc);
  border-top: none;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* ══════════════════════════════════════════════ */
/* ── Partículas (Desactivadas para estilo elegante) ── */
/* ══════════════════════════════════════════════ */
.ia-aura {
  display: none !important;
}
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.ia-particle {
  position: absolute;
  bottom: -50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  animation-name: none;
}

.ia-panel-wrapper.ia-open .ia-particle {
  animation-name: ia-float;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

.ia-particle:nth-child(1) {
  left: 10%;
  width: 15px;
  height: 15px;
  animation-duration: 8s;
  animation-delay: 0s;
}

.ia-particle:nth-child(2) {
  left: 25%;
  width: 25px;
  height: 25px;
  animation-duration: 12s;
  animation-delay: 2s;
}

.ia-particle:nth-child(3) {
  left: 40%;
  width: 10px;
  height: 10px;
  animation-duration: 7s;
  animation-delay: 4s;
}

.ia-particle:nth-child(4) {
  left: 55%;
  width: 20px;
  height: 20px;
  animation-duration: 10s;
  animation-delay: 1s;
}

.ia-particle:nth-child(5) {
  left: 70%;
  width: 12px;
  height: 12px;
  animation-duration: 9s;
  animation-delay: 3s;
}

.ia-particle:nth-child(6) {
  left: 85%;
  width: 18px;
  height: 18px;
  animation-duration: 11s;
  animation-delay: 5s;
}

.ia-particle:nth-child(7) {
  left: 15%;
  width: 8px;
  height: 8px;
  animation-duration: 6s;
  animation-delay: 6s;
}

.ia-particle:nth-child(8) {
  left: 50%;
  width: 22px;
  height: 22px;
  animation-duration: 14s;
  animation-delay: 0.5s;
}

.ia-particle:nth-child(9) {
  left: 80%;
  width: 14px;
  height: 14px;
  animation-duration: 8.5s;
  animation-delay: 2.5s;
}

.ia-particle:nth-child(10) {
  left: 35%;
  width: 16px;
  height: 16px;
  animation-duration: 13s;
  animation-delay: 7s;
}

@keyframes ia-float {
  0% {
    transform: translateY(0) scale(1);
    opacity: 0;
  }

  10% {
    opacity: 0.8;
  }

  80% {
    opacity: 0.6;
  }

  100% {
    transform: translateY(-120vh) scale(1.5);
    opacity: 0;
  }
}

/* ================================================
   PESTAÑAS IA
   ================================================ */
.ia-tabs {
  display: flex;
  position: relative;
  z-index: 1;
  padding: 6px 10px;
  gap: 8px;
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  background: var(--bg-container, #ffffff);
}

.ia-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted, #64748b);
  border-radius: 12px;
  transition: all 0.2s ease;
  user-select: none;
  opacity: 0.8;
}

.ia-tab:hover {
  opacity: 1;
  color: var(--text-main, #0f172a);
  background: var(--card-hover, rgba(0, 0, 0, 0.04));
}

.ia-tab.active {
  opacity: 1;
  color: #2563eb;
  background: rgba(37, 99, 235, 0.08);
  font-weight: 700;
  border-bottom: none;
}

.ia-tab-icon {
  font-size: 1.2em;
  line-height: 1;
}

.ia-tab-text {
  font-size: 0.62em;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
}

.ia-tab-img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  vertical-align: middle;
  pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.1));
}

/* ================================================
   PANELES DE CONTENIDO IA
   ================================================ */
.ia-tab-panel {
  display: none;
  flex: 1;
  overflow: hidden;
  position: relative;
  z-index: 1;
  flex-direction: column;
}

.ia-tab-panel.active {
  display: flex;
}

/* ── Scroll de resultados ── */
.ia-results-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* ── Placeholder vacío ── */
.ia-placeholder {
  text-align: center;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

.ia-placeholder-icon {
  font-size: 2.8em;
  margin-bottom: 16px;
  animation: ia-wobble 1.6s ease-in-out infinite;
}

.ia-placeholder-img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  margin-bottom: 15px;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.15));
}

.ia-placeholder-title {
  font-size: 1.2em;
  font-weight: 800;
  color: #3A2800;
  margin: 0 0 8px;
}

.ia-placeholder-sub {
  font-size: 0.88em;
  color: #5A3C00;
  margin: 0;
  line-height: 1.5;
}

@keyframes ia-wobble {

  0%,
  100% {
    transform: rotate(-6deg);
  }

  50% {
    transform: rotate(6deg);
  }
}

/* ── "En construcción" ── */
.ia-construction {
  text-align: center;
  padding: 40px 20px;
}

.ia-construction-icon {
  font-size: 2.8em;
  margin-bottom: 16px;
  animation: ia-wobble 1.6s ease-in-out infinite;
}

.ia-construction-title {
  font-size: 1.2em;
  font-weight: 800;
  color: #3A2800;
  margin: 0 0 8px;
}

.ia-construction-sub {
  font-size: 0.88em;
  color: #5A3C00;
  margin: 0;
  line-height: 1.5;
}

.ia-construction-sub em {
  opacity: 0.7;
  font-size: 0.78em;
}

/* ================================================
   CHAT INPUT
   ================================================ */
/* ================================================
   CHAT INPUT
   ================================================ */
.ia-chat-input-wrapper {
  padding: 12px 16px;
  background: var(--bg-container, #ffffff);
  border-top: 1px solid var(--border, rgba(0, 0, 0, 0.08));
}

.ia-chat-input {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-card, #f8fafc);
  border: 1.5px solid var(--border, rgba(0, 0, 0, 0.1));
  border-radius: 20px;
  padding: 6px 10px 6px 16px;
  transition: all 0.2s ease;
}

.ia-chat-input:focus-within {
  border-color: #2563eb;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* ── Textarea autoexpandible ── */
.ia-chat-input textarea {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 15px;
  color: var(--text-main, #0f172a);
  padding: 6px 0;
  resize: none;
  min-height: 32px;
  max-height: 140px;
  overflow-y: auto;
  line-height: 1.5;
  font-family: inherit;
}

.ia-chat-input textarea::placeholder {
  color: var(--text-muted, #94a3b8);
}

.ia-chat-input textarea:disabled {
  opacity: 0.5;
}

/* Botón Nueva Conversación */
.ia-chat-new-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  background: var(--bg-card, #ffffff);
  color: var(--text-muted, #64748b);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.ia-chat-new-btn:hover {
  color: #2563eb;
  border-color: #2563eb;
  background: rgba(37, 99, 235, 0.08);
  transform: scale(1.06);
}

/* Botón Enviar */
.ia-chat-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: #2563eb;
  color: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.28);
  margin-bottom: 2px;
}

.ia-chat-send:hover:not(:disabled) {
  background: #1d4ed8;
  transform: scale(1.06);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.38);
}

.ia-chat-send:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ================================================
   RESULTADOS IA — Tarjetas
   ================================================ */
.ia-search-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: rgba(58, 40, 0, 0.08);
  border-radius: 8px;
  font-size: 0.82em;
  color: #3A2800;
}

.ia-search-stats .search-total {
  font-size: 0.82em;
}

.ia-search-stats .search-range {
  font-size: 0.75em;
  opacity: 0.7;
}

.ia-result-card {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(58, 40, 0, 0.12);
  border-left: 4px solid #c8a000;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: background 0.2s, box-shadow 0.2s;
}

.ia-result-card:hover {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 8px rgba(58, 40, 0, 0.1);
}

.ia-result-card .search-result-header {
  margin-bottom: 6px;
}

.ia-result-ref {
  font-size: 0.88em;
  font-weight: 700;
  color: #8B6914;
}

.ia-result-card .search-result-text {
  font-size: 0.88em;
  line-height: 1.65;
  color: #3A2800;
  margin: 0;
}

/* ================================================
   PAGINACIÓN IA
   ================================================ */
.ia-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 16px 0 8px;
  flex-wrap: wrap;
}

.ia-page-btn {
  padding: 8px 18px;
  border: 2px solid rgba(58, 40, 0, 0.2);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.6);
  color: #3A2800;
  font-size: 0.82em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.ia-page-btn:hover {
  background: rgba(255, 255, 255, 0.9);
  border-color: #c8a000;
}

.ia-pagination .pagination-info {
  font-size: 0.82em;
  color: #5A3C00;
  font-weight: 600;
}

/* ================================================
   LOADING
   ================================================ */
.ia-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.ia-loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(58, 40, 0, 0.15);
  border-top-color: #c8a000;
  border-radius: 50%;
  animation: ia-spin 0.8s linear infinite;
  margin-bottom: 20px;
}

@keyframes ia-spin {
  to {
    transform: rotate(360deg);
  }
}

.ia-loading-text {
  font-size: 0.92em;
  font-weight: 600;
  color: #3A2800;
  margin: 0 0 6px;
}

.ia-loading-sub {
  font-size: 0.82em;
  color: #5A3C00;
  opacity: 0.7;
  margin: 0;
}

/* ================================================
   EMPTY / ERROR
   ================================================ */
.ia-empty,
.ia-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.ia-empty-icon,
.ia-error-icon {
  font-size: 2.8em;
  margin-bottom: 16px;
}

.ia-empty h3 {
  font-size: 1.1em;
  font-weight: 700;
  color: #3A2800;
  margin: 0 0 8px;
}

.ia-empty p {
  font-size: 0.88em;
  color: #5A3C00;
  margin: 0 0 4px;
}

.ia-error-text {
  font-size: 0.88em;
  color: #8B2500;
  font-weight: 600;
  margin: 0;
  line-height: 1.5;
}

/* =====================================================
   COLORES DINÁMICOS DEL PANEL IA (AURAS DE PODER)
   ===================================================== */

:root,
[data-skin="classic"] {
  --ia-bg-grad: linear-gradient(135deg, #F0F4F8 0%, #D9E2EC 100%);
  --ia-text-main: #1B365D;
  --ia-text-muted: #486581;
  --ia-input-bg: #FFFFFF;
  --ia-btn-bg: #1B365D;
  --ia-btn-text: #D4AF37;
}

[data-theme="dark"]:root,
[data-theme="dark"][data-skin="classic"] {
  --ia-bg-grad: linear-gradient(135deg, #0F172A 0%, #1E293B 100%);
  --ia-text-main: #F8FAFC;
  --ia-text-muted: #94A3B8;
  --ia-input-bg: #0F172A;
  --ia-btn-bg: #C9A84C;
  --ia-btn-text: #0F172A;
}

[data-skin="lavanda"] {
  --ia-bg-grad: linear-gradient(135deg, #A8B2E0 0%, #7B8DC4 100%);
  --ia-text-main: #1A1A30;
  --ia-text-muted: #3D4570;
  --ia-input-bg: #F3F5FC;
  --ia-btn-bg: #4A5A9A;
  --ia-btn-text: #FFFFFF;
}

[data-skin="scriptorium"] {
  --ia-bg-grad: linear-gradient(135deg, #F7F4EE 0%, #EAE3D5 100%);
  --ia-text-main: #2C2420;
  --ia-text-muted: #7A6A60;
  --ia-input-bg: #FFFFFF;
  --ia-btn-bg: #2C2420;
  --ia-btn-text: #C4A052;
}

[data-theme="dark"][data-skin="scriptorium"] {
  --ia-bg-grad: linear-gradient(135deg, #161E2C 0%, #0D131D 100%);
  --ia-text-main: #EDE8DC;
  --ia-text-muted: #907868;
  --ia-input-bg: #0B0E14;
  --ia-btn-bg: #A0722A;
  --ia-btn-text: #161E2C;
}

[data-skin="blossom"] {
  --ia-bg-grad: linear-gradient(135deg, #F8BBD0 0%, #D81B60 100%);
  --ia-text-main: #4A0020;
  --ia-text-muted: #80003A;
  --ia-input-bg: #FFF0F5;
  --ia-btn-bg: #6A0030;
  --ia-btn-text: #F8BBD0;
}

[data-skin="ocean"] {
  --ia-bg-grad: linear-gradient(135deg, #48CAE4 0%, #0077B6 100%);
  --ia-text-main: #002233;
  --ia-text-muted: #004A70;
  --ia-input-bg: #E8F8FA;
  --ia-btn-bg: #03045E;
  --ia-btn-text: #48CAE4;
}

[data-skin="sunset"] {
  --ia-bg-grad: linear-gradient(135deg, #F8A888 0%, #C060A0 100%);
  --ia-text-main: #2A0820;
  --ia-text-muted: #5A1840;
  --ia-input-bg: #FFF4F8;
  --ia-btn-bg: #4A3878;
  --ia-btn-text: #F8C8A8;
}

[data-skin="forest"] {
  --ia-bg-grad: linear-gradient(135deg, #A8E6CF 0%, #388E3C 100%);
  --ia-text-main: #0A2912;
  --ia-text-muted: #1B4D26;
  --ia-input-bg: #E8F5E9;
  --ia-btn-bg: #132A18;
  --ia-btn-text: #A8E6CF;
}

[data-skin="fire"] {
  --ia-bg-grad: linear-gradient(135deg, #FF7A00 0%, #C72213 100%);
  --ia-text-main: #3A0500;
  --ia-text-muted: #601000;
  --ia-input-bg: #FFF0E8;
  --ia-btn-bg: #2A1005;
  --ia-btn-text: #FF7A00;
}

/* Aplicación Mágica (Sobreescribe automáticamente) */
.ia-panel {
  background: var(--ia-bg-grad);
  border-top: 3px solid rgba(255, 255, 255, 0.4);
}

.ia-tab {
  color: var(--ia-text-muted);
}

.ia-tab.active {
  border-bottom-color: var(--ia-text-main);
}

.ia-placeholder-title,
.ia-construction-title,
.ia-empty h3 {
  color: var(--ia-text-main);
}

.ia-placeholder-sub,
.ia-construction-sub,
.ia-empty p,
.ia-loading-sub {
  color: var(--ia-text-muted);
}

/* ================================================
   ESTILOS MODERNOS Y ELEGANTES DE BURBUJAS DE CHAT
   ================================================ */

/* Fila de mensaje del usuario */
.ia-user-msg-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1.5rem;
  padding-left: 2rem;
}

/* Burbuja del usuario: sutil, ligera, integrada, sin tosquedad */
.ia-user-bubble {
  display: inline-block;
  max-width: 82%;
  background: var(--bg-card, #ffffff);
  color: var(--text-main, #1e293b);
  border: 1px solid var(--border, rgba(0, 0, 0, 0.1));
  border-radius: 16px 16px 4px 16px;
  padding: 12px 18px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  font-size: 0.96rem;
  line-height: 1.55;
  font-weight: 450;
  text-align: left;
  word-break: break-word;
}

/* Burbuja de IA: tarjeta limpia, espaciosa, con cabecera y botón copiar */
.ia-ai-bubble {
  background: var(--bg-card, #ffffff);
  color: var(--text-main, #0f172a);
  border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  border-radius: 20px 20px 20px 4px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  margin-bottom: 1.8rem;
  padding: 16px 20px;
  max-width: 96%;
  word-break: break-word;
}

.ia-ai-bubble-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.06));
}

.ia-ai-bubble-author {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ia-ai-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: rgba(37, 99, 235, 0.1);
  color: #2563eb;
}

.ia-ai-title-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main, #0f172a);
  letter-spacing: -0.01em;
}

.ia-ai-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted, #64748b);
  cursor: pointer;
  transition: all 0.2s ease;
}

.ia-ai-copy-btn:hover {
  background: var(--card-hover, rgba(0, 0, 0, 0.04));
  color: var(--text-main, #0f172a);
  border-color: var(--text-muted, #64748b);
}

.ia-chat-text {
  font-size: 1.02rem;
  line-height: 1.74;
  color: var(--text-main, #1e293b);
}

.ia-chat-text p {
  margin: 0 0 0.9em;
}

.ia-chat-text p:last-child {
  margin-bottom: 0;
}

/* Enlaces dentro del chat de IA (Versículos) */
.ia-ai-bubble a {
  color: #2563eb;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px dashed #2563eb;
  transition: opacity 0.15s ease;
}

.ia-ai-bubble a:hover {
  opacity: 0.8;
}

/* Tarjeta de recomendación de obra teológica en biblioteca interna */
.ia-theology-tip-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ia-theology-tip-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08) !important;
}

.ia-open-theology-paragraph-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* ══════════════════════════════════════════════
   ADAPTACIONES MODO OSCURO
   ══════════════════════════════════════════════ */
[data-theme="dark"] .ia-panel {
  background: var(--bg-body, #0b1120);
}

[data-theme="dark"] .ia-panel-wrapper.ia-open {
  background: var(--bg-body, #0b1120) !important;
}

[data-theme="dark"] .ia-top-bar,
[data-theme="dark"] .ia-tabs,
[data-theme="dark"] .ia-chat-input-wrapper {
  background: var(--bg-container, #0f172a);
  border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .ia-top-title {
  color: #f1f5f9;
}

[data-theme="dark"] .ia-tab {
  color: #94a3b8;
}

[data-theme="dark"] .ia-tab:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .ia-tab.active {
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.15);
}

[data-theme="dark"] .ia-back-btn {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
}

[data-theme="dark"] .ia-back-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

[data-theme="dark"] .ia-modal-card {
  background: #0f172a;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
}

[data-skin="scriptorium"] .ia-modal-card {
  background: #f7f4ee;
  border-color: rgba(44, 36, 32, 0.12);
}

[data-theme="dark"] .ia-user-bubble {
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

[data-skin="scriptorium"] .ia-user-bubble {
  background: #fdfbf7;
  color: #2c2420;
  border-color: rgba(44, 36, 32, 0.14);
  box-shadow: 0 2px 6px rgba(44, 36, 32, 0.05);
}

[data-theme="dark"] .ia-ai-bubble {
  background: #111b2d;
  border-color: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .ia-ai-bubble-header {
  border-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .ia-ai-title-label {
  color: #f1f5f9;
}

[data-theme="dark"] .ia-ai-copy-btn {
  border-color: rgba(255, 255, 255, 0.12);
  color: #94a3b8;
}

[data-theme="dark"] .ia-ai-copy-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
}

[data-theme="dark"] .ia-chat-text {
  color: #cbd5e1;
}

[data-theme="dark"] .ia-ai-bubble a {
  color: #60a5fa;
  border-bottom-color: #60a5fa;
}

[data-theme="dark"] .ia-chat-input {
  background: #0b1120;
  border-color: rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] .ia-chat-input textarea {
  color: #f8fafc;
}

[data-theme="dark"] .ia-chat-input textarea::placeholder {
  color: #64748b;
}

[data-theme="dark"] .ia-chat-new-btn {
  background: #111b2d;
  border-color: rgba(255, 255, 255, 0.12);
  color: #94a3b8;
}

[data-theme="dark"] .ia-chat-new-btn:hover {
  color: #60a5fa;
  border-color: #60a5fa;
  background: rgba(59, 130, 246, 0.15);
}

[data-theme="dark"] .ia-placeholder-title,
[data-theme="dark"] .ia-construction-title {
  color: #f1f5f9;
}

[data-theme="dark"] .ia-placeholder-sub,
[data-theme="dark"] .ia-construction-sub {
  color: #94a3b8;
}

[data-theme="dark"] .ia-theology-tip-card {
  background: #131f33 !important;
  border-color: #273752 !important;
  border-left-color: #38bdf8 !important;
}

[data-theme="dark"] .ia-theology-tip-card div {
  color: #e2e8f0 !important;
}

[data-theme="dark"] .ia-theology-tip-card em {
  color: #7dd3fc !important;
}


/* Cuando el sidebar NORMAL o el de IA están abiertos */
.app-layout.has-sidebar,
.app-layout.has-ia-sidebar {
  max-width: 1300px;
  margin: 0 auto;
  gap: 24px;
  align-items: flex-start;
}

/* Ajuste del contenedor principal de la Biblia */
.app-layout.has-sidebar .container,
.app-layout.has-ia-sidebar .container {
  flex: 1;
  margin: 0;
}

/* ================================================
   DESKTOP SIDEBAR MODE (≥ 1180px)
   En pantalla grande, el panel IA deja de ser
   un drawer inferior y se convierte en sidebar lateral
   ================================================ */
@media (min-width: 1180px) {

  /* Cuando está dentro de la ventana de escritorio #desktopWinIA */
  #desktopWinIA #iaPanelWrapper,
  #desktopWinIA .ia-modal-backdrop,
  #desktopWinIA .ia-panel-wrapper {
    position: static !important;
    transform: none !important;
    transition: none !important;
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    padding: 0 !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    z-index: 1 !important;
  }

  #desktopWinIA .ia-modal-card {
    position: static !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    filter: none !important;
    background: transparent !important;
  }

  #desktopWinIA .ia-top-bar,
  #desktopWinIA .ia-trigger-bar {
    display: none !important;
  }

  #desktopWinIA .ia-panel {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    border-radius: 0 !important;
    border-top: none !important;
    min-height: 0 !important;
  }

}

/* Fix teclado iOS/mobile: anula transiciones y transformaciones cuando el teclado está abierto */
.ia-panel-wrapper.keyboard-open {
  transition: none !important;
  transform: none !important;
}