/* ─────────────────────────────────────────────
   Usmart Chat Widget — Design System Aligned
   Background: #070B14 | Blue: #38BDF8 | Purple: #A78BFA
   Font: Sora (headings) + Inter (body)
───────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Sora:wght@600;700&display=swap');

/* ── Root wrapper ── */
#usmart-agent {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  --ua-bg: #070B14;
  --ua-surface: rgba(255, 255, 255, 0.04);
  --ua-border: rgba(255, 255, 255, 0.08);
  --ua-blue: #38BDF8;
  --ua-purple: #A78BFA;
  --ua-green: #34D399;
  --ua-text: #F1F5F9;
  --ua-muted: #94A3B8;
  --ua-radius: 16px;
  --ua-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255,255,255,0.06);
}

/* ── Launcher button ── */
#ua-launcher {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #38BDF8, #A78BFA);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(56, 189, 248, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  color: #fff;
  margin-left: auto;
}
#ua-launcher:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 40px rgba(56, 189, 248, 0.5);
}
#ua-launcher svg {
  width: 24px;
  height: 24px;
}
#ua-icon-close { display: none; }

/* Badge */
#ua-badge {
  position: absolute;
  top: 0;
  right: 0;
  width: 18px;
  height: 18px;
  background: #EF4444;
  border-radius: 50%;
  border: 2px solid var(--ua-bg);
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
}

/* ── Panel ── */
#ua-panel {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 120px);
  background: var(--ua-bg);
  border-radius: var(--ua-radius);
  border: 1px solid var(--ua-border);
  box-shadow: var(--ua-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.97);
  transition: opacity 0.22s ease, transform 0.22s ease;
  /* Dot-grid overlay */
  background-image: radial-gradient(rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: 0 0;
  background-color: var(--ua-bg);
}
#ua-panel.ua-open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
}

/* ── Header ── */
#ua-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.035);
  border-bottom: 1px solid var(--ua-border);
  flex-shrink: 0;
}
#ua-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
#ua-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #38BDF8, #A78BFA);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#ua-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}
#ua-agent-name {
  font-family: 'Sora', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--ua-text);
}
#ua-status {
  font-size: 11px;
  color: var(--ua-green);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
}
#ua-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ua-green);
  animation: ua-pulse 2s infinite;
}
@keyframes ua-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
#ua-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
#ua-header-actions button {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--ua-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
#ua-header-actions button:hover {
  background: rgba(255,255,255,0.07);
  color: var(--ua-text);
}
#ua-header-actions button.ua-active {
  color: var(--ua-blue);
}
#ua-header-actions button svg {
  width: 16px;
  height: 16px;
}

/* ── Messages ── */
#ua-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
#ua-messages::-webkit-scrollbar { width: 4px; }
#ua-messages::-webkit-scrollbar-track { background: transparent; }
#ua-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* Message rows */
.ua-msg {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: ua-fadeup 0.2s ease;
}
@keyframes ua-fadeup {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.ua-user { align-self: flex-end; align-items: flex-end; }
.ua-assistant { align-self: flex-start; align-items: flex-start; }

/* Bubbles */
.ua-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.55;
  font-size: 13.5px;
}
.ua-user .ua-bubble {
  background: linear-gradient(135deg, rgba(56,189,248,0.2), rgba(167,139,250,0.15));
  border: 1px solid rgba(56,189,248,0.25);
  color: var(--ua-text);
  border-bottom-right-radius: 4px;
}
.ua-assistant .ua-bubble {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--ua-border);
  color: var(--ua-text);
  border-bottom-left-radius: 4px;
}

/* ── Typing indicator ── */
#ua-typing {
  display: none;
  align-items: center;
  gap: 4px;
  padding: 8px 16px 4px;
  flex-shrink: 0;
}
#ua-typing span {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ua-blue);
  opacity: 0.4;
  animation: ua-bounce 1.2s infinite;
}
#ua-typing span:nth-child(2) { animation-delay: 0.2s; }
#ua-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ua-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* ── Cards ── */
.ua-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 14px;
  margin-top: 8px;
  width: 100%;
  box-sizing: border-box;
}
.ua-card-title {
  font-family: 'Sora', sans-serif;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ua-blue);
  margin-bottom: 10px;
}

/* Cost calc */
.ua-calc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 8px;
}
.ua-calc-row label {
  font-size: 12px;
  color: var(--ua-muted);
  flex: 1;
}
.ua-calc-row input {
  width: 90px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--ua-border);
  border-radius: 8px;
  color: var(--ua-text);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  padding: 5px 8px;
  text-align: right;
  outline: none;
  flex-shrink: 0;
}
.ua-calc-row input:focus {
  border-color: var(--ua-blue);
}
.ua-calc-result {
  font-size: 13px;
  color: var(--ua-text);
  padding-top: 8px;
  border-top: 1px solid var(--ua-border);
}
.ua-calc-result strong { color: var(--ua-blue); }
.ua-saving {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--ua-green);
}

/* Calendly card */
.ua-calendly p {
  font-size: 12.5px;
  color: var(--ua-muted);
  margin: 0 0 12px;
}
.ua-btn-book {
  display: inline-block;
  background: linear-gradient(135deg, #38BDF8, #A78BFA);
  color: #fff;
  font-family: 'Sora', sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 8px;
  text-decoration: none;
  transition: opacity 0.15s;
}
.ua-btn-book:hover { opacity: 0.88; }

/* ── Input area ── */
#ua-input-area {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--ua-border);
  background: rgba(255,255,255,0.02);
  flex-shrink: 0;
}
#ua-input {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--ua-border);
  border-radius: 10px;
  color: var(--ua-text);
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  line-height: 1.5;
  padding: 8px 12px;
  resize: none;
  outline: none;
  transition: border-color 0.15s;
  max-height: 120px;
  overflow-y: auto;
}
#ua-input::placeholder { color: var(--ua-muted); }
#ua-input:focus { border-color: rgba(56,189,248,0.5); }

/* Mic + Send buttons */
#ua-mic, #ua-send {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}
#ua-mic {
  background: rgba(255,255,255,0.06);
  color: var(--ua-muted);
}
#ua-mic:hover { background: rgba(255,255,255,0.1); color: var(--ua-text); }
#ua-mic.ua-recording {
  background: rgba(239, 68, 68, 0.2);
  color: #EF4444;
  animation: ua-rec-pulse 1s infinite;
}
@keyframes ua-rec-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}
#ua-send {
  background: linear-gradient(135deg, #38BDF8, #A78BFA);
  color: #fff;
}
#ua-send:hover { transform: scale(1.07); }
#ua-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
#ua-mic svg, #ua-send svg { width: 16px; height: 16px; }

/* ── Footer ── */
#ua-footer {
  text-align: center;
  font-size: 10.5px;
  color: rgba(148,163,184,0.5);
  padding: 5px 0 8px;
  flex-shrink: 0;
}
#ua-footer strong { color: rgba(56,189,248,0.6); }

/* ── Mobile ── */
@media (max-width: 640px) {
  #usmart-agent {
    bottom: 16px;
    right: 16px;
  }
  #ua-launcher {
    width: 52px;
    height: 52px;
  }
  #ua-panel {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
    z-index: 100000;
  }
  #ua-panel.ua-open {
    transform: translateY(0) scale(1);
  }
}
