/* PDF Monster - Mit PDF chatten */

.cwp-workspace { padding: 0; }

/* Layout: chat | source */
.cwp-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  margin-top: 12px;
  align-items: stretch;
}

@media (max-width: 1024px) {
  .cwp-layout { grid-template-columns: 1fr; }
  .cwp-source { order: 2; max-height: 280px; }
}

/* --- Chat Column --- */
.cwp-chat {
  display: flex;
  flex-direction: column;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: 14px;
  min-height: 560px;
  overflow: hidden;
}

.cwp-chat-stream {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  max-height: 560px;
}

.cwp-msg { display: flex; }
.cwp-msg-user { justify-content: flex-end; }
.cwp-msg-bot, .cwp-msg-system { justify-content: flex-start; }

.cwp-msg-bubble {
  max-width: 80%;
  padding: 12px 14px;
  border-radius: 14px;
  line-height: 1.5;
  font-size: 0.95rem;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.cwp-msg-user .cwp-msg-bubble {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.cwp-msg-bot .cwp-msg-bubble {
  background: #f3f4f6;
  color: #111827;
  border-bottom-left-radius: 4px;
}
.cwp-msg-system .cwp-msg-bubble {
  background: #ede9fe;
  color: #4338ca;
  border: 1px dashed #c4b5fd;
}
.cwp-msg-loading .cwp-msg-bubble { opacity: 0.7; }

.cwp-answer-text { white-space: pre-wrap; }

.cwp-inline-sources {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(0,0,0,0.08);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.cwp-inline-label { font-size: 0.8rem; color: #6b7280; }
.cwp-source-chip {
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  color: #4338ca;
  font-weight: 600;
  cursor: pointer;
}
.cwp-source-chip:hover { background: #ede9fe; border-color: #a78bfa; }

/* Indexing progress */
.cwp-indexing {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--color-border, #e5e7eb);
  background: #fafafa;
}
.cwp-indexing-spinner {
  width: 18px; height: 18px;
  border: 2px solid #c4b5fd;
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: cwp-spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes cwp-spin { to { transform: rotate(360deg); } }
.cwp-indexing-text { font-size: 0.85rem; color: #4b5563; }
.cwp-progress {
  flex: 1;
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
  margin-left: auto;
  max-width: 220px;
}
.cwp-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
  transition: width 0.3s;
}

/* Input row */
.cwp-input-row {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--color-border, #e5e7eb);
  background: #fff;
}
.cwp-input {
  flex: 1;
  padding: 11px 14px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font-size: 0.95rem;
  background: #f9fafb;
}
.cwp-input:focus {
  outline: none;
  border-color: #6366f1;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.cwp-input:disabled { opacity: 0.6; cursor: not-allowed; }

.cwp-send-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
}
.cwp-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
@media (max-width: 480px) {
  .cwp-send-label { display: none; }
}

.cwp-disclaimer {
  font-size: 0.75rem;
  color: #6b7280;
  padding: 6px 14px 10px;
  display: flex;
  gap: 6px;
  align-items: center;
}

/* --- Source Column --- */
.cwp-source {
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.cwp-source-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border, #e5e7eb);
  background: linear-gradient(180deg, #faf5ff 0%, #fff 100%);
}
.cwp-source-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1f2937;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.cwp-source-hint {
  display: block;
  font-size: 0.8rem;
  color: #9ca3af;
  margin-top: 4px;
}
.cwp-source-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cwp-source-card {
  background: #fafafa;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 12px;
  transition: all 0.2s;
}
.cwp-source-card.is-focused {
  background: #ede9fe;
  border-color: #a78bfa;
  box-shadow: 0 0 0 3px rgba(167,139,250,0.18);
}
.cwp-source-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.cwp-source-page {
  font-size: 0.78rem;
  font-weight: 700;
  color: #4338ca;
  background: #fff;
  border: 1px solid #c4b5fd;
  padding: 2px 8px;
  border-radius: 999px;
}
.cwp-source-score {
  font-size: 0.7rem;
  color: #9ca3af;
  font-family: monospace;
}
.cwp-source-card-body {
  font-size: 0.82rem;
  color: #374151;
  line-height: 1.5;
  max-height: 180px;
  overflow-y: auto;
}

/* Mode badge */
.cwp-badge-local {
  background: #ede9fe !important;
  color: #4338ca !important;
}
.cwp-badge-ai {
  background: linear-gradient(135deg, #10b981, #0d9488) !important;
  color: #fff !important;
}

/* --- Settings Modal --- */
.cwp-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(17,24,39,0.55);
  z-index: 1000;
}
.cwp-modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, 92vw);
  max-height: 90vh;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.3);
  z-index: 1001;
  flex-direction: column;
  overflow: hidden;
}
.cwp-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.cwp-modal-title { margin: 0; font-size: 1.1rem; font-weight: 700; }
.cwp-modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.cwp-modal-desc {
  font-size: 0.88rem;
  color: #4b5563;
  margin: 0;
  line-height: 1.5;
}
.cwp-mode-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.cwp-mode-option:hover { border-color: #a78bfa; background: #faf5ff; }
.cwp-mode-option input[type="radio"] { margin-top: 4px; }
.cwp-mode-name { font-weight: 600; color: #1f2937; }
.cwp-mode-desc { font-size: 0.82rem; color: #6b7280; margin-top: 2px; }

.cwp-key-block {
  border-top: 1px dashed #e5e7eb;
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cwp-key-label, .cwp-key-model-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
}
.cwp-key-input { font-family: monospace; }
.cwp-key-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.cwp-model-select {
  flex: 1;
  max-width: 220px;
}
.cwp-key-hint {
  font-size: 0.78rem;
  color: #6b7280;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cwp-modal-footer {
  padding: 14px 20px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Dragover state */
.upload-card.dragover {
  border-color: #6366f1 !important;
  background: #ede9fe !important;
}
