/* =============================================================================
   atlas-shell.css — Atlas AI Shared Design Tokens + Shell Layout
   Extracted from admin.html design system. GitHub-inspired dark theme.
   ============================================================================= */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:ital,wght@0,300;0,400;0,500;0,600;1,400&display=swap');

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

:root {
  /* === BACKGROUNDS === */
  --bg:            #080c12;
  --surface:       #0d1117;
  --card:          #111720;
  --card-hover:    #161d28;

  /* === BORDERS === */
  --border:        #1e2733;
  --border-soft:   #161e2a;
  --border-bright: #2d3a4a;

  /* === TEXT === */
  --text:          #b8c4d0;
  --text-dim:      #5a6a7a;
  --text-bright:   #e8f0f8;
  --text-muted:    #3d4e5e;

  /* === ACCENT (Electric Blue) === */
  --accent:        #3b82f6;
  --accent-dim:    rgba(59,130,246,0.10);
  --accent-glow:   rgba(59,130,246,0.20);

  /* === STATUS COLORS === */
  --green:         #10b981;
  --green-dim:     rgba(16,185,129,0.10);
  --orange:        #f59e0b;
  --orange-dim:    rgba(245,158,11,0.10);
  --red:           #ef4444;
  --red-dim:       rgba(239,68,68,0.10);
  --purple:        #8b5cf6;
  --purple-dim:    rgba(139,92,246,0.10);

  /* === TYPOGRAPHY === */
  --radius:        8px;
  --font-mono:     'IBM Plex Mono', monospace;
  --font-sans:     'IBM Plex Sans', sans-serif;
}

html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Typography ─────────────────────────────────── */
h1, h2, h3 { color: var(--text-bright); font-weight: 600; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 0.95rem; }
.mono { font-family: var(--font-mono); }
.dim { color: var(--text-dim); }

/* ── Buttons ────────────────────────────────────── */
.btn {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn:hover {
  border-color: var(--accent);
  color: var(--text-bright);
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  opacity: 0.9;
  box-shadow: 0 0 12px var(--accent-glow);
}

/* ── Cards ──────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1rem;
}

/* ── Inputs ─────────────────────────────────────── */
.input {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  outline: none;
  width: 100%;
  transition: border-color 0.15s ease;
}
.input:focus {
  border-color: var(--accent);
}

/* ── Badges ─────────────────────────────────────── */
.badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-sr { background: var(--green-dim); color: var(--green); }
.badge-ps { background: var(--accent-dim); color: var(--accent); }
.badge-je { background: var(--orange-dim); color: var(--orange); }
.badge-uq { background: var(--red-dim); color: var(--red); }
.badge-founder { background: var(--purple-dim); color: var(--purple); }
.badge-admin { background: var(--accent-dim); color: var(--accent); }
.badge-operator { background: var(--green-dim); color: var(--green); }

/* ── Toast ──────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  color: var(--text);
  animation: toastIn 0.3s ease;
  max-width: 360px;
}
.toast-success { border-left: 3px solid var(--green); }
.toast-error { border-left: 3px solid var(--red); }
.toast-info { border-left: 3px solid var(--accent); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Loading Spinner ────────────────────────────── */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 3rem;
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* ── Language Switcher ─────────────────────────── */
.lang-switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--border-soft);
  border-radius: 6px;
  padding: 2px;
  margin-right: 0.5rem;
}
.lang-btn {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  font-weight: 600;
  padding: 0.25rem 0.45rem;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: all 0.15s;
  min-height: 24px;
  line-height: 1;
}
.lang-btn:hover {
  color: var(--text);
  background: var(--border);
}
.lang-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ── Upgraded Interactive States ───────────────── */
.btn-primary {
  box-shadow: 0 0 0 0 var(--accent-glow);
  transition: box-shadow 0.2s, opacity 0.15s;
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  outline: none;
}
.card:hover {
  border-color: var(--border-bright);
}

/* ── Scrollbar (webkit) ────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-bright);
}

/* ── Top Bar ─────────────────────────────── */
.topbar {
  height: 52px;
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  flex-shrink: 0;
  z-index: 50;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.topbar-logo {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-bright);
  letter-spacing: 2px;
}
.topbar-version {
  font-size: 0.65rem;
}
.topbar-spacer { flex: 1; }
.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.topbar-name {
  font-size: 0.8rem;
  color: var(--text);
}
.topbar-logout {
  font-size: 0.68rem;
  padding: 0.3rem 0.6rem;
}
.topbar-mascot {
  height: 34px;
  width: 34px;
  margin-right: 0.5rem;
  object-fit: contain;
  vertical-align: middle;
  filter: drop-shadow(0 0 8px rgba(96,165,250,0.85)) drop-shadow(0 0 3px rgba(37,99,235,0.7));
  animation: mascot-float 4s ease-in-out infinite;
}
@keyframes mascot-float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-3px); }
}

/* ── App Layout ─────────────────────────── */
.app-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────── */
#sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: width 0.2s ease;
}
#sidebar.collapsed {
  width: 48px;
}
#sidebar.collapsed .sidebar-label {
  display: none;
}
#sidebar.collapsed .sidebar-collapse-btn span {
  transform: rotate(180deg);
}
.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.sidebar-collapse-btn button {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  font-size: 0.85rem;
  transition: color 0.15s, transform 0.2s;
}
.sidebar-collapse-btn button:hover {
  color: var(--text);
}
.sidebar-collapse-btn button span {
  display: inline-block;
  transition: transform 0.2s;
}
#sidebar.collapsed .sidebar-collapse-btn {
  justify-content: center;
  padding: 0.5rem;
}
.sidebar-nav {
  flex: 1;
  padding: 0.5rem 0;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.82rem;
  font-family: var(--font-sans);
  text-align: left;
  border-radius: 6px;
  margin: 1px 4px;
  width: calc(100% - 8px);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-item:hover {
  background: var(--border-soft);
  color: var(--text);
}
.sidebar-item.active {
  background: var(--accent-dim);
  color: var(--accent);
}
.sidebar-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.15s;
}
.sidebar-footer {
  padding: 0.5rem 0;
  border-top: 1px solid var(--border-soft);
}

/* ── Workspace ───────────────────────────── */
#workspace {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  min-width: 0;
}

/* ── KAIA panel ──────────────────────────── */
#sifu-panel {
  width: 340px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease;
  overflow: hidden;
}
#sifu-panel.collapsed {
  width: 0;
  border-left: none;
}

/* ── Manager Badge ───────────────────────── */
.badge-manager { background: var(--orange-dim); color: var(--orange); }

/* ── Language Dropdown ───────────────────── */
.lang-select {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  background: var(--border-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem 0.4rem;
  cursor: pointer;
  margin-right: 0.5rem;
  outline: none;
}
.lang-select:hover {
  border-color: var(--border-bright);
}

/* ── KAIA panel components (detailed) ───────────────── */
.sifu-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sifu-header h3 {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.sifu-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.1rem;
}
.sifu-close:hover { color: var(--text); }
.sifu-body {
  flex: 1;
  padding: 0;
  overflow-y: auto;
  font-size: 0.82rem;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
}
.sifu-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.sifu-msg {
  max-width: 88%;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  font-size: 0.82rem;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.sifu-msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 3px;
}
.sifu-msg.assistant {
  align-self: flex-start;
  background: var(--bg);
  color: var(--text);
  border-bottom-left-radius: 3px;
}
.sifu-msg.system {
  align-self: center;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.75rem;
  text-align: center;
  padding: 0.3rem;
}
.sifu-typing {
  align-self: flex-start;
  color: var(--text-dim);
  font-size: 0.75rem;
  padding: 0.3rem 0.75rem;
}
.sifu-quick-actions {
  display: flex;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border-soft);
  flex-wrap: wrap;
}
.sifu-quick-btn {
  font-size: 0.7rem;
  padding: 0.25rem 0.55rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
}
.sifu-quick-btn:hover {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}
.sifu-input-area {
  padding: 0.6rem 0.75rem;
  border-top: 1px solid var(--border-soft);
  display: flex;
  gap: 0.4rem;
  position: relative;
  align-items: center;
}
.sifu-input-area input[type="text"] {
  flex: 1;
  font-size: 0.82rem;
}
.sifu-send-btn {
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
}
.sifu-plus-btn {
  padding: 0.35rem 0.55rem;
  font-size: 0.9rem;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  min-width: 34px;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}
.sifu-plus-btn:hover { background: var(--bg); }
.sifu-upload-menu {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  z-index: 100;
  min-width: 200px;
  padding: 0.3rem 0;
}
.sifu-upload-menu.show { display: block; }
.sifu-upload-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text);
  min-height: 44px;
  white-space: nowrap;
}
.sifu-upload-option:hover { background: var(--bg); }

/* ── KAIA confirm cards ─────────────────── */
.sifu-confirm-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  margin: 0.4rem 0;
  font-size: 0.8rem;
}
.sifu-confirm-card p {
  margin: 0 0 0.5rem 0;
  color: var(--text);
}
.sifu-confirm-btns { display: flex; gap: 0.4rem; }
.sifu-confirm-btns button {
  font-size: 0.72rem;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid var(--border);
}
.sifu-confirm-yes {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.sifu-confirm-no {
  background: var(--surface);
  color: var(--text-dim);
}

/* ── KAIA insight cards (detailed) ─────────────────── */
.sifu-insights-container {
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.sifu-insight-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--text);
}
.sifu-insight-card.high {
  border-left-color: #e74c3c;
  background: rgba(231, 76, 60, 0.06);
}
.sifu-insight-card.medium {
  border-left-color: #f39c12;
  background: rgba(243, 156, 18, 0.06);
}
.sifu-insight-card.info {
  border-left-color: var(--accent);
  background: rgba(59, 130, 246, 0.06);
}
.sifu-insight-text { margin-bottom: 0.35rem; }
.sifu-insight-actions { display: flex; gap: 0.3rem; }
.sifu-insight-actions button {
  font-size: 0.65rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
}
.sifu-insight-actions button:hover {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}
.sifu-insight-actions .insight-act {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.sifu-insight-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #e74c3c;
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ── Edit Mode Options Cards ────────────── */
.options-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 1rem;
  margin: 0.5rem 0;
  max-width: 420px;
}
.options-card-question {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.75rem;
}
.options-list { display: flex; flex-direction: column; gap: 0.4rem; }
.option-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  background: var(--bg);
  font-size: 0.82rem;
}
.option-number { color: var(--text-muted); min-width: 18px; font-size: 0.75rem; }
.option-label { flex: 1; color: var(--text); }
.option-value { color: var(--text); font-weight: 500; min-width: 60px; text-align: right; }
.option-value-input {
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  font-size: 0.82rem;
  min-width: 70px;
  max-width: 100px;
  text-align: right;
  background: var(--surface);
  color: var(--text);
  display: none;
}
.options-card.edit-mode .option-value { display: none; }
.options-card.edit-mode .option-value-input { display: block; }
.options-card-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.btn-edit-mode {
  font-size: 0.78rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  min-height: 32px;
}
.btn-edit-mode:hover { background: var(--bg); }
.btn-send-changes {
  font-size: 0.78rem;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  border: none;
  min-height: 32px;
  display: none;
}
.options-card.edit-mode .btn-send-changes { display: block; }
.options-card.edit-mode .btn-edit-mode { display: none; }
.option-custom-input {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  font-size: 0.82rem;
  background: var(--surface);
  color: var(--text);
  display: none;
}
.options-card.edit-mode .option-custom-input { display: block; }

/* ── KAIA copy button ───────────────────── */
.sifu-msg-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 88%;
  gap: 0.2rem;
}
.sifu-msg-wrapper.user {
  align-self: flex-end;
  align-items: flex-end;
}
.sifu-msg-wrapper .sifu-msg {
  max-width: 100%;
}
.sifu-copy-btn {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  white-space: nowrap;
}
.sifu-msg-wrapper:hover .sifu-copy-btn {
  opacity: 1;
}
.sifu-copy-btn.copied {
  color: var(--green);
  border-color: var(--green);
}

/* ── KAIA edit button ──────────────────────── */
.sifu-edit-btn {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  white-space: nowrap;
}
.sifu-msg-wrapper.user:hover .sifu-edit-btn {
  opacity: 1;
}

/* ── Notification Bell ────────────────────── */
.notif-bell {
  background: none;
  border: none;
  cursor: pointer;
  position: relative;
  font-size: 1rem;
  padding: 0.25rem;
  color: var(--text-dim);
}
.notif-bell:hover { color: var(--text); }
.notif-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--red);
  color: white;
  font-size: 0.55rem;
  font-weight: 700;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Mobile Responsive ───────────────────── */
@media (max-width: 768px) {
  #sidebar { width: 56px; }
  #sidebar .sidebar-label { display: none; }
  #sifu-panel {
    position: fixed;
    right: 0; top: 52px;
    height: calc(100vh - 52px);
    z-index: 100;
    box-shadow: -4px 0 20px rgba(0,0,0,0.3);
  }
}
