/* === HORNET MOTO COPILOTO TÉCNICO — CHAT FLOTANTE === */

/* --- FAB (Floating Action Button) --- */
.copilot-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 8000;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FFD700 0%, #B8960F 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(255, 215, 0, 0.35), 0 2px 8px rgba(0,0,0,0.3);
  transition: transform 0.3s cubic-bezier(.34,1.56,.64,1), box-shadow 0.3s;
  animation: copilot-pulse 3s ease-in-out infinite;
}

.copilot-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(255, 215, 0, 0.5), 0 4px 12px rgba(0,0,0,0.4);
}

.copilot-fab:active {
  transform: scale(0.95);
}

.copilot-fab svg {
  width: 28px;
  height: 28px;
  fill: #0d0d0d;
  transition: transform 0.3s;
}

.copilot-fab.open svg {
  transform: rotate(90deg);
}

.copilot-fab .fab-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #0d0d0d;
  animation: copilot-badge-pulse 2s ease-in-out infinite;
}

@keyframes copilot-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(255, 215, 0, 0.35), 0 2px 8px rgba(0,0,0,0.3); }
  50%      { box-shadow: 0 4px 28px rgba(255, 215, 0, 0.5), 0 2px 8px rgba(0,0,0,0.3); }
}

@keyframes copilot-badge-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

/* --- Chat Panel --- */
.copilot-panel {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 7999;
  width: 380px;
  max-height: 560px;
  border-radius: 20px;
  background: rgba(18, 18, 22, 0.92);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid rgba(255, 215, 0, 0.15);
  box-shadow: 0 16px 48px rgba(0,0,0,0.55), 0 0 0 1px rgba(227,6,19,0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Animate in/out */
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(.34,1.56,.64,1);
}

.copilot-panel.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* --- Header --- */
.copilot-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: linear-gradient(135deg, rgba(255,215,0,0.12) 0%, rgba(227,6,19,0.04) 100%);
  border-bottom: 1px solid rgba(227,6,19,0.1);
  flex-shrink: 0;
}

.copilot-header-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #FFD700, #B8960F);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.copilot-header-info {
  flex: 1;
  min-width: 0;
}

.copilot-header-info h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #FFD700;
  margin: 0;
  letter-spacing: 0.3px;
}

.copilot-header-info p {
  font-size: 0.72rem;
  color: #a0a0a0;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.copilot-header-close {
  background: none;
  border: none;
  color: #a0a0a0;
  cursor: pointer;
  font-size: 20px;
  padding: 4px;
  transition: color 0.2s;
  flex-shrink: 0;
}

.copilot-header-close:hover {
  color: #FFD700;
}

/* --- Messages Area --- */
.copilot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 280px;
  max-height: 380px;
  scroll-behavior: smooth;
}

/* Custom scrollbar */
.copilot-messages::-webkit-scrollbar {
  width: 5px;
}
.copilot-messages::-webkit-scrollbar-track {
  background: transparent;
}
.copilot-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 215, 0, 0.2);
  border-radius: 10px;
}

/* --- Message Bubbles --- */
.copilot-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.55;
  word-wrap: break-word;
  animation: copilot-msg-in 0.25s ease-out;
}

@keyframes copilot-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.copilot-msg.bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  color: #e8e8e8;
  border-bottom-left-radius: 4px;
}

.copilot-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(227,6,19,0.18) 0%, rgba(227,6,19,0.08) 100%);
  color: #FFD700;
  border-bottom-right-radius: 4px;
}

/* Markdown-ish styling inside bot messages */
.copilot-msg.bot strong,
.copilot-msg.bot b {
  color: #FFD700;
  font-weight: 600;
}

.copilot-msg.bot code {
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.83rem;
  font-family: 'Consolas', 'Monaco', monospace;
}

.copilot-msg.bot ul,
.copilot-msg.bot ol {
  margin: 6px 0;
  padding-left: 18px;
}

.copilot-msg.bot li {
  margin-bottom: 3px;
}

/* --- Typing indicator --- */
.copilot-typing {
  align-self: flex-start;
  display: flex;
  gap: 5px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

.copilot-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a0a0a0;
  animation: copilot-dot 1.4s ease-in-out infinite;
}

.copilot-typing span:nth-child(2) { animation-delay: 0.2s; }
.copilot-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes copilot-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* --- Input Area --- */
.copilot-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid rgba(255, 215, 0, 0.08);
  background: rgba(10, 10, 14, 0.6);
  flex-shrink: 0;
}

.copilot-input-area textarea {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 215, 0, 0.12);
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.88rem;
  font-family: inherit;
  resize: none;
  min-height: 42px;
  max-height: 110px;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.4;
}

.copilot-input-area textarea:focus {
  border-color: rgba(255, 215, 0, 0.4);
}

.copilot-input-area textarea::placeholder {
  color: #666;
}

.copilot-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #FFD700, #B8960F);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, opacity 0.2s;
  flex-shrink: 0;
}

.copilot-send-btn:hover {
  transform: scale(1.08);
}

.copilot-send-btn:active {
  transform: scale(0.95);
}

.copilot-send-btn:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}

.copilot-send-btn svg {
  width: 18px;
  height: 18px;
  fill: #0d0d0d;
}

/* --- Welcome message --- */
.copilot-welcome {
  text-align: center;
  padding: 20px 10px;
}

.copilot-welcome .welcome-icon {
  font-size: 2.4rem;
  margin-bottom: 8px;
}

.copilot-welcome h4 {
  color: #FFD700;
  font-size: 1rem;
  margin-bottom: 6px;
}

.copilot-welcome p {
  color: #a0a0a0;
  font-size: 0.8rem;
  line-height: 1.5;
  margin-bottom: 14px;
}

.copilot-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.copilot-suggestion-btn {
  background: rgba(255, 215, 0, 0.08);
  border: 1px solid rgba(255, 215, 0, 0.12);
  color: #ccc;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.8rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s, border-color 0.2s;
}

.copilot-suggestion-btn:hover {
  background: rgba(255, 215, 0, 0.15);
  border-color: rgba(255, 215, 0, 0.3);
  color: #FFD700;
}

/* --- Multimodal / Image Upload Styles --- */

.copilot-attach-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 10px;
  transition: background 0.2s, transform 0.2s;
  flex-shrink: 0;
}

.copilot-attach-btn:hover {
  background: rgba(255, 215, 0, 0.15);
  transform: scale(1.05);
}

.copilot-attach-btn svg {
  width: 20px;
  height: 20px;
  fill: #FFD700;
}

/* Preview Area */
.copilot-preview-container {
  padding: 10px 14px;
  background: rgba(20, 20, 25, 0.95);
  border-top: 1px solid rgba(255, 215, 0, 0.1);
  display: flex;
  align-items: center;
  animation: copilot-slide-up 0.25s cubic-bezier(.34,1.56,.64,1);
  flex-shrink: 0;
}

@keyframes copilot-slide-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.copilot-preview-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 215, 0, 0.15);
  padding: 6px 12px;
  border-radius: 12px;
  width: 100%;
  position: relative;
}

.copilot-preview-box img {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(255, 215, 0, 0.2);
}

.copilot-preview-box span {
  font-size: 0.78rem;
  color: #e0e0e0;
  font-family: inherit;
  flex-grow: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.copilot-preview-box button {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #a0a0a0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.copilot-preview-box button:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

/* User Message Image bubble style */
.copilot-msg-img-container {
  margin-bottom: 6px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 215, 0, 0.25);
  cursor: zoom-in;
  transition: transform 0.2s;
  max-width: 100%;
}

.copilot-msg-img-container:hover {
  transform: scale(1.02);
}

.copilot-msg-img {
  max-width: 220px;
  max-height: 160px;
  width: 100%;
  height: auto;
  object-fit: cover;
  display: block;
}

.copilot-msg-text {
  word-wrap: break-word;
}

/* Lightbox for Zoom */
.copilot-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.copilot-lightbox.visible {
  opacity: 1;
  pointer-events: all;
}

.copilot-lightbox img {
  max-width: 92%;
  max-height: 85vh;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
  transform: scale(0.92);
  transition: transform 0.3s cubic-bezier(.34,1.56,.64,1);
  border: 1px solid rgba(255, 215, 0, 0.2);
}

.copilot-lightbox.visible img {
  transform: scale(1);
}

.copilot-lightbox-close {
  position: absolute;
  top: 24px;
  right: 24px;
  font-size: 38px;
  color: #a0a0a0;
  cursor: pointer;
  transition: color 0.2s, transform 0.2s;
  user-select: none;
}

.copilot-lightbox-close:hover {
  color: #FFD700;
  transform: scale(1.1);
}

/* --- Responsive --- */
@media (max-width: 480px) {
  .copilot-panel {
    right: 10px;
    left: 10px;
    bottom: 90px;
    width: auto;
    max-height: 70vh;
    border-radius: 16px;
  }

  .copilot-fab {
    bottom: 18px;
    right: 18px;
    width: 54px;
    height: 54px;
  }
}

/* --- Botón Manual PDF --- */
.copilot-manual-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  padding: 8px;
  border-radius: 10px;
  transition: background 0.2s, transform 0.2s;
  flex-shrink: 0;
  line-height: 1;
}

.copilot-manual-btn:hover {
  background: rgba(255, 215, 0, 0.15);
  transform: scale(1.08);
}

/* --- Menú flotante de Manuales --- */
.copilot-manual-menu {
  position: fixed;
  z-index: 9000;
  background: rgba(18, 18, 22, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 215, 0, 0.2);
  border-radius: 16px;
  width: 300px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  overflow: hidden;
  animation: copilot-msg-in 0.2s ease-out;
}

.copilot-manual-menu.hidden {
  display: none;
}

.manual-menu-header {
  padding: 12px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #FFD700;
  border-bottom: 1px solid rgba(255, 215, 0, 0.1);
  letter-spacing: 0.5px;
}

.manual-menu-items {
  max-height: 220px;
  overflow-y: auto;
  padding: 6px;
}

.manual-menu-loading {
  padding: 16px;
  text-align: center;
  color: #666;
  font-size: 0.82rem;
}

.manual-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s;
  color: #e0e0e0;
}

.manual-menu-item:hover {
  background: rgba(255, 215, 0, 0.1);
  color: #FFD700;
}

.manual-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.manual-info strong {
  display: block;
  font-size: 0.83rem;
  font-weight: 600;
}

.manual-info small {
  display: block;
  font-size: 0.73rem;
  color: #888;
}

.manual-menu-divider {
  height: 1px;
  background: rgba(255, 215, 0, 0.08);
  margin: 4px 0;
}

.manual-menu-upload {
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  color: #a0a0a0;
  cursor: pointer;
  font-size: 0.82rem;
  text-align: left;
  transition: background 0.2s, color 0.2s;
}

.manual-menu-upload:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

/* --- PDF Preview icon --- */
#copilot-preview-pdf-icon {
  font-size: 28px;
  flex-shrink: 0;
}

/* --- PDF bubble en el chat --- */
.copilot-pdf-bubble {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
}

/* --- Barra de manual cargado (encima del chat) --- */
.copilot-manuales-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(255, 215, 0, 0.06);
  border-bottom: 1px solid rgba(255, 215, 0, 0.1);
  flex-shrink: 0;
}

.manuales-bar-icon { font-size: 16px; }

.manuales-select {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 215, 0, 0.2);
  color: #e0e0e0;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 0.78rem;
  outline: none;
}

.manuales-load-btn {
  background: linear-gradient(135deg, #FFD700, #B8960F);
  border: none;
  color: #000;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s;
}

.manuales-load-btn:hover { transform: scale(1.05); }
