/* ==========================================================================
   RESUME COPILOT WIDGET
   Matches the portfolio's design system using CSS variables
   ========================================================================== */

/* --------------------------------------------------------------------------
   Widget Container & Toggle
   -------------------------------------------------------------------------- */
.copilot-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1500;
  width: 60px;
  height: 60px;
  border-radius: var(--radius-full);
  background: var(--gradient-accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
  transition: var(--transition-base);
}

.copilot-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 30px rgba(99, 102, 241, 0.5);
}

.copilot-toggle svg {
  width: 28px;
  height: 28px;
  color: white;
  transition: var(--transition-base);
}

.copilot-toggle.active svg.icon-chat {
  display: none;
}

.copilot-toggle:not(.active) svg.icon-close {
  display: none;
}

/* --------------------------------------------------------------------------
   Chat Window
   -------------------------------------------------------------------------- */
.copilot-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  z-index: 1499;
  width: 400px;
  max-width: calc(100vw - 48px);
  height: 600px;
  max-height: calc(100vh - 140px);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: var(--transition-base);
}

.copilot-window.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.copilot-header {
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.copilot-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.copilot-header-title svg {
  width: 18px;
  height: 18px;
  color: var(--accent-primary);
}

.copilot-header-title h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.copilot-header-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}

.copilot-header-actions {
  position: absolute;
  top: 10px;
  right: 12px;
  display: flex;
  gap: 8px;
}

.copilot-header-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
}

.copilot-header-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.copilot-header-btn svg {
  width: 16px;
  height: 16px;
}

/* --------------------------------------------------------------------------
   Quick Questions (Chips)
   -------------------------------------------------------------------------- */
.copilot-chips {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  white-space: nowrap;
  flex-shrink: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.copilot-chips::-webkit-scrollbar {
  display: none;
}

.copilot-chips-inner {
  display: flex;
  gap: 6px;
}

.copilot-chip {
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 500;
  font-family: var(--font-sans);
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition-fast);
  flex-shrink: 0;
}

.copilot-chip:hover {
  color: var(--text-primary);
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.1);
}

/* --------------------------------------------------------------------------
   Messages Area
   -------------------------------------------------------------------------- */
.copilot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-tertiary) transparent;
}

.copilot-messages::-webkit-scrollbar {
  width: 6px;
}

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

.copilot-messages::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 3px;
}

/* Message Bubbles */
.copilot-message {
  display: flex;
  flex-direction: column;
  max-width: 90%;
}

.copilot-message.user {
  align-self: flex-end;
}

.copilot-message.assistant {
  align-self: flex-start;
}

.copilot-message-content {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  line-height: 1.55;
}

.copilot-message.user .copilot-message-content {
  background: var(--gradient-accent);
  color: white;
  border-bottom-right-radius: 4px;
}

.copilot-message.assistant .copilot-message-content {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
}

/* Message Text Formatting */
.copilot-message-content p {
  margin: 0 0 12px 0;
}

.copilot-message-content p:last-child {
  margin-bottom: 0;
}

.copilot-message-content ul,
.copilot-message-content ol {
  margin: 8px 0;
  padding-left: 20px;
}

.copilot-message-content li {
  margin-bottom: 6px;
}

.copilot-message-content strong {
  font-weight: 600;
  color: var(--text-primary);
}

.copilot-message-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

/* Sources Section */
.copilot-sources {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.copilot-sources-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

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

.copilot-source-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--accent-primary);
  text-decoration: none;
  transition: var(--transition-fast);
}

.copilot-source-link:hover {
  color: var(--accent-secondary);
  text-decoration: underline;
}

.copilot-source-link svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

/* Quick Actions (30-sec / 2-min buttons) */
.copilot-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.copilot-action-btn {
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font-sans);
  color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition-fast);
}

.copilot-action-btn:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.3);
}

/* Follow-up Questions */
.copilot-followups {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.copilot-followup-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-family: var(--font-sans);
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: var(--transition-fast);
}

.copilot-followup-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.05);
}

.copilot-followup-btn svg {
  width: 14px;
  height: 14px;
  color: var(--accent-primary);
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Loading State
   -------------------------------------------------------------------------- */
.copilot-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  align-self: flex-start;
}

.copilot-loading-dots {
  display: flex;
  gap: 4px;
}

.copilot-loading-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-primary);
  border-radius: 50%;
  animation: copilot-bounce 1.4s ease-in-out infinite;
}

.copilot-loading-dot:nth-child(1) { animation-delay: 0s; }
.copilot-loading-dot:nth-child(2) { animation-delay: 0.2s; }
.copilot-loading-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes copilot-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

.copilot-loading-text {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Error State
   -------------------------------------------------------------------------- */
.copilot-error {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-md);
  align-self: flex-start;
}

.copilot-error-text {
  font-size: 0.9rem;
  color: #fca5a5;
}

.copilot-retry-btn {
  align-self: flex-start;
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font-sans);
  color: white;
  background: rgba(239, 68, 68, 0.8);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

.copilot-retry-btn:hover {
  background: rgba(239, 68, 68, 1);
}

/* --------------------------------------------------------------------------
   Input Area
   -------------------------------------------------------------------------- */
.copilot-input-container {
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.copilot-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  transition: var(--transition-fast);
}

.copilot-input-wrapper:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.copilot-input {
  flex: 1;
  min-height: 24px;
  max-height: 120px;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  color: var(--text-primary);
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  line-height: 1.5;
}

.copilot-input::placeholder {
  color: var(--text-muted);
}

.copilot-send-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-accent);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  cursor: pointer;
  transition: var(--transition-fast);
  flex-shrink: 0;
}

.copilot-send-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.copilot-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.copilot-send-btn svg {
  width: 18px;
  height: 18px;
}

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

.copilot-welcome-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-accent);
  border-radius: var(--radius-md);
}

.copilot-welcome-icon svg {
  width: 20px;
  height: 20px;
  color: white;
}

.copilot-welcome h4 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 6px 0;
}

.copilot-welcome p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   Mobile Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .copilot-toggle {
    bottom: 16px;
    right: 16px;
    width: 52px;
    height: 52px;
  }

  .copilot-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: calc(100vh - 60px);
    max-height: calc(100vh - 60px);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(100%);
  }

  .copilot-window.open {
    transform: translateY(0);
  }

  .copilot-header {
    padding: 10px 14px;
  }

  .copilot-chips {
    padding: 8px 14px;
  }

  .copilot-messages {
    padding: 12px 14px;
  }

  .copilot-input-container {
    padding: 8px 14px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
}

/* --------------------------------------------------------------------------
   Reduced Motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .copilot-toggle,
  .copilot-window,
  .copilot-chip,
  .copilot-action-btn,
  .copilot-send-btn {
    transition: none;
  }

  .copilot-loading-dot {
    animation: none;
    opacity: 1;
  }
}

/* --------------------------------------------------------------------------
   Print: Hide Widget
   -------------------------------------------------------------------------- */
@media print {
  .copilot-toggle,
  .copilot-window {
    display: none !important;
  }
}
