/* ════════════════════════════════════════════════════════════
   TuriaTV Smart Search — Modal v2
   ════════════════════════════════════════════════════════════ */

/* ─── Scroll lock ─────────────────────────────────────────── */
body.ts-no-scroll { overflow: hidden; }

/* ─── Overlay ─────────────────────────────────────────────── */
.ts-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: oklch(0% 0 0 / 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: clamp(32px, 6vh, 72px);
  padding-inline: var(--page-padding, 16px);
  padding-bottom: 24px;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.ts-overlay[hidden] { display: none; }
.ts-overlay.is-open { opacity: 1; }

/* ─── Modal Panel ─────────────────────────────────────────── */
.ts-modal {
  background: var(--bg, #f9f7f4);
  border-radius: 12px;
  box-shadow:
    0 0 0 1px oklch(0% 0 0 / 0.06),
    0 20px 60px oklch(0% 0 0 / 0.18),
    0 4px 16px oklch(0% 0 0 / 0.1);
  width: 100%;
  max-width: 680px;
  max-height: calc(100vh - clamp(32px, 6vh, 72px) - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(-6px);
  transition: transform 0.18s ease-out;
}
.ts-overlay.is-open .ts-modal { transform: translateY(0); }

/* ─── Header — el input ES el header ─────────────────────── */
.ts-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 16px 18px 20px;
  flex-shrink: 0;
}

.ts-icon-search {
  color: var(--ink-muted, oklch(48% 0.01 260));
  flex-shrink: 0;
}


.ts-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-family: var(--font-sans, 'DM Sans', sans-serif);
  font-size: 17px;
  font-weight: 400;
  color: var(--ink, oklch(13% 0.01 260));
  outline: none;
  line-height: 1.4;
}
.ts-input::placeholder { color: var(--ink-muted, oklch(48% 0.01 260)); }
.ts-input::-webkit-search-cancel-button,
.ts-input::-webkit-search-decoration { -webkit-appearance: none; display: none; }

/* Header right side: shortcut hint + clear + close */
.ts-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ⌘K hint — se oculta cuando hay texto */
.ts-kbd {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 7px;
  background: var(--bg-subtle, #f2ede8);
  border: 1px solid var(--border, #e0dbd4);
  border-radius: 5px;
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  color: var(--ink-muted, oklch(48% 0.01 260));
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.ts-kbd.is-hidden { opacity: 0; }

/* Botón limpiar */
.ts-clear {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle, #f2ede8);
  border: none;
  border-radius: 50%;
  color: var(--ink-muted, oklch(48% 0.01 260));
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}
.ts-clear:hover {
  background: var(--border, #e0dbd4);
  color: var(--ink, oklch(13% 0.01 260));
}

/* Botón cerrar — pastilla "Esc" */
.ts-close {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0;
  flex-shrink: 0;
}
.ts-close-kbd {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  background: var(--bg-subtle, #f2ede8);
  border: 1px solid var(--border, #e0dbd4);
  border-radius: 5px;
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-muted, oklch(48% 0.01 260));
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  user-select: none;
  white-space: nowrap;
}
.ts-close:hover .ts-close-kbd {
  background: var(--border, #e0dbd4);
  color: var(--ink, oklch(13% 0.01 260));
}

/* ─── Separador header/body ───────────────────────────────── */
.ts-header-border {
  height: 1px;
  background: var(--border, #e0dbd4);
  flex-shrink: 0;
}

/* ─── Body / Scrollable ───────────────────────────────────── */
.ts-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border, #e0dbd4) transparent;
}
.ts-body::-webkit-scrollbar { width: 4px; }
.ts-body::-webkit-scrollbar-track { background: transparent; }
.ts-body::-webkit-scrollbar-thumb {
  background: var(--border, #e0dbd4);
  border-radius: 2px;
}

/* ─── Skeleton Loader ─────────────────────────────────────── */
.ts-skeleton-list {
  padding: 8px 0;
}

.ts-skeleton-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border, #e0dbd4);
}
.ts-skeleton-item:last-child { border-bottom: none; }

.ts-skel-thumb {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--bg-subtle, #f2ede8);
  overflow: hidden;
  position: relative;
}

.ts-skel-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.ts-skel-line {
  height: 10px;
  border-radius: 5px;
  background: var(--bg-subtle, #f2ede8);
  overflow: hidden;
  position: relative;
}
.ts-skel-line.w-40 { width: 40%; }
.ts-skel-line.w-75 { width: 75%; }
.ts-skel-line.w-90 { width: 90%; }
.ts-skel-line.w-55 { width: 55%; }

/* Shimmer */
.ts-skel-thumb::after,
.ts-skel-line::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    oklch(100% 0 0 / 0.55) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: ts-shimmer 1.4s infinite;
}

@keyframes ts-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

/* ─── Results header ──────────────────────────────────────── */
.ts-results-header {
  padding: 12px 20px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-muted, oklch(48% 0.01 260));
}

/* ─── Result Items ────────────────────────────────────────── */
.ts-results-list {
  padding: 4px 0;
}

.ts-result-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 20px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--border, #e0dbd4);
  transition: background 0.1s;
  outline: none;
  position: relative;
}
.ts-result-item:last-child { border-bottom: none; }

/* Left accent line on hover/selected */
.ts-result-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--accent, oklch(55% 0.22 25));
  opacity: 0;
  transform: scaleY(0.5);
  transition: opacity 0.12s, transform 0.12s;
}
.ts-result-item:hover::before,
.ts-result-item.is-selected::before {
  opacity: 1;
  transform: scaleY(1);
}

.ts-result-item:hover,
.ts-result-item.is-selected {
  background: var(--bg-subtle, #f2ede8);
}

.ts-result-item:focus-visible {
  outline: 2px solid var(--accent, oklch(55% 0.22 25));
  outline-offset: -2px;
}

/* Thumbnail — cuadrado, ratio fijo */
.ts-result-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--bg-subtle, #f2ede8);
  display: block;
}
.ts-no-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--border, #c8c0b8);
}

/* Result body */
.ts-result-body {
  flex: 1;
  min-width: 0;
}

.ts-result-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 5px;
}

.ts-result-cat {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent, oklch(55% 0.22 25));
  text-decoration: none;
}
.ts-result-cat:hover { text-decoration: underline; }

.ts-meta-dot {
  font-size: 10px;
  color: var(--border, #c8c0b8);
  line-height: 1;
}

.ts-result-date {
  font-size: 11px;
  color: var(--ink-muted, oklch(48% 0.01 260));
}

.ts-result-title {
  font-family: var(--font-sans, sans-serif);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--ink, oklch(13% 0.01 260));
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin: 0;
}

/* Flecha → aparece al hover */
.ts-result-arrow {
  flex-shrink: 0;
  color: var(--ink-muted, oklch(48% 0.01 260));
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.12s, transform 0.12s;
}
.ts-result-item:hover .ts-result-arrow,
.ts-result-item.is-selected .ts-result-arrow {
  opacity: 1;
  transform: translateX(0);
}

/* Highlight matches */
.ts-result-title mark {
  background: var(--accent-light, oklch(93% 0.04 25));
  color: var(--accent-dark, oklch(45% 0.20 25));
  border-radius: 2px;
  padding: 0 1px;
  font-style: normal;
}

/* ─── Section label (Municipios / Noticias) ───────────────── */
.ts-section-label {
  padding-top: 14px;
  border-top: 1px solid var(--border, #e0dbd4);
  margin-top: 4px;
}
.ts-results-list + .ts-section-label { margin-top: 0; }

/* ─── Municipality result item ────────────────────────────── */
.ts-muni-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent, oklch(55% 0.22 25));
  background: var(--accent-light, oklch(93% 0.04 25));
  border-radius: 6px;
}

.ts-muni-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent, oklch(55% 0.22 25));
}

/* ─── View All — CTA prominente ───────────────────────────── */
.ts-view-all {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 12px 16px 16px;
  padding: 11px 20px;
  background: var(--accent, oklch(55% 0.22 25));
  color: #fff;
  border-radius: 8px;
  font-family: var(--font-sans, sans-serif);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.12s, transform 0.1s;
}
.ts-view-all:hover {
  background: var(--accent-dark, oklch(45% 0.20 25));
  transform: translateY(-1px);
}
.ts-view-all:active { transform: translateY(0); }

.ts-view-all strong { font-weight: 700; }

.ts-view-all-arrow {
  display: flex;
  align-items: center;
  opacity: 0.8;
}

.ts-count {
  background: oklch(100% 0 0 / 0.2);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  min-width: 22px;
  text-align: center;
}

/* ─── Empty State ─────────────────────────────────────────── */
.ts-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px 44px;
  text-align: center;
  gap: 8px;
}
.ts-empty-icon { color: var(--border, #c8c0b8); margin-bottom: 4px; }
.ts-empty p { font-size: 15px; color: var(--ink, oklch(13% 0.01 260)); margin: 0; }
.ts-empty-hint { font-size: 13px !important; color: var(--ink-muted, oklch(48% 0.01 260)) !important; }

/* ─── Welcome Screen ──────────────────────────────────────── */
.ts-welcome {
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.ts-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-muted, oklch(48% 0.01 260));
  margin-bottom: 10px;
}

.ts-recents-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ts-recent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-sans, sans-serif);
  font-size: 14px;
  color: var(--ink, oklch(13% 0.01 260));
  transition: background 0.1s;
}
.ts-recent-item:hover { background: var(--bg-subtle, #f2ede8); }

.ts-recent-icon { color: var(--ink-muted, oklch(48% 0.01 260)); flex-shrink: 0; }

.ts-recent-text { flex: 1; text-align: left; }

/* Botón × individual por búsqueda reciente */
.ts-recent-delete {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 50%;
  color: var(--ink-muted, oklch(48% 0.01 260));
  opacity: 0;
  transition: opacity 0.12s, background 0.12s;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}
.ts-recent-item:hover .ts-recent-delete { opacity: 1; }
.ts-recent-delete:hover {
  background: var(--border, #e0dbd4);
  color: var(--ink, oklch(13% 0.01 260));
}

.ts-clear-recents {
  background: none;
  border: none;
  font-family: var(--font-sans, sans-serif);
  font-size: 11px;
  color: var(--ink-muted, oklch(48% 0.01 260));
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  transition: all 0.12s;
  font-weight: 500;
}
.ts-clear-recents:hover {
  color: var(--ink, oklch(13% 0.01 260));
  background: var(--bg-subtle, #f2ede8);
}

/* ─── Tags / Categorías ───────────────────────────────────── */
.ts-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.ts-tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  background: var(--bg-subtle, #f2ede8);
  border: 1px solid var(--border, #e0dbd4);
  border-radius: 20px;
  font-family: var(--font-sans, sans-serif);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink, oklch(13% 0.01 260));
  text-decoration: none;
  transition: all 0.12s;
}
.ts-tag:hover {
  background: var(--accent-light, oklch(93% 0.04 25));
  border-color: var(--accent, oklch(55% 0.22 25));
  color: var(--accent-dark, oklch(45% 0.20 25));
}
.ts-tag:focus-visible {
  outline: 2px solid var(--accent, oklch(55% 0.22 25));
  outline-offset: 2px;
}

/* ─── Welcome hint vacío ──────────────────────────────────── */
.ts-welcome-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 24px 24px;
  gap: 10px;
  text-align: center;
  color: var(--ink-muted, oklch(48% 0.01 260));
}
.ts-welcome-hint p { font-size: 15px; margin: 0; }

/* ─── Dark mode ───────────────────────────────────────────── */
[data-theme="dark"] .ts-overlay {
  background: oklch(0% 0 0 / 0.65);
}
[data-theme="dark"] .ts-modal {
  box-shadow:
    0 0 0 1px oklch(100% 0 0 / 0.08),
    0 24px 64px oklch(0% 0 0 / 0.55);
}
[data-theme="dark"] .ts-skel-thumb::after,
[data-theme="dark"] .ts-skel-line::after {
  background: linear-gradient(
    90deg,
    transparent 0%,
    oklch(100% 0 0 / 0.08) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: ts-shimmer 1.4s infinite;
}

/* ─── Mobile ──────────────────────────────────────────────── */
@media (max-width: 600px) {
  .ts-overlay {
    padding-top: 0;
    padding-inline: 0;
    align-items: flex-start;
  }
  .ts-modal {
    max-width: 100%;
    border-radius: 0 0 16px 16px;
    box-shadow: 0 8px 40px oklch(0% 0 0 / 0.22);
    max-height: 88vh;
    transform: translateY(-100%);
  }
  .ts-overlay.is-open .ts-modal { transform: translateY(0); }

  .ts-header { padding: 14px 14px 14px 16px; }
  .ts-input  { font-size: 16px; }
  .ts-kbd    { display: none; }

  .ts-result-item { padding: 10px 16px; }
  .ts-result-thumb { width: 48px; height: 48px; }
  .ts-result-title { font-size: 13px; }

  .ts-welcome { padding: 14px 16px 18px; }
  .ts-view-all { margin: 10px 12px 14px; }
}

@media (max-width: 380px) {
  .ts-result-thumb { display: none; }
  .ts-result-arrow { display: none; }
}

/* ─── Reduced motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .ts-overlay,
  .ts-modal,
  .ts-result-item,
  .ts-result-item::before,
  .ts-result-arrow { transition: none !important; }
  .ts-skel-thumb::after,
  .ts-skel-line::after { animation: none !important; }
}
