/* 
 * chatbot.css - Chatbot Widget Styling 
 * Dark Mode & Glassmorphism Design for codingsbums.com
 */

:root {
  /* Aligned with codingsbums.com design tokens */
  --chat-bg: rgba(14, 14, 14, 0.82); /* Matches --bg with glass */
  --chat-bg-opaque: #0e0e0e;
  --chat-border: rgba(255, 255, 255, 0.08); /* Matches --border */
  --chat-text: #f2ede8; /* Matches --text */
  --chat-text-muted: #888480; /* Matches --text-muted */
  --chat-primary: #c8a96e; /* Matches --accent (Gold) */
  --chat-primary-hover: #b99a62; /* Matches --sand-dark */
  --chat-primary-text: #0e0e0e; /* Dark text on gold button */
  --chat-bot-msg: rgba(255, 255, 255, 0.04); /* Matches --surface */
  --chat-user-msg: rgba(200, 169, 110, 0.12); /* Matches --accent-dim */
  --chat-radius-lg: 20px;
  --chat-radius-md: 12px;
}

/* Light Mode Overrides */
[data-theme="light"] {
  --chat-bg: rgba(255, 255, 255, 0.85); /* Light Glass */
  --chat-bg-opaque: #ffffff;
  --chat-border: rgba(0, 0, 0, 0.1);
  --chat-text: #1a1a1a;
  --chat-text-muted: #666666;
  --chat-primary: #e5e5e5; /* Helles Grau für Buttons */
  --chat-primary-hover: #d4d4d4;
  --chat-primary-text: #1a1a1a; /* Dunkle Icons/Texte */
  --chat-bot-msg: rgba(0, 0, 0, 0.03); 
  --chat-user-msg: rgba(0, 0, 0, 0.08); 
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --chat-bg: rgba(255, 255, 255, 0.85);
    --chat-bg-opaque: #ffffff;
    --chat-border: rgba(0, 0, 0, 0.1);
    --chat-text: #1a1a1a;
    --chat-text-muted: #666666;
    --chat-primary: #e5e5e5;
    --chat-primary-hover: #d4d4d4;
    --chat-primary-text: #1a1a1a;
    --chat-bot-msg: rgba(0, 0, 0, 0.03);
    --chat-user-msg: rgba(0, 0, 0, 0.08);
  }
}

#cb-widget-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--chat-text);
}

/* Floating Action Button */
#cb-fab {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--chat-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.3s;
}

#cb-fab:hover {
  transform: scale(1.1);
  background: var(--chat-primary-hover);
}

#cb-fab svg {
  width: 28px;
  height: 28px;
  fill: var(--chat-primary-text);
}

/* Chat Window & Overlay shared styles */
#cb-window,
.cb-overlay {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 350px;
  background: var(--chat-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--chat-border);
  border-radius: var(--chat-radius-lg);
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  transform-origin: bottom right;
}

#cb-window {
  max-height: 550px;
  height: calc(100vh - 120px);
}

#cb-window.cb-open,
#cb-age-gate.cb-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* Age Gate Overlay */
.cb-overlay {
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 10001;
}

.cb-gate-card {
  padding: 32px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.cb-gate-icon {
  width: 64px;
  height: 64px;
  background: var(--chat-user-msg);
  color: var(--chat-primary);
  border: 1px solid var(--chat-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  margin-bottom: 8px;
  box-shadow: 0 0 20px rgba(200, 169, 110, 0.2);
}

.cb-gate-card h3 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  color: var(--chat-primary);
}

.cb-gate-card p {
  font-size: 14px;
  color: var(--chat-text-muted);
  line-height: 1.6;
  margin: 0;
}

.cb-gate-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: 12px;
}

.cb-btn-primary {
  background: var(--chat-primary);
  color: var(--chat-primary-text);
  border: none;
  padding: 12px 20px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.cb-btn-primary:hover {
  background: var(--chat-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(200, 169, 110, 0.3);
}

.cb-btn-secondary {
  background: transparent;
  color: var(--chat-text-muted);
  border: 1px solid var(--chat-border);
  padding: 10px 20px;
  border-radius: 20px;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.cb-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--chat-text);
}

/* Header */
#cb-header {
  padding: 16px 20px;
  background: rgba(0,0,0,0.2);
  border-bottom: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.cb-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--chat-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
}

.cb-title-wrap {
  display: flex;
  flex-direction: column;
}

.cb-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}

.cb-subtitle {
  font-size: 12px;
  color: var(--chat-text-muted);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.cb-status-dot {
  width: 6px;
  height: 6px;
  background: #22c55e;
  border-radius: 50%;
}

#cb-close-btn {
  background: none;
  border: none;
  color: var(--chat-text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#cb-close-btn:hover {
  background: rgba(255,255,255,0.1);
  color: var(--chat-text);
}

/* Chat Area */
#cb-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

/* Custom Scrollbar for messages */
#cb-messages::-webkit-scrollbar {
  width: 6px;
}
#cb-messages::-webkit-scrollbar-track {
  background: transparent;
}
#cb-messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
  border-radius: 10px;
}

.cb-msg-wrap {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}

.cb-msg-wrap.bot {
  align-self: flex-start;
}

.cb-msg-wrap.user {
  align-self: flex-end;
}

.cb-msg {
  padding: 12px 16px;
  border-radius: var(--chat-radius-md);
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.bot .cb-msg {
  background: var(--chat-bot-msg);
  border: 1px solid var(--chat-border);
  border-bottom-left-radius: 4px;
}

.user .cb-msg {
  background: var(--chat-user-msg);
  color: var(--chat-text);
  border-bottom-right-radius: 4px;
}

/* Typing Indicator Animation */
.cb-typing {
  display: flex;
  gap: 4px;
  padding: 8px 4px;
}

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

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

@keyframes cb-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Input Area */
#cb-input-area {
  padding: 16px;
  background: rgba(0,0,0,0.2);
  border-top: 1px solid var(--chat-border);
}

.cb-input-wrapper {
  display: flex;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--chat-border);
  border-radius: 24px;
  padding: 4px 4px 4px 16px;
  align-items: center;
}

.cb-input-wrapper:focus-within {
  border-color: var(--chat-primary);
  background: rgba(255,255,255,0.08);
}

#cb-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--chat-text);
  font-size: 14px;
  outline: none;
  font-family: inherit;
}

#cb-input::placeholder {
  color: var(--chat-text-muted);
}

#cb-send-btn {
  background: var(--chat-primary);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--chat-primary-text);
  transition: background 0.2s, transform 0.2s;
}

#cb-send-btn:hover {
  background: var(--chat-primary-hover);
  transform: scale(1.05);
}

#cb-send-btn:disabled {
  background: var(--chat-border);
  cursor: not-allowed;
  transform: none;
}

/* Mobile responsive */
@media (max-width: 480px) {
  #cb-window,
  #cb-age-gate {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }
  
  .cb-gate-card {
    height: 100%;
    justify-content: center;
  }
}
