/* ===========================================================
   SYSTEMINFORMATIC - BÚSQUEDA MEJORADA v2
   Estilos adicionales para los resultados enriquecidos
   =========================================================== */

/* === Highlighting de términos === */
.py1-hl {
  background: rgba(79, 195, 247, 0.25);
  color: #4fc3f7;
  padding: 0 2px;
  border-radius: 2px;
  font-style: normal;
}

/* === Título con precio === */
.py1-sr-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.py1-sr-price {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  color: #00e676;
  background: rgba(0, 230, 118, 0.12);
  padding: 1px 8px;
  border-radius: 6px;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

.py1-search-result-item:hover .py1-sr-price {
  background: rgba(0, 230, 118, 0.2);
  color: #69f0ae;
}

/* === Cabecera de categoría === */
.py1-sr-cat-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--cat-bg, #4fc3f7);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: 'Inter', sans-serif;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-top: 4px;
}

.py1-sr-cat-header:first-child {
  margin-top: 0;
}

.py1-sr-cat-icon {
  font-size: 12px;
  line-height: 1;
}

/* === Resultados con hover mejorado === */
.py1-search-result-item {
  position: relative;
  padding: 10px 16px;
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
}

.py1-search-result-item:hover,
.py1-search-result-item.highlighted {
  border-left-color: #4fc3f7;
  background: rgba(79, 195, 247, 0.08);
}

.py1-search-result-item.highlighted {
  background: rgba(79, 195, 247, 0.12);
}

/* === Footer de resultados === */
.py1-sr-footer {
  padding: 10px 16px;
  text-align: center;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  font-family: 'Inter', sans-serif;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.py1-sr-footer a {
  color: #4fc3f7;
  text-decoration: none;
  font-weight: 600;
}

.py1-sr-footer a:hover {
  color: #00e5ff;
  text-decoration: underline;
}

/* === No results mejorado === */
.py1-sr-noresults {
  padding: 24px 20px;
  text-align: center;
  font-family: 'Inter', sans-serif;
}

.py1-sr-noresults-icon {
  font-size: 32px;
  margin-bottom: 8px;
  opacity: 0.5;
}

.py1-sr-noresults-title {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: 12px;
  line-height: 1.5;
}

.py1-sr-noresults-title strong {
  color: rgba(255, 255, 255, 0.7);
}

.py1-sr-noresults-sub {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.35);
  margin-bottom: 8px;
}

.py1-sr-noresults-suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-bottom: 16px;
}

.py1-sr-suggestion-chip {
  display: inline-block;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  color: #4fc3f7;
  background: rgba(79, 195, 247, 0.1);
  border: 1px solid rgba(79, 195, 247, 0.15);
  border-radius: 20px;
  text-decoration: none;
  transition: all 0.2s;
  font-family: 'Inter', sans-serif;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.py1-sr-suggestion-chip:hover {
  background: rgba(79, 195, 247, 0.2);
  border-color: rgba(79, 195, 247, 0.3);
  color: #ffffff;
}

.py1-sr-noresults-cta {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.3);
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.py1-sr-noresults-cta a {
  color: #f1c232;
  text-decoration: none;
  font-weight: 600;
}

.py1-sr-noresults-cta a:hover {
  color: #ffd54f;
  text-decoration: underline;
}

/* === Scrollbar personalizada para los resultados === */
.py1-search-results::-webkit-scrollbar {
  width: 5px;
}

.py1-search-results::-webkit-scrollbar-track {
  background: transparent;
}

.py1-search-results::-webkit-scrollbar-thumb {
  background: rgba(79, 195, 247, 0.25);
  border-radius: 3px;
}

.py1-search-results::-webkit-scrollbar-thumb:hover {
  background: rgba(79, 195, 247, 0.4);
}

/* === Animación de carga suave al abrir resultados === */
.py1-search-results.open {
  animation: py1ResultsFadeIn 0.2s ease-out;
}

@keyframes py1ResultsFadeIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===========================================================
   SECCIÓN DE RESPUESTA IA
   =========================================================== */

.py1-ai-section {
  padding: 16px 16px 12px;
  border-bottom: 1px solid rgba(79, 195, 247, 0.12);
  background: linear-gradient(180deg, rgba(79, 195, 247, 0.04) 0%, transparent 100%);
}

.py1-ai-section.py1-ai-error {
  background: linear-gradient(180deg, rgba(255, 23, 68, 0.04) 0%, transparent 100%);
  border-bottom-color: rgba(255, 23, 68, 0.12);
}

.py1-ai-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.py1-ai-icon {
  font-size: 20px;
  line-height: 1;
}

.py1-ai-title {
  font-size: 13px;
  font-weight: 700;
  color: #4fc3f7;
  font-family: 'Inter', sans-serif;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.py1-ai-badge {
  font-size: 9px;
  font-weight: 700;
  color: #0a1628;
  background: #4fc3f7;
  padding: 1px 6px;
  border-radius: 8px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-family: 'Inter', sans-serif;
  margin-left: 4px;
}

.py1-ai-answer {
  font-size: 13px;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.85);
  font-family: 'Inter', sans-serif;
  font-weight: 400;
}

.py1-ai-answer p {
  margin: 0 0 8px;
}

.py1-ai-answer p:last-child {
  margin-bottom: 0;
}

.py1-ai-answer strong {
  color: #ffffff;
  font-weight: 600;
}

/* === Loading spinner === */
.py1-ai-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}

.py1-ai-loading span {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  font-family: 'Inter', sans-serif;
}

.py1-ai-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(79, 195, 247, 0.15);
  border-top-color: #4fc3f7;
  border-radius: 50%;
  animation: py1AiSpin 0.7s linear infinite;
  flex-shrink: 0;
}

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

/* === Fuentes consultadas === */
.py1-ai-sources {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.py1-ai-sources-title {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.3);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
  font-family: 'Inter', sans-serif;
}

.py1-ai-source-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.15s;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
}

.py1-ai-source-link:hover {
  background: rgba(79, 195, 247, 0.08);
  color: #4fc3f7;
}

.py1-ai-source-icon {
  font-size: 12px;
  flex-shrink: 0;
}

/* === CTA === */
.py1-ai-cta {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
  font-family: 'Inter', sans-serif;
  text-align: center;
}

.py1-ai-phone {
  color: #f1c232;
  text-decoration: none;
  font-weight: 700;
  display: inline-block;
  padding: 6px 14px;
  background: rgba(241, 194, 50, 0.08);
  border: 1px solid rgba(241, 194, 50, 0.15);
  border-radius: 8px;
  transition: all 0.2s;
}

.py1-ai-phone:hover {
  background: rgba(241, 194, 50, 0.15);
  border-color: rgba(241, 194, 50, 0.25);
  color: #ffd54f;
}

/* === Responsive: resultados adaptados a móvil === */
@media (max-width: 600px) {
  .py1-search-results {
    position: fixed;
    top: auto;
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-height: 50vh;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  }

  .py1-sr-price {
    font-size: 10px;
    padding: 1px 6px;
  }

  .py1-sr-title {
    font-size: 12px;
  }

  .py1-sr-desc {
    font-size: 10px;
  }
}

/* ===========================================================
   FLOATING CHAT WIDGET - ESTILO HEADER (dark + glass + cyan)
   =========================================================== */

/* Botón flotante */
#py1-chat-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(10,30,60,0.7);
  border: 2px solid rgba(79,195,247,0.6);
  box-shadow:
    0 0 18px rgba(79,195,247,0.25),
    0 0 40px rgba(79,195,247,0.1),
    0 8px 32px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 99999;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

#py1-chat-btn:hover {
  transform: scale(1.1);
  border-color: rgba(79,195,247,0.9);
  box-shadow:
    0 0 30px rgba(79,195,247,0.4),
    0 0 60px rgba(79,195,247,0.2),
    0 8px 32px rgba(0,0,0,0.3);
}

#py1-chat-btn.hidden {
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
}

.py1-chat-btn-icon {
  font-size: 28px;
  line-height: 1;
  filter: drop-shadow(0 0 6px rgba(79,195,247,0.4));
}

/* Panel flotante - glass oscuro */
#py1-chat-panel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 540px;
  max-height: calc(100vh - 160px);
  background: rgba(10,22,40,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(79,195,247,0.15);
  border-radius: 20px;
  box-shadow:
    0 20px 60px rgba(0,0,0,0.5),
    0 0 40px rgba(79,195,247,0.08);
  z-index: 99998;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transform-origin: bottom right;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  overflow: hidden;
}

#py1-chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header oscuro con línea cyan */
.py1-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(10,30,60,0.6);
  border-bottom: 1px solid rgba(79,195,247,0.12);
  flex-shrink: 0;
}

.py1-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.py1-chat-header-icon img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(79,195,247,0.3);
  box-shadow: 0 0 12px rgba(79,195,247,0.15);
}

.py1-chat-header-title {
  font-size: 15px;
  font-weight: 700;
  color: #4fc3f7;
  font-family: 'Inter', sans-serif;
  text-shadow: 0 0 20px rgba(79,195,247,0.15);
}

.py1-chat-header-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  font-family: 'Inter', sans-serif;
  font-weight: 500;
}

.py1-chat-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.3);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s;
  font-family: 'Inter', sans-serif;
}

.py1-chat-close:hover {
  color: rgba(255,255,255,0.8);
  background: rgba(79,195,247,0.1);
}

/* Messages area */
.py1-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: transparent;
}

.py1-chat-messages::-webkit-scrollbar {
  width: 4px;
}

.py1-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.py1-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(79,195,247,0.2);
  border-radius: 2px;
}

.py1-chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(79,195,247,0.35);
}

/* Mensajes - SIN bocadillos, solo texto */
.py1-chat-msg {
  display: flex;
  animation: py1ChatFadeIn 0.25s ease-out;
  line-height: 1.6;
}

.py1-chat-msg-user {
  justify-content: flex-end;
}

.py1-chat-msg-ai {
  justify-content: flex-start;
}

.py1-chat-msg-bubble {
  max-width: 88%;
  font-size: 13.5px;
  line-height: 1.65;
  font-family: 'Inter', sans-serif;
  font-weight: 400;
}

/* Mensaje del usuario: solo texto a la derecha, sin fondo, sin bocadillo */
.py1-chat-msg-user .py1-chat-msg-bubble {
  background: transparent;
  color: #4fc3f7;
  padding: 0;
  border-radius: 0;
  text-align: right;
  font-weight: 500;
}

/* Mensaje del asistente IA: solo texto a la izquierda, sin bocadillo */
.py1-chat-msg-ai .py1-chat-msg-bubble {
  background: transparent;
  color: rgba(255,255,255,0.9);
  padding: 0;
  border-radius: 0;
}

.py1-chat-msg-ai .py1-chat-msg-bubble p {
  margin: 0 0 10px;
}

.py1-chat-msg-ai .py1-chat-msg-bubble p:last-child {
  margin-bottom: 0;
}

.py1-chat-msg-ai .py1-chat-msg-bubble strong {
  color: #ffffff;
  font-weight: 600;
}

.py1-chat-msg-ai .py1-chat-msg-bubble em {
  color: #4fc3f7;
  font-style: normal;
  font-weight: 600;
}

.py1-chat-msg-ai .py1-chat-msg-bubble code {
  background: rgba(79,195,247,0.1);
  color: #4fc3f7;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'Fira Code', monospace;
}

/* Typing loader - inline sin bocadillo */
.py1-chat-loader-bubble {
  padding: 6px 0 !important;
  background: transparent !important;
}

.py1-chat-loader {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 0;
}

.py1-chat-loader span {
  width: 8px;
  height: 8px;
  background: rgba(79,195,247,0.5);
  border-radius: 50%;
  display: inline-block;
  animation: py1ChatBounce 1.2s ease-in-out infinite;
}

.py1-chat-loader span:nth-child(2) {
  animation-delay: 0.2s;
}

.py1-chat-loader span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes py1ChatBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Sources - enlaces sutiles */
.py1-chat-sources {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(79,195,247,0.1);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.py1-chat-source-link {
  font-size: 11.5px;
  color: rgba(79,195,247,0.6);
  text-decoration: none;
  padding: 2px 0;
  font-weight: 500;
  transition: all 0.15s;
  font-family: 'Inter', sans-serif;
}

.py1-chat-source-link:hover {
  color: #4fc3f7;
  padding-left: 4px;
}

/* Input area - como la caja de búsqueda del header */
.py1-chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid rgba(79,195,247,0.1);
  background: rgba(10,22,40,0.5);
  flex-shrink: 0;
}

.py1-chat-input {
  flex: 1;
  height: 42px;
  padding: 0 16px 0 20px;
  border: 2px solid rgba(79,195,247,0.4);
  border-radius: 40px;
  background: rgba(10,30,60,0.5);
  color: rgba(255,255,255,0.9);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  outline: none;
  transition: all 0.3s ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow:
    0 0 12px rgba(79,195,247,0.15),
    0 0 30px rgba(79,195,247,0.05),
    inset 0 1px 0 rgba(255,255,255,0.06);
  letter-spacing: 0.2px;
}

.py1-chat-input::placeholder {
  color: rgba(255,255,255,0.3);
  font-weight: 400;
  font-size: 12.5px;
  letter-spacing: 0.3px;
}

.py1-chat-input:focus {
  border-color: rgba(79,195,247,0.8);
  background: rgba(10,30,60,0.6);
  box-shadow:
    0 0 24px rgba(79,195,247,0.3),
    0 0 50px rgba(79,195,247,0.1),
    inset 0 0 20px rgba(79,195,247,0.05);
}

.py1-chat-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid rgba(79,195,247,0.5);
  background: rgba(10,30,60,0.5);
  color: #4fc3f7;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  flex-shrink: 0;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow:
    0 0 12px rgba(79,195,247,0.15),
    inset 0 1px 0 rgba(255,255,255,0.06);
}

.py1-chat-send:hover {
  background: rgba(79,195,247,0.15);
  border-color: rgba(79,195,247,0.8);
  transform: scale(1.05);
  box-shadow:
    0 0 24px rgba(79,195,247,0.3),
    inset 0 1px 0 rgba(255,255,255,0.08);
}

.py1-chat-send:active {
  transform: scale(0.95);
}

/* Animación de entrada de mensajes */
@keyframes py1ChatFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive: chat en móvil */
@media (max-width: 768px) {
  #py1-chat-btn {
    display: none !important;
  }
}

@media (max-width: 600px) {
  #py1-chat-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 80vh;
    max-height: 80vh;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    background: rgba(10,22,40,0.96);
  }
  
  #py1-chat-panel.open {
    transform: translateY(0);
  }
  
  #py1-chat-btn {
    bottom: 16px;
    right: 16px;
    width: 54px;
    height: 54px;
  }
  
  .py1-chat-btn-icon {
    font-size: 24px;
  }
}
