/* ═══════════════════════════════════════════
   AICSS — Floating AI Assistant Widget v3
   Right-edge docked, hover-slide, branded
════════════════════════════════════════════ */

/* ── Root Container ──
   Docked to right edge. Collapsed = translateX(348px) so only
   the 28px slim tab pill peeks out from the screen edge.
   Hover or .ai-pinned (panel open) slides the full widget in.
───────────────────────────────────────────── */
#ai-assistant-root {
  position: fixed;
  right: 0;
  bottom: 100px;      /* above Donate Now button */
  z-index: 1050;      /* below Donate z-index:1200, above page content */
  display: flex;
  align-items: center; /* tab pill centers vertically on body panel */
  width: 376px;        /* 28px tab + 348px body */
  transform: translateX(348px);  /* only the slim tab peeks out */
  transition: transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  will-change: transform;
}

/* Slide in on hover (desktop) or when panel is pinned open */
#ai-assistant-root:hover,
#ai-assistant-root.ai-pinned {
  transform: translateX(0);
}

/* ── Tab Handle ──
   Slim 28×72 pill — only the icon + pulse dot, no full-height strip.
   Centred on the body panel so it doesn't span the whole viewport height.
───────────────────────────────────────────── */
.ai-tab-handle {
  flex-shrink: 0;
  width: 28px;
  height: 72px;        /* fixed height — NOT full-height stretch */
  background: linear-gradient(180deg, #1a1b9f 0%, #0b61a4 60%, #1a7ec8 100%);
  border-radius: 12px 0 0 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: -3px 3px 18px rgba(11, 97, 164, 0.5), -1px 0 0 rgba(26, 126, 200, 0.25);
  position: relative;
  z-index: 2;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.3s ease, box-shadow 0.3s ease, width 0.25s ease;
}

.ai-tab-handle:hover {
  width: 32px; /* subtle swell on hover */
  background: linear-gradient(180deg, #1a1b9f 0%, #1a7ec8 100%);
  box-shadow: -5px 3px 28px rgba(11, 97, 164, 0.65), -1px 0 0 rgba(26, 126, 200, 0.35);
}

/* Pulse dot — gold accent, signals "live" */
.ai-tab-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f0c64a;
  flex-shrink: 0;
  animation: ai-tab-pulse 2.4s ease-in-out infinite;
}

@keyframes ai-tab-pulse {
  0%, 100% { opacity: 1;   transform: scale(1);    }
  50%       { opacity: 0.4; transform: scale(0.7); }
}

/* Bot icon on tab — slightly smaller to fit slim pill */
.ai-tab-icon {
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.92;
}

.ai-tab-icon svg {
  width: 16px;
  height: 16px;
}

/* "AI" label hidden — too wide for slim 28px pill */
.ai-tab-label {
  display: none;
}

/* ── Widget Body ──
   Dark-navy panel matching the site's nav/footer aesthetic.
───────────────────────────────────────────── */
.ai-widget-body {
  flex: 1;
  min-width: 0;
  background: linear-gradient(160deg, #062040 0%, #030f1f 100%);
  border: 1px solid rgba(26, 126, 200, 0.22);
  border-right: none;
  border-radius: 16px 0 0 16px;
  overflow: hidden;
  box-shadow: -10px 0 48px rgba(4, 24, 56, 0.45);
  display: flex;
  flex-direction: column;
}

/* ── Panel Header ── */
.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 12px;
  border-bottom: 1px solid rgba(26, 126, 200, 0.15);
  background: rgba(26, 27, 159, 0.08);
}

.ai-panel-header .status-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-panel-header .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
  animation: ai-status-pulse 2s ease-in-out infinite;
}

@keyframes ai-status-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.ai-panel-header .status-label {
  font-size: 13px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.92);
  letter-spacing: 0.01em;
}

.ai-panel-header .header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Badges */
.ai-badge {
  padding: 3px 9px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 20px;
  letter-spacing: 0.04em;
}

.ai-badge.model {
  background: rgba(26, 126, 200, 0.2);
  color: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(26, 126, 200, 0.3);
}

.ai-badge.pro {
  background: rgba(201, 147, 10, 0.18);
  color: #f0c64a;
  border: 1px solid rgba(240, 198, 74, 0.3);
}

/* Close button */
.ai-close-btn {
  padding: 6px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  line-height: 1;
}

.ai-close-btn:hover {
  background: rgba(26, 126, 200, 0.2);
  color: rgba(255, 255, 255, 0.9);
}

/* ── Textarea ── */
.ai-textarea-wrap {
  position: relative;
  flex: 1;
}

.ai-textarea {
  width: 100%;
  min-height: 110px;
  padding: 14px 18px;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-size: 13.5px;
  font-weight: 400;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.88);
  font-family: inherit;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(26, 126, 200, 0.3) transparent;
}

.ai-textarea::-webkit-scrollbar { width: 4px; }
.ai-textarea::-webkit-scrollbar-track { background: transparent; }
.ai-textarea::-webkit-scrollbar-thumb {
  background: rgba(26, 126, 200, 0.3);
  border-radius: 4px;
}

.ai-textarea::placeholder {
  color: rgba(255, 255, 255, 0.28);
  font-size: 13px;
}

/* ── Controls ── */
.ai-controls {
  padding: 0 14px 14px;
  border-top: 1px solid rgba(26, 126, 200, 0.1);
  margin-top: 2px;
}

.ai-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
}

.ai-left-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-attach-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: rgba(11, 97, 164, 0.12);
  border-radius: 10px;
  border: 1px solid rgba(26, 126, 200, 0.18);
}

.ai-icon-btn {
  position: relative;
  padding: 8px;
  background: transparent;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.38);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s, transform 0.2s;
}

.ai-icon-btn:hover {
  background: rgba(26, 126, 200, 0.18);
  color: rgba(255, 255, 255, 0.85);
  transform: scale(1.08);
}

.ai-icon-btn.link:hover   { color: #f0c64a; }
.ai-icon-btn.code:hover   { color: #4ade80; }
.ai-icon-btn.design:hover { color: #c084fc; }

.ai-voice-btn {
  padding: 8px;
  background: transparent;
  border: 1px solid rgba(26, 126, 200, 0.22);
  border-radius: 7px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.38);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s, border-color 0.2s, transform 0.2s;
}

.ai-voice-btn:hover {
  color: #f0c64a;
  background: rgba(11, 97, 164, 0.18);
  border-color: rgba(240, 198, 74, 0.35);
  transform: scale(1.08);
}

/* Tooltips */
.ai-icon-btn .ai-tooltip,
.ai-voice-btn .ai-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 10px;
  background: rgba(3, 15, 31, 0.96);
  color: rgba(255, 255, 255, 0.88);
  font-size: 11px;
  border-radius: 7px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  border: 1px solid rgba(26, 126, 200, 0.3);
}

.ai-icon-btn:hover .ai-tooltip,
.ai-voice-btn:hover .ai-tooltip {
  opacity: 1;
}

/* ── Right Controls ── */
.ai-right-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-char-count {
  font-size: 10.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.25);
}

.ai-char-count .current {
  color: rgba(255, 255, 255, 0.5);
}

/* Send button — gold gradient matching donate button aesthetic */
.ai-send-btn {
  position: relative;
  padding: 10px 12px;
  background: linear-gradient(135deg, #c9930a 0%, #f0c64a 100%);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  color: #03182b;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(201, 147, 10, 0.35);
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
  overflow: hidden;
}

.ai-send-btn:hover {
  transform: scale(1.08) rotate(-2deg);
  box-shadow: 0 6px 22px rgba(201, 147, 10, 0.5);
  background: linear-gradient(135deg, #d9a30c, #f5d060);
}

.ai-send-btn:active {
  transform: scale(0.96);
}

.ai-send-btn svg {
  transition: transform 0.2s;
}

.ai-send-btn:hover svg {
  transform: translateX(1px) translateY(-1px) rotate(10deg) scale(1.1);
}

/* ── Footer ── */
.ai-panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(26, 126, 200, 0.1);
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.3);
  gap: 12px;
}

.ai-footer-hint {
  display: flex;
  align-items: center;
  gap: 5px;
}

.ai-footer-hint kbd {
  padding: 2px 5px;
  background: rgba(11, 97, 164, 0.2);
  border: 1px solid rgba(26, 126, 200, 0.3);
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.55);
  font-family: monospace;
  font-size: 9.5px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.ai-footer-status {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.3);
}

.ai-status-dot-green {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}

/* ── Overlay shimmer ── */
.ai-widget-overlay {
  position: absolute;
  inset: 0;
  border-radius: 16px 0 0 16px;
  pointer-events: none;
  background: linear-gradient(160deg, rgba(26, 27, 159, 0.06), transparent 40%, rgba(26, 126, 200, 0.04));
}

/* ── Responsive ── */

/* Tablet */
@media (max-width: 900px) {
  #ai-assistant-root {
    width: 348px;         /* 28px tab + 320px body */
    transform: translateX(320px);
    bottom: 96px;
  }

  #ai-assistant-root:hover,
  #ai-assistant-root.ai-pinned {
    transform: translateX(0);
  }
}

/* Mobile */
@media (max-width: 600px) {
  #ai-assistant-root {
    /* On mobile, no hover. JS handles tap-to-toggle on tab. */
    width: 308px;         /* 24px tab + 284px body */
    transform: translateX(284px);
    bottom: 88px;
  }

  .ai-tab-handle {
    width: 24px;
    height: 60px;
    border-radius: 10px 0 0 10px;
  }

  /* Disable hover-based expansion on touch devices */
  #ai-assistant-root:hover:not(.ai-pinned) {
    transform: translateX(284px);
  }

  #ai-assistant-root.ai-pinned {
    transform: translateX(0);
  }

  .ai-textarea {
    min-height: 90px;
    font-size: 13px;
  }

  .ai-badge.model { display: none; }

  .ai-panel-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
}

/* Very small screens */
@media (max-width: 380px) {
  #ai-assistant-root {
    width: 292px;         /* 24px tab + 268px body */
    transform: translateX(268px);
  }

  #ai-assistant-root.ai-pinned {
    transform: translateX(0);
  }

  #ai-assistant-root:hover:not(.ai-pinned) {
    transform: translateX(268px);
  }
}
