/* ============================================================
   Agent Team Builder — Kundportal
   Delar designsystem med showcasen men egen chatt-layout.
   ============================================================ */

:root {
  --bg: #0a0a0f;
  --surface: #13131a;
  --surface-2: #1a1a24;
  --surface-3: #20202c;
  --border: #2a2a3a;
  --text: #e8e8f0;
  --text-dim: #9a9ab5;
  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --accent-2: #818cf8;
  --green: #34d399;
  --red: #f87171;
  --cyan: #22d3ee;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}
#root { height: 100%; }
.grad {
  background: linear-gradient(110deg, var(--accent-2), var(--cyan));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}

/* ---------- KEY SETUP ---------- */
.setup {
  max-width: 520px; margin: 0 auto; min-height: 100%;
  display: flex; flex-direction: column; justify-content: center;
  padding: 40px 24px; gap: 4px;
}
.setup-badge {
  display: inline-flex; width: fit-content; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  padding: 7px 14px; border-radius: 100px; font-size: 13px; font-weight: 600; color: var(--text-dim);
  margin-bottom: 18px;
}
.setup h1 { font-size: clamp(28px, 5vw, 40px); font-weight: 800; letter-spacing: -0.025em; line-height: 1.1; }
.setup-lead { color: var(--text-dim); font-size: 16px; margin-top: 16px; }
.setup-field { margin-top: 28px; }
.setup-field input {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 15px 16px; color: var(--text); font-size: 15px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; outline: none; transition: border-color 0.2s;
}
.setup-field input:focus { border-color: var(--accent); }
.setup-err { color: var(--red); font-size: 13px; margin-top: 10px; }
.btn-primary {
  margin-top: 18px; width: 100%; background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #fff; border: none; border-radius: 12px; padding: 15px; font-size: 15px; font-weight: 700;
  cursor: pointer; transition: transform 0.15s, box-shadow 0.2s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 30px -12px var(--accent-glow); }
.setup-help { margin-top: 22px; font-size: 13.5px; color: var(--text-dim); }
.setup-help a { color: var(--accent-2); }

/* ---------- TEAM PICKER ---------- */
.picker {
  max-width: 640px; margin: 0 auto; min-height: 100%;
  display: flex; flex-direction: column; justify-content: center;
  padding: 48px 24px; gap: 4px;
}
.picker h1 { font-size: clamp(26px, 4.5vw, 38px); font-weight: 800; letter-spacing: -0.025em; line-height: 1.1; }
.picker-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 28px; }
@media (max-width: 560px) { .picker-grid { grid-template-columns: 1fr; } }
.pcard {
  display: flex; align-items: center; gap: 13px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.2s;
}
.pcard:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 16px 36px -22px var(--accent-glow); }
.pcard-icon { font-size: 22px; width: 46px; height: 46px; flex-shrink: 0; display: grid; place-items: center; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.pcard-meta { display: flex; flex-direction: column; min-width: 0; }
.pcard-name { font-weight: 700; font-size: 15px; }
.pcard-tag { font-size: 12.5px; color: var(--text-dim); }
.picker-empty { color: var(--text-dim); font-size: 14px; margin-top: 24px; }
.hublink { display: inline-flex; align-items: center; gap: 7px; color: var(--text-dim); text-decoration: none; font-size: 13px; margin-bottom: 22px; width: fit-content; }
.hublink:hover { color: var(--text); }

/* ---------- a11y: fokus + reducerad rörelse ---------- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ---------- composer-knapp disablad under svar ---------- */
.composer-send:disabled { opacity: 0.45; cursor: default; transform: none; }

/* ---------- mobil agent-rad (sidebaren göms < 720px) ---------- */
.mobile-bar { display: none; }
.side-foot .hub-foot { color: var(--text-dim); font-size: 12.5px; text-decoration: none; display: block; margin-bottom: 4px; }
.side-foot .hub-foot:hover { color: var(--text); }
@media (max-width: 720px) {
  .mobile-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface); }
  .mobile-bar .mb-home { color: var(--text-dim); text-decoration: none; font-size: 17px; flex-shrink: 0; }
  .mobile-bar select { flex: 1; min-width: 0; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: 9px; padding: 9px 10px; font-size: 14px; font-family: inherit; }
  .mobile-bar .mb-reset { background: none; border: none; color: var(--text-dim); font-size: 12.5px; cursor: pointer; flex-shrink: 0; }
  .chat-log { padding: 18px 14px; }
}

/* ---------- APP SHELL ---------- */
.app { display: grid; grid-template-columns: 280px 1fr; height: 100%; }

/* ---------- SIDEBAR ---------- */
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 20px 20px 18px; border-bottom: 1px solid var(--border); }
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--green); flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(52,211,153,0.6); animation: blink 2s infinite;
}
@keyframes blink { 0%,100% { box-shadow: 0 0 0 0 rgba(52,211,153,0.5); } 50% { box-shadow: 0 0 0 6px rgba(52,211,153,0); } }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.brand-sub { font-size: 12px; color: var(--text-dim); }

.agent-list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.agent-item {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  background: transparent; border: 1px solid transparent; border-radius: 12px;
  padding: 11px 12px; cursor: pointer; color: var(--text); transition: background 0.18s, border-color 0.18s;
}
.agent-item:hover { background: var(--surface-2); }
.agent-item.active { background: var(--surface-2); border-color: var(--border); }
.agent-item.active .agent-icon { box-shadow: 0 0 0 1px var(--accent), 0 0 16px -4px var(--accent-glow); }
.agent-icon {
  font-size: 19px; width: 40px; height: 40px; flex-shrink: 0; display: grid; place-items: center;
  border-radius: 11px; background: var(--surface-3); border: 1px solid var(--border);
}
.agent-meta { display: flex; flex-direction: column; min-width: 0; }
.agent-name { font-weight: 600; font-size: 14px; }
.agent-role { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.side-foot { padding: 14px 16px 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.side-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); }
.model-select {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 9px; padding: 9px 10px; font-size: 13px; font-family: inherit; cursor: pointer; outline: none;
}
.model-select:focus { border-color: var(--accent); }
.link-btn { background: none; border: none; color: var(--text-dim); font-size: 12.5px; cursor: pointer; text-align: left; padding: 4px 0; }
.link-btn:hover { color: var(--text); text-decoration: underline; }

/* ---------- MAIN / CHAT ---------- */
.main { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.chat-header { display: flex; align-items: center; gap: 13px; padding: 16px 28px; border-bottom: 1px solid var(--border); background: rgba(10,10,15,0.6); backdrop-filter: blur(10px); }
.chat-icon { font-size: 22px; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.chat-title { font-weight: 700; font-size: 16px; }
.chat-sub { font-size: 13px; color: var(--text-dim); }

.chat-log { flex: 1; overflow-y: auto; padding: 28px; display: flex; flex-direction: column; gap: 18px; }

.empty { margin: auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; opacity: 0.85; }
.empty-icon { font-size: 40px; width: 78px; height: 78px; display: grid; place-items: center; border-radius: 20px; background: var(--surface); border: 1px solid var(--border); margin-bottom: 8px; }
.empty-title { font-weight: 700; font-size: 18px; }
.empty-sub { color: var(--text-dim); font-size: 14px; max-width: 360px; }

.msg { display: flex; max-width: 760px; width: 100%; margin: 0 auto; }
.msg-user { justify-content: flex-end; }
.msg-assistant { justify-content: flex-start; }
.bubble {
  max-width: 78%; padding: 13px 16px; border-radius: 16px; font-size: 14.5px; line-height: 1.55;
  white-space: pre-wrap; word-wrap: break-word;
}
.msg-user .bubble { background: linear-gradient(120deg, var(--accent), var(--accent-2)); color: #fff; border-bottom-right-radius: 5px; }
.msg-assistant .bubble { background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.bubble.typing { color: var(--text-dim); }
.bubble.error { background: rgba(248,113,113,0.1); border-color: rgba(248,113,113,0.35); color: #fca5a5; }

/* ---------- COMPOSER ---------- */
.composer { padding: 16px 28px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: flex-end; max-width: 820px; width: 100%; margin: 0 auto; }
.composer-input {
  flex: 1; resize: none; background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 13px 16px; color: var(--text); font-family: inherit; font-size: 14.5px; line-height: 1.5; outline: none;
  max-height: 200px; transition: border-color 0.2s;
}
.composer-input:focus { border-color: var(--accent); }
.composer-send {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 12px; border: none; cursor: pointer;
  background: linear-gradient(120deg, var(--accent), var(--accent-2)); color: #fff; font-size: 18px; font-weight: 700;
  transition: transform 0.15s, opacity 0.2s;
}
.composer-send:hover { transform: translateY(-1px); }
.composer-send:active { transform: translateY(0); }

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
