/* 3CX CSR Assistant — functional dark-mode stylesheet */

:root {
  --bg: #1a1a1a;
  --surface: #242424;
  --surface2: #2e2e2e;
  --border: #3a3a3a;
  --text: #e2e2e2;
  --text-dim: #8a8a8a;
  --accent: #0078d4;
  --accent-hover: #106ebe;
  --success: #2d7d32;
  --warn: #e65100;
  --danger: #c62828;
  --danger-bg: #3b0a0a;
  --info: #01579b;
  --info-bg: #0a2540;
  --tag-bg: #333;
  --tag-text: #bbb;
  --placeholder-warn: #ff9800;
  --font-mono: "Consolas", "Cascadia Code", "Courier New", monospace;
  --font-ui: "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}

header h1 span { color: var(--accent); }

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

/* ── Main layout ──────────────────────────────────── */
main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  overflow: hidden;
  height: calc(100vh - 47px);
}

.panel {
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow-y: auto;
  gap: 12px;
}

.panel-left { border-right: 1px solid var(--border); }

/* ── Form elements ────────────────────────────────── */
label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 4px;
}

input[type="email"],
textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 8px 10px;
  resize: vertical;
  transition: border-color 0.15s;
}

input[type="email"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea#ticket-input {
  height: 300px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
}

textarea#draft-output {
  height: 320px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
}

/* ── Buttons ──────────────────────────────────────── */
button {
  cursor: pointer;
  border: none;
  border-radius: 4px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  transition: background 0.15s, opacity 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}

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

/* ── Tags / chips ─────────────────────────────────── */
.tag {
  display: inline-block;
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tag-path-canned    { background: #1b4332; color: #52b788; }
.tag-path-rag       { background: #1b3a5c; color: #74c0fc; }
.tag-path-security  { background: var(--danger-bg); color: #ff8a80; }
.tag-path-forward   { background: #3e2723; color: #ffcc80; }

/* ── Analysis metadata row ────────────────────────── */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}

.meta-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
}

.meta-item .meta-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  margin-bottom: 3px;
}

.meta-item .meta-value {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

/* ── Confidence bar ───────────────────────────────── */
.confidence-bar-outer {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  margin-top: 5px;
  overflow: hidden;
}
.confidence-bar-inner {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.4s;
}

/* ── Divider ──────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

/* ── Section heading ──────────────────────────────── */
.section-heading {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
}

/* ── Placeholder warning chips ────────────────────── */
.placeholder-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.placeholder-chip {
  background: #3e2000;
  color: var(--placeholder-warn);
  border: 1px solid #7c4e00;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  font-family: var(--font-mono);
}

/* ── Sources list ─────────────────────────────────── */
.sources-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sources-list li {
  font-size: 12px;
  color: var(--text-dim);
  padding: 2px 0;
}

.sources-list li::before {
  content: "·  ";
  color: var(--accent);
}

/* ── Next actions list ────────────────────────────── */
.actions-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.actions-list li {
  font-size: 12px;
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.actions-list li::before {
  content: "→";
  color: var(--accent);
  flex-shrink: 0;
}

.actions-list li:last-child { border-bottom: none; }

/* ── Security alert box ───────────────────────────── */
.security-alert {
  background: var(--danger-bg);
  border: 2px solid var(--danger);
  border-radius: 6px;
  padding: 16px;
}

.security-alert .alert-title {
  font-size: 16px;
  font-weight: 700;
  color: #ff8a80;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.security-alert .alert-title .icon { font-size: 20px; }

.escalation-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: step-counter;
}

.escalation-steps li {
  counter-increment: step-counter;
  padding: 8px 0 8px 36px;
  position: relative;
  border-bottom: 1px solid #5a1010;
  font-size: 13px;
  line-height: 1.6;
}

.escalation-steps li:last-child { border-bottom: none; }

.escalation-steps li::before {
  content: counter(step-counter);
  position: absolute;
  left: 0;
  top: 8px;
  width: 24px;
  height: 24px;
  background: var(--danger);
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 24px;
}

/* ── Forward-to-CSR box ───────────────────────────── */
.forward-box {
  background: var(--info-bg);
  border: 1px solid #1565c0;
  border-radius: 6px;
  padding: 16px;
}

.forward-box .forward-title {
  font-size: 14px;
  font-weight: 600;
  color: #90caf9;
  margin-bottom: 8px;
}

/* ── Preamble / knowledge gap notices ─────────────── */
.notice {
  background: #1c2a1c;
  border-left: 3px solid #4caf50;
  padding: 8px 12px;
  border-radius: 0 4px 4px 0;
  font-size: 12px;
  color: #a5d6a7;
}

.notice.warn {
  background: #2a1f0e;
  border-left-color: var(--placeholder-warn);
  color: #ffcc80;
}

/* ── Spinner ──────────────────────────────────────── */
#spinner {
  display: none;
  align-items: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: 13px;
  padding: 12px 0;
}

.spinner-ring {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ──────────────────────────────────── */
#empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  gap: 8px;
  font-size: 13px;
  padding: 40px;
  text-align: center;
}

#empty-state .empty-icon { font-size: 36px; opacity: 0.4; }

/* ── Toast notification ───────────────────────────── */
#toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 999;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ── Utility ──────────────────────────────────────── */
.hidden { display: none !important; }
.text-dim { color: var(--text-dim); }
.text-sm { font-size: 12px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.gap-8 { gap: 8px; }
