/* ========================================
   Rainverse Chat Drawer v5 - Deep Blue Theme
   ======================================== */

:root {
  --rv-bg: #0a0c14;
  --rv-bg-elevated: #11141f;
  --rv-bg-input: #161a28;
  --rv-border: #23283a;
  --rv-border-soft: #1c2233;
  --rv-text: #e8e9f0;
  --rv-text-muted: #7a8199;
  --rv-text-dim: #545b72;
  --rv-accent: #3b82f6;
  --rv-accent-glow: #60a5fa;
  --rv-accent-deep: #1e40af;
  --rv-user-bubble: #1e40af;
  --rv-lumin-bubble: #161a28;
  --rv-success: #34d399;
  --rv-danger: #f87171;
  --rv-radius: 16px;
  --rv-radius-sm: 10px;
  --rv-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, sans-serif;
  --rv-mono: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  --rv-drawer-width: 420px;
  --rv-header-h: 64px;
  --rv-transition: cubic-bezier(0.32, 0.72, 0, 1);
}

/* Backdrop */
.rv-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  z-index: 99998;
}

.rv-drawer-backdrop.rv-open {
  opacity: 1;
  visibility: visible;
}

/* Drawer Container */
.rv-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--rv-drawer-width);
  max-width: 100vw;
  height: 100vh;
  background: var(--rv-bg);
  color: var(--rv-text);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.4s var(--rv-transition);
  z-index: 99999;
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
  border-left: 1px solid var(--rv-border);
  font-family: var(--rv-font);
}

.rv-drawer.rv-open {
  transform: translateX(0);
}

/* Header */
.rv-header {
  height: var(--rv-header-h);
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--rv-bg-elevated);
  border-bottom: 1px solid var(--rv-border);
  flex-shrink: 0;
}

.rv-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rv-lumin-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--rv-accent-deep), var(--rv-accent-glow));
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
}

.rv-lumin-avatar svg {
  width: 22px;
  height: 22px;
  color: white;
}

.rv-lumin-status-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  background: var(--rv-success);
  border: 2.5px solid var(--rv-bg-elevated);
  border-radius: 50%;
}

.rv-header-info {
  display: flex;
  flex-direction: column;
}

.rv-lumin-name {
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.rv-lumin-badge {
  font-size: 10px;
  background: rgba(59, 130, 246, 0.15);
  color: var(--rv-accent);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.rv-lumin-status {
  font-size: 12px;
  color: var(--rv-text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.rv-header-actions {
  display: flex;
  gap: 4px;
}

.rv-icon-btn {
  background: transparent;
  border: none;
  color: var(--rv-text-muted);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.rv-icon-btn:hover {
  background: var(--rv-bg-input);
  color: var(--rv-text);
}

.rv-icon-btn svg { width: 18px; height: 18px; }

/* CRM Bar */
.rv-crm-bar {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.08), transparent);
  border-bottom: 1px solid var(--rv-border-soft);
  padding: 8px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--rv-text-muted);
  flex-shrink: 0;
}

.rv-crm-context {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rv-crm-tag {
  background: rgba(59, 130, 246, 0.12);
  color: var(--rv-accent);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
}

.rv-crm-switch {
  background: transparent;
  border: 1px solid var(--rv-border);
  color: var(--rv-text-muted);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  font-family: var(--rv-font);
}

.rv-crm-switch:hover { border-color: var(--rv-accent); color: var(--rv-text); }

/* Messages Area */
.rv-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  scroll-behavior: smooth;
  background: var(--rv-bg);
}

.rv-messages::-webkit-scrollbar { width: 6px; }
.rv-messages::-webkit-scrollbar-track { background: transparent; }
.rv-messages::-webkit-scrollbar-thumb {
  background: var(--rv-border);
  border-radius: 3px;
}
.rv-messages::-webkit-scrollbar-thumb:hover { background: var(--rv-text-dim); }

/* Message Bubbles */
.rv-msg {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  animation: rv-msg-in 0.35s var(--rv-transition);
}

@keyframes rv-msg-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.rv-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: white;
}

.rv-msg.lumin .rv-msg-avatar {
  background: linear-gradient(135deg, var(--rv-accent-deep), var(--rv-accent-glow));
}

.rv-msg.user .rv-msg-avatar {
  background: var(--rv-user-bubble);
}

.rv-msg-body {
  flex: 1;
  min-width: 0;
}

.rv-msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.rv-msg-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--rv-text);
}

.rv-msg-time {
  font-size: 11px;
  color: var(--rv-text-dim);
}

.rv-msg-bubble {
  background: var(--rv-lumin-bubble);
  border: 1px solid var(--rv-border-soft);
  border-radius: 4px 14px 14px 14px;
  padding: 11px 14px;
  font-size: 14px;
  line-height: 1.6;
  word-wrap: break-word;
  color: var(--rv-text);
}

.rv-msg.user .rv-msg-bubble {
  background: var(--rv-user-bubble);
  border-color: var(--rv-user-bubble);
  color: white;
  border-radius: 14px 4px 14px 14px;
}

.rv-msg-bubble p { margin: 0 0 8px; }
.rv-msg-bubble p:last-child { margin-bottom: 0; }
.rv-msg-bubble strong { font-weight: 600; }

/* Input Area */
.rv-input-area {
  border-top: 1px solid var(--rv-border);
  background: var(--rv-bg-elevated);
  padding: 14px 18px 16px;
  flex-shrink: 0;
}

.rv-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: var(--rv-bg-input);
  border: 1px solid var(--rv-border);
  border-radius: 14px;
  padding: 8px 8px 8px 14px;
  transition: border-color 0.15s;
}

.rv-input-row:focus-within {
  border-color: var(--rv-accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.rv-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--rv-text);
  font-family: var(--rv-font);
  font-size: 16px;
  line-height: 1.5;
  resize: none;
  max-height: 140px;
  min-height: 22px;
  padding: 5px 0;
}

.rv-input::placeholder { color: var(--rv-text-dim); }

.rv-input-tools {
  display: flex;
  gap: 2px;
  align-items: center;
}

.rv-tool-btn {
  background: transparent;
  border: none;
  color: var(--rv-text-dim);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.rv-tool-btn:hover { color: var(--rv-accent); background: rgba(59, 130, 246, 0.08); }
.rv-tool-btn svg { width: 16px; height: 16px; }

.rv-send-btn {
  background: linear-gradient(135deg, var(--rv-accent-deep), var(--rv-accent));
  color: white;
  border: none;
  border-radius: 10px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.rv-send-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 0 16px rgba(59, 130, 246, 0.5);
}

.rv-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.rv-send-btn svg { width: 16px; height: 16px; }

.rv-input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  font-size: 11px;
  color: var(--rv-text-dim);
}

.rv-layer-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rv-layer-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--rv-accent);
}

.rv-layer-dot.outer { background: var(--rv-accent-glow); opacity: 0.5; }

/* Empty State */
.rv-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 24px;
}

.rv-empty-orb {
  width: 72px;
  height: 72px;
  aspect-ratio: 1;
  flex-shrink: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--rv-accent-glow), var(--rv-accent-deep));
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  box-shadow: 0 0 40px rgba(59, 130, 246, 0.4);
  animation: rv-orb-float 3s ease-in-out infinite;
}

@keyframes rv-orb-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.rv-empty-orb svg { width: 32px; height: 32px; color: white; }

.rv-empty h3 {
  font-size: 18px;
  margin-bottom: 6px;
  background: linear-gradient(135deg, var(--rv-accent-glow), var(--rv-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.rv-empty p {
  color: var(--rv-text-muted);
  font-size: 13px;
  max-width: 280px;
  line-height: 1.5;
}

.rv-suggestions {
  display: grid;
  gap: 8px;
  margin-top: 22px;
  width: 100%;
  max-width: 340px;
}

.rv-suggestion {
  background: var(--rv-bg-elevated);
  border: 1px solid var(--rv-border-soft);
  border-radius: 12px;
  padding: 11px 14px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  color: var(--rv-text);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--rv-font);
}

.rv-suggestion:hover {
  border-color: var(--rv-accent);
  background: rgba(59, 130, 246, 0.05);
  transform: translateX(2px);
}

.rv-suggestion-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

/* Mobile */
@media (max-width: 600px) {
  .rv-drawer {
    width: 100vw;
    border-left: none;
  }
  .rv-drawer-backdrop.rv-open { background: rgba(0,0,0,0.6); }
}