/* ============================================================================
   GIGI IA CHAT - Digno Homenaje
   Diseño Mejorado - Distribución Horizontal y Vertical Balanceada
   ============================================================================ */

:root {
  /* Paleta de colores profesional - Digno Homenaje */
  --gigi-negro: #2C5F4B;
  --gigi-negro-dark: #1a3d31;
  --gigi-crema: #F5E6E0;
  --gigi-crema-dark: #E8D5CC;
  --gigi-rosa: #C9A962;
  --gigi-rosa-dark: #b89220;
  --gigi-rosa-light: #F5D5DD;
  --gigi-white: #ffffff;
  --gigi-off-white: #FDFBF9;

  /* Gradientes elegantes */
  --gigi-gradient-header: linear-gradient(135deg, #2C5F4B 0%, #1a3d31 100%);
  --gigi-gradient-crema: linear-gradient(135deg, #F5E6E0 0%, #E8D5CC 100%);
  --gigi-gradient-rosa: linear-gradient(135deg, #C9A962 0%, #b89220 100%);
  --gigi-gradient-subtle: linear-gradient(135deg, rgba(245, 230, 224, 0.8) 0%, rgba(201, 169, 98, 0.6) 100%);

  /* Sombras refinadas */
  --gigi-shadow-sm: 0 2px 8px rgba(44, 95, 75, 0.08);
  --gigi-shadow-md: 0 8px 24px rgba(44, 95, 75, 0.12);
  --gigi-shadow-lg: 0 16px 48px rgba(44, 95, 75, 0.18);
  --gigi-shadow-rosa: 0 8px 32px rgba(201, 169, 98, 0.15);

  /* Bordes redondeados */
  --gigi-radius-sm: 12px;
  --gigi-radius-md: 18px;
  --gigi-radius-lg: 24px;

  /* Transiciones suaves */
  --gigi-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================================
   BOTÓN FLOTANTE PRINCIPAL
   ============================================================================ */
#gigi-widget-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#gigi-chat-button {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--gigi-gradient-header);
  border: 2px solid var(--gigi-crema);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--gigi-shadow-md), 0 0 0 4px rgba(245, 230, 224, 0.2);
  transition: var(--gigi-transition);
  position: relative;
  overflow: hidden;
}

#gigi-chat-button:hover {
  transform: scale(1.08);
  box-shadow: var(--gigi-shadow-lg), 0 0 0 6px rgba(245, 230, 224, 0.3);
  border-color: var(--gigi-rosa);
}

#gigi-chat-button:active {
  transform: scale(1.02);
}

/* Efecto de anillo animado */
#gigi-chat-button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: radial-gradient(circle, rgba(201, 169, 98, 0.3) 0%, transparent 70%);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  animation: gigiRipple 2.5s ease-out infinite;
}

@keyframes gigiRipple {
  0% {
    width: 0;
    height: 0;
    opacity: 0.6;
  }
  100% {
    width: 160px;
    height: 160px;
    opacity: 0;
  }
}

/* Icono del botón */
#gigi-chat-button svg {
  width: 28px;
  height: 28px;
  fill: var(--gigi-crema);
  position: relative;
  z-index: 2;
  transition: var(--gigi-transition);
}

#gigi-chat-button:hover svg {
  fill: var(--gigi-rosa);
}

/* Indicador "En línea" animado */
#gigi-chat-button::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 11px;
  height: 11px;
  background: var(--gigi-rosa);
  border: 2px solid var(--gigi-white);
  border-radius: 50%;
  z-index: 3;
  box-shadow: 0 0 10px rgba(201, 169, 98, 0.6);
  animation: gigiOnlinePulse 2s ease-in-out infinite;
}

@keyframes gigiOnlinePulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(201, 169, 98, 0.6);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(201, 169, 98, 0);
    transform: scale(1.12);
  }
}

/* ============================================================================
   VENTANA DEL CHAT
   ============================================================================ */
#gigi-chat-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  height: 580px;
  max-height: calc(100vh - 120px);
  max-width: calc(100vw - 48px);
  background: var(--gigi-white);
  border-radius: var(--gigi-radius-lg);
  box-shadow: var(--gigi-shadow-lg);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 999999;
  border: 1px solid rgba(245, 230, 224, 0.5);
}

#gigi-chat-window.open {
  display: flex;
  animation: gigiSlideIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes gigiSlideIn {
  from {
    opacity: 0;
    transform: translateY(25px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ============================================================================
   HEADER DEL CHAT - Diseño Horizontal Mejorado
   ============================================================================ */
.gigi-header {
  background: var(--gigi-gradient-header);
  color: var(--gigi-white);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: relative;
  border-bottom: 1px solid rgba(245, 230, 224, 0.15);
}

.gigi-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 50px;
  height: 2px;
  background: var(--gigi-gradient-rosa);
  border-radius: 2px;
}

.gigi-header-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

/* Avatar de Gigi */
.gigi-avatar-container {
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.gigi-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--gigi-white);
  object-fit: cover;
  border: 2px solid var(--gigi-crema);
  box-shadow: var(--gigi-shadow-sm);
}

.gigi-avatar-badge {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 12px;
  height: 12px;
  background: var(--gigi-rosa);
  border: 2px solid var(--gigi-negro);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(201, 169, 98, 0.8);
}

/* Información de Gigi */
.gigi-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.gigi-name {
  font-family: sans-serif;
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.3px;
  color: var(--gigi-white);
  white-space: nowrap;
}

.gigi-subtitle {
  font-size: 11px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 400;
  color: var(--gigi-crema);
}

.gigi-status-dot {
  width: 6px;
  height: 6px;
  background: var(--gigi-rosa);
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 6px rgba(201, 169, 98, 0.8);
  animation: gigiStatusPulse 2s ease-in-out infinite;
}

@keyframes gigiStatusPulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.15);
  }
}

/* Botones del header */
.gigi-header-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.gigi-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(245, 230, 224, 0.15);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(245, 230, 224, 0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gigi-crema);
  font-size: 16px;
  transition: var(--gigi-transition);
}

.gigi-action-btn:hover {
  background: rgba(245, 230, 224, 0.25);
  border-color: var(--gigi-rosa);
  color: var(--gigi-rosa);
  transform: scale(1.08);
}

/* ============================================================================
   CUERPO DEL CHAT (Mensajes)
   ============================================================================ */
.gigi-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: linear-gradient(180deg, var(--gigi-off-white) 0%, rgba(245, 230, 224, 0.3) 100%);
  scroll-behavior: smooth;
}

/* Scrollbar personalizado */
.gigi-chat-body::-webkit-scrollbar {
  width: 5px;
}

.gigi-chat-body::-webkit-scrollbar-track {
  background: transparent;
}

.gigi-chat-body::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--gigi-rosa) 0%, var(--gigi-rosa-dark) 100%);
  border-radius: 10px;
}

.gigi-chat-body::-webkit-scrollbar-thumb:hover {
  background: var(--gigi-negro);
}

/* Mensajes */
.gigi-message {
  margin-bottom: 14px;
  display: flex;
  gap: 10px;
  animation: gigiMessageIn 0.3s ease-out both;
  max-width: 100%;
}

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

.gigi-message.bot {
  flex-direction: row;
}

.gigi-message.user {
  flex-direction: row-reverse;
}

/* Wrapper del contenido del mensaje */
.gigi-message-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 70%;
}

.gigi-message.bot .gigi-message-wrapper {
  align-items: flex-start;
}

.gigi-message.user .gigi-message-wrapper {
  align-items: flex-end;
}

/* Avatar del mensaje */
.gigi-msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--gigi-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: var(--gigi-shadow-sm);
  border: 2px solid var(--gigi-crema);
  overflow: hidden;
}

.gigi-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gigi-message.user .gigi-msg-avatar {
  background: var(--gigi-negro);
  border-color: var(--gigi-negro-dark);
}

/* Contenido del mensaje */
.gigi-msg-content {
  max-width: 100%;
  padding: 11px 14px;
  border-radius: var(--gigi-radius-md);
  font-size: 13.5px;
  line-height: 1.55;
  position: relative;
  word-wrap: break-word;
  font-weight: 400;
  display: inline-block;
}

.gigi-message.bot .gigi-msg-content {
  background: var(--gigi-white);
  color: var(--gigi-negro);
  border-bottom-left-radius: 5px;
  box-shadow: var(--gigi-shadow-sm);
  border: 1px solid rgba(245, 230, 224, 0.5);
}

.gigi-message.user .gigi-msg-content {
  background: var(--gigi-gradient-header);
  color: var(--gigi-crema);
  border-bottom-right-radius: 5px;
  box-shadow: var(--gigi-shadow-md);
}

/* Tiempo del mensaje */
.gigi-msg-time {
  font-size: 10px;
  opacity: 0.6;
  margin-top: 4px;
  text-align: right;
  font-weight: 400;
  letter-spacing: 0.2px;
}

.gigi-message.bot .gigi-msg-time {
  color: var(--gigi-negro);
}

.gigi-message.user .gigi-msg-time {
  color: var(--gigi-crema);
}

/* Indicador de escritura */
.gigi-typing {
  display: inline-flex;
  gap: 5px;
  padding: 12px 16px;
  background: var(--gigi-white);
  border-radius: var(--gigi-radius-md);
  box-shadow: var(--gigi-shadow-sm);
  border: 1px solid rgba(245, 230, 224, 0.5);
  animation: gigiTypingIn 0.3s ease both;
}

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

.gigi-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gigi-rosa);
  animation: gigiTyping 1.4s ease-in-out infinite;
}

.gigi-typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.gigi-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes gigiTyping {
  0%, 60%, 100% {
    transform: translateY(0) scale(1);
    opacity: 0.6;
  }
  30% {
    transform: translateY(-5px) scale(1.08);
    opacity: 1;
  }
}

/* ============================================================================
   FOOTER DEL CHAT - Diseño Mejorado
   ============================================================================ */
.gigi-footer {
  padding: 14px 16px;
  background: var(--gigi-white);
  border-top: 1px solid rgba(245, 230, 224, 0.5);
  flex-shrink: 0;
}

.gigi-input-wrapper {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--gigi-off-white);
  padding: 5px;
  border-radius: 50px;
  border: 1.5px solid rgba(201, 169, 98, 0.3);
  transition: var(--gigi-transition);
}

.gigi-input-wrapper:focus-within {
  border-color: var(--gigi-rosa);
  box-shadow: 0 0 0 3px rgba(201, 169, 98, 0.1);
  background: var(--gigi-white);
}

#gigi-input {
  flex: 1;
  padding: 10px 14px;
  border: none;
  border-radius: 50px;
  font-size: 13.5px;
  outline: none;
  background: transparent;
  font-family: inherit;
  color: var(--gigi-negro);
  min-width: 0;
}

#gigi-input::placeholder {
  color: #999;
}

#gigi-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--gigi-gradient-header);
  border: 2px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gigi-crema);
  font-size: 16px;
  transition: var(--gigi-transition);
  flex-shrink: 0;
}

#gigi-send-btn:hover {
  background: var(--gigi-gradient-rosa);
  border-color: var(--gigi-rosa);
  color: var(--gigi-white);
  transform: scale(1.06);
}

#gigi-send-btn:active {
  transform: scale(1.02);
}

#gigi-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Badges del footer - Diseño horizontal */
.gigi-footer-badges {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding-top: 10px;
  border-top: 1px solid rgba(245, 230, 224, 0.4);
  flex-wrap: wrap;
}

.gigi-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 500;
  color: #666;
  background: linear-gradient(135deg, var(--gigi-off-white) 0%, rgba(245, 230, 224, 0.7) 100%);
  padding: 4px 10px;
  border-radius: 14px;
  border: 1px solid rgba(201, 169, 98, 0.2);
  transition: var(--gigi-transition);
  white-space: nowrap;
}

.gigi-badge:hover {
  background: var(--gigi-gradient-subtle);
  border-color: var(--gigi-rosa);
  color: var(--gigi-negro);
  transform: translateY(-1px);
}

/* ============================================================================
   RESPONSIVE (Móviles)
   ============================================================================ */
@media (max-width: 480px) {
  #gigi-chat-window {
    bottom: 80px;
    right: 12px;
    left: 12px;
    width: auto;
    max-width: none;
    height: calc(100vh - 150px);
    border-radius: var(--gigi-radius-md);
  }

  #gigi-chat-button {
    width: 58px;
    height: 58px;
    bottom: 12px;
    right: 12px;
  }

  .gigi-msg-content {
    max-width: 78%;
  }

  .gigi-header {
    padding: 16px;
  }

  .gigi-chat-body {
    padding: 14px;
  }

  .gigi-name {
    font-size: 15px;
  }

  .gigi-subtitle {
    font-size: 10px;
  }

  .gigi-footer-badges {
    gap: 4px;
  }

  .gigi-badge {
    font-size: 9px;
    padding: 3px 8px;
  }
}

/* ============================================================================
   MODO OSCURO (Automático según preferencia del sistema)
   ============================================================================ */
@media (prefers-color-scheme: dark) {
  #gigi-chat-window {
    background: #1a1a1a;
    border-color: rgba(245, 230, 224, 0.12);
  }

  .gigi-chat-body {
    background: linear-gradient(180deg, #1a1a1a 0%, #242424 100%);
  }

  .gigi-message.bot .gigi-msg-content {
    background: #242424;
    color: var(--gigi-crema);
    border-color: rgba(245, 230, 224, 0.1);
  }

  .gigi-typing {
    background: #242424;
    border-color: rgba(245, 230, 224, 0.1);
  }

  .gigi-footer {
    background: #1a1a1a;
    border-color: rgba(245, 230, 224, 0.12);
  }

  .gigi-input-wrapper {
    background: #242424;
    border-color: rgba(201, 169, 98, 0.15);
  }

  .gigi-input-wrapper:focus-within {
    background: #1a1a1a;
  }

  #gigi-input {
    color: var(--gigi-crema);
  }

  .gigi-badge {
    background: linear-gradient(135deg, #242424 0%, #2a2a2a 100%);
    color: var(--gigi-crema);
    border-color: rgba(201, 169, 98, 0.15);
  }
}
