
/* Nutria WooCommerce Chat - Estilos minimalistas */
/* Widget ocupa 100% del div padre, sin header, ultra limpio */

/* Estilos específicos para imágenes DENTRO del chat únicamente */
.nutria-chat-widget .nutria-message-content img,
.nutria-chat-widget .nutria-custom-greeting img {
    height: auto !important;
    max-width: 100% !important;
}

.nutria-chat-widget {
  width: 100%;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  margin: 20px 0;
}

.nutria-chat-widget * {
  box-sizing: border-box;
}

/* Contenedor principal del chat (sin header) */
.nutria-chat-container {
  display: flex !important;
  flex-direction: column;
  height: auto;
  min-height: 100px;
  max-height: 450px;
}

/* Título introductorio */
.nutria-chat-intro {
  padding: 16px 20px 8px 20px;
  background: white;
}

.nutria-chat-intro p {
  margin: 0;
  font-size: 19px;
  font-weight: 500;
  color: #336dca;
  text-align: center;
  line-height: 1.4;
}

.nutria-chat-subtitle p {
  margin: 0;
  font-size: 15px;
  font-weight: 400;
  color: #6b7280;
  text-align: center;
  line-height: 1.4;
  margin-top: 4px;
}

.nutria-chat-subtitle {
  text-align: center;
  padding: 0 20px 12px 20px;
}

/* Header personalizable con avatar */
.nutria-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
}

.nutria-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  display: none; /* Hidden by default, shown when customization is applied */
  border: 2px solid #336dca;
}

.nutria-chat-title-section {
  flex: 1;
  text-align: center;
}

/* Footer "Powered by Nutria" */
.nutria-powered-by-footer {
  padding: 8px 20px;
  text-align: center;
  border-top: 1px solid #e5e7eb;
  background-color: #f9fafb;
  margin-top: auto;
}

.nutria-powered-by-footer small {
  color: #6b7280;
  font-size: 11px;
  font-weight: 400;
  text-decoration: none;
}

/* Enlace destacado en el footer "Powered by Nutria" */
.nutria-powered-link {
  color: var(--wp--preset--color--primary) !important;
  text-decoration: none !important;
  font-weight: bold;
  transition: color 0.2s;
}
.nutria-powered-link:hover {
  color: #204d96 !important;
}

/* Saludo personalizable */
.nutria-custom-greeting {
  padding: 0 20px 16px 20px;
  text-align: center;
  background: white;
}

.nutria-custom-greeting p {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: #336dca;
  line-height: 1.4;
}

.nutria-mini-description {
  margin-top: 8px;
  padding: 10px;
  background: #f8fafc;
  border-radius: 8px;
  border-left: 3px solid #336dca;
}

.nutria-mini-description p {
  margin: 0;
  font-size: 13px;
  font-weight: 400;
  color: #64748b;
  line-height: 1.4;
  text-align: left;
}

/* Tarjetas predefinidas ultra minimalistas */
.nutria-predefined-cards {
  padding: 12px 20px 16px 20px;
  background: white;
}

.nutria-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nutria-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  line-height: 1.4;
  width: 100%;
  box-sizing: border-box;
}

.nutria-card:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.nutria-card:active {
  transform: translateY(0);
}

/* Área de mensajes */
.nutria-chat-messages {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
  max-height: 300px;
  background: white;
}

.nutria-chat-messages:empty {
  display: none;
}

/* Mensajes individuales */
.nutria-message {
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.nutria-message.user {
  flex-direction: row-reverse;
}

.nutria-message-avatar .nutria-thinking-avatar {
    font-size: 12px;
    margin-top: 0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.nutria-message.user .nutria-message-avatar {
  display: none;
}

.nutria-message-content {
  background: #f8fafc;
  padding: 0px 12px;
  border-radius: 18px;
  max-width: 75%;
  font-size: 14px;
  line-height: 1.5;
  color: #334155;
}

.nutria-message.user .nutria-message-content {
  background: #3b82f6;
  color: white;
}

.nutria-message.assistant .nutria-message-content {
  background: #f8fafc;
  color: #334155;
}

/* Enlaces en mensajes */
.nutria-message-content a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(0, 0, 0, 0.3);
}

.nutria-message.user .nutria-message-content a {
  text-decoration-color: rgba(255, 255, 255, 0.5);
}

.nutria-message.assistant .nutria-message-content a {
  color: #3b82f6;
  text-decoration-color: rgba(59, 130, 246, 0.3);
}

.nutria-message-content strong {
  font-weight: 600;
}

.nutria-message-content em {
  font-style: italic;
}

/* Código inline */
.nutria-message-content code {
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.9em;
}

.nutria-message.user .nutria-message-content code {
  background: rgba(255, 255, 255, 0.2);
}

/* Listas */
.nutria-message-content ul {
  margin: 8px 0;
  padding-left: 20px;
}

.nutria-message-content li {
  margin: 4px 0;
  line-height: 1.4;
}

/* Mensaje de "pensando" */
.nutria-thinking {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.nutria-thinking-content {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  padding: 12px 16px;
  border-radius: 18px;
  max-width: 75%;
  font-size: 14px;
  color: #64748b;
}

.nutria-thinking-dots {
  display: flex;
  gap: 3px;
}

.nutria-thinking-dot {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: thinking 1.4s infinite both;
}

.nutria-thinking-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.nutria-thinking-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes thinking {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Contenedor del input minimalista */
.nutria-chat-input-container {
  padding: 16px 20px 20px 20px;
  background: white;
  border-top: 1px solid #f1f5f9;
}

.nutria-chat-form {
  width: 100%;
}

.nutria-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 25px;
  overflow: hidden;
  transition: all 0.2s ease;
}

.nutria-input-wrapper:focus-within {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.08);
  background: #ffffff;
}

.nutria-chat-input {
  flex: 1 !important;
  border: none !important;
  outline: none !important;
  padding: 14px 18px !important;
  font-size: 14px !important;
  background: transparent;
  color: #1e293b !important;
  font-family: inherit !important;
}

.nutria-chat-input::placeholder {
  color: #94a3b8;
}

.nutria-send-button {
  background: #3b82f6;
  padding: 5px !important;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  margin: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  color: white;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}

.nutria-send-button:hover {
  background: #2563eb;
  transform: scale(1.05);
  box-shadow: 0 3px 12px rgba(59, 130, 246, 0.35);
}

.nutria-send-button:active {
  transform: scale(0.95);
}

.nutria-send-button:disabled {
  background: #d1d5db !important;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: none !important;
}

.nutria-send-icon {
  width: 18px;
  height: 18px;
}

/* Efecto de escritura */
.nutria-typing {
  border-right: 2px solid #3b82f6;
  animation: blink 1s infinite;
}

/* Cursor de escritura mejorado */
.nutria-typing-cursor {
  color: #3b82f6;
  font-weight: bold;
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 50% { border-color: transparent; }
  51%, 100% { border-color: #3b82f6; }
}

/* Estados deshabilitados durante procesamiento */
.nutria-chat-input:disabled {
  background: #f1f5f9 !important;
  color: #94a3b8 !important;
  cursor: not-allowed !important;
}

/* Regla de máxima especificidad para logos - debe sobrescribir cualquier estilo de WooCommerce */
.woocommerce .nutria-chat-widget .nutria-message-avatar img.logo-img,
.woocommerce-page .nutria-chat-widget .nutria-message-avatar img.logo-img,
.woocommerce .nutria-chat-widget .nutria-thinking-avatar img.logo-img,
.woocommerce-page .nutria-chat-widget .nutria-thinking-avatar img.logo-img,
.nutria-chat-widget .nutria-message-avatar img[alt="Nutria"],
.nutria-chat-widget .nutria-thinking-avatar img[alt="Nutria"] {
    border-radius: 50% !important;
    object-fit: cover !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    position: static !important;
    float: none !important;
    width: 40px;
    height: 40px;
}

/* Contenedores de avatar cuando contienen imágenes */
.nutria-chat-widget .nutria-message-avatar:has(img),
.nutria-chat-widget .nutria-thinking-avatar:has(img) {
    padding: 0 !important;
    margin: 0 !important;
    margin-top: 3px !important;
    overflow: hidden !important;
}

/* Responsivo - Mobile */
@media (max-width: 768px) {
  .nutria-chat-widget {
    border-radius: 8px;
    margin: 10px 0;
  }
  
  .nutria-chat-intro {
    padding: 12px 16px 6px 16px;
  }
  
  .nutria-chat-intro p {
    font-size: 14px;
  }
  
  .nutria-chat-subtitle {
    padding: 0 16px 8px 16px;
  }
  
  .nutria-tips-btn {
    font-size: 1rem;
    padding: 0.6rem 1.1rem;
  }
  
  .nutria-predefined-cards {
    padding: 8px 16px 12px 16px;
  }
  
  .nutria-card {
    padding: 10px 16px;
    font-size: 13px;
    border-radius: 16px;
  }
  
  .nutria-chat-messages {
    padding: 0px 16px;
    max-height: 250px;
  }
  
  .nutria-message-content {
    font-size: 13px;
    padding: 10px 14px;
    max-width: 85%;
  }
  
  .nutria-chat-input-container {
    padding: 12px 16px 16px 16px;
  }
  
  .nutria-chat-input {
    padding: 12px 16px;
    font-size: 13px;
  }
  
  .nutria-send-button {
    width: 36px;
    height: 36px;
  }
  
  .nutria-send-icon {
    width: 16px;
    height: 16px;
  }
}

/* Scroll personalizado */
.nutria-chat-messages::-webkit-scrollbar {
  width: 6px;
}

.nutria-chat-messages::-webkit-scrollbar-track {
  background: #f8fafc;
  border-radius: 3px;
}

.nutria-chat-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.nutria-chat-messages::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Accesibilidad */
.nutria-card:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.nutria-send-button:focus {
  outline: 2px solid #1d4ed8;
  outline-offset: 2px;
}

/* Fallback para cuando no hay logo */
.nutria-chat-widget .nutria-message-avatar,
.nutria-chat-widget .nutria-thinking-avatar {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-weight: 600 !important;
    color: #336dca !important;
    background: #f8fafc !important;
    border-radius: 50% !important;
    font-size: 12px !important;
    line-height: 1 !important;
    flex-shrink: 0 !important;
}

/* ==============================================
   CONSEJOS/TIPS MODAL
   ============================================== */

/* Botón de consejos en el subtítulo */
.nutria-tips-btn {
  margin: 8px auto 0 auto;
  display: block;
  background: #217ef0;
  color: #ededed;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  padding: 0.7rem 1.3rem;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 2px 8px #ffe06644;
  transition: background 0.2s;
}

.nutria-tips-btn:hover {
  background: #ffe066;
}

/* Modal overlay */
.nutria-tips-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.18);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s;
}

.nutria-tips-modal-overlay.active {
  display: flex;
}

/* Modal popup */
.nutria-tips-popup {
  background: #fffbe7;
  border-left: 5px solid #ffd600;
  border-radius: 12px;
  box-shadow: 0 4px 24px #ffe06666;
  padding: 2rem 2.2rem 1.5rem 2rem;
  max-width: 430px;
  width: 95vw;
  color: #7a5d00;
  position: relative;
  animation: fadeIn 0.4s;
  max-height: 80vh;
  overflow-y: auto;
}

/* Botón cerrar */
.nutria-close-btn {
  position: absolute;
  top: 0.7rem;
  right: 1.1rem;
  background: none;
  border: none;
  font-size: 1.7rem;
  color: #b48a00;
  cursor: pointer;
  font-weight: bold;
  line-height: 1;
  transition: color 0.2s;
}

.nutria-close-btn:hover {
  color: #ff9800;
}

.nutria-close-btn:active,
.nutria-close-btn:focus {
  color: #ff9800 !important;
  background: none !important;
  box-shadow: none !important;
  outline: none !important;
}


/* Título del modal */
.nutria-tip-title {
  font-weight: bold;
  color: #b48a00;
  margin-bottom: 0.5rem;
  font-size: 1.08rem;
  display: flex;
  align-items: center;
  gap: 0.4em;
}

/* Lista de consejos - AISLAMIENTO TOTAL CON CLASES ESPECÍFICAS */
.nutria-modal-scoped .nutria-tips-list {
  margin: 0 !important;
  padding-left: 1.2em !important;
  margin-block-start: 0 !important;
  margin-block-end: 0 !important;
  -webkit-margin-before: 0 !important;
  -webkit-margin-after: 0 !important;
}

.nutria-modal-scoped .nutria-tip-item {
  margin-bottom: 0.6em !important;
  line-height: 1.5 !important;
  margin-block-start: 0 !important;
  margin-block-end: 0.6em !important;
  -webkit-margin-before: 0 !important;
  -webkit-margin-after: 0.6em !important;
}

/* Palabras clave destacadas */
.nutria-tip-keyword {
  background: #ffe066;
  color: #7a5d00;
  padding: 1px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.98em;
}

/* Texto en cursiva */
.nutria-tips-popup em {
  color: #b48a00;
  font-style: italic;
}

/* Texto en negrita */
.nutria-tips-popup strong {
  color: #b48a00;
}

/* Animación fadeIn */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Responsive para móvil */
@media (max-width: 768px) {
  .nutria-tips-popup {
    width: 95vw;
    max-height: 85vh;
    margin: 20px;
    padding: 1.5rem 1.8rem 1.2rem 1.5rem;
  }
  
  .nutria-tip-title {
    font-size: 1rem;
  }
  
  .nutria-modal-scoped .nutria-tip-item {
    font-size: 0.95rem;
    margin-bottom: 0.5em;
  }
  
  .nutria-close-btn {
    top: 0.5rem;
    right: 0.8rem;
    font-size: 1.5rem;
  }
}

/* Scroll personalizado para el contenido del modal */
.nutria-tips-popup::-webkit-scrollbar {
  width: 6px;
}

.nutria-tips-popup::-webkit-scrollbar-track {
  background: #fffbe7;
}

.nutria-tips-popup::-webkit-scrollbar-thumb {
  background: #ffd600;
  border-radius: 3px;
}

.nutria-tips-popup::-webkit-scrollbar-thumb:hover {
  background: #e6c200;
}

/* Estilos para el admin - Metabox del producto */
.nutria-product-settings {
    padding: 10px 0;
}

.nutria-product-settings label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

.nutria-product-settings textarea {
    width: 100%;
    min-height: 80px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.4;
    resize: vertical;
}

.nutria-product-settings textarea:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 1px #0073aa;
    outline: none;
}

.nutria-product-settings .description {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
    line-height: 1.3;
}

#nutria-chat-product-settings .inside {
    margin: 0;
    padding: 12px;
}

/* Estilos para botón de fuentes - Replicando estilo del frontend Vue */
.nutria-sources-button-container {
    margin: 0.8rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color, #e5e7eb);
}

.nutria-sources-btn {
    background: var(--surface-color, #f8fafc);
    border: 1px solid var(--primary-color, #3b82f6);
    color: var(--primary-color, #3b82f6);
    border-radius: 20px;
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-family: inherit;
    outline: none;
    font-weight: 500;
}

.nutria-sources-btn:hover {
    background: var(--primary-color, #3b82f6);
    color: var(--bg-color, #ffffff);
}

.nutria-sources-btn:active {
    transform: translateY(0px);
}

/* Estilos para modal de fuentes - Replicando estilo del frontend Vue */
.nutria-sources-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    animation: nutria-fadeIn 0.3s;
}

.nutria-sources-popup {
    background: var(--bg-color, #ffffff);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.2);
    padding: 2rem 2.2rem 1.5rem 2rem;
    max-width: 600px;
    width: 95vw;
    max-height: 80vh;
    overflow-y: auto;
    color: var(--text-color, #1f2937);
    position: relative;
    animation: nutria-fadeIn 0.4s;
}

.nutria-sources-close {
    position: absolute;
    top: 0.7rem;
    right: 1.1rem;
    background: none;
    border: none;
    font-size: 1.7rem;
    color: var(--primary-color, #3b82f6);
    cursor: pointer;
    font-weight: bold;
    line-height: 1;
    transition: color 0.2s;
    outline: none;
}
.nutria-sources-close:active {
  background: none !important;
}

.nutria-sources-close:hover {
    color: #ff9800;
}

.nutria-sources-title {
    font-weight: bold;
    color: var(--primary-color, #3b82f6);
    margin-bottom: 1rem;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.4em;
}

.nutria-sources-list {
    margin: 1rem 0;
}

.nutria-source-item {
    background: var(--surface-color, #f8fafc);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.nutria-source-item:hover {
    border-color: var(--primary-color, #3b82f6);
    box-shadow: 0 2px 8px rgba(33, 126, 240, 0.1);
}

.nutria-source-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.nutria-source-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color, #3b82f6);
    line-height: 1.3;
    flex: 1;
    margin-right: 0.5rem;
}

.nutria-source-year {
    background: var(--primary-color, #3b82f6);
    color: var(--bg-color, #ffffff);
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    flex-shrink: 0;
}

.nutria-source-details {
    color: var(--text-color, #4b5563);
    opacity: 0.8;
}

.nutria-source-authors {
    margin: 0.3rem 0;
    font-size: 0.9rem;
    font-style: italic;
}

.nutria-source-journal {
    margin: 0.3rem 0;
    font-size: 0.9rem;
    font-weight: 500;
}

.nutria-source-links {
    margin-top: 0.5rem;
}

.nutria-source-link {
    color: var(--primary-color, #3b82f6);
    font-size: 0.85rem;
    font-weight: 500;
}

.nutria-sources-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color, #e5e7eb);
    text-align: center;
    color: var(--text-color, #6b7280);
    opacity: 0.7;
}

.nutria-sources-footer em {
    font-size: 0.9rem;
}

@keyframes nutria-fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (max-width: 600px) {
    .nutria-sources-popup {
        padding: 1.5rem 1rem;
        max-width: 95vw;
    }
    
    .nutria-source-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .nutria-source-year {
        margin-top: 0.5rem;
        align-self: flex-start;
    }
    
    .nutria-sources-btn {
        font-size: 0.85rem;
        padding: 0.3rem 0.6rem;
    }
}
