/* ============================================================
   SPORT BONE - AI Assistant Widget Styles
   Floating chatbot button + chat panel
   ============================================================ */

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --ai-primary: #2563eb;
  --ai-primary-dark: #1d4ed8;
  --ai-primary-light: #3b82f6;
  --ai-bg: #ffffff;
  --ai-bg-secondary: #f8fafc;
  --ai-text: #1e293b;
  --ai-text-muted: #64748b;
  --ai-border: #e2e8f0;
  --ai-bot-bubble: #f1f5f9;
  --ai-user-bubble: #2563eb;
  --ai-user-text: #ffffff;
  --ai-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  --ai-shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.1);
  --ai-radius: 16px;
  --ai-radius-sm: 12px;
  --ai-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Floating Button ───────────────────────────────────────── */
.ai-floating-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: var(--ai-primary);
  color: #fff;
  font-size: 26px;
  cursor: pointer;
  box-shadow: var(--ai-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--ai-transition), background var(--ai-transition), box-shadow var(--ai-transition);
  animation: aiFloatIn 0.5s ease-out;
}

.ai-floating-btn:hover {
  transform: scale(1.08);
  background: var(--ai-primary-dark);
  box-shadow: 0 14px 48px rgba(37, 99, 235, 0.35);
}

.ai-floating-btn:active {
  transform: scale(0.95);
}

.ai-floating-btn.ai-hidden {
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
}

/* Pulse ring */
.ai-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 3px solid var(--ai-primary);
  animation: aiPulse 2s ease-out infinite;
}

@keyframes aiFloatIn {
  from { transform: scale(0) translateY(20px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes aiPulse {
  0%   { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* ── Chat Panel ────────────────────────────────────────────── */
.ai-chat-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 9999;
  width: 400px;
  max-width: calc(100vw - 48px);
  height: 560px;
  max-height: calc(100vh - 140px);
  background: var(--ai-bg);
  border-radius: var(--ai-radius);
  box-shadow: var(--ai-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(0.9);
  opacity: 0;
  pointer-events: none;
  transition: transform var(--ai-transition), opacity var(--ai-transition);
}

.ai-chat-panel.ai-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* ── Chat Header ───────────────────────────────────────────── */
.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--ai-primary);
  color: #fff;
  flex-shrink: 0;
}

.ai-chat-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.ai-chat-header-left strong {
  display: block;
  font-size: 15px;
  line-height: 1.2;
}

.ai-chat-header-left small {
  font-size: 11px;
  opacity: 0.8;
}

.ai-chat-header-right {
  display: flex;
  gap: 4px;
}

.ai-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.ai-icon-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ── Messages Area ─────────────────────────────────────────── */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--ai-bg-secondary);
  scroll-behavior: smooth;
}

.ai-chat-messages::-webkit-scrollbar {
  width: 5px;
}

.ai-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
  background: var(--ai-border);
  border-radius: 10px;
}

/* ── Message Bubbles ───────────────────────────────────────── */
.ai-message {
  display: flex;
  animation: aiMsgIn 0.3s ease-out;
}

.ai-message-user {
  justify-content: flex-end;
}

.ai-message-bot,
.ai-message-assistant {
  justify-content: flex-start;
}

.ai-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: var(--ai-radius-sm);
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}

.ai-message-user .ai-bubble {
  background: var(--ai-user-bubble);
  color: var(--ai-user-text);
  border-bottom-right-radius: 4px;
}

.ai-message-bot .ai-bubble,
.ai-message-assistant .ai-bubble {
  background: var(--ai-bot-bubble);
  color: var(--ai-text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--ai-border);
}

.ai-bubble ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.ai-bubble li {
  margin-bottom: 2px;
}

.ai-bubble strong {
  color: var(--ai-primary);
}

.ai-visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ai-floating-btn:focus-visible,
.ai-icon-btn:focus-visible,
.ai-send-btn:focus-visible,
.ai-quick-chip:focus-visible {
  outline: 3px solid #facc15;
  outline-offset: 2px;
}

@keyframes aiMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Suggestions ───────────────────────────────────────────── */
.ai-suggestions {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
}

.ai-suggestions li {
  padding: 4px 0;
  font-size: 13px;
}

/* ── Typing Indicator ──────────────────────────────────────── */
.ai-typing-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 18px;
}

.ai-typing-bubble span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ai-text-muted);
  animation: aiTypingDot 1.4s ease-in-out infinite;
}

.ai-typing-bubble span:nth-child(2) {
  animation-delay: 0.2s;
}

.ai-typing-bubble span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes aiTypingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-6px); opacity: 1; }
}

/* ── Input Area ────────────────────────────────────────────── */
.ai-chat-input-area {
  padding: 12px 16px;
  background: var(--ai-bg);
  border-top: 1px solid var(--ai-border);
  flex-shrink: 0;
}

.ai-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--ai-bg-secondary);
  border: 1px solid var(--ai-border);
  border-radius: 24px;
  padding: 4px 4px 4px 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ai-input-wrapper:focus-within {
  border-color: var(--ai-primary-light);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.ai-chat-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  color: var(--ai-text);
  padding: 8px 0;
  min-width: 0;
}

.ai-chat-input::placeholder {
  color: var(--ai-text-muted);
}

.ai-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--ai-primary);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.2s;
}

.ai-send-btn:hover {
  background: var(--ai-primary-dark);
}

.ai-send-btn:active {
  transform: scale(0.9);
}

.ai-send-btn:disabled {
  background: var(--ai-border);
  color: var(--ai-text-muted);
  cursor: not-allowed;
}

.ai-disclaimer {
  text-align: center;
  margin-top: 6px;
}

.ai-disclaimer small {
  font-size: 10px;
  color: var(--ai-text-muted);
}

/* ── Quick-Action Chips ────────────────────────────────────── */
.ai-quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.ai-quick-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--ai-border);
  background: var(--ai-bg);
  color: var(--ai-text);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.ai-quick-chip:hover {
  background: var(--ai-primary);
  color: #fff;
  border-color: var(--ai-primary);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.ai-quick-chip:active {
  transform: scale(0.96);
}

/* ── Voice Input ───────────────────────────────────────────── */
.ai-voice-status {
  text-align: center;
  padding: 6px;
  font-size: 13px;
  color: var(--ai-primary);
  background: rgba(37, 99, 235, 0.08);
  border-radius: 8px;
  margin-bottom: 8px;
  animation: aiPulse 1.5s ease-in-out infinite;
}

.ai-voice-active {
  background: #ef4444 !important;
  animation: aiVoicePulse 1s ease-in-out infinite;
}

@keyframes aiVoicePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50%      { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

/* ── Rich Cards (in bot messages) ──────────────────────────── */
.ai-rich-card {
  margin-top: 10px;
  border: 1px solid var(--ai-border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--ai-bg);
  transition: box-shadow 0.2s;
}

.ai-rich-card:hover {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.ai-rich-card-header {
  padding: 10px 12px;
  background: var(--ai-primary);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-rich-card-body {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--ai-text);
}

.ai-rich-card-body p {
  margin: 0 0 4px;
}

.ai-rich-card-body .ai-card-meta {
  font-size: 11px;
  color: var(--ai-text-muted);
}

.ai-rich-card-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--ai-border);
}

.ai-rich-card-footer a,
.ai-rich-card-footer button {
  font-size: 12px;
  color: var(--ai-primary);
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.ai-rich-card-footer a:hover,
.ai-rich-card-footer button:hover {
  text-decoration: underline;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 480px) {
  .ai-chat-panel {
    right: 8px;
    bottom: 88px;
    width: calc(100vw - 16px);
    height: calc(100vh - 160px);
    max-height: none;
    border-radius: var(--ai-radius) var(--ai-radius) 0 0;
  }

  .ai-floating-btn {
    bottom: 16px;
    right: 16px;
    width: 52px;
    height: 52px;
    font-size: 22px;
  }

  .ai-bubble {
    max-width: 90%;
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ai-floating-btn,
  .ai-pulse,
  .ai-chat-panel,
  .ai-message,
  .ai-typing-bubble span,
  .ai-voice-status,
  .ai-voice-active {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Dark Mode (optional, jika app punya dark mode) ────────── */
@media (prefers-color-scheme: dark) {
  /* Uncomment jika ingin dark mode support:
  :root {
    --ai-bg: #1e293b;
    --ai-bg-secondary: #0f172a;
    --ai-text: #f1f5f9;
    --ai-text-muted: #94a3b8;
    --ai-border: #334155;
    --ai-bot-bubble: #1e293b;
  }
  */
}
