/* ============================================================
   WHALE OS — Floating AI Copilot Design System
   Fixed bottom-left popup with frosted glass, quick chips & FAB
   ============================================================ */

.floating-copilot-container {
  position: fixed;
  bottom: 24px;
  left: 28px;
  z-index: 99999;
  font-family: var(--font-arabic, 'Cairo', 'Segoe UI', sans-serif);
  direction: rtl;
  pointer-events: none;
}

/* FAB Trigger Button */
.copilot-trigger-btn {
  pointer-events: auto;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0284c7 0%, #2563eb 50%, #06b6d4 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(2, 132, 199, 0.45), 0 0 20px rgba(6, 182, 212, 0.3);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

.copilot-trigger-btn::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(6, 182, 212, 0.4);
  animation: copilotRingPulse 2.5s infinite;
  opacity: 0.8;
}

@keyframes copilotRingPulse {
  0% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.18); opacity: 0; }
  100% { transform: scale(1); opacity: 0; }
}

.copilot-trigger-btn:hover {
  transform: scale(1.08) rotate(6deg);
  box-shadow: 0 14px 40px rgba(2, 132, 199, 0.6), 0 0 30px rgba(6, 182, 212, 0.5);
}

.copilot-trigger-btn.active {
  transform: rotate(90deg);
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Floating Chat Panel */
.copilot-panel {
  pointer-events: auto;
  position: fixed;
  bottom: 92px;
  left: 28px;
  width: 400px;
  max-width: calc(100vw - 48px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6), 0 0 40px rgba(2, 132, 199, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 99999;
}

.copilot-panel.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Panel Header */
.copilot-header {
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.copilot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.3), rgba(6, 182, 212, 0.2));
  border: 1px solid rgba(6, 182, 212, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.copilot-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.copilot-title {
  color: #ffffff;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.2px;
}

.copilot-subtitle {
  color: #38bdf8;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.copilot-subtitle::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
}

.copilot-close {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.6);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.copilot-close:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
  transform: scale(1.05);
}

/* Chat Body */
.copilot-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.copilot-chat-body::-webkit-scrollbar {
  width: 5px;
}

.copilot-chat-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}

/* Message Bubbles */
.copilot-msg {
  max-width: 86%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.6;
  position: relative;
  word-break: break-word;
}

.copilot-msg.bot {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: #f1f5f9;
  align-self: flex-start;
  border-bottom-right-radius: 4px;
}

.copilot-msg.user {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  align-self: flex-end;
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 15px rgba(2, 132, 199, 0.3);
}

.copilot-msg-meta {
  display: block;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 6px;
  text-align: left;
}

/* Quick Action Chips */
.copilot-quick-chips-wrapper {
  padding: 10px 16px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  scrollbar-width: none;
}

.copilot-quick-chips-wrapper::-webkit-scrollbar {
  display: none;
}

.copilot-quick-chip {
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9999px;
  color: #e2e8f0;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.copilot-quick-chip:hover {
  background: rgba(2, 132, 199, 0.25);
  border-color: rgba(2, 132, 199, 0.5);
  color: #38bdf8;
  transform: translateY(-2px);
}

/* Footer / Input Bar */
.copilot-footer {
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.02);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.copilot-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px 14px;
  color: #ffffff;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
}

.copilot-input:focus {
  border-color: #0284c7;
  background: rgba(0, 0, 0, 0.45);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.2);
}

.copilot-input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.copilot-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  border: none;
  color: #ffffff;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.copilot-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(2, 132, 199, 0.5);
}

.copilot-send-btn:active {
  transform: scale(0.95);
}

/* Light Theme Support */
[data-theme="light"] .copilot-panel,
body.light-theme .copilot-panel {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.15), 0 0 30px rgba(2, 132, 199, 0.1);
}

[data-theme="light"] .copilot-header,
body.light-theme .copilot-header {
  background: rgba(0, 0, 0, 0.02);
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .copilot-title,
body.light-theme .copilot-title {
  color: #0f172a;
}

[data-theme="light"] .copilot-close,
body.light-theme .copilot-close {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
  color: #64748b;
}

[data-theme="light"] .copilot-msg.bot,
body.light-theme .copilot-msg.bot {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #1e293b;
}

[data-theme="light"] .copilot-quick-chips-wrapper,
body.light-theme .copilot-quick-chips-wrapper {
  background: #f8fafc;
  border-top-color: #e2e8f0;
}

[data-theme="light"] .copilot-quick-chip,
body.light-theme .copilot-quick-chip {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #334155;
}

[data-theme="light"] .copilot-footer,
body.light-theme .copilot-footer {
  background: #ffffff;
  border-top-color: #e2e8f0;
}

[data-theme="light"] .copilot-input,
body.light-theme .copilot-input {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}

[data-theme="light"] .copilot-input::placeholder,
body.light-theme .copilot-input::placeholder {
  color: #94a3b8;
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .floating-copilot-container {
    bottom: 16px;
    left: 16px;
  }
  .copilot-panel {
    bottom: 80px;
    left: 12px;
    right: 12px;
    width: auto;
    max-width: calc(100vw - 24px);
    height: 480px;
  }
}
