/**
 * VD KB Advisor Widget Styles
 *
 * Styles for the AI Advisor Widget (Michael + Sarah)
 *
 * @package VD_Knowledge_Base
 */

/* ========================== */
/* BASE VARIABLES             */
/* ========================== */

.ai-section {
  --ai-primary: #009EE3;
  --ai-primary-light: #33B7F0;
  --ai-primary-dark: #0070A8;
  --ai-primary-gradient: linear-gradient(135deg, #009EE3 0%, #33B7F0 40%, #0070A8 100%);
}

/* ========================== */
/* SECTION LAYOUT             */
/* ========================== */

.ai-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ========================== */
/* AGENT BUTTONS              */
/* ========================== */

.ai-agents {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  justify-content: center;
  align-items: stretch;
}

@media (min-width: 640px) {
  .ai-agents {
    flex-direction: row;
    align-items: center;
  }
}

.ai-section .ai-agent-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-radius: 1.25rem;
  border: 2px solid rgba(255, 255, 255, 0.6) !important;
  min-height: 80px;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  background: var(--ai-primary-gradient) !important;
  color: #ffffff !important;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
  transition: all 0.25s ease;
}

@media (min-width: 640px) {
  .ai-section .ai-agent-btn {
    margin: 0;
  }
}

/* Link button (Termin) */
.ai-section .ai-agent-btn--link {
  /* Same as .ai-agent-btn */
}

/* Hover state */
.ai-section .ai-agent-btn:hover {
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: var(--ai-primary) !important;
  box-shadow: 0 20px 46px rgba(0, 158, 227, 0.25);
}

.ai-section .ai-agent-btn:hover .ai-agent-icon svg {
  color: #0f172a;
}

/* Active state */
.ai-section .ai-agent-btn--active {
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: var(--ai-primary) !important;
  box-shadow: 0 22px 48px rgba(0, 158, 227, 0.30);
}

.ai-section .ai-agent-btn--active .ai-agent-icon svg {
  color: #0f172a !important;
}

/* Avatar wrapper */
.ai-agent-avatar-wrapper {
  position: relative;
}

.ai-agent-avatar,
.ai-chat-avatar {
  position: relative;
  overflow: hidden;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  width: 4rem;
  height: 4rem;
}

.ai-chat-avatar {
  border-width: 0;
  width: 3.5rem;
  height: 3.5rem;
}

.ai-agent-avatar img,
.ai-chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Status dot */
.ai-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 999px;
  background: #22c55e;
  border: 2px solid #ffffff;
}

/* Agent text */
.ai-agent-text {
  flex: 1;
  text-align: left;
}

.ai-agent-text--full {
  padding-left: 0.25rem;
}

.ai-agent-name {
  font-weight: 600;
  font-size: 1.05rem;
}

.ai-agent-role {
  font-size: 0.875rem;
  opacity: 0.9;
}

.ai-agent-icon svg {
  width: 1.5rem;
  height: 1.5rem;
  color: #ffffff;
}

/* ========================== */
/* CHAT CARD                  */
/* ========================== */

.ai-chat-card {
  border-radius: 0.75rem;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  height: 400px;
  overflow: hidden;
}

.ai-chat-card--hidden {
  display: none;
}

@media (min-width: 640px) {
  .ai-chat-card {
    height: 500px;
  }
}

/* Chat header */
.ai-chat-header {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.45);
}

@media (min-width: 640px) {
  .ai-chat-header {
    padding: 1.25rem 1.25rem;
  }
}

.ai-chat-header-text {
  flex: 1;
}

.ai-chat-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.ai-chat-subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: #64748b;
}

.ai-chat-badge {
  background: var(--ai-primary-gradient);
  padding: 0.4rem;
  border-radius: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-chat-badge svg {
  width: 1.1rem;
  height: 1.1rem;
  color: #ffffff;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

/* Chat body */
.ai-chat-body {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.ai-chat-row {
  display: flex;
  margin-bottom: 0.75rem;
}

.ai-chat-row--left {
  justify-content: flex-start;
}

.ai-chat-row--right {
  justify-content: flex-end;
}

/* Chat bubbles */
.ai-chat-bubble {
  position: relative;
  max-width: 85%;
  border-radius: 0.75rem;
  padding: 0.7rem 0.9rem;
  background: var(--ai-primary-gradient);
  color: #ffffff;
  font-size: 0.9rem;
  line-height: 1.4;
}

.ai-chat-bubble--user {
  background: #f1f5f9;
  color: #0f172a;
}

@media (min-width: 640px) {
  .ai-chat-bubble {
    max-width: 80%;
  }
}

.ai-chat-message {
  white-space: pre-wrap;
  margin: 0;
  color: inherit;
}

/* Ensure bot messages have white text (high specificity to override theme) */
.ai-chat-bubble:not(.ai-chat-bubble--user) .ai-chat-message,
.ai-chat-bubble:not(.ai-chat-bubble--user) p,
.ai-chat-bubble:not(.ai-chat-bubble--user) a {
  color: #ffffff !important;
}

/* Copy button */
.ai-section .ai-copy-btn {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 0.35rem;
  border: none !important;
  background: transparent !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0;
  transition: opacity 0.2s ease, background 0.2s ease;
  color: rgba(255, 255, 255, 0.7) !important;
  cursor: pointer;
}

.ai-section .ai-chat-bubble:hover .ai-copy-btn {
  opacity: 1;
}

.ai-section .ai-copy-btn:hover {
  background: rgba(255, 255, 255, 0.14) !important;
  color: #ffffff !important;
}

.ai-section .ai-copy-btn svg {
  width: 0.9rem;
  height: 0.9rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

/* Chat form */
.ai-chat-form {
  border-top: 1px solid rgba(148, 163, 184, 0.4);
  padding: 0.9rem 1rem;
}

.ai-input-row {
  display: flex;
  gap: 0.5rem;
}

.ai-chat-input {
  flex: 1;
  height: 2.5rem;
  border-radius: 0.45rem;
  border: 1px solid rgba(148, 163, 184, 0.8);
  padding: 0.4rem 0.75rem;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ai-chat-input::placeholder {
  color: #94a3b8;
}

.ai-chat-input:focus {
  border-color: var(--ai-primary);
  box-shadow: 0 0 0 1px rgba(0, 158, 227, 0.35);
}

.ai-section .ai-send-btn {
  border: none !important;
  border-radius: 0.45rem;
  padding: 0 0.9rem;
  font-size: 0.9rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: not-allowed;
  background: var(--ai-primary-gradient) !important;
  color: #ffffff !important;
  box-shadow: 0 12px 25px rgba(15, 23, 42, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ai-section .ai-send-btn:not(:disabled) {
  cursor: pointer;
}

.ai-section .ai-send-btn:not(:disabled):hover {
  transform: scale(1.05);
  box-shadow: 0 18px 35px rgba(15, 23, 42, 0.35);
}

.ai-section .ai-send-btn svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

/* Typing indicator */
.ai-typing-indicator {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem;
}

.ai-typing-indicator span {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  animation: ai-typing-bounce 1.4s ease-in-out infinite;
}

.ai-typing-indicator span:nth-child(1) { animation-delay: 0s; }
.ai-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ai-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-0.25rem); }
}

/* ========================== */
/* VOICE CARD (Michael)       */
/* ========================== */

.ai-voice-card {
  border-radius: 0.75rem;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  height: 400px;
  overflow: hidden;
}

.ai-voice-card--hidden {
  display: none;
}

@media (min-width: 640px) {
  .ai-voice-card {
    height: 500px;
  }
}

/* Voice header (same as chat header) */
.ai-voice-header {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.45);
}

@media (min-width: 640px) {
  .ai-voice-header {
    padding: 1.25rem 1.25rem;
  }
}

/* Voice body */
.ai-voice-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  gap: 1.5rem;
}

/* Voice visualizer */
.ai-voice-visualizer {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: var(--ai-primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.3s ease;
}

.ai-voice-visualizer--active {
  transform: scale(1.05);
}

.ai-voice-pulse {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  animation: ai-voice-pulse 2s ease-in-out infinite;
}

.ai-voice-visualizer--listening .ai-voice-pulse {
  animation: ai-voice-pulse-fast 0.8s ease-in-out infinite;
  background: rgba(255, 255, 255, 0.4);
}

.ai-voice-visualizer--speaking .ai-voice-pulse {
  animation: ai-voice-speaking 0.3s ease-in-out infinite;
  background: rgba(255, 255, 255, 0.5);
}

@keyframes ai-voice-pulse {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.1); opacity: 1; }
}

@keyframes ai-voice-pulse-fast {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.15); opacity: 1; }
}

@keyframes ai-voice-speaking {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.1); }
  50% { transform: scale(0.95); }
  75% { transform: scale(1.08); }
}

/* Voice icon in visualizer */
.ai-voice-visualizer svg {
  position: absolute;
  width: 3rem;
  height: 3rem;
  color: #ffffff;
  fill: currentColor;
}

/* Voice status text */
.ai-voice-status {
  font-size: 1rem;
  font-weight: 500;
  color: #64748b;
  text-align: center;
}

.ai-voice-status--active {
  color: var(--ai-primary);
}

/* Voice transcript */
.ai-voice-transcript {
  font-size: 0.9rem;
  color: #64748b;
  text-align: center;
  max-height: 80px;
  overflow-y: auto;
  padding: 0 1rem;
  margin: 0;
}

/* Voice controls */
.ai-voice-controls {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 1rem;
  border-top: 1px solid rgba(148, 163, 184, 0.4);
}

.ai-section .ai-voice-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  border: none !important;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ai-section .ai-voice-btn--start {
  background: var(--ai-primary-gradient) !important;
  color: #ffffff !important;
  box-shadow: 0 12px 25px rgba(0, 158, 227, 0.3);
}

.ai-section .ai-voice-btn--start:hover {
  transform: scale(1.03);
  box-shadow: 0 16px 30px rgba(0, 158, 227, 0.4);
}

.ai-section .ai-voice-btn--stop {
  background: #ef4444 !important;
  color: #ffffff !important;
  box-shadow: 0 12px 25px rgba(239, 68, 68, 0.3);
}

.ai-section .ai-voice-btn--stop:hover {
  background: #dc2626 !important;
  box-shadow: 0 16px 30px rgba(239, 68, 68, 0.4);
}

.ai-section .ai-voice-btn--hidden {
  display: none;
}

.ai-section .ai-voice-btn svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: currentColor;
}

/* Voice error message */
.ai-voice-error {
  color: #ef4444;
  font-size: 0.85rem;
  text-align: center;
  padding: 0.5rem 1rem;
}

/* Voice permission notice */
.ai-voice-permission {
  font-size: 0.8rem;
  color: #94a3b8;
  text-align: center;
  padding: 0 1rem;
}

/* ========================== */
/* FAQ SECTION                */
/* ========================== */

.ai-faq-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
  animation: ai-fade-in 0.5s ease forwards;
}

.ai-faq-section--hidden {
  display: none;
}

.ai-faq-intro {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 500;
  color: #111827;
}

.ai-faq-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

@media (min-width: 640px) {
  .ai-faq-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.ai-section .ai-faq-btn {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  padding: 0.65rem 0.8rem;
  border-radius: 0.6rem;
  border: 2px solid transparent !important;
  background: #ffffff !important;
  color: #0f172a !important;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.10);
  font-size: 0.8rem;
  text-align: left;
  white-space: normal;
  cursor: pointer;
  transition: all 0.2s ease;
}

@media (min-width: 640px) {
  .ai-section .ai-faq-btn {
    font-size: 0.9rem;
    padding: 0.75rem 1rem;
  }
}

.ai-section .ai-faq-btn:hover {
  border-color: var(--ai-primary) !important;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.16);
}

.ai-faq-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 0.25rem;
  flex-shrink: 0;
}

.ai-faq-icon svg {
  width: 1rem;
  height: 1rem;
  color: var(--ai-primary-dark);
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

/* ========================== */
/* ANIMATIONS                 */
/* ========================== */

@keyframes ai-fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Card entrance animation */
.ai-chat-card,
.ai-voice-card {
  animation: ai-card-entrance 0.3s ease forwards;
}

@keyframes ai-card-entrance {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
