:root {
  --bg-main: #070312;
  --panel-bg: rgba(17, 10, 35, 0.78);
  --panel-border: rgba(170, 94, 255, 0.18);

  --text-main: #f5edff;
  --text-soft: #bba9d6;
  --text-faded: #8d78ad;

  --primary: #a855f7;
  --primary-strong: #c084fc;
  --primary-dark: #7e22ce;
  --accent: #22d3ee;

  --input-bg: rgba(8, 4, 20, 0.95);
  --shadow-main: 0 20px 60px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 30px rgba(168, 85, 247, 0.25);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: "Inter", Arial, sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at top, rgba(124, 58, 237, 0.18), transparent 25%),
    radial-gradient(circle at 80% 20%, rgba(34, 211, 238, 0.08), transparent 18%),
    linear-gradient(160deg, #05020d 0%, #0b0618 45%, #120a24 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

.page-glow {
  position: fixed;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  opacity: 0.35;
  z-index: 0;
}

.glow-1 { top: -80px; left: -80px; background: rgba(168, 85, 247, 0.45); }
.glow-2 { right: -100px; bottom: -100px; background: rgba(59, 130, 246, 0.28); }

/* ── Shell ─────────────────────────────────────────── */
.app-shell {
  position: relative;
  z-index: 1;
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 64px;
}

/* ── Hero ──────────────────────────────────────────── */
.hero {
  text-align: center;
  margin-bottom: 36px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border: 1px solid rgba(192, 132, 252, 0.28);
  border-radius: 999px;
  background: rgba(168, 85, 247, 0.08);
  color: var(--primary-strong);
  font-size: 0.82rem;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
  box-shadow: var(--shadow-glow);
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(2.4rem, 5vw, 4rem);
  font-weight: 700;
  line-height: 1;
  color: #f6eeff;
  text-shadow: 0 0 20px rgba(168, 85, 247, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.hero-logo {
  height: 48px;
  width: auto;
  object-fit: contain;
}

.hero-accent {
  background: linear-gradient(135deg, #c084fc, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  width: min(680px, 100%);
  margin: 0 auto;
  color: var(--text-soft);
  font-size: 1rem;
  line-height: 1.7;
}

/* ── Workspace 2 colunas ───────────────────────────── */
.workspace {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  align-items: start;
}

.col-left,
.col-right {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Panel ─────────────────────────────────────────── */
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--shadow-main);
  backdrop-filter: blur(14px);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.panel-kicker {
  display: block;
  margin-bottom: 5px;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary-strong);
  font-weight: 600;
}

.panel-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
}

/* ── Upload ────────────────────────────────────────── */
.upload-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.file-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: background 0.2s, border-color 0.2s;
  align-self: flex-start;
}

.file-label:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(192, 132, 252, 0.3);
}

#fileInput { display: none; }

.file-name {
  color: var(--text-soft);
  font-size: 0.88rem;
  word-break: break-word;
  min-height: 20px;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 10px 28px rgba(126, 34, 206, 0.32);
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(126, 34, 206, 0.45);
}

.primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.full-width { width: 100%; }

.status-text {
  min-height: 20px;
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 4px;
}

.progress-wrapper {
  width: 100%;
  height: 6px;
  margin: 8px 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #a855f7, #c084fc);
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.4);
  transition: width 0.25s ease;
}

.hidden { display: none !important; }

/* ── Docs list ─────────────────────────────────────── */
.docs-count {
  background: rgba(168, 85, 247, 0.15);
  color: var(--primary-strong);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid rgba(192, 132, 252, 0.22);
  white-space: nowrap;
}

.docs-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 2px;
}

.docs-list::-webkit-scrollbar { width: 5px; }
.docs-list::-webkit-scrollbar-thumb {
  background: rgba(168, 85, 247, 0.3);
  border-radius: 999px;
}

.doc-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(192, 132, 252, 0.1);
  transition: border-color 0.2s, background 0.2s;
}

.doc-card:hover {
  background: rgba(168, 85, 247, 0.07);
  border-color: rgba(192, 132, 252, 0.22);
}

.doc-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.doc-info {
  flex: 1;
  min-width: 0;
}

.doc-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-meta {
  font-size: 0.78rem;
  color: var(--text-faded);
  margin-top: 2px;
}

.doc-delete {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-faded);
  padding: 4px;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.doc-delete:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

/* ── Chat ──────────────────────────────────────────── */
.chat-status {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.chat-status.locked {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-faded);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-status.ready {
  background: rgba(34, 197, 94, 0.1);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.messages {
  min-height: 340px;
  max-height: 440px;
  overflow-y: auto;
  padding: 16px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(8, 4, 20, 0.96) 0%, rgba(12, 7, 28, 0.96) 100%);
  border: 1px solid rgba(192, 132, 252, 0.1);
  margin-bottom: 14px;
}

.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-thumb {
  background: rgba(168, 85, 247, 0.3);
  border-radius: 999px;
}

.message {
  width: fit-content;
  max-width: 88%;
  margin-bottom: 12px;
  padding: 12px 15px;
  border-radius: 16px;
  line-height: 1.6;
  font-size: 0.92rem;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.message.user {
  margin-left: auto;
  background: linear-gradient(135deg, #7e22ce, #a855f7);
  color: white;
  border-bottom-right-radius: 5px;
  box-shadow: 0 8px 22px rgba(126, 34, 206, 0.25);
}

.message.bot {
  margin-right: auto;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom-left-radius: 5px;
}

.message.welcome-msg {
  color: var(--text-soft);
  font-size: 0.88rem;
  border-style: dashed;
}

.input-area {
  display: grid;
  grid-template-columns: 1fr 48px;
  gap: 10px;
}

.input-area input {
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid rgba(192, 132, 252, 0.14);
  background: var(--input-bg);
  color: var(--text-main);
  outline: none;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-area input::placeholder { color: var(--text-faded); }

.input-area input:focus {
  border-color: rgba(192, 132, 252, 0.5);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.12);
}

.input-area input:disabled { opacity: 0.5; cursor: not-allowed; }

.input-area .primary-btn {
  width: 48px;
  padding: 0;
  border-radius: 12px;
}

/* ── Sources ───────────────────────────────────────── */
.sources-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.source-item {
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(192, 132, 252, 0.1);
}

.source-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.source-file {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-chunk {
  font-size: 0.75rem;
  color: var(--text-faded);
  background: rgba(168, 85, 247, 0.1);
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

.source-item p {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.88rem;
  line-height: 1.6;
}

.empty-state {
  color: var(--text-faded);
  font-size: 0.9rem;
  text-align: center;
  padding: 16px 0;
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .app-shell { padding: 28px 0 40px; }
  .panel { padding: 16px; border-radius: 16px; }
  .messages { min-height: 260px; }
  .message { max-width: 100%; }
}
