/**
 * CYJ Studio AI Assistant Styles
 * Mobile-first, Accessible, Custom-branded
 */

:root {
  --cyj-ai-primary: #00E5FF;
  --cyj-ai-primary-hover: #00b4d8;
  --cyj-ai-secondary: #0077B6;
  --cyj-ai-bg: #0A1128;
  --cyj-ai-surface: #101B39;
  --cyj-ai-surface-alt: #172554;
  --cyj-ai-border: rgba(0, 229, 255, 0.18);
  --cyj-ai-text: #F8FAFC;
  --cyj-ai-text-muted: #94A3B8;
  --cyj-ai-wa: #25D366;
  --cyj-ai-wa-hover: #1EBE5D;
}

/* Floating Launcher Button */
.cyj-ai-launcher {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 99990;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyj-ai-primary) 0%, var(--cyj-ai-secondary) 100%);
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 8px 24px rgba(0, 229, 255, 0.35), 0 4px 12px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
  outline: none;
  padding: 0;
  margin: 0;
}

.cyj-ai-launcher:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 12px 30px rgba(0, 229, 255, 0.5), 0 6px 16px rgba(0, 0, 0, 0.5);
}

.cyj-ai-launcher:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
}

.cyj-ai-launcher-icon {
  width: 28px;
  height: 28px;
  fill: #0A1128;
  transition: transform 0.2s ease;
}

.cyj-ai-launcher:hover .cyj-ai-launcher-icon {
  transform: rotate(-5deg) scale(1.05);
}

/* Pulsing Badge Ring */
.cyj-ai-pulse-ring {
  position: absolute;
  top: -4px;
  right: -4px;
  bottom: -4px;
  left: -4px;
  border-radius: 50%;
  border: 2px solid var(--cyj-ai-primary);
  opacity: 0.8;
  animation: cyj-ai-pulse 2.4s infinite;
  pointer-events: none;
}

@keyframes cyj-ai-pulse {
  0% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.22); opacity: 0; }
  100% { transform: scale(1); opacity: 0; }
}

/* Notification Badge */
.cyj-ai-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #EF4444;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--cyj-ai-bg);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

/* Launcher Tooltip */
.cyj-ai-tooltip {
  position: absolute;
  left: 72px;
  bottom: 12px;
  background: var(--cyj-ai-surface);
  color: var(--cyj-ai-text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid var(--cyj-ai-border);
  box-shadow: 0 6px 18px rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.cyj-ai-launcher:hover .cyj-ai-tooltip {
  opacity: 1;
  transform: translateX(0);
}

/* Chat Widget Container */
.cyj-ai-widget {
  position: fixed;
  bottom: 96px;
  left: 24px;
  z-index: 99995;
  width: 390px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 120px);
  background: var(--cyj-ai-bg);
  border: 1px solid var(--cyj-ai-border);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(0, 229, 255, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: inherit;
}

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

/* Header */
.cyj-ai-header {
  background: linear-gradient(180deg, var(--cyj-ai-surface) 0%, rgba(16, 27, 57, 0.95) 100%);
  padding: 14px 16px;
  border-bottom: 1px solid var(--cyj-ai-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.cyj-ai-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyj-ai-primary) 0%, var(--cyj-ai-secondary) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

.cyj-ai-avatar-icon {
  width: 22px;
  height: 22px;
  fill: #0A1128;
}

.cyj-ai-online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10B981;
  border: 2px solid var(--cyj-ai-bg);
}

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

.cyj-ai-title {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
  line-height: 1.3;
}

.cyj-ai-status {
  font-size: 12px;
  color: var(--cyj-ai-text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.cyj-ai-status-pulse {
  width: 6px;
  height: 6px;
  background: #10B981;
  border-radius: 50%;
  display: inline-block;
}

.cyj-ai-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cyj-ai-btn-icon {
  background: transparent;
  border: none;
  color: var(--cyj-ai-text-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
  padding: 0;
}

.cyj-ai-btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.cyj-ai-btn-icon:focus-visible {
  outline: 2px solid var(--cyj-ai-primary);
}

/* Chat Messages Area */
.cyj-ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.cyj-ai-messages::-webkit-scrollbar {
  width: 5px;
}

.cyj-ai-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

/* Welcome Card */
.cyj-ai-welcome-card {
  background: rgba(0, 229, 255, 0.04);
  border: 1px solid var(--cyj-ai-border);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  margin-bottom: 4px;
}

.cyj-ai-welcome-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--cyj-ai-primary);
  margin-bottom: 6px;
}

.cyj-ai-welcome-desc {
  font-size: 13px;
  color: var(--cyj-ai-text-muted);
  line-height: 1.5;
}

/* Suggested Question Chips */
.cyj-ai-chips-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--cyj-ai-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.cyj-ai-chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.cyj-ai-chip {
  background: var(--cyj-ai-surface);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--cyj-ai-text);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: right;
  line-height: 1.3;
}

.cyj-ai-chip:hover {
  border-color: var(--cyj-ai-primary);
  background: rgba(0, 229, 255, 0.08);
  color: var(--cyj-ai-primary);
  transform: translateY(-1px);
}

/* Message Rows */
.cyj-ai-msg-row {
  display: flex;
  gap: 10px;
  max-width: 90%;
  animation: cyj-ai-msg-appear 0.25s ease forwards;
}

@keyframes cyj-ai-msg-appear {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.cyj-ai-msg-row.is-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.cyj-ai-msg-row.is-model {
  align-self: flex-start;
}

.cyj-ai-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyj-ai-primary), var(--cyj-ai-secondary));
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
}

.cyj-ai-msg-bubble {
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.6;
  position: relative;
  word-break: break-word;
}

.cyj-ai-msg-row.is-user .cyj-ai-msg-bubble {
  background: linear-gradient(135deg, var(--cyj-ai-primary) 0%, #0096c7 100%);
  color: #0A1128;
  font-weight: 600;
  border-bottom-left-radius: 3px;
  box-shadow: 0 4px 12px rgba(0, 229, 255, 0.2);
}

.cyj-ai-msg-row.is-model .cyj-ai-msg-bubble {
  background: var(--cyj-ai-surface);
  color: var(--cyj-ai-text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom-right-radius: 3px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.cyj-ai-msg-bubble p {
  margin: 0 0 8px 0;
}

.cyj-ai-msg-bubble p:last-child {
  margin-bottom: 0;
}

.cyj-ai-msg-bubble ul, .cyj-ai-msg-bubble ol {
  margin: 4px 0 8px 18px;
  padding: 0;
}

.cyj-ai-msg-bubble li {
  margin-bottom: 4px;
}

.cyj-ai-msg-bubble strong {
  color: #ffffff;
  font-weight: 700;
}

.cyj-ai-msg-time {
  font-size: 10.5px;
  color: var(--cyj-ai-text-muted);
  margin-top: 4px;
  text-align: left;
}

.cyj-ai-msg-row.is-user .cyj-ai-msg-time {
  text-align: right;
}

/* Call To Action Buttons inside Chat Bubble */
.cyj-ai-action-card {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cyj-ai-btn-wa {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--cyj-ai-wa);
  color: #ffffff !important;
  text-decoration: none !important;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 8px;
  transition: background 0.2s ease, transform 0.15s ease;
  box-shadow: 0 4px 10px rgba(37, 211, 102, 0.25);
}

.cyj-ai-btn-wa:hover {
  background: var(--cyj-ai-wa-hover);
  transform: translateY(-1px);
}

.cyj-ai-btn-store {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(0, 229, 255, 0.15);
  border: 1px solid var(--cyj-ai-primary);
  color: var(--cyj-ai-primary) !important;
  text-decoration: none !important;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.cyj-ai-btn-store:hover {
  background: var(--cyj-ai-primary);
  color: #0A1128 !important;
}

/* Typing Indicator */
.cyj-ai-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: var(--cyj-ai-surface);
  border-radius: 14px;
  width: fit-content;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.cyj-ai-typing-dot {
  width: 7px;
  height: 7px;
  background: var(--cyj-ai-primary);
  border-radius: 50%;
  animation: cyj-ai-bounce 1.3s infinite ease-in-out;
}

.cyj-ai-typing-dot:nth-child(2) { animation-delay: 0.18s; }
.cyj-ai-typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes cyj-ai-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* Chat Input Bar */
.cyj-ai-input-bar {
  background: var(--cyj-ai-surface);
  border-top: 1px solid var(--cyj-ai-border);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cyj-ai-input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.cyj-ai-textarea {
  flex: 1;
  background: rgba(10, 17, 40, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 10px 12px;
  color: #ffffff;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.4;
  resize: none;
  max-height: 100px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.cyj-ai-textarea:focus {
  border-color: var(--cyj-ai-primary);
  box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.2);
}

.cyj-ai-textarea::placeholder {
  color: var(--cyj-ai-text-muted);
}

.cyj-ai-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--cyj-ai-primary);
  border: none;
  color: #0A1128;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.15s ease, opacity 0.2s ease;
  flex-shrink: 0;
}

.cyj-ai-send-btn:hover:not(:disabled) {
  background: var(--cyj-ai-primary-hover);
  transform: translateY(-1px);
}

.cyj-ai-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.cyj-ai-send-icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.cyj-ai-footer-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--cyj-ai-text-muted);
  padding: 0 2px;
}

.cyj-ai-lang-switch {
  background: none;
  border: none;
  color: var(--cyj-ai-primary);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
  .cyj-ai-launcher {
    bottom: 16px;
    left: 16px;
    width: 54px;
    height: 54px;
  }

  .cyj-ai-widget {
    bottom: 0;
    left: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
  }

  .cyj-ai-header {
    padding: 12px 14px;
  }

  .cyj-ai-tooltip {
    display: none;
  }
}
