/* AI Quiz Builder Chat Modal Styles */

/* Floating Button */
.ai-quiz-builder-button {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: transform 0.2s, box-shadow 0.2s;
  z-index: 999;
  overflow: visible;
  position: relative;
}

.ai-quiz-builder-button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.ai-quiz-builder-button:active {
  transform: scale(1.05);
}

/* Organic shapes in button */
.ai-quiz-builder-button .organic-shape {
  position: absolute;
  border-radius: 63% 37% 54% 46% / 55% 48% 52% 45%;
}

.ai-quiz-builder-button .shape-1 {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.1));
  top: 8px;
  left: 8px;
  animation: gentle-float-1 14s ease-in-out infinite;
  border-radius: 58% 42% 48% 52% / 62% 45% 55% 38%;
}

.ai-quiz-builder-button .shape-2 {
  width: 26px;
  height: 26px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.08));
  bottom: 10px;
  right: 10px;
  animation: gentle-float-2 15s ease-in-out infinite;
  animation-delay: 5s;
  border-radius: 52% 48% 35% 65% / 48% 62% 38% 52%;
}

.ai-quiz-builder-button .shape-3 {
  width: 22px;
  height: 22px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.06));
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  animation: gentle-float-3 13s ease-in-out infinite;
  animation-delay: 10s;
  border-radius: 68% 32% 55% 45% / 42% 58% 42% 58%;
}

/* Chat Modal */
.ai-chat-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 5000;
  backdrop-filter: blur(4px);
}

.ai-chat-modal.open {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.ai-chat-container {
  background: white;
  border-radius: 16px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.3s ease-out;
  position: relative;
  z-index: 1;
}

@keyframes slideUp {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Header */
.ai-chat-header {
  padding: 24px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: flex-start;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 16px 16px 0 0;
}

.ai-chat-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-right: auto;
}

.ai-chat-title h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.ai-chat-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-chat-beta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #ffffff;
  font-weight: 600;
}

.ai-chat-title p {
  margin: 4px 0 0 0;
  font-size: 13px;
  opacity: 0.9;
}

.ai-chat-close {
  margin-left: auto;
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  opacity: 0.9;
  transition: opacity 0.2s;
}

.ai-chat-close:hover {
  opacity: 1;
}

/* Usage Indicator */
.ai-usage-indicator {
  padding: 12px 24px;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.ai-usage-bar {
  flex: 1;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}

.ai-usage-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981 0%, #059669 100%);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.ai-usage-fill.warning {
  background: linear-gradient(90deg, #f59e0b 0%, #d97706 100%);
}

.ai-usage-fill.danger {
  background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%);
}

/* Chat Body */
.ai-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ai-chat-message {
  display: flex;
  gap: 12px;
  animation: messageSlide 0.3s ease-out;
}

@keyframes messageSlide {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ai-chat-message.user {
  flex-direction: row-reverse;
}

.ai-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-message-avatar.ai {
  background: transparent;
  color: white;
  position: relative;
  overflow: visible;
  box-shadow: none;
}

.ai-message-avatar.ai .ai-avatar-shapes {
  position: absolute;
  inset: 0;
}

.ai-message-avatar.ai .organic-shape {
  position: absolute;
  border-radius: 63% 37% 54% 46% / 55% 48% 52% 45%;
  opacity: 0.9;
  filter: drop-shadow(0 2px 4px rgba(15, 23, 42, 0.15));
}

.ai-message-avatar.ai .shape-1,
.ai-message-avatar.ai .shape-2,
.ai-message-avatar.ai .shape-3 {
  background: linear-gradient(135deg, rgba(124, 108, 255, 0.62), rgba(124, 108, 255, 0.28));
}

.ai-message-avatar.ai .shape-1 {
  width: 20px;
  height: 20px;
  top: 2px;
  left: 4px;
  animation: gentle-float-1 10s ease-in-out infinite;
}

.ai-message-avatar.ai .shape-2 {
  width: 16px;
  height: 16px;
  bottom: 2px;
  right: 6px;
  animation: gentle-float-2 12s ease-in-out infinite;
  animation-delay: 3s;
}

.ai-message-avatar.ai .shape-3 {
  width: 14px;
  height: 14px;
  top: 50%;
  right: -2px;
  transform: translateY(-50%);
  animation: gentle-float-3 11s ease-in-out infinite;
  animation-delay: 6s;
}

.ai-message-avatar.user {
  background: #e5e7eb;
  color: #374151;
  font-weight: 600;
  font-size: 14px;
}

.ai-message-content {
  flex: 1;
  padding: 12px 16px;
  border-radius: 12px;
  max-width: 80%;
}

.ai-message-content.ai {
  background: #f3f4f6;
  color: #1f2937;
}

.ai-message-content.user {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

/* Loading indicator */
.ai-typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.ai-typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ca3af;
  animation: typing 1.4s infinite;
}

.ai-typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.ai-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.6;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* Chat Footer */
.ai-chat-footer {
  padding: 16px 24px;
  border-top: 1px solid #e5e7eb;
  background: white;
  border-radius: 0 0 16px 16px;
}

.ai-chat-disclaimer {
  font-size: 12px;
  color: #4b5563;
  line-height: 1.5;
  margin-bottom: 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 12px;
}

.ai-chat-disclaimer strong {
  color: #1f2937;
}

body[data-theme="dark"] .ai-message-avatar.ai .organic-shape {
  filter: drop-shadow(0 2px 6px rgba(15, 23, 42, 0.6));
  opacity: 0.9;
}

body[data-theme="dark"] .ai-message-avatar.ai .shape-1,
body[data-theme="dark"] .ai-message-avatar.ai .shape-2,
body[data-theme="dark"] .ai-message-avatar.ai .shape-3 {
  background: linear-gradient(135deg, rgba(170, 160, 255, 0.75), rgba(150, 138, 255, 0.42));
}

.ai-chat-input-wrapper {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.ai-chat-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  font-size: 14px;
  resize: none;
  font-family: inherit;
  max-height: 120px;
  transition: border-color 0.2s;
}

.ai-chat-input:focus {
  outline: none;
  border-color: #667eea;
}

.ai-chat-send {
  padding: 12px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}

.ai-chat-send:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.ai-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Quiz Preview */
.ai-quiz-preview {
  background: #f9fafb;
  border: 2px solid #10b981;
  border-radius: 12px;
  padding: 16px;
  margin-top: 12px;
}

.ai-quiz-preview h4 {
  margin: 0 0 12px 0;
  color: #059669;
  font-size: 16px;
}

.ai-quiz-preview-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.ai-quiz-preview-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s;
  font-size: 14px;
}

.ai-quiz-preview-btn.primary {
  background: #10b981;
  color: white;
}

.ai-quiz-preview-btn.secondary {
  background: white;
  color: #059669;
  border: 1px solid #10b981;
}

.ai-quiz-preview-btn:hover {
  transform: translateY(-1px);
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
  .ai-chat-container {
    background: #1f2937;
    color: #f9fafb;
  }

  .ai-chat-header {
    border-bottom-color: #374151;
  }

  .ai-usage-indicator {
    background: #111827;
    border-bottom-color: #374151;
  }

  .ai-message-content.ai {
    background: #374151;
    color: #f9fafb;
  }

  .ai-chat-input {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
  }

  .ai-chat-footer {
    background: #1f2937;
    border-top-color: #374151;
  }

  .ai-chat-disclaimer {
    background: #111827;
    border-color: #374151;
    color: #e5e7eb;
  }

  .ai-chat-disclaimer strong {
    color: #f9fafb;
  }
}

/* Responsive */
@media (max-width: 640px) {
  .ai-chat-container {
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .ai-quiz-builder-button {
    bottom: 16px;
    left: 16px;
    width: 56px;
    height: 56px;
  }
}

/* Organic shape animations (from Mysa homepage) */
@keyframes gentle-float-1 {
  0%, 100% {
    transform: translate(0, 0) rotate(0deg);
  }
  25% {
    transform: translate(4px, -3px) rotate(4deg);
  }
  50% {
    transform: translate(-2px, 2px) rotate(-2deg);
  }
  75% {
    transform: translate(2px, 4px) rotate(3deg);
  }
}

@keyframes gentle-float-2 {
  0%, 100% {
    transform: translate(0, 0) rotate(0deg);
  }
  30% {
    transform: translate(-4px, 4px) rotate(-5deg);
  }
  60% {
    transform: translate(3px, -3px) rotate(4deg);
  }
  85% {
    transform: translate(-2px, 2px) rotate(-2deg);
  }
}

@keyframes gentle-float-3 {
  0%, 100% {
    transform: translate(0, 0) rotate(0deg);
  }
  20% {
    transform: translate(3px, 4px) rotate(6deg);
  }
  55% {
    transform: translate(-4px, -2px) rotate(-4deg);
  }
  80% {
    transform: translate(4px, -4px) rotate(3deg);
  }
}

/* Loading overlay with organic shapes */
.ai-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.ai-loading-overlay.visible {
  opacity: 1;
}

.ai-loading-content {
  text-align: center;
}

.ai-loading-shapes {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 24px;
}

.ai-loading-shapes .organic-shape {
  position: absolute;
}

.ai-loading-shapes .shape-1 {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.8), rgba(102, 126, 234, 0.3));
  top: 10%;
  left: 10%;
  animation: gentle-float-1 2s ease-in-out infinite;
  border-radius: 58% 42% 48% 52% / 62% 45% 55% 38%;
}

.ai-loading-shapes .shape-2 {
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, rgba(118, 75, 162, 0.7), rgba(118, 75, 162, 0.25));
  bottom: 15%;
  right: 15%;
  animation: gentle-float-2 2.5s ease-in-out infinite;
  animation-delay: 0.7s;
  border-radius: 52% 48% 35% 65% / 48% 62% 38% 52%;
}

.ai-loading-shapes .shape-3 {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.6), rgba(139, 92, 246, 0.2));
  top: 40%;
  right: 20%;
  animation: gentle-float-3 2.2s ease-in-out infinite;
  animation-delay: 1.4s;
  border-radius: 68% 32% 55% 45% / 42% 58% 42% 58%;
}

.ai-loading-text {
  color: white;
  font-size: 18px;
  font-weight: 500;
  margin: 0;
  opacity: 0.9;
}

/* Success notification */
.ai-success-notification {
  position: fixed;
  top: 24px;
  right: 24px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  padding: 16px 24px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
  font-size: 15px;
  font-weight: 500;
  z-index: 10001;
  opacity: 0;
  transform: translateY(-20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.ai-success-notification.visible {
  opacity: 1;
  transform: translateY(0);
}
