/* TRiON Platform — Main Stylesheet */
/* DM Sans font, Black & White, Light/Dark modes */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,200;0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;0,9..40,800;1,9..40,300;1,9..40,400&display=swap');

/* ═══════════════════════════════════════
   CSS VARIABLES — DARK MODE (DEFAULT)
═══════════════════════════════════════ */
:root {
  --bg:          #0a0a0a;
  --bg-2:        #111111;
  --bg-3:        #181818;
  --bg-4:        #222222;
  --border:      #2a2a2a;
  --border-2:    #333333;
  --text:        #f0f0f0;
  --text-2:      #aaaaaa;
  --text-3:      #666666;
  --accent:      #ffffff;
  --accent-dim:  rgba(255,255,255,0.08);
  --accent-hover:rgba(255,255,255,0.12);
  --shadow:      0 4px 24px rgba(0,0,0,0.6);
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.4);
  --radius:      8px;
  --radius-lg:   16px;
  --sidebar-w:   260px;
  --topbar-h:    60px;
  --transition:  0.2s cubic-bezier(0.4,0,0.2,1);
  --green:       #22c55e;
  --yellow:      #eab308;
  --red:         #ef4444;
  --blue:        #3b82f6;
}

[data-theme="light"] {
  --bg:          #f8f8f8;
  --bg-2:        #ffffff;
  --bg-3:        #f0f0f0;
  --bg-4:        #e8e8e8;
  --border:      #e0e0e0;
  --border-2:    #cccccc;
  --text:        #0a0a0a;
  --text-2:      #555555;
  --text-3:      #999999;
  --accent:      #000000;
  --accent-dim:  rgba(0,0,0,0.06);
  --accent-hover:rgba(0,0,0,0.10);
  --shadow:      0 4px 24px rgba(0,0,0,0.10);
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.07);
}

/* ═══════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; font-size: 15px; }

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; }
ul { list-style: none; }

/* ═══════════════════════════════════════
   LAYOUT
═══════════════════════════════════════ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
}

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-body {
  padding: 32px;
  flex: 1;
}

/* ═══════════════════════════════════════
   SIDEBAR COMPONENTS
═══════════════════════════════════════ */
.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  width: 36px; height: 36px;
  background: var(--text);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: var(--bg);
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.logo-text {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 2px;
  color: var(--text);
}

.logo-sub {
  font-size: 10px;
  color: var(--text-3);
  letter-spacing: 0.5px;
  line-height: 1.2;
}

.sidebar-section {
  padding: 16px 12px 8px;
}

.sidebar-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--text-3);
  text-transform: uppercase;
  padding: 0 8px;
  margin-bottom: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.nav-item:hover {
  background: var(--accent-dim);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 500;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 25%; bottom: 25%;
  width: 2px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
  margin-left: -12px;
}

.nav-icon {
  width: 18px; height: 18px;
  opacity: 0.7;
  flex-shrink: 0;
}

.nav-item.active .nav-icon { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: var(--bg);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  transition: background var(--transition);
  cursor: pointer;
}

.user-chip:hover { background: var(--accent-dim); }

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-4);
  border: 1px solid var(--border);
  object-fit: cover;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
  flex-shrink: 0;
}

.user-name { font-size: 13px; font-weight: 500; }
.user-role { font-size: 11px; color: var(--text-3); }

/* ═══════════════════════════════════════
   TOPBAR COMPONENTS
═══════════════════════════════════════ */
.topbar-title {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
}

.topbar-search {
  display: flex;
  align-items: center;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  gap: 8px;
  flex: 0 1 320px;
}

.topbar-search input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
  width: 100%;
}

.topbar-search input::placeholder { color: var(--text-3); }

.icon-btn {
  width: 36px; height: 36px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-2);
}

.icon-btn:hover { background: var(--accent-dim); color: var(--text); border-color: var(--border-2); }
.icon-btn svg { width: 16px; height: 16px; }

/* ═══════════════════════════════════════
   CARDS & PANELS
═══════════════════════════════════════ */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
}

.card-body { padding: 24px; }

.card-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-3);
}

/* ═══════════════════════════════════════
   BUTTONS
═══════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.btn-primary:hover { opacity: 0.85; transform: translateY(-1px); }

.btn-secondary {
  background: var(--bg-3);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover { background: var(--accent-hover); border-color: var(--border-2); }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: transparent;
}

.btn-ghost:hover { background: var(--accent-dim); color: var(--text); }

.btn-danger {
  background: transparent;
  color: var(--red);
  border-color: var(--red);
}

.btn-danger:hover { background: rgba(239,68,68,0.1); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ═══════════════════════════════════════
   FORMS
═══════════════════════════════════════ */
.form-group { margin-bottom: 20px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}

.form-label span { color: var(--red); margin-left: 2px; }

.form-control {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  transition: border-color var(--transition);
  outline: none;
}

.form-control:focus { border-color: var(--text-3); }
.form-control::placeholder { color: var(--text-3); }

textarea.form-control { resize: vertical; min-height: 100px; line-height: 1.5; }

select.form-control { appearance: none; cursor: pointer; }

.form-hint {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ═══════════════════════════════════════
   BADGES & TAGS
═══════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.badge-gray   { background: var(--bg-4); color: var(--text-2); }
.badge-yellow { background: rgba(234,179,8,0.15); color: var(--yellow); }
.badge-blue   { background: rgba(59,130,246,0.15); color: var(--blue); }
.badge-green  { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-white  { background: var(--accent); color: var(--bg); }
.badge-red    { background: rgba(239,68,68,0.15); color: var(--red); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 4px;
  background: var(--bg-4);
  color: var(--text-2);
  font-size: 12px;
  border: 1px solid var(--border);
}

/* ═══════════════════════════════════════
   TABLES
═══════════════════════════════════════ */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-3);
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover { background: var(--accent-dim); }

/* ═══════════════════════════════════════
   STATS / KPI CARDS
═══════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-change {
  font-size: 12px;
  color: var(--text-3);
}

/* ═══════════════════════════════════════
   MODALS
═══════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.2s ease;
}

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

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-title { font-size: 16px; font-weight: 600; flex: 1; }
.modal-body  { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ═══════════════════════════════════════
   AI PANEL
═══════════════════════════════════════ */
.ai-panel {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.ai-panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-3);
}

.ai-dot {
  width: 8px; height: 8px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.ai-panel-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.ai-result {
  padding: 20px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-2);
  white-space: pre-wrap;
  min-height: 120px;
}

.ai-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-3);
  font-size: 13px;
  padding: 20px;
}

.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border-2);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

/* ═══════════════════════════════════════
   UPLOAD ZONE
═══════════════════════════════════════ */
.upload-zone {
  border: 2px dashed var(--border-2);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-3);
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--text-3);
  background: var(--accent-dim);
  color: var(--text-2);
}

.upload-zone svg { margin: 0 auto 12px; opacity: 0.4; }
.upload-zone p { font-size: 14px; }
.upload-zone small { font-size: 12px; display: block; margin-top: 4px; }

/* ═══════════════════════════════════════
   WORKFLOW STATUS
═══════════════════════════════════════ */
.workflow {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 16px 0;
}

.workflow-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
}

.workflow-step::after {
  content: '';
  position: absolute;
  top: 12px; left: 50%; right: -50%;
  height: 1px;
  background: var(--border);
  z-index: 0;
}

.workflow-step:last-child::after { display: none; }

.workflow-dot {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-3);
  z-index: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  font-weight: 700;
  transition: all var(--transition);
}

.workflow-step.done .workflow-dot { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.workflow-step.current .workflow-dot { border-color: var(--text-2); background: var(--bg); box-shadow: 0 0 0 4px var(--accent-dim); }

.workflow-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-3);
  margin-top: 6px;
  text-align: center;
}

.workflow-step.done .workflow-label, .workflow-step.current .workflow-label { color: var(--text-2); }

/* ═══════════════════════════════════════
   EMPTY STATES
═══════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
}

.empty-state svg { margin: 0 auto 16px; opacity: 0.3; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.empty-state p { font-size: 14px; }

/* ═══════════════════════════════════════
   ALERTS
═══════════════════════════════════════ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid transparent;
}

.alert-success { background: rgba(34,197,94,0.1); border-color: rgba(34,197,94,0.2); color: var(--green); }
.alert-error   { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.2); color: var(--red); }
.alert-info    { background: rgba(59,130,246,0.1); border-color: rgba(59,130,246,0.2); color: var(--blue); }
.alert-warn    { background: rgba(234,179,8,0.1); border-color: rgba(234,179,8,0.2); color: var(--yellow); }

/* ═══════════════════════════════════════
   PAGE HEADERS
═══════════════════════════════════════ */
.page-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
}

.page-header-text { flex: 1; }

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.page-header p {
  font-size: 14px;
  color: var(--text-2);
}

/* ═══════════════════════════════════════
   TABS
═══════════════════════════════════════ */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  gap: 0;
  margin-bottom: 24px;
}

.tab {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  margin-bottom: -1px;
}

.tab:hover { color: var(--text-2); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* ═══════════════════════════════════════
   CITATION MAP / NETWORK GRAPH
═══════════════════════════════════════ */
#citation-canvas {
  width: 100%;
  height: 400px;
  background: var(--bg-3);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* ═══════════════════════════════════════
   CODE DISPLAY
═══════════════════════════════════════ */
pre {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
}

code { font-family: 'DM Mono', 'Fira Code', monospace; font-size: 13px; }

/* ═══════════════════════════════════════
   TRION ID DISPLAY
═══════════════════════════════════════ */
.trion-id {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--text-3);
  background: var(--bg-4);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  letter-spacing: 0.5px;
}

/* ═══════════════════════════════════════
   AUTH PAGES
═══════════════════════════════════════ */
.auth-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}

.auth-box {
  width: 100%;
  max-width: 420px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo .logo-mark {
  margin: 0 auto 12px;
  width: 48px; height: 48px;
  font-size: 16px;
}

.auth-logo h1 { font-size: 22px; font-weight: 700; letter-spacing: 2px; }
.auth-logo p  { font-size: 13px; color: var(--text-3); margin-top: 4px; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-3);
  font-size: 12px;
}

.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

.sso-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 10px;
  transition: all var(--transition);
  text-decoration: none;
}

.sso-btn:hover { background: var(--accent-hover); border-color: var(--border-2); }
.sso-btn img   { width: 18px; height: 18px; }

/* ═══════════════════════════════════════
   SCROLLBARS
═══════════════════════════════════════ */
::-webkit-scrollbar        { width: 6px; height: 6px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ═══════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════ */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-260px); width: 260px; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-body { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ═══════════════════════════════════════
   TOAST NOTIFICATIONS
═══════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.toast-success { border-left: 3px solid var(--green); }
.toast-error   { border-left: 3px solid var(--red); }
.toast-info    { border-left: 3px solid var(--blue); }

/* ═══════════════════════════════════════
   MISC UTILITIES
═══════════════════════════════════════ */
.flex   { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.mt-1   { margin-top: 4px; }
.mt-2   { margin-top: 8px; }
.mt-3   { margin-top: 12px; }
.mt-4   { margin-top: 16px; }
.mb-4   { margin-bottom: 16px; }
.mb-6   { margin-bottom: 24px; }
.text-sm  { font-size: 13px; }
.text-xs  { font-size: 11px; }
.text-muted { color: var(--text-3); }
.text-secondary { color: var(--text-2); }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.hidden { display: none !important; }
/* ═══════════════════════════════════════
   NEW FEATURES — V2 UPGRADE
═══════════════════════════════════════ */

/* AI Lab */
.ai-lab-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}

.ai-lab-sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.ai-lab-sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-lab-session-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}

.ai-lab-session-item:hover { background: var(--accent-dim); }
.ai-lab-session-item.active { background: var(--accent-hover); border-left: 2px solid var(--accent); }

.ai-lab-chat {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-h));
  background: var(--bg);
}

.ai-lab-mode-bar {
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-2);
  flex-wrap: wrap;
}

.mode-chip {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.mode-chip:hover, .mode-chip.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.ai-lab-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.chat-message {
  display: flex;
  gap: 14px;
  max-width: 820px;
}

.chat-message.user { flex-direction: row-reverse; margin-left: auto; }

.chat-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}

.chat-bubble {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  font-size: 14px;
  line-height: 1.7;
  max-width: 640px;
}

.chat-message.user .chat-bubble {
  background: var(--bg-4);
  border-color: var(--border-2);
}

.chat-bubble p { margin-bottom: 8px; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble code { background: var(--bg-3); padding: 1px 5px; border-radius: 3px; font-size: 12px; }
.chat-bubble pre { background: var(--bg-3); padding: 12px; border-radius: var(--radius); overflow-x: auto; margin: 8px 0; }

.ai-lab-input-area {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
}

.ai-lab-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.ai-lab-textarea {
  flex: 1;
  min-height: 52px;
  max-height: 200px;
  resize: none;
  padding: 14px 16px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  font-family: inherit;
  overflow-y: auto;
}

.ai-lab-textarea:focus { outline: none; border-color: var(--border-2); }

.ai-lab-send-btn {
  width: 52px; height: 52px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--bg);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: opacity var(--transition);
}

.ai-lab-send-btn:hover { opacity: 0.85; }
.ai-lab-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Survey Tool */
.survey-chat {
  display: flex;
  flex-direction: column;
  height: 560px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg);
}

.survey-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.survey-msg {
  display: flex;
  gap: 12px;
  max-width: 560px;
}

.survey-msg.user { flex-direction: row-reverse; margin-left: auto; }

.survey-bubble {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.6;
}

.survey-msg.user .survey-bubble {
  background: var(--bg-4);
}

.survey-chat-input {
  padding: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  background: var(--bg-2);
}

.survey-chat-input input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}

.survey-chat-input input:focus { outline: none; border-color: var(--border-2); }

/* Survey Options */
.survey-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.survey-option-btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-3);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.survey-option-btn:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

/* Collaborators */
.collab-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.collab-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition);
}

.collab-item:hover { border-color: var(--border-2); }

.collab-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  flex-shrink: 0;
}

.collab-info { flex: 1; }
.collab-name { font-size: 14px; font-weight: 600; }
.collab-role { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.collab-status {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.collab-status.pending  { background: rgba(234,179,8,0.15); color: var(--yellow); }
.collab-status.accepted { background: rgba(34,197,94,0.15); color: var(--green); }
.collab-status.declined { background: rgba(239,68,68,0.15); color: var(--red); }

/* Task Board */
.task-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  overflow-x: auto;
}

.task-column {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  min-height: 400px;
}

.task-column-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.task-column-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 300px;
}

.task-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: all var(--transition);
}

.task-card:hover {
  border-color: var(--border-2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.task-title { font-size: 13px; font-weight: 500; margin-bottom: 8px; }

.task-priority {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.priority-low      { background: rgba(34,197,94,0.12); color: var(--green); }
.priority-medium   { background: rgba(59,130,246,0.12); color: var(--blue); }
.priority-high     { background: rgba(234,179,8,0.12); color: var(--yellow); }
.priority-critical { background: rgba(239,68,68,0.12); color: var(--red); }

/* Milestone Timeline */
.milestone-timeline {
  position: relative;
  padding-left: 32px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.milestone-timeline::before {
  content: '';
  position: absolute;
  left: 10px; top: 0; bottom: 0;
  width: 2px;
  background: var(--border);
}

.milestone-item {
  position: relative;
  padding: 0 0 24px 20px;
}

.milestone-dot {
  position: absolute;
  left: -26px; top: 2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--bg-3);
  border: 2px solid var(--border-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
}

.milestone-dot.achieved { background: var(--green); border-color: var(--green); color: #fff; }
.milestone-dot.missed   { background: var(--red); border-color: var(--red); color: #fff; }

/* Enhanced AI Panel */
.ai-tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

/* Survey Results */
.result-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.result-bar-label { font-size: 13px; min-width: 140px; }
.result-bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg-3);
  border-radius: 4px;
  overflow: hidden;
}

.result-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.6s ease;
}

.result-bar-count { font-size: 12px; color: var(--text-3); min-width: 40px; text-align: right; }

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 12px 18px;
}

.typing-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-3);
  animation: typingBounce 1.2s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-6px); }
}

/* Invite Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal-box {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow);
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title { font-size: 16px; font-weight: 700; }

/* Progress rings */
.progress-ring {
  transform: rotate(-90deg);
}

/* Enhanced Stats */
.stat-card-lg {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  transition: border-color var(--transition);
}

.stat-card-lg:hover { border-color: var(--border-2); }

/* Nav badge for survey/collab */
.nav-badge-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--red);
  color: #fff;
  border-radius: 8px;
  font-size: 9px;
  font-weight: 700;
  margin-left: auto;
}

/* AI Lab prompt cards */
.prompt-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition);
}

.prompt-card:hover {
  border-color: var(--border-2);
  background: var(--bg-3);
}

.prompt-card-title { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.prompt-card-text  { font-size: 12px; color: var(--text-3); line-height: 1.5; }

/* Section divider */
.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.section-divider::before,
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
