/* CopilotKit Agent-Native UI for TuTaDev Cloud Ecosystem */
:root {
  --cp-bg: #0b1120;
  --cp-surface: #131c31;
  --cp-border: #1e293b;
  --cp-primary: #38bdf8;
  --cp-primary-glow: rgba(56, 189, 248, 0.35);
  --cp-accent: #818cf8;
  --cp-success: #10b981;
  --cp-warning: #f59e0b;
  --cp-danger: #ef4444;
  --cp-text: #f8fafc;
  --cp-text-muted: #94a3b8;
}

/* Floating Trigger Button */
.copilot-trigger-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0284c7, #6366f1);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 25px rgba(2, 132, 199, 0.4), 0 0 20px rgba(99, 102, 241, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}
.copilot-trigger-btn:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 12px 30px rgba(2, 132, 199, 0.5), 0 0 25px rgba(99, 102, 241, 0.4);
}
.copilot-trigger-btn::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--cp-primary);
  opacity: 0.6;
  animation: cp-pulse 2.5s infinite;
}
@keyframes cp-pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 0; }
  100% { transform: scale(0.95); opacity: 0; }
}

/* Floating Badge */
.copilot-trigger-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--cp-success);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--cp-bg);
}

/* Main Drawer / Panel */
.copilot-drawer {
  position: fixed;
  bottom: 94px;
  right: 24px;
  width: 420px;
  max-width: calc(100vw - 32px);
  height: 640px;
  max-height: calc(100vh - 120px);
  background: rgba(11, 17, 32, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(56, 189, 248, 0.15);
  display: flex;
  flex-direction: column;
  z-index: 9998;
  overflow: hidden;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
}
.copilot-drawer.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.copilot-header {
  padding: 14px 18px;
  background: rgba(19, 28, 49, 0.8);
  border-bottom: 1px solid var(--cp-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.copilot-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.copilot-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0284c7, #818cf8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 0 10px var(--cp-primary-glow);
}
.copilot-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--cp-text);
  display: flex;
  flex-direction: column;
}
.copilot-subtitle {
  font-size: 0.7rem;
  color: var(--cp-primary);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
}
.copilot-subtitle::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--cp-success);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--cp-success);
}
.copilot-close-btn {
  background: transparent;
  border: none;
  color: var(--cp-text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.copilot-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* Quick Action Pills */
.copilot-pills {
  padding: 10px 14px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  background: rgba(15, 23, 42, 0.4);
  border-bottom: 1px solid var(--cp-border);
}
.copilot-pills::-webkit-scrollbar { display: none; }
.copilot-pill {
  white-space: nowrap;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(56, 189, 248, 0.1);
  color: var(--cp-primary);
  border: 1px solid rgba(56, 189, 248, 0.25);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}
.copilot-pill:hover {
  background: rgba(56, 189, 248, 0.25);
  transform: translateY(-1px);
}

/* Message List */
.copilot-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: #1e293b transparent;
}
.copilot-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  gap: 4px;
}
.copilot-msg.user {
  align-self: flex-end;
}
.copilot-msg.assistant {
  align-self: flex-start;
}
.copilot-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.85rem;
  line-height: 1.5;
  word-break: break-word;
}
.copilot-msg.user .copilot-bubble {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.copilot-msg.assistant .copilot-bubble {
  background: var(--cp-surface);
  color: var(--cp-text);
  border: 1px solid var(--cp-border);
  border-bottom-left-radius: 4px;
}

/* GENERATIVE UI CARDS (CopilotKit Signature) */
.gen-card {
  margin-top: 8px;
  background: #070d19;
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.gen-card-title {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--cp-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.gen-card-video {
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  aspect-ratio: 16/9;
}
.gen-card-video video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.gen-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.gen-btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}
.gen-btn-primary {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: #fff;
}
.gen-btn-secondary {
  background: #1e293b;
  color: var(--cp-text);
  border: 1px solid #334155;
}

/* Telemetry Card */
.gen-telemetry-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.gen-stat-box {
  background: #0f172a;
  border: 1px solid var(--cp-border);
  border-radius: 8px;
  padding: 8px 10px;
}
.gen-stat-label {
  font-size: 0.65rem;
  color: var(--cp-text-muted);
  text-transform: uppercase;
  font-weight: 700;
}
.gen-stat-val {
  font-size: 0.85rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 800;
  color: var(--cp-success);
  margin-top: 2px;
}

/* Input Bar */
.copilot-input-area {
  padding: 12px 14px;
  background: rgba(19, 28, 49, 0.95);
  border-top: 1px solid var(--cp-border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.copilot-textarea {
  flex: 1;
  background: #090e1a;
  border: 1px solid var(--cp-border);
  border-radius: 12px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--cp-text);
  resize: none;
  max-height: 100px;
  outline: none;
  transition: border-color 0.2s ease;
}
.copilot-textarea:focus {
  border-color: var(--cp-primary);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}
.copilot-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--cp-primary);
  color: #0b1120;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 16px;
  flex-shrink: 0;
}
.copilot-send-btn:hover {
  background: #7dd3fc;
  transform: scale(1.05);
}
.copilot-send-btn:disabled {
  background: #334155;
  color: #64748b;
  cursor: not-allowed;
  transform: none;
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
  .copilot-drawer {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 85vh;
    max-height: 85vh;
    border-radius: 20px 20px 0 0;
  }
}
