/* ============================================================
   Pocharlies Qdrant – RAG Dashboard Stylesheet
   ============================================================ */

/* ── CSS Variables ────────────────────────────────────────── */

:root {
  --bg-0: #081019;
  --bg-1: #0f1b2a;
  --bg-2: #17283b;
  --glass: rgba(12, 22, 35, 0.62);
  --glass-strong: rgba(10, 18, 30, 0.78);
  --line: rgba(171, 216, 255, 0.22);
  --line-soft: rgba(171, 216, 255, 0.12);
  --text: #e8f3ff;
  --muted: #99aec5;
  --accent: #46d5ff;
  --accent-2: #8ef0b1;
  --accent-3: #ffc873;
  --success: #74f6a4;
  --warning: #ffcf74;
  --danger: #ff7d9f;
  --radius-xs: 10px;
  --radius-sm: 14px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 26px rgba(0, 0, 0, 0.28);
  --mono: 'IBM Plex Mono', monospace;
}

/* ── Reset + Body ─────────────────────────────────────────── */

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

html,
body {
  min-height: 100%;
}

body {
  font-family: 'Space Grotesk', sans-serif;
  color: var(--text);
  background:
    radial-gradient(1400px 600px at -5% -10%, #1d4669 0%, transparent 55%),
    radial-gradient(900px 500px at 110% 0%, #38542d 0%, transparent 56%),
    linear-gradient(145deg, var(--bg-0), var(--bg-1) 45%, var(--bg-2));
  line-height: 1.45;
  overflow-x: hidden;
}

/* ── Background Layer ─────────────────────────────────────── */

.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.bg-orb {
  position: absolute;
  border-radius: 999px;
  filter: blur(38px);
  opacity: 0.36;
}

.orb-a {
  width: clamp(240px, 32vw, 460px);
  height: clamp(240px, 32vw, 460px);
  top: -8%;
  left: -8%;
  background: linear-gradient(135deg, #1fcfff, #3679ff);
}

.orb-b {
  width: clamp(220px, 28vw, 420px);
  height: clamp(220px, 28vw, 420px);
  right: -8%;
  top: 8%;
  background: linear-gradient(135deg, #58f0a4, #3ed8ff);
}

.bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(170, 214, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(170, 214, 255, 0.055) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(circle at 30% 10%, black, transparent 80%);
}

/* ── App Container ────────────────────────────────────────── */

.app {
  max-width: 1360px;
  margin: 0 auto;
  padding: clamp(16px, 2.2vw, 28px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Glass Effect ─────────────────────────────────────────── */

.glass {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-md);
}

/* ── Header ───────────────────────────────────────────────── */

.header {
  border-radius: var(--radius-lg);
  padding: clamp(16px, 2vw, 24px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.logo-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 0.9rem;
  background: linear-gradient(135deg, rgba(70, 213, 255, 0.25), rgba(142, 240, 177, 0.2));
  border: 1px solid var(--line);
  color: #d8f8ff;
}

.logo-copy h1 {
  font-size: clamp(1.1rem, 2.2vw, 1.55rem);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.logo-copy p {
  font-size: 0.84rem;
  color: var(--muted);
  margin-top: 2px;
}

/* ── Section ──────────────────────────────────────────────── */

.section {
  border-radius: var(--radius-lg);
  padding: clamp(14px, 1.8vw, 20px);
  border: 1px solid var(--line-soft);
  min-width: 0;
  overflow: hidden;
}

.section h2 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.section-desc {
  margin-top: 4px;
  margin-bottom: 12px;
  font-size: 0.84rem;
  color: var(--muted);
}

/* ── Qdrant Health ───────────────────────────────────────── */

.qdrant-health-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.qdrant-health-header h2 {
  margin: 0;
}

.qdrant-health-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.qdrant-health-badge.healthy {
  color: var(--success);
  border: 1px solid rgba(116,246,164,.35);
  background: rgba(116,246,164,.08);
}

.qdrant-health-badge.unhealthy {
  color: var(--danger);
  border: 1px solid rgba(255,125,159,.35);
  background: rgba(255,125,159,.08);
  animation: ragPulse 1.2s ease-in-out infinite;
}

.qdrant-health-badge.loading {
  color: var(--muted);
  border: 1px solid rgba(153,174,197,.2);
  background: rgba(153,174,197,.04);
}

.qdrant-health-details {
  margin-top: 4px;
  font-size: 0.82rem;
}

/* ── Utilities ────────────────────────────────────────────── */

.muted {
  color: var(--muted);
  font-size: 0.8rem;
}

.hidden {
  display: none !important;
}

/* ── Button Base ──────────────────────────────────────────── */

.btn {
  border: 0;
  border-radius: 11px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: all 170ms ease;
}

.btn-ghost {
  background: rgba(145, 190, 224, 0.15);
  color: var(--text);
  border: 1px solid var(--line-soft);
}

.btn-ghost:hover {
  background: rgba(145, 190, 224, 0.26);
}

.btn-primary {
  color: #072334;
  background: linear-gradient(135deg, #72e7ff, #8ff8bc);
  box-shadow: 0 12px 24px rgba(86, 231, 255, 0.22);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 16px 28px rgba(86, 231, 255, 0.35);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Modal ────────────────────────────────────────────────── */

.op-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 16px;
}

.op-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 8, 14, 0.72);
  backdrop-filter: blur(2px);
}

.op-modal-panel {
  position: relative;
  width: min(1100px, 100%);
  max-height: min(84vh, 920px);
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--glass-strong);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
}

.op-modal-header {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.op-modal-header-copy h3 {
  font-size: 1rem;
  margin-bottom: 2px;
}

.op-modal-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.op-modal-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 0.76rem;
}

.op-state {
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.66rem;
}

.op-state-running {
  color: #d2f2ff;
  background: rgba(70, 213, 255, 0.2);
}

.op-state-success,
.op-state-completed {
  color: #ddffe9;
  background: rgba(116, 246, 164, 0.2);
}

.op-state-failed,
.op-state-error {
  color: #ffd3de;
  background: rgba(255, 125, 159, 0.22);
}

.op-state-warning {
  color: #ffe0a3;
  background: rgba(255, 165, 0, 0.2);
}

.op-modal-log {
  margin: 0;
  padding: 14px 16px;
  overflow: auto;
  min-height: 260px;
  max-height: 60vh;
  font-family: var(--mono);
  font-size: 0.77rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── RAG: Collections ─────────────────────────────────────── */

.rag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.rag-collection-card {
  border-radius: var(--radius-sm);
  padding: 14px;
  border: 1px solid var(--line-soft);
  background: var(--glass-strong);
}

.rag-cc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.rag-cc-name {
  font-weight: 700;
  font-size: .95rem;
  font-family: var(--mono);
}

.rag-cc-stats { display: flex; gap: 18px; }
.rag-cc-stat { display: flex; flex-direction: column; }

.rag-cc-stat-val {
  font-size: 1.3rem;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--accent);
}

.rag-cc-stat-lbl {
  font-size: .72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.rag-status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.rag-status-badge.active {
  color: var(--success);
  border: 1px solid rgba(116,246,164,.35);
  background: rgba(116,246,164,.08);
}

.rag-status-badge.running {
  color: var(--accent);
  border: 1px solid rgba(70,213,255,.35);
  background: rgba(70,213,255,.08);
  animation: ragPulse 1.2s ease-in-out infinite;
}

.rag-status-badge.failed {
  color: var(--danger);
  border: 1px solid rgba(255,125,159,.35);
  background: rgba(255,125,159,.08);
}

.rag-status-badge.stopped {
  color: #ffa500;
  border: 1px solid rgba(255,165,0,.35);
  background: rgba(255,165,0,.08);
}

.rag-status-badge.inactive {
  color: var(--muted);
  border: 1px solid rgba(153,174,197,.2);
  background: rgba(153,174,197,.04);
}

@keyframes ragPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .6; }
}

/* ── RAG: Form ────────────────────────────────────────────── */

.rag-form { margin-top: 8px; }

.rag-form-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.rag-input {
  flex: 1;
  min-width: 180px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
  background: var(--bg-1);
  color: var(--text);
  font-size: .88rem;
  font-family: inherit;
  outline: none;
  transition: border-color 180ms;
}

.rag-input:focus { border-color: var(--accent); }
.rag-input-sm { flex: 0 0 90px; min-width: 80px; }

.rag-select {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
  background: var(--bg-1);
  color: var(--text);
  font-size: .85rem;
  font-family: inherit;
  cursor: pointer;
  outline: none;
}

.rag-select:focus { border-color: var(--accent); }

.rag-smart-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .85em;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.rag-smart-toggle input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.btn-accent {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(135deg, var(--accent), #9eeeff);
  color: #05141f;
  font-weight: 700;
  font-size: .85rem;
  cursor: pointer;
  transition: all 180ms;
  white-space: nowrap;
}

.btn-accent:hover { box-shadow: 0 6px 16px rgba(70,213,255,.35); }
.btn-accent:disabled { opacity: .5; cursor: not-allowed; }

.btn-danger-sm {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,125,159,.3);
  background: rgba(255,125,159,.08);
  color: var(--danger);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 180ms;
}

.btn-danger-sm:hover {
  background: rgba(255,125,159,.18);
  border-color: rgba(255,125,159,.5);
}

/* ── RAG: Progress Bar ────────────────────────────────────── */

.rag-crawl-status { margin-top: 14px; }

.rag-progress-bar-wrap {
  height: 6px;
  border-radius: 3px;
  background: var(--bg-2);
  overflow: hidden;
  margin-bottom: 8px;
}

.rag-progress-bar {
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 400ms ease;
}

/* ── RAG: Sources ─────────────────────────────────────────── */

.rag-sources-list { display: flex; flex-direction: column; gap: 8px; }

.rag-source-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
  background: var(--glass-strong);
}

.rag-source-info { display: flex; flex-direction: column; gap: 2px; }
.rag-source-domain { font-weight: 600; font-size: .9rem; }
.rag-source-meta { font-size: .78rem; color: var(--muted); }

/* ── RAG: Jobs ────────────────────────────────────────────── */

.rag-jobs-list { display: flex; flex-direction: column; gap: 8px; }

.rag-job-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
  background: var(--glass-strong);
}

.rag-job-info { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.rag-job-url {
  font-weight: 600;
  font-size: .88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rag-job-stats {
  display: flex;
  gap: 14px;
  font-size: .82rem;
  font-family: var(--mono);
  color: var(--muted);
}

.rag-eta { color: var(--accent-3); font-weight: 600; }

.rag-job-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-logs {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
  background: rgba(70,213,255,.06);
  color: var(--accent);
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 180ms;
}

.btn-logs:hover {
  background: rgba(70,213,255,.15);
  border-color: rgba(70,213,255,.4);
}

.btn-stop {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,80,80,.3);
  background: rgba(255,80,80,.1);
  color: #ff5050;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 180ms;
}

.btn-stop:hover {
  background: rgba(255,80,80,.2);
  border-color: rgba(255,80,80,.5);
}

.btn-resume {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(80,200,120,.3);
  background: rgba(80,200,120,.1);
  color: #50c878;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 180ms;
}

.btn-resume:hover {
  background: rgba(80,200,120,.2);
  border-color: rgba(80,200,120,.5);
}

/* ── RAG: Search Results ──────────────────────────────────── */

.rag-result-card {
  margin-top: 10px;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
  background: var(--glass-strong);
}

.rag-result-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.rag-result-rank {
  font-weight: 700;
  font-size: .82rem;
  color: var(--accent);
  font-family: var(--mono);
}

.rag-result-url {
  flex: 1;
  font-size: .82rem;
  color: var(--accent-2);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rag-result-url:hover { text-decoration: underline; }

.rag-result-score {
  font-family: var(--mono);
  font-size: .78rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(70,213,255,.1);
  color: var(--accent);
  white-space: nowrap;
}

.rag-result-title {
  font-weight: 600;
  font-size: .88rem;
  margin-bottom: 4px;
}

.rag-result-text {
  font-size: .82rem;
  color: var(--muted);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.rag-result-meta {
  margin-top: 6px;
  font-size: .72rem;
  color: var(--muted);
}

/* ── Footer ───────────────────────────────────────────────── */

.footer {
  display: flex;
  justify-content: center;
  padding: 8px 0 4px;
  color: #9eb7cd;
  font-size: 0.72rem;
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 840px) {
  .app { padding: 12px; }
  .op-modal { padding: 10px; }
  .op-modal-header { flex-direction: column; align-items: flex-start; }
  .op-modal-actions { width: 100%; }
  .op-modal-actions .btn { flex: 1; }
}

@media (max-width: 600px) {
  .rag-form-row { flex-direction: column; }
  .rag-input, .rag-input-sm, .rag-select { min-width: 100%; flex: unset; }
  .rag-job-row { flex-direction: column; align-items: flex-start; }
}
