/* =================================================================
   WIK Technologies - Chatbot Widget (Hiro)
   ================================================================= */

:root {
  --wik-chat-primary: #1E40AF;
  --wik-chat-secondary: #3B82F6;
  --wik-chat-accent: #DC2626;
  --wik-chat-dark: #0A0A0A;
  --wik-chat-bg: #0F1014;
  --wik-chat-surface: #1A1B23;
  --wik-chat-border: #2A2D3A;
  --wik-chat-text: #FFFFFF;
  --wik-chat-text-muted: #9CA3AF;
  --wik-chat-user-bubble: linear-gradient(135deg, #1E40AF 0%, #3B82F6 100%);
  --wik-chat-bot-bubble: #1F2230;
}

/* =================================================================
   Floating Launcher Button
   ================================================================= */
.wik-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(145deg, #1E3A8A 0%, #2563EB 60%, #3B82F6 100%);
  color: white;
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(30, 64, 175, 0.5), 0 0 0 0 rgba(59, 130, 246, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.22s ease;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}

.wik-chat-launcher:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 28px rgba(30, 64, 175, 0.6), 0 0 0 6px rgba(59, 130, 246, 0.15);
}

.wik-chat-launcher:active {
  transform: scale(0.95);
}

.wik-chat-launcher svg {
  width: 26px;
  height: 26px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

.wik-chat-launcher .wik-chat-launcher-close {
  display: none;
}

.wik-chat-launcher.is-open .wik-chat-launcher-open {
  display: none;
}

.wik-chat-launcher.is-open .wik-chat-launcher-close {
  display: block;
}

/* Notification dot for new opening */
.wik-chat-launcher-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 12px;
  height: 12px;
  background: var(--wik-chat-accent);
  border: 2px solid white;
  border-radius: 50%;
  animation: wik-chat-pulse 2s infinite;
}

.wik-chat-launcher.is-open .wik-chat-launcher-dot,
.wik-chat-launcher.has-interacted .wik-chat-launcher-dot {
  display: none;
}

@keyframes wik-chat-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.7; }
}

/* =================================================================
   Chat Panel
   ================================================================= */
.wik-chat-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 120px);
  background: var(--wik-chat-bg);
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255,255,255,0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  color: var(--wik-chat-text);
  border: 1px solid var(--wik-chat-border);
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.34, 1.2, 0.64, 1);
  /* Enables container queries so text scales as the user resizes the panel */
  container-type: inline-size;
  container-name: wikchat;
}

/* Scale text/inputs as the panel widens */
@container wikchat (min-width: 440px) {
  .wik-chat-message { font-size: 14.5px; }
  .wik-chat-input { font-size: 15px; }
  .wik-chat-header-name { font-size: 15px; }
  .wik-chat-chip { font-size: 13px; }
}
@container wikchat (min-width: 540px) {
  .wik-chat-message { font-size: 15.5px; line-height: 1.65; }
  .wik-chat-input { font-size: 16px; }
  .wik-chat-header-name { font-size: 16px; }
  .wik-chat-header-status { font-size: 12px; }
  .wik-chat-chip { font-size: 13.5px; padding: 8px 14px; }
  .wik-chat-messages { padding: 22px 20px; gap: 14px; }
}
@container wikchat (min-width: 680px) {
  .wik-chat-message { font-size: 16.5px; }
  .wik-chat-input { font-size: 17px; }
  .wik-chat-messages { padding: 26px 24px; gap: 16px; }
}

.wik-chat-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* =================================================================
   Resize handles (desktop: top/left/corner; mobile: top only)
   ================================================================= */
.wik-chat-resize-handle {
  position: absolute;
  z-index: 2;
  background: transparent;
  touch-action: none;
}
.wik-chat-resize-n  { top: -4px; left: 12px; right: 12px; height: 8px; cursor: ns-resize; }
.wik-chat-resize-w  { left: -4px; top: 12px; bottom: 12px; width: 8px; cursor: ew-resize; }
.wik-chat-resize-nw { top: -4px; left: -4px; width: 16px; height: 16px; cursor: nwse-resize; z-index: 3; }

.wik-chat-resize-nw::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-top: 2px solid rgba(255, 255, 255, 0.25);
  border-left: 2px solid rgba(255, 255, 255, 0.25);
  border-top-left-radius: 6px;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.wik-chat-panel:hover .wik-chat-resize-nw::after,
.wik-chat-panel.is-resizing .wik-chat-resize-nw::after {
  opacity: 1;
}

.wik-chat-panel.is-resizing {
  transition: none;
  user-select: none;
}

/* =================================================================
   Header
   ================================================================= */
.wik-chat-header {
  background: #0D0E14;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--wik-chat-border);
  position: relative;
}

.wik-chat-header::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--wik-chat-primary), var(--wik-chat-secondary), var(--wik-chat-primary));
  background-size: 200% 100%;
  animation: wik-chat-header-shimmer 4s ease infinite;
}

@keyframes wik-chat-header-shimmer {
  0%, 100% { background-position: 0% 0; }
  50% { background-position: 100% 0; }
}

.wik-chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(145deg, #1E3A8A 0%, #2563EB 100%);
  border: 1px solid rgba(59, 130, 246, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(30, 64, 175, 0.35);
}

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

.wik-chat-header-name {
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.wik-chat-header-status {
  font-size: 11px;
  color: var(--wik-chat-text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
}

.wik-chat-status-dot {
  width: 8px;
  height: 8px;
  background: #22C55E;
  border-radius: 50%;
  display: inline-block;
}

.wik-chat-close-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--wik-chat-text-muted);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
  margin-left: auto;
}

.wik-chat-close-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: white;
}

/* =================================================================
   Messages Area
   ================================================================= */
.wik-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--wik-chat-border) transparent;
}

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

.wik-chat-messages::-webkit-scrollbar-thumb {
  background: var(--wik-chat-border);
  border-radius: 3px;
}

.wik-chat-message {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.6;
  word-wrap: break-word;
  animation: wik-chat-fade-in 0.2s ease;
}

@keyframes wik-chat-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.wik-chat-message.bot {
  align-self: flex-start;
  background: var(--wik-chat-bot-bubble);
  color: var(--wik-chat-text);
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255,255,255,0.05);
}

.wik-chat-message.user {
  align-self: flex-end;
  background: var(--wik-chat-user-bubble);
  color: white;
  border-bottom-right-radius: 4px;
}

.wik-chat-message a {
  color: #93C5FD;
  text-decoration: underline;
  word-break: break-all;
}

.wik-chat-message.user a {
  color: white;
}

.wik-chat-message strong {
  font-weight: 700;
}

.wik-chat-message ul,
.wik-chat-message ol {
  margin: 6px 0 6px 20px;
  padding: 0;
}

.wik-chat-message li {
  margin: 2px 0;
}

.wik-chat-message code {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 13px;
}

/* Typing indicator */
.wik-chat-typing {
  align-self: flex-start;
  background: var(--wik-chat-bot-bubble);
  padding: 12px 16px;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 4px;
}

.wik-chat-typing span {
  width: 8px;
  height: 8px;
  background: var(--wik-chat-text-muted);
  border-radius: 50%;
  animation: wik-chat-bounce 1.4s infinite ease-in-out both;
}

.wik-chat-typing span:nth-child(1) { animation-delay: -0.32s; }
.wik-chat-typing span:nth-child(2) { animation-delay: -0.16s; }

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

/* =================================================================
   Quick Reply Chips
   ================================================================= */
.wik-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 4px;
  margin-top: 4px;
}

.wik-chat-chip {
  background: rgba(30, 64, 175, 0.12);
  color: #93C5FD;
  border: 1px solid rgba(59, 130, 246, 0.25);
  padding: 7px 13px;
  border-radius: 20px;
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  letter-spacing: 0.01em;
}

.wik-chat-chip:hover {
  background: var(--wik-chat-primary);
  border-color: var(--wik-chat-secondary);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(30, 64, 175, 0.3);
}

/* =================================================================
   Input Area
   ================================================================= */
.wik-chat-input-wrap {
  border-top: 1px solid var(--wik-chat-border);
  padding: 10px 12px;
  background: #0D0E14;
  flex-shrink: 0;
}

.wik-chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #16171F;
  border: 1px solid var(--wik-chat-border);
  border-radius: 24px;
  padding: 6px 6px 6px 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.wik-chat-input-row:focus-within {
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.08);
}

.wik-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--wik-chat-text);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  min-height: 24px;
  line-height: 1.4;
  padding: 6px 0;
}

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

.wik-chat-send-btn {
  background: linear-gradient(135deg, var(--wik-chat-primary) 0%, var(--wik-chat-secondary) 100%);
  color: white;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.wik-chat-send-btn:hover:not(:disabled) {
  transform: scale(1.06);
}

.wik-chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.wik-chat-send-btn svg {
  width: 16px;
  height: 16px;
}

.wik-chat-footer {
  text-align: center;
  font-size: 11px;
  color: var(--wik-chat-text-muted);
  margin-top: 8px;
}

.wik-chat-footer a {
  color: var(--wik-chat-secondary);
  text-decoration: none;
}

/* =================================================================
   Mobile responsive
   ================================================================= */
@media (max-width: 480px) {
  .wik-chat-launcher {
    bottom: 18px;
    right: 18px;
    width: 52px;
    height: 52px;
  }

  .wik-chat-panel {
    bottom: 84px;
    right: 12px;
    left: 12px;
    width: auto;
    max-width: 100%;
    height: 68vh;
    height: 68dvh;
    max-height: 520px;
    border-radius: 16px;
    border: 1px solid var(--wik-chat-border);
  }

  .wik-chat-resize-w,
  .wik-chat-resize-nw {
    display: none;
  }
  .wik-chat-resize-n {
    left: 24px;
    right: 24px;
    height: 14px;
    top: -6px;
  }
  .wik-chat-resize-n::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.25);
  }
}

/* =================================================================
   Error message
   ================================================================= */
.wik-chat-error {
  align-self: center;
  background: rgba(220, 38, 38, 0.15);
  color: #FCA5A5;
  border: 1px solid rgba(220, 38, 38, 0.3);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  max-width: 90%;
  text-align: center;
}
