/* ═══════════════════════════════════════════════════════════════
   Renzo Chart Copilot — Conversational Data Assistant
   Feature flag: window.RENZO_DASH_V2
   ═══════════════════════════════════════════════════════════════ */

/* Panel container — docked right side of dashboard */
.rcp-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 380px;
  max-width: 100vw;
  background: var(--bg-card, rgba(22,32,56,0.95));
  border-left: 1px solid var(--border, rgba(99,102,241,0.1));
  display: flex;
  flex-direction: column;
  z-index: 1100;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.rcp-panel.rcp-open {
  transform: translateX(0);
}

/* Header */
.rcp-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.rcp-header-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}
.rcp-header-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.rcp-header-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(99,102,241,0.12);
  color: var(--primary-light, #818cf8);
  font-weight: 600;
  letter-spacing: 0.03em;
}
.rcp-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.15s;
}
.rcp-close:hover {
  background: rgba(148,163,184,0.1);
  color: var(--text);
}

/* Dataset info bar */
.rcp-dataset {
  padding: 8px 16px;
  background: rgba(99,102,241,0.04);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.rcp-dataset-name {
  font-weight: 600;
  color: var(--text);
}
.rcp-dataset-meta {
  opacity: 0.7;
}

/* Messages area */
.rcp-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Message bubbles */
.rcp-msg {
  max-width: 92%;
  animation: rcpMsgIn 0.2s ease;
}
.rcp-msg-user {
  align-self: flex-end;
  background: var(--user-msg, linear-gradient(135deg, #5b5ef0, #7c5ce6));
  color: #fff;
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  font-size: 13px;
  line-height: 1.5;
}
.rcp-msg-ai {
  align-self: flex-start;
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
}
.rcp-msg-ai p { margin: 4px 0; }
.rcp-msg-ai strong { color: var(--text); font-weight: 600; }

/* Chart rendered inside copilot */
.rcp-chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin: 8px 0;
}
.rcp-chart-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.rcp-chart-canvas {
  width: 100%;
  max-height: 200px;
}
.rcp-chart-narrative {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
  line-height: 1.5;
}
.rcp-chart-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.rcp-refine-btn {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: none;
  color: var(--primary-light);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.rcp-refine-btn:hover {
  background: rgba(99,102,241,0.08);
  border-color: rgba(99,102,241,0.3);
}
.rcp-export-btn, .rcp-undo-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.rcp-export-btn:hover {
  background: rgba(34,197,94,0.08);
  border-color: rgba(34,197,94,0.3);
  color: #22c55e;
}
.rcp-undo-btn:hover:not(:disabled) {
  background: rgba(245,158,11,0.08);
  border-color: rgba(245,158,11,0.3);
  color: #f59e0b;
}
.rcp-undo-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Follow-up chips */
.rcp-followups {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.rcp-chip {
  font-size: 11px;
  padding: 6px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(99,102,241,0.04);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  white-space: nowrap;
}
.rcp-chip:hover {
  background: rgba(99,102,241,0.1);
  border-color: rgba(99,102,241,0.3);
  color: var(--primary-light);
}

/* Clarification questions */
.rcp-clarify {
  background: rgba(251,191,36,0.06);
  border: 1px solid rgba(251,191,36,0.15);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 4px 0;
}
.rcp-clarify-q {
  font-size: 12px;
  color: var(--text);
  margin-bottom: 6px;
}
.rcp-clarify-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* Typing indicator */
.rcp-typing {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}
.rcp-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary-light);
  opacity: 0.4;
  animation: rcpDot 1.2s infinite;
}
.rcp-typing span:nth-child(2) { animation-delay: 0.2s; }
.rcp-typing span:nth-child(3) { animation-delay: 0.4s; }

/* Input area */
.rcp-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.rcp-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input, rgba(22,32,56,0.88));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px 4px 4px 14px;
  transition: border-color 0.2s;
}
.rcp-input-wrap:focus-within {
  border-color: rgba(99,102,241,0.4);
}
.rcp-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  padding: 8px 0;
}
.rcp-input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}
.rcp-send {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--primary, #6366f1);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, opacity 0.15s;
  opacity: 0.6;
}
.rcp-send:hover { opacity: 1; transform: scale(1.05); }

/* Toggle button (shown on dashboard toolbar) */
.rcp-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(99,102,241,0.06);
  color: var(--primary-light);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.15s;
}
.rcp-toggle:hover {
  background: rgba(99,102,241,0.12);
  border-color: rgba(99,102,241,0.3);
}
.rcp-toggle.rcp-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Welcome state */
.rcp-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
  gap: 12px;
}
.rcp-welcome-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(139,92,246,0.08));
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-light);
}
.rcp-welcome-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.rcp-welcome-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 280px;
}
.rcp-welcome-starters {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  width: 100%;
}

/* Error/retry */
.rcp-error {
  font-size: 12px;
  color: #ef4444;
  padding: 8px 12px;
  background: rgba(239,68,68,0.06);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.rcp-retry {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(239,68,68,0.2);
  background: none;
  color: #ef4444;
  cursor: pointer;
  font-family: inherit;
}
.rcp-retry:hover { background: rgba(239,68,68,0.08); }

/* Animations */
@keyframes rcpMsgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes rcpDot {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1.2); }
}

/* Responsive — bottom sheet on mobile */
@media (max-width: 900px) {
  .rcp-panel {
    width: 100%;
    height: 60vh;
    top: auto;
    bottom: 0;
    right: 0;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }
  .rcp-panel.rcp-open {
    transform: translateY(0);
  }
}

/* Light theme */
[data-theme="light"] .rcp-panel {
  background: rgba(255,255,255,0.97);
}
[data-theme="light"] .rcp-msg-user {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
}
[data-theme="light"] .rcp-input-wrap {
  background: rgba(241,245,249,0.9);
}
[data-theme="light"] .rcp-chart-card {
  background: #fff;
  border-color: rgba(0,0,0,0.06);
}

/* Data overview in welcome state */
.rcp-data-overview {
  width: 100%;
  background: rgba(99,102,241,0.04);
  border: 1px solid rgba(99,102,241,0.1);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 8px 0;
  text-align: left;
}
.rcp-data-overview-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.rcp-data-group {
  margin: 6px 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.rcp-data-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  min-width: 70px;
}
.rcp-data-tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
}
.rcp-tag-measure {
  background: rgba(34,197,153,0.1);
  color: #22c55e;
  border: 1px solid rgba(34,197,153,0.2);
}
.rcp-tag-dim {
  background: rgba(99,102,241,0.08);
  color: var(--primary-light);
  border: 1px solid rgba(99,102,241,0.15);
}
.rcp-tag-date {
  background: rgba(245,158,11,0.08);
  color: #f59e0b;
  border: 1px solid rgba(245,158,11,0.2);
}
.rcp-data-more {
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0.7;
}
.rcp-data-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 8px;
  opacity: 0.7;
}

/* Light theme data overview */
[data-theme="light"] .rcp-data-overview {
  background: rgba(99,102,241,0.03);
  border-color: rgba(99,102,241,0.08);
}
[data-theme="light"] .rcp-tag-measure {
  background: rgba(34,197,153,0.06);
  color: #059669;
}
[data-theme="light"] .rcp-tag-dim {
  background: rgba(99,102,241,0.05);
  color: #4f46e5;
}
[data-theme="light"] .rcp-tag-date {
  background: rgba(245,158,11,0.06);
  color: #d97706;
}
