/* ═══════════════════════════════════════════════════════
   CostaCraft AI Widget v3.0 — Styles
   Premium dark UI | Glassmorphism | Microinteractions
═══════════════════════════════════════════════════════ */

/* ── FAB DIAL ─────────────────────────────────────────── */
#cc-dial {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

#cc-dial-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.dial-item-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 16px;
  border-radius: 30px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: .8rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  border: none;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,.5), 0 1px 3px rgba(0,0,0,.4);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: all .2s cubic-bezier(.34,1.56,.64,1);
}
.dial-item-btn:hover {
  transform: translateX(-4px) scale(1.02);
}

.dial-discord {
  background: rgba(88,101,242,.2);
  border: 1px solid rgba(88,101,242,.4);
  color: #7289da;
}
.dial-discord:hover { background: rgba(88,101,242,.32); }

.dial-wa {
  background: rgba(37,211,102,.15);
  border: 1px solid rgba(37,211,102,.35);
  color: #25d166;
}
.dial-wa:hover { background: rgba(37,211,102,.26); }

.dial-ai {
  background: rgba(99,102,241,.2);
  border: 1px solid rgba(99,102,241,.45);
  color: #818cf8;
}
.dial-ai:hover { background: rgba(99,102,241,.32); }

.dial-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3730a3, #4f46e5);
  border: 2px solid rgba(99,102,241,.5);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px rgba(99,102,241,.6), 0 0 0 1px rgba(99,102,241,.3);
  transition: all .25s cubic-bezier(.34,1.56,.64,1);
  outline: none;
  position: relative;
  overflow: hidden;
}
.dial-toggle img { border-radius: 50%; }
.dial-toggle::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid rgba(99,102,241,.3);
  animation: dial-ring 2.5s ease-in-out infinite;
}
@keyframes dial-ring {
  0%, 100% { opacity: 0; transform: scale(.95); }
  50% { opacity: 1; transform: scale(1.05); }
}
.dial-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 32px rgba(99,102,241,.7);
}
.dial-toggle.open {
  background: linear-gradient(135deg, #1e1b4b, #312e81);
  transform: rotate(0deg);
}
.dial-toggle.open::after { display: none; }

/* ── AI CHAT WINDOW ──────────────────────────────────── */
#cc-ai-window {
  position: fixed;
  bottom: 90px;
  right: 24px;
  z-index: 9999;
  width: min(400px, calc(100vw - 32px));
  height: min(600px, calc(100vh - 120px));
  background: #060810;
  border: 1px solid rgba(99,102,241,.25);
  border-radius: 20px;
  display: none;
  flex-direction: column;
  overflow: hidden;
  box-shadow:
    0 32px 80px rgba(0,0,0,.8),
    0 0 0 1px rgba(99,102,241,.12),
    inset 0 1px 0 rgba(255,255,255,.03);
  font-family: 'Plus Jakarta Sans', sans-serif;
  transition: opacity .28s cubic-bezier(.4,0,.2,1), transform .28s cubic-bezier(.4,0,.2,1);
  transform: translateY(16px) scale(.97);
  opacity: 0;
}
#cc-ai-window.visible {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Header */
.ai-win-header {
  padding: 14px 16px;
  background: rgba(8,12,30,.97);
  border-bottom: 1px solid rgba(99,102,241,.18);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  backdrop-filter: blur(20px);
}
.ai-win-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3730a3, #4f46e5);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 16px rgba(99,102,241,.5);
  overflow: hidden;
  border: 1.5px solid rgba(99,102,241,.4);
}
.ai-win-avatar img { width: 100%; height: 100%; object-fit: contain; border-radius: 50%; }
.ai-win-info { flex: 1; min-width: 0; }
.ai-win-name {
  font-size: .88rem;
  font-weight: 800;
  color: #f1f5f9;
  letter-spacing: -.02em;
}
.ai-win-status {
  font-size: .7rem;
  color: #22c55e;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
}
.ai-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34,197,94,.8);
  animation: ai-pulse 1.8s ease-in-out infinite;
}
@keyframes ai-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px rgba(34,197,94,.8); }
  50% { opacity: .6; box-shadow: 0 0 4px rgba(34,197,94,.4); }
}
.ai-win-badge {
  font-size: .58rem;
  background: rgba(99,102,241,.14);
  color: #818cf8;
  border: 1px solid rgba(99,102,241,.25);
  border-radius: 99px;
  padding: 2px 8px;
  font-weight: 800;
  letter-spacing: .06em;
}
.ai-win-new {
  background: none;
  border: none;
  color: rgba(100,116,139,.6);
  cursor: pointer;
  padding: 5px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  transition: all .2s;
  flex-shrink: 0;
}
.ai-win-new:hover {
  color: #818cf8;
  background: rgba(99,102,241,.1);
}
.ai-win-close {
  background: none;
  border: none;
  color: rgba(100,116,139,.6);
  cursor: pointer;
  padding: 5px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  transition: all .2s;
  flex-shrink: 0;
}
.ai-win-close:hover {
  color: #f1f5f9;
  background: rgba(255,255,255,.06);
}

/* Messages area */
.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.ai-messages::-webkit-scrollbar { width: 3px; }
.ai-messages::-webkit-scrollbar-track { background: transparent; }
.ai-messages::-webkit-scrollbar-thumb { background: rgba(99,102,241,.3); border-radius: 99px; }

/* Message bubbles */
.ai-msg {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 88%;
  animation: msg-in .2s ease-out;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ai-msg.user { align-self: flex-end; align-items: flex-end; }
.ai-msg.ai   { align-self: flex-start; align-items: flex-start; }

.ai-msg-bubble {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: .84rem;
  line-height: 1.65;
  word-break: break-word;
}
.ai-msg.user .ai-msg-bubble {
  background: rgba(99,102,241,.22);
  border: 1px solid rgba(99,102,241,.32);
  color: #f1f5f9;
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}
.ai-msg.ai .ai-msg-bubble {
  background: rgba(15,22,48,.9);
  border: 1px solid rgba(55,65,81,.4);
  color: #e2e8f0;
  border-bottom-left-radius: 4px;
}

/* Formatted AI bubble (markdown rendering) */
.ai-formatted { white-space: normal; }
.ai-formatted br { display: block; margin: 3px 0; }
.ai-formatted strong { color: #f1f5f9; font-weight: 700; }
.ai-formatted ul, .ai-formatted ol {
  margin: 6px 0 4px 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ai-formatted li { color: #cbd5e1; line-height: 1.5; }
.ai-formatted ol { list-style: decimal; }
.ai-formatted ul { list-style: disc; }
.ai-formatted code {
  background: rgba(99,102,241,.12);
  border: 1px solid rgba(99,102,241,.2);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: .8em;
  color: #a5b4fc;
}

.ai-msg-time {
  font-size: .63rem;
  color: rgba(100,116,139,.6);
  padding: 0 3px;
}
.ai-sender-label {
  font-size: .68rem;
  font-weight: 700;
  color: #818cf8;
  padding: 0 3px;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 1px;
}

/* Typing indicator */
.ai-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 11px 14px;
  background: rgba(15,22,48,.9);
  border: 1px solid rgba(55,65,81,.4);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}
.ai-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6366f1;
  animation: typing-dot .9s ease-in-out infinite;
}
.ai-typing-dot:nth-child(2) { animation-delay: .18s; }
.ai-typing-dot:nth-child(3) { animation-delay: .36s; }
@keyframes typing-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Transfer card */
.ai-transfer-card {
  background: rgba(99,102,241,.07);
  border: 1px solid rgba(99,102,241,.22);
  border-radius: 14px;
  padding: 14px;
  margin-top: 4px;
  align-self: stretch;
}
.ai-transfer-card.ai-transfer-urgent {
  background: rgba(239,68,68,.07);
  border-color: rgba(239,68,68,.3);
  animation: ai-urgent-pulse 2s ease-in-out 3;
}
@keyframes ai-urgent-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,.0); }
  50% { box-shadow: 0 0 0 4px rgba(239,68,68,.15); }
}
.ai-transfer-card.ai-transfer-urgent .ai-transfer-title { color: #f87171; }
.ai-transfer-title {
  font-size: .78rem;
  font-weight: 700;
  color: #818cf8;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ai-transfer-summary {
  font-size: .76rem;
  color: rgba(203,213,225,.65);
  line-height: 1.65;
  white-space: normal;
  margin-bottom: 10px;
  border-top: 1px solid rgba(55,65,81,.3);
  padding-top: 8px;
}
.ai-transfer-summary strong { color: rgba(203,213,225,.9); }
.ai-transfer-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.ai-transfer-btn {
  flex: 1;
  min-width: 100px;
  padding: 8px 12px;
  border-radius: 9px;
  font-size: .77rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all .2s;
  font-family: inherit;
  text-decoration: none;
}
.ai-transfer-wa {
  background: rgba(37,211,102,.14);
  border: 1px solid rgba(37,211,102,.28);
  color: #25d166;
}
.ai-transfer-wa:hover { background: rgba(37,211,102,.24); }
.ai-transfer-dc {
  background: rgba(88,101,242,.14);
  border: 1px solid rgba(88,101,242,.28);
  color: #7289da;
}
.ai-transfer-dc:hover { background: rgba(88,101,242,.24); }

/* Quick replies */
.ai-quick-replies {
  padding: 8px 14px 6px;
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  border-top: 1px solid rgba(55,65,81,.2);
  flex-shrink: 0;
}
.ai-quick-btn {
  background: rgba(99,102,241,.07);
  border: 1px solid rgba(99,102,241,.2);
  color: #818cf8;
  border-radius: 99px;
  padding: 5px 12px;
  font-size: .74rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  font-family: inherit;
  white-space: nowrap;
}
.ai-quick-btn:hover {
  background: rgba(99,102,241,.17);
  border-color: rgba(99,102,241,.4);
  transform: translateY(-1px);
}

/* Input area */
.ai-input-area {
  padding: 10px 12px;
  border-top: 1px solid rgba(55,65,81,.25);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: rgba(6,8,16,.85);
  flex-shrink: 0;
}
.ai-textarea {
  flex: 1;
  background: rgba(15,22,48,.8);
  border: 1px solid rgba(55,65,81,.4);
  border-radius: 12px;
  padding: 9px 12px;
  color: #f1f5f9;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: .85rem;
  resize: none;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  max-height: 100px;
  min-height: 38px;
  line-height: 1.5;
}
.ai-textarea:focus {
  border-color: rgba(99,102,241,.5);
  box-shadow: 0 0 0 3px rgba(99,102,241,.08);
}
.ai-textarea::placeholder { color: rgba(100,116,139,.55); }
.ai-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4338ca, #6366f1);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all .2s;
  box-shadow: 0 2px 12px rgba(99,102,241,.4);
}
.ai-send-btn:hover:not(:disabled) {
  opacity: .88;
  transform: scale(1.06);
}
.ai-send-btn:disabled {
  opacity: .3;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Footer */
.ai-footer-note {
  font-size: .63rem;
  color: rgba(100,116,139,.45);
  text-align: center;
  padding: 4px 14px 9px;
  flex-shrink: 0;
}

/* ── RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 480px) {
  #cc-ai-window {
    bottom: 82px;
    right: 10px;
    left: 10px;
    width: auto;
    height: calc(100dvh - 106px);
    border-radius: 18px;
  }
  #cc-dial {
    bottom: 16px;
    right: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dial-toggle::after { display: none; }
  @keyframes msg-in { from { opacity: 1; } }
  @keyframes typing-dot { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }
}
