/* css/semantic-search.css — Búsqueda Semántica Vectorial en Recursos */

.semantic-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 860px;
  min-width: 0;
  margin: 0 auto;
  padding: 1.25rem 1rem calc(6rem + env(safe-area-inset-bottom, 24px));
  box-sizing: border-box;
  overflow-x: hidden;
}

/* ─── Cabecera y Caja de Búsqueda ─── */
.semantic-header-box {
  margin-bottom: 1.25rem;
  text-align: center;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.semantic-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.4rem;
}

.semantic-title-icon {
  width: 22px;
  height: 22px;
  color: var(--accent, #a0722a);
}

.semantic-title {
  font-family: var(--font-title, 'Playfair Display', 'Georgia', serif);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-main, #2c2420);
  margin: 0;
  letter-spacing: -0.01em;
}

.semantic-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted, #7a6a60);
  margin: 0 auto 1.25rem;
  max-width: 560px;
  line-height: 1.5;
}

/* ─── Barra de Búsqueda Minimalista ─── */
.semantic-search-bar {
  display: flex;
  align-items: center;
  background: var(--bg-container, #ffffff);
  border: 1px solid var(--border, rgba(160, 114, 42, 0.25));
  border-radius: 999px;
  padding: 0.32rem 0.4rem 0.32rem 1.15rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.semantic-search-bar:focus-within {
  border-color: var(--accent, #a0722a);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #a0722a) 15%, transparent);
}

.semantic-input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  border: none;
  background: transparent;
  font-family: var(--font-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  font-size: 14.5px;
  color: var(--text-main, #2c2420);
  outline: none;
  padding: 0.45rem 0;
  box-sizing: border-box;
}

.semantic-input::placeholder {
  color: var(--text-muted, #9ca3af);
  font-size: 14px;
}

.semantic-btn-search {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--accent, #a0722a);
  color: #ffffff;
  border: none;
  border-radius: 999px;
  padding: 0.52rem 1.15rem;
  font-family: var(--font-ui, sans-serif);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 2px 6px color-mix(in srgb, var(--accent, #a0722a) 25%, transparent);
  transition: all 0.18s ease;
}

.semantic-btn-search:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.semantic-btn-search:active {
  transform: translateY(0);
}

.semantic-btn-search svg {
  width: 15px;
  height: 15px;
}

/* ─── Pestañas de Resultados Dual (Píldoras Elegantes) ─── */
.semantic-tabs-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 1.25rem 0 0.9rem;
  padding: 0.25rem;
  background: color-mix(in srgb, var(--border, #d1d5db) 28%, transparent);
  border-radius: 12px;
  width: fit-content;
  max-width: 100%;
  box-sizing: border-box;
  flex-wrap: wrap;
}

.semantic-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: transparent;
  border: none;
  border-radius: 9px;
  padding: 0.42rem 0.85rem;
  font-family: var(--font-ui, sans-serif);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted, #6b7280);
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.semantic-tab-btn:hover:not(.active) {
  color: var(--text-main, #1f2937);
  background: rgba(255, 255, 255, 0.4);
}

.semantic-tab-btn.active {
  color: var(--accent, #a0722a);
  background: var(--bg-container, #ffffff);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.semantic-tab-btn svg {
  width: 15px;
  height: 15px;
}

.semantic-tab-count {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-muted, #6b7280) 15%, transparent);
  color: inherit;
}

.semantic-tab-btn.active .semantic-tab-count {
  background: color-mix(in srgb, var(--accent, #a0722a) 15%, transparent);
  color: var(--accent, #a0722a);
}

/* ─── Barra de Filtros Minimalista y Pulida ─── */
.semantic-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.75rem;
  background: var(--bg-container, #ffffff);
  border: 1px solid var(--border, rgba(160, 114, 42, 0.18));
  border-radius: 12px;
  padding: 0.45rem 0.75rem;
  margin-bottom: 1.15rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.semantic-filter-group {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1 1 180px;
  min-width: 0;
  box-sizing: border-box;
}

.semantic-filter-group.shrink-0 {
  flex: 0 0 auto;
}

/* Selector de tipo en píldoras */
.semantic-type-pills {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  background: var(--bg-filters, #f9f6f0);
  padding: 0.18rem;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(160, 114, 42, 0.18));
  flex-shrink: 0;
}

.semantic-type-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.55rem;
  font-family: var(--font-ui, sans-serif);
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted, #7a6a60);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.semantic-type-btn svg {
  width: 12px;
  height: 12px;
}

.semantic-type-btn:hover:not(.active) {
  color: var(--text-main, #2c2420);
  background: rgba(255, 255, 255, 0.5);
}

.semantic-type-btn.active {
  background: var(--bg-container, #ffffff);
  color: var(--accent, #a0722a);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.semantic-filter-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted, #7a6a60);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.semantic-filter-label svg {
  width: 13px;
  height: 13px;
  color: var(--accent, #a0722a);
}

.semantic-filter-select-wrap {
  position: relative;
  flex: 1;
  min-width: 100px;
  box-sizing: border-box;
}

.semantic-filter-select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 100%;
  padding: 0.38rem 1.6rem 0.38rem 0.65rem;
  font-family: var(--font-ui, sans-serif);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-main, #2c2420);
  background: var(--bg-filters, #f9f6f0);
  border: 1px solid var(--border, rgba(160, 114, 42, 0.2));
  border-radius: 8px;
  outline: none;
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  box-sizing: border-box;
  transition: all 0.18s ease;
}

.semantic-filter-select:hover {
  border-color: var(--accent, #a0722a);
  background: var(--bg-container, #ffffff);
}

.semantic-filter-select:focus {
  border-color: var(--accent, #a0722a);
  background: var(--bg-container, #ffffff);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent, #a0722a) 15%, transparent);
}

.semantic-select-arrow {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  width: 11px;
  height: 12px;
  color: var(--text-muted, #7a6a60);
}

.semantic-filter-reset {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.7rem;
  font-family: var(--font-ui, sans-serif);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted, #7a6a60);
  background: transparent;
  border: 1px solid var(--border, rgba(160, 114, 42, 0.2));
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: auto;
}

.semantic-filter-reset:hover {
  color: #b91c1c;
  border-color: #fca5a5;
  background: rgba(239, 68, 68, 0.06);
}

.semantic-filter-reset svg {
  width: 12px;
  height: 12px;
}

/* ─── Listado y Tarjetas Estilo Clásico/Editorial ─── */
.semantic-results-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.semantic-card {
  background: var(--bg-container, #ffffff);
  border: 1px solid var(--border, rgba(160, 114, 42, 0.16));
  border-radius: 14px;
  padding: 1.15rem 1.25rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.025);
  transition: all 0.18s ease;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

.semantic-card:hover {
  transform: translateY(-1.5px);
  border-color: color-mix(in srgb, var(--accent, #a0722a) 45%, transparent);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05);
}

.semantic-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.7rem;
  gap: 0.75rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.semantic-author-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  flex: 1 1 auto;
}

.semantic-author-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent, #a0722a) 14%, transparent);
  color: var(--accent, #a0722a);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-title, serif);
  font-size: 0.78rem;
  font-weight: 700;
  flex-shrink: 0;
  border: 1px solid color-mix(in srgb, var(--accent, #a0722a) 25%, transparent);
}

.semantic-author-name {
  font-family: var(--font-title, 'Playfair Display', 'Georgia', serif);
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-main, #2c2420);
  min-width: 0;
  word-break: break-word;
}

.book-scope-badge {
  display: inline-block;
  font-family: var(--font-ui, sans-serif);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent, #a0722a) 12%, transparent);
  color: var(--accent, #a0722a);
  margin-left: 0.4rem;
  vertical-align: middle;
  white-space: nowrap;
}

.semantic-ref-sub {
  font-size: 0.8rem;
  color: var(--text-muted, #7a6a60);
  display: block;
  margin-top: 2px;
  word-break: break-word;
}

.semantic-affinity-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.1);
  color: #047857;
  flex-shrink: 0;
  white-space: nowrap;
}

.semantic-affinity-badge svg {
  width: 11px;
  height: 11px;
}

.semantic-snippet {
  font-family: var(--font-body, 'Georgia', serif);
  font-size: 0.94rem;
  line-height: 1.62;
  color: var(--text-main, #2c2420);
  margin-bottom: 0.85rem;
  overflow-wrap: break-word;
  word-break: break-word;
}

.semantic-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--border, rgba(160, 114, 42, 0.12));
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.semantic-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  background: transparent;
  border: 1px solid var(--border, rgba(160, 114, 42, 0.24));
  border-radius: 7px;
  padding: 0.4rem 0.75rem;
  font-family: var(--font-ui, sans-serif);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main, #2c2420);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.semantic-action-btn:hover {
  background: var(--accent, #a0722a);
  color: #ffffff;
  border-color: var(--accent, #a0722a);
}

.semantic-action-btn svg {
  width: 13px;
  height: 13px;
}

/* ─── Estados Vacíos y Carga ─── */
.semantic-loading-box,
.semantic-empty-box {
  text-align: center;
  padding: 3.5rem 1rem;
  color: var(--text-muted, #7a6a60);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.semantic-spinner {
  width: 32px;
  height: 32px;
  animation: spin 0.9s linear infinite;
  color: var(--accent, #a0722a);
  margin: 0 auto 1rem;
}

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

/* ─── Theological Alignment Loader ─── */
.semantic-theological-loader-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3.5rem 1.5rem;
  text-align: center;
}

.semantic-theological-canvas-wrap {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 0 auto 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.semantic-theological-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Anillos orbitales concéntricos */
.theo-ring {
  fill: none;
  stroke: var(--accent, #a0722a);
}

.theo-ring-inner {
  stroke-width: 1;
  stroke-dasharray: 4 6;
  opacity: 0.35;
  transform-origin: 0 0;
  animation: theoRotateReverse 24s linear infinite;
}

.theo-ring-outer {
  stroke-width: 1;
  stroke-dasharray: 2 6;
  opacity: 0.22;
  transform-origin: 0 0;
  animation: theoRotate 36s linear infinite;
}

/* Hilos de resonancia / alineación */
.theo-thread {
  stroke: var(--accent, #a0722a);
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
  stroke-linecap: round;
  opacity: 0.55;
  animation: theoFlowThread 2.2s linear infinite;
}

.theo-thread-n { animation-delay: 0s; }
.theo-thread-e { animation-delay: 0.55s; }
.theo-thread-s { animation-delay: 1.1s; }
.theo-thread-w { animation-delay: 1.65s; }

/* Nodos teológicos en órbita */
.theo-node-bg {
  fill: var(--bg-card, #fffaf3);
}

.theo-node-border {
  fill: none;
  stroke: var(--accent, #a0722a);
  stroke-width: 1.2;
}

.theo-node-icon {
  fill: none;
  stroke: var(--accent, #a0722a);
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theo-node-icon-line {
  stroke: var(--accent, #a0722a);
  stroke-width: 1.2;
  stroke-linecap: round;
}

.theo-node-group {
  animation: theoFloatNode 3.5s ease-in-out infinite alternate;
}

.theo-node-n { animation-delay: 0s; }
.theo-node-e { animation-delay: 0.9s; }
.theo-node-s { animation-delay: 1.8s; }
.theo-node-w { animation-delay: 2.7s; }

/* Libro Sagrado Central */
.theo-center-book {
  transform-origin: 0 0;
  animation: theoPulseBook 2.8s ease-in-out infinite alternate;
}

.theo-book-halo {
  fill: color-mix(in srgb, var(--accent, #a0722a) 12%, transparent);
  stroke: var(--accent, #a0722a);
  stroke-width: 1;
  stroke-opacity: 0.35;
}

.theo-book-pages {
  fill: var(--bg-card, #fffaf3);
  stroke: var(--accent, #a0722a);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.theo-book-spine {
  stroke: var(--accent, #a0722a);
  stroke-width: 1.5;
  stroke-linecap: round;
}

.theo-book-text {
  stroke: color-mix(in srgb, var(--accent, #a0722a) 60%, transparent);
  stroke-width: 1;
  stroke-linecap: round;
}

/* Textos de estado Teológico */
.semantic-theological-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 480px;
}

.semantic-theological-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.8rem;
  border-radius: 9999px;
  background: color-mix(in srgb, var(--accent, #a0722a) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent, #a0722a) 25%, transparent);
  font-size: 0.74rem;
  font-family: var(--font-title, serif);
  color: var(--accent, #a0722a);
  margin-bottom: 0.65rem;
  letter-spacing: 0.02em;
  font-weight: 600;
}

.theo-badge-sparkle {
  display: flex;
  align-items: center;
}

.theo-badge-sparkle svg {
  width: 12px;
  height: 12px;
  color: var(--accent, #a0722a);
}

.semantic-theological-title {
  font-family: var(--font-title, serif);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main, #2c2420);
  min-height: 1.6rem;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.semantic-theological-sub {
  font-size: 0.86rem;
  color: var(--text-muted, #7a6a60);
  margin-top: 0.35rem;
  line-height: 1.4;
}

/* Keyframes */
@keyframes theoRotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes theoRotateReverse {
  from { transform: rotate(360deg); }
  to { transform: rotate(0deg); }
}

@keyframes theoFlowThread {
  from { stroke-dashoffset: 16; }
  to { stroke-dashoffset: 0; }
}

@keyframes theoPulseBook {
  0% { transform: scale(0.96); filter: drop-shadow(0 0 2px rgba(160, 114, 42, 0.2)); }
  100% { transform: scale(1.06); filter: drop-shadow(0 0 8px rgba(212, 175, 55, 0.6)); }
}

@keyframes theoFloatNode {
  0% { transform: scale(0.95); }
  100% { transform: scale(1.08); }
}

.semantic-empty-icon {
  width: 40px;
  height: 40px;
  color: color-mix(in srgb, var(--accent, #a0722a) 40%, transparent);
  margin-bottom: 0.75rem;
}

.semantic-empty-title {
  font-family: var(--font-title, serif);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main, #2c2420);
  margin-bottom: 0.35rem;
}

.semantic-empty-desc {
  font-size: 0.88rem;
  color: var(--text-muted, #7a6a60);
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.5;
}

.semantic-btn-theologian {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.25rem;
  background: var(--accent, #a0722a);
  color: #ffffff;
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1.3rem;
  font-family: var(--font-ui, sans-serif);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent, #a0722a) 25%, transparent);
  transition: all 0.18s ease;
}

.semantic-btn-theologian:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.semantic-btn-theologian svg {
  width: 16px;
  height: 16px;
}

/* ─── Media Queries Responsivas ─── */
@media (max-width: 600px) {
  .semantic-container {
    padding: 1rem 0.65rem calc(140px + env(safe-area-inset-bottom, 32px));
  }
  .semantic-title {
    font-size: 1.25rem;
  }
  .semantic-subtitle {
    font-size: 0.82rem;
    margin-bottom: 1rem;
  }
  .semantic-search-bar {
    padding: 0.25rem 0.35rem 0.25rem 0.9rem;
  }
  .semantic-btn-search {
    padding: 0.45rem 0.85rem;
    font-size: 0.8rem;
  }
  .semantic-filter-group {
    flex: 1 1 100%;
  }
  .semantic-card {
    padding: 0.95rem 1rem;
  }
  .semantic-pagination {
    margin-top: 1.5rem;
    padding-top: 1rem;
    margin-bottom: 2.5rem;
    gap: 0.75rem;
  }
  .semantic-page-btn {
    padding: 0.55rem 0.95rem;
    font-size: 0.82rem;
  }
}

/* Aislamiento de selección */
body.semantic-active #mobileSelectionBar,
body.library-active #mobileSelectionBar,
body.dict-active #mobileSelectionBar,
body.atlas-active #mobileSelectionBar {
  display: none !important;
}

/* ─── Paginación Dinámica ─── */
.semantic-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  margin-bottom: 2rem;
  border-top: 1px solid var(--border, rgba(160, 114, 42, 0.15));
  width: 100%;
  box-sizing: border-box;
}

.semantic-page-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--bg-container, #ffffff);
  border: 1px solid var(--border, rgba(160, 114, 42, 0.3));
  border-radius: 999px;
  padding: 0.5rem 1.1rem;
  font-family: var(--font-ui, sans-serif);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main, #2c2420);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  transition: all 0.16s ease;
}

.semantic-page-btn:hover:not(:disabled) {
  background: var(--accent, #a0722a);
  color: #ffffff;
  border-color: var(--accent, #a0722a);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--accent, #a0722a) 25%, transparent);
  transform: translateY(-1px);
}

.semantic-page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.semantic-page-btn svg {
  width: 15px;
  height: 15px;
}

.semantic-page-info {
  font-family: var(--font-ui, sans-serif);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-muted, #7a6a60);
}

