/* chatbot_flotante.css - Estilos del chatbot flotante para Servicio Técnico Lima */
:root {
  --chatbot-primary: #1e40af;
  --chatbot-primary-hover: #1e3a8a;
  --chatbot-secondary: #8bc34a;
  --chatbot-secondary-hover: #689f38;
  --chatbot-bg: #ffffff;
  --chatbot-panel-bg: #f8fafc;
  --chatbot-border: #e2e8f0;
  --chatbot-text: #0f172a;
  --chatbot-text-secondary: #64748b;
  --chatbot-shadow: 0 10px 25px rgba(30, 64, 175, 0.15);
  --chatbot-shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.1);
  --chatbot-radius: 12px;
  --chatbot-panel-w: 380px;
  --chatbot-panel-h: 550px;
  --chatbot-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

/* Floating Action Button */
#chat-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-secondary));
  color: #fff;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--chatbot-shadow);
  z-index: 9999;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: var(--chatbot-font);
  user-select: none;
}

#chat-fab:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: var(--chatbot-shadow-lg);
}

#chat-fab:active {
  transform: translateY(0) scale(0.95);
}

#chat-fab.active {
  background: linear-gradient(135deg, #dc2626, #ef4444) !important;
  transform: rotate(45deg);
}

/* Panel principal */
#chat-panel {
  position: fixed;
  right: 24px;
  bottom: 100px;
  width: var(--chatbot-panel-w);
  height: var(--chatbot-panel-h);
  background: var(--chatbot-bg);
  border-radius: var(--chatbot-radius);
  box-shadow: var(--chatbot-shadow-lg);
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  overflow: hidden;
  z-index: 9998;
  font-family: var(--chatbot-font);
  font-size: 14px;
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--chatbot-border);
}

#chat-panel.hidden {
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
}

/* Header del panel */
#chat-panel header {
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-secondary));
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#chat-panel header > div {
  flex: 1;
}

#chat-panel header strong {
  font-size: 16px;
  font-weight: 600;
  display: block;
  margin-bottom: 2px;
}

/* Área de mensajes */
#messages {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--chatbot-panel-bg);
  scrollbar-width: thin;
  scrollbar-color: var(--chatbot-border) transparent;
}

#messages::-webkit-scrollbar {
  width: 6px;
}

#messages::-webkit-scrollbar-track {
  background: transparent;
}

#messages::-webkit-scrollbar-thumb {
  background: var(--chatbot-border);
  border-radius: 3px;
}

#messages::-webkit-scrollbar-thumb:hover {
  background: var(--chatbot-text-secondary);
}

/* Mensajes */
.msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  line-height: 1.4;
  word-wrap: break-word;
  position: relative;
  animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msg.user {
  align-self: flex-end;
  background: var(--chatbot-secondary);
  color: white;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.msg.bot {
  align-self: flex-start;
  background: white;
  color: var(--chatbot-text);
  border: 1px solid var(--chatbot-border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.msg.thinking {
  opacity: 0.7;
  font-style: italic;
  background: #f1f5f9 !important;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 0.9; }
}

/* Controles */
#controls {
  display: flex;
  gap: 8px;
  padding: 16px;
  border-top: 1px solid var(--chatbot-border);
  background: var(--chatbot-bg);
}

#controls input[type="text"] {
  flex: 1;
  padding: 12px 16px;
  border-radius: 24px;
  border: 1px solid var(--chatbot-border);
  background: var(--chatbot-panel-bg);
  color: var(--chatbot-text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
}

#controls input[type="text"]:focus {
  border-color: var(--chatbot-primary);
  background: white;
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

#controls input[type="text"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Botones */
.btn {
  padding: 12px;
  border-radius: 50%;
  border: 1px solid var(--chatbot-border);
  background: white;
  color: var(--chatbot-text);
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  user-select: none;
}

.btn:hover {
  background: var(--chatbot-panel-bg);
  border-color: var(--chatbot-primary);
  transform: translateY(-1px);
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

#btn-voice {
  background: var(--chatbot-secondary);
  color: white;
  border-color: var(--chatbot-secondary);
}

#btn-voice:hover:not(:disabled) {
  background: var(--chatbot-secondary-hover);
  border-color: var(--chatbot-secondary-hover);
}

#btn-send {
  background: var(--chatbot-primary);
  color: white;
  border-color: var(--chatbot-primary);
}

#btn-send:hover:not(:disabled) {
  background: var(--chatbot-primary-hover);
  border-color: var(--chatbot-primary-hover);
}

#close-chat {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  width: 32px;
  height: 32px;
  font-size: 14px;
}

#close-chat:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
}

/* Estado y texto pequeño */
.small {
  font-size: 12px;
  color: var(--chatbot-text-secondary);
  line-height: 1.3;
}

#status {
  padding: 8px 16px;
  text-align: center;
  background: var(--chatbot-panel-bg);
  border-top: 1px solid var(--chatbot-border);
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Animaciones adicionales */
.dots::after {
  content: '';
  animation: dots 1.5s infinite;
}

@keyframes dots {
  0%, 20% { content: ''; }
  40% { content: '.'; }
  60% { content: '..'; }
  80%, 100% { content: '...'; }
}

/* Responsive design */
@media (max-width: 480px) {
  #chat-fab {
    right: 20px;
    bottom: 20px;
    width: 56px;
    height: 56px;
    font-size: 24px;
  }

  #chat-panel {
    right: 10px;
    left: 10px;
    width: calc(100vw - 20px);
    bottom: 90px;
    height: calc(100vh - 120px);
    max-height: 600px;
  }

  #controls {
    padding: 12px;
    gap: 6px;
  }

  #controls input[type="text"] {
    font-size: 16px; /* Evita zoom en iOS */
  }

  .msg {
    max-width: 90%;
    padding: 10px 14px;
  }
}

@media (max-width: 360px) {
  #chat-panel {
    height: calc(100vh - 100px);
  }
  
  .btn {
    width: 40px;
    height: 40px;
    font-size: 14px;
  }
}

/* Mejoras de accesibilidad */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --chatbot-bg: #1e293b;
    --chatbot-panel-bg: #0f172a;
    --chatbot-border: #334155;
    --chatbot-text: #f1f5f9;
    --chatbot-text-secondary: #94a3b8;
  }

  .msg.bot {
    background: #334155;
    border-color: #475569;
    color: var(--chatbot-text);
  }

  #controls input[type="text"] {
    background: #334155;
    color: var(--chatbot-text);
    border-color: #475569;
  }

  #controls input[type="text"]:focus {
    background: #475569;
  }

  .btn {
    background: #334155;
    color: var(--chatbot-text);
    border-color: #475569;
  }

  .btn:hover {
    background: #475569;
  }
}

/* Indicadores de estado especiales */
.listening-indicator {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 16px;
  height: 16px;
  background: #dc2626;
  border-radius: 50%;
  animation: pulse 1s infinite;
}

/* Tooltips mejorados */
.btn[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 1000;
  margin-bottom: 4px;
}

/* Focus visible para accesibilidad */
.btn:focus-visible,
#controls input:focus-visible {
  outline: 2px solid var(--chatbot-primary);
  outline-offset: 2px;
}

/* Estilos para timestamps */
.timestamp {
  font-size: 10px !important;
  opacity: 0.6 !important;
  margin-top: 4px !important;
  display: block !important;
}

/* Mejoras visuales adicionales */
#chat-panel header .small {
  opacity: 0.9;
  font-weight: 400;
}

.msg.user::after,
.msg.bot::after {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
}

.msg.user::after {
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-left-color: var(--chatbot-secondary);
}

.msg.bot::after {
  left: -7px;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: white;
}