/* ===== Chat Panel ===== */
.chat-panel {
  position: fixed;
  top: 0; right: -480px;
  width: 480px;
  height: 100vh;
  background: rgba(15,15,30,0.98);
  backdrop-filter: blur(30px);
  border-left: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  z-index: 400;
  transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.chat-panel.open {
  right: 0;
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.chat-header-left {
  display: flex; align-items: center; gap: 10px;
  font-size: 15px; font-weight: 600;
}

/* Model selector */
.chat-model-selector select {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: rgba(255,255,255,0.85);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  cursor: pointer;
  outline: none;
  max-width: 160px;
  transition: all 0.2s;
  -webkit-appearance: auto;
  appearance: auto;
}
.chat-model-selector select:hover {
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.2);
}
.chat-model-selector select option {
  background: #1a1a2e;
  color: #fff;
}
.chat-header-right {
  display: flex; gap: 4px;
}
.chat-header-right button {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
}
.chat-header-right button:hover {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.8);
}

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.chat-welcome {
  text-align: center;
  padding: 60px 20px 20px;
}
.chat-welcome-icon {
  font-size: 40px;
  margin-bottom: 16px;
}
.chat-welcome h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}
.chat-welcome p {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
  margin-bottom: 24px;
}
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.chat-suggestions button {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 6px 16px;
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.chat-suggestions button:hover {
  background: rgba(108,92,231,0.2);
  border-color: rgba(108,92,231,0.4);
  color: #fff;
}

/* Message bubbles */
.chat-msg {
  margin-bottom: 20px;
  animation: msgIn 0.3s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-msg-user {
  display: flex;
  justify-content: flex-end;
}
.chat-msg-user .chat-bubble {
  background: var(--accent, #6c5ce7);
  color: #fff;
  border-radius: 16px 16px 4px 16px;
  max-width: 85%;
  padding: 10px 16px;
  font-size: 14px;
  line-height: 1.6;
}
.chat-msg-ai {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.chat-ai-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}
.chat-msg-ai .chat-bubble {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.9);
  border-radius: 16px 16px 16px 4px;
  max-width: 85%;
  padding: 10px 16px;
  font-size: 14px;
  line-height: 1.7;
}
.chat-bubble p { margin-bottom: 8px; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble strong { color: #a29bfe; }
.chat-bubble code {
  background: rgba(0,0,0,0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

/* Typing indicator */
.chat-typing {
  display: flex; gap: 4px; padding: 4px 0;
}
.chat-typing span {
  width: 6px; height: 6px;
  background: rgba(255,255,255,0.4);
  border-radius: 50%;
  animation: typingDot 1.4s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Input area */
.chat-attachments-preview {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 20px 0;
}
.chat-att-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: rgba(255,255,255,0.8);
  max-width: 200px;
}
.chat-att-icon { font-size: 14px; flex-shrink: 0; }
.chat-att-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}
.chat-att-size {
  font-size: 10px;
  color: rgba(255,255,255,0.4);
  flex-shrink: 0;
}
.chat-att-remove {
  cursor: pointer;
  color: rgba(255,255,255,0.4);
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  transition: color 0.2s;
  flex-shrink: 0;
}
.chat-att-remove:hover { color: #ff4757; }

.chat-input-area {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.chat-attach-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}
.chat-attach-btn:hover {
  background: rgba(108,92,231,0.15);
  border-color: rgba(108,92,231,0.3);
  color: var(--accent-light, #a29bfe);
}
.chat-input-area textarea {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 10px 14px;
  color: #fff;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: 120px;
  font-family: inherit;
}
.chat-input-area textarea::placeholder {
  color: rgba(255,255,255,0.3);
}
.chat-input-area textarea:focus {
  border-color: rgba(108,92,231,0.5);
}
.chat-send-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent, #6c5ce7);
  border: none;
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}
.chat-send-btn:hover {
  background: var(--accent-light, #a29bfe);
}
.chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Mobile */
@media (max-width: 768px) {
  .chat-panel {
    width: 100%;
    right: -100%;
  }
  .chat-header { padding: 12px 14px; }
  .chat-header-right button { width: 36px; height: 36px; }
  .chat-header-right button svg { width: 18px; height: 18px; }
  .chat-suggestions button { padding: 8px 14px; font-size: 12px; }
  .chat-attach-btn { width: 40px; height: 40px; }
  .chat-send-btn { width: 40px; height: 40px; }
  .chat-input-area { padding: 8px 10px; gap: 6px; }
  .chat-input { font-size: 16px; }
  .chat-messages { padding: 16px 12px; }
  .chat-msg-user .chat-bubble { max-width: 80%; font-size: 14px; }
  .chat-att-chip { max-width: 160px; }
  .chat-att-name { max-width: 100px; }
}

@media (max-width: 480px) {
  .chat-header-right button { width: 34px; height: 34px; }
  .chat-suggestions { gap: 6px; }
  .chat-suggestions button { padding: 6px 12px; font-size: 11px; }
  .chat-input-area { padding: 6px 8px; }
  .chat-attach-btn { width: 38px; height: 38px; }
  .chat-send-btn { width: 38px; height: 38px; }
  .chat-header-left { font-size: 14px; gap: 6px; }
  .chat-header-left svg { width: 22px; height: 22px; }
  .chat-model-selector select { font-size: 11px; max-width: 120px; padding: 3px 8px; }
}
