/* ============================================================
   AI CHAT WIDGET — floating bottom-right
   ============================================================ */

.ai-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
}

/* === BUBBLE (closed state) === */
.ai-chat-bubble {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 14px 22px 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  box-shadow:
    0 12px 32px -6px rgba(31, 58, 92, 0.4),
    0 4px 12px -2px rgba(31, 58, 92, 0.2);
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.2px;
  position: relative;
}

.ai-chat-bubble:hover {
  transform: translateY(-2px);
  box-shadow:
    0 16px 40px -6px rgba(31, 58, 92, 0.5),
    0 6px 16px -2px rgba(31, 58, 92, 0.25);
}

.ai-chat-bubble-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.ai-chat-bubble-label {
  white-space: nowrap;
}

/* Pulsujący wskaźnik (że AI jest aktywne) */
.ai-chat-bubble-pulse {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: #61c554;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: chat-pulse 2s ease-in-out infinite;
}

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

.ai-chat-widget.open .ai-chat-bubble {
  transform: scale(0.85);
  opacity: 0;
  pointer-events: none;
}

/* === CHAT PANEL (open state) === */
.ai-chat-panel {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 80px);
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  box-shadow:
    0 32px 64px -12px rgba(31, 58, 92, 0.35),
    0 12px 24px -8px rgba(31, 58, 92, 0.18);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  overflow: hidden;
}

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

/* === HEADER === */
.ai-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, var(--accent) 0%, #2c4d77 100%);
  color: white;
}

.ai-chat-header-info {
  display: flex;
  gap: 12px;
  align-items: center;
}

.ai-chat-avatar {
  width: 38px;
  height: 38px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.ai-chat-avatar svg { width: 20px; height: 20px; }

.ai-chat-header-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.3px;
}

.ai-chat-header-status {
  font-size: 11px;
  opacity: 0.8;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.ai-chat-status-dot {
  width: 6px;
  height: 6px;
  background: #61c554;
  border-radius: 50%;
  animation: chat-pulse 2s ease-in-out infinite;
}

.ai-chat-close {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding-bottom: 2px;
  transition: background 0.2s;
}

.ai-chat-close:hover { background: rgba(255, 255, 255, 0.25); }

/* === BODY === */
.ai-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ai-chat-msg {
  display: flex;
  max-width: 85%;
}

.ai-chat-msg-bot {
  align-self: flex-start;
}

.ai-chat-msg-user {
  align-self: flex-end;
}

.ai-chat-msg-bubble {
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
}

.ai-chat-msg-bot .ai-chat-msg-bubble {
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.ai-chat-msg-user .ai-chat-msg-bubble {
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 4px;
}

/* Loading dots (gdy AI "myśli") */
.ai-chat-msg-loading .ai-chat-msg-bubble {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 14px 18px;
}

.ai-chat-msg-loading-dot {
  width: 6px;
  height: 6px;
  background: var(--text-3);
  border-radius: 50%;
  animation: dot-bounce 1.4s infinite ease-in-out;
}

.ai-chat-msg-loading-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-chat-msg-loading-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* === SUGESTIE === */
.ai-chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.ai-chat-suggestion {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 10px 14px;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
  font-family: var(--font-sans);
}

.ai-chat-suggestion:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateX(2px);
}

/* === INPUT === */
.ai-chat-input-form {
  display: flex;
  gap: 8px;
  padding: 14px 16px 4px;
  border-top: 1px solid var(--border);
}

.ai-chat-input {
  flex: 1;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13.5px;
  font-family: var(--font-sans);
  background: var(--bg-3);
  color: var(--text);
  transition: all 0.2s;
}

.ai-chat-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.ai-chat-send {
  width: 38px;
  height: 38px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.ai-chat-send:hover { transform: scale(1.08); }
.ai-chat-send svg { width: 16px; height: 16px; }

.ai-chat-disclaimer {
  text-align: center;
  font-size: 10px;
  color: var(--text-3);
  padding: 6px 16px 14px;
  font-style: italic;
}

/* === MOBILE === */
@media (max-width: 600px) {
  .ai-chat-widget { bottom: 16px; right: 16px; }
  .ai-chat-bubble {
    padding: 12px 14px;
  }
  .ai-chat-bubble-label { display: none; }
  .ai-chat-panel {
    width: calc(100vw - 32px);
    height: calc(100vh - 100px);
  }
}
