/* ==========================================================================
   components.css — kai.research.my v2
   Shared UI components for admin and user layouts
   Flat CSS only. Uses design tokens from tokens.css.
   ========================================================================== */

/* --------------------------------------------------------------------------
   APP LAYOUT
   -------------------------------------------------------------------------- */

.app-page {
  margin: 0;
  padding: 0;
  background: var(--bg-black);
  color: var(--text-white);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* --------------------------------------------------------------------------
   SIDEBAR
   -------------------------------------------------------------------------- */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  z-index: var(--z-sidebar);
  overflow-y: auto;
}

.sidebar-top {
  display: flex;
  flex-direction: column;
}

.sidebar-bottom {
  margin-top: auto;
}

.sidebar-logo {
  padding: var(--space-24) var(--space-20);
}

.brand-text {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-white);
}

.sidebar-separator {
  height: 1px;
  background: var(--border);
  margin: 0 var(--space-20);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: var(--space-12) var(--space-12);
  gap: var(--space-4);
}

/* --------------------------------------------------------------------------
   NAV ITEMS
   -------------------------------------------------------------------------- */

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  padding: var(--space-8) var(--space-12);
  color: var(--text-gray);
  text-decoration: none;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.nav-item:hover {
  color: var(--text-white);
  background: var(--bg-elevated);
}

.nav-item.active {
  color: var(--accent-teal);
  background: var(--bg-elevated);
}

.nav-item svg,
.nav-item i {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   CONVERSATION SESSION LIST (user sidebar)
   -------------------------------------------------------------------------- */

.convo-session-list {
  padding: 0 var(--space-12) var(--space-8) var(--space-32);
}

.convo-date-group {
  margin-bottom: var(--space-8);
}

.convo-date-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: var(--space-4) 0;
}

.convo-session-item {
  display: block;
  padding: var(--space-4) var(--space-8);
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--transition-fast);
}

.convo-session-item:hover {
  color: var(--text-white);
}

.convo-session-item.active {
  color: var(--accent-teal);
}

/* --------------------------------------------------------------------------
   SIDEBAR USER
   -------------------------------------------------------------------------- */

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  padding: var(--space-16) var(--space-20);
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--accent-teal);
  flex-shrink: 0;
}

.user-avatar svg,
.user-avatar i {
  width: 16px;
  height: 16px;
  color: var(--accent-teal);
}

.user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  text-decoration: none;
  transition: color var(--transition-fast);
  flex-shrink: 0;
}

.logout-btn:hover {
  color: var(--color-error);
}

.logout-btn svg,
.logout-btn i {
  width: 16px;
  height: 16px;
}

/* --------------------------------------------------------------------------
   MAIN CONTENT
   -------------------------------------------------------------------------- */

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

.page-header {
  padding: var(--space-32) var(--space-40) var(--space-24);
  border-bottom: 1px solid var(--border);
}

.page-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-white);
  margin: 0;
}

.page-body {
  padding: var(--space-32) var(--space-40);
  flex: 1;
}

/* --------------------------------------------------------------------------
   STAT CARDS
   -------------------------------------------------------------------------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-16);
  margin-bottom: var(--space-32);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: var(--space-24);
}

.stat-card__label {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-8);
}

.stat-card__value {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 36px;
  color: var(--text-white);
  line-height: 1;
  margin-bottom: var(--space-8);
}

.stat-card__footer {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

/* --------------------------------------------------------------------------
   DATA TABLE
   -------------------------------------------------------------------------- */

.data-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  margin-bottom: var(--space-24);
}

.data-table-header {
  padding: var(--space-20) var(--space-24);
  border-bottom: 1px solid var(--border);
}

.data-table-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-gray);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead th {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
  text-align: left;
  padding: var(--space-12) var(--space-16);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody td {
  padding: var(--space-12) var(--space-16);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-gray);
  vertical-align: middle;
}

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

.data-table tbody tr:hover {
  background: var(--bg-elevated);
}

/* Table column helpers */

.col-name {
  font-weight: 500;
  color: var(--text-white);
}

a.col-name {
  text-decoration: none;
  transition: color var(--transition-fast);
}

a.col-name:hover {
  color: var(--accent-teal);
}

.col-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

.col-mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

.col-nowrap {
  white-space: nowrap;
}

.col-truncate {
  max-width: 300px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-right {
  text-align: right;
}

.col-checkbox {
  width: 40px;
  text-align: center;
}

/* --------------------------------------------------------------------------
   BADGES
   -------------------------------------------------------------------------- */

.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-gray);
  white-space: nowrap;
}

.badge--teal {
  color: var(--accent-teal);
  border-color: var(--accent-teal);
  background: rgba(14, 165, 233, 0.1);
}

.badge--blue {
  color: var(--accent-blue);
  border-color: var(--accent-blue);
  background: rgba(75, 123, 245, 0.1);
}

.badge--red {
  color: var(--color-error);
  border-color: var(--color-error);
  background: rgba(255, 102, 102, 0.1);
}

.badge--gray {
  color: var(--text-dim);
  border-color: var(--border);
  background: var(--bg-elevated);
}

.badge--active {
  color: var(--color-success);
  border-color: var(--color-success);
  background: rgba(34, 197, 94, 0.1);
}

.badge--available {
  color: var(--text-muted);
  border-color: var(--border);
  background: var(--bg-elevated);
}

.badge--survey {
  color: var(--accent-blue);
  border-color: var(--accent-blue);
  background: rgba(75, 123, 245, 0.1);
}

.badge--standard {
  color: var(--text-dim);
  border-color: var(--border);
  background: var(--bg-elevated);
}

/* --------------------------------------------------------------------------
   BUTTONS
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-8);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-decoration: none;
  padding: var(--space-8) var(--space-16);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-white);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
}

.btn:hover {
  background: var(--border-light);
}

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

.btn--primary:hover,
.btn-primary:hover {
  background: #0d93ce;
  border-color: #0d93ce;
}

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

.btn--ghost:hover {
  background: var(--bg-elevated);
  color: var(--text-white);
}

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text-gray);
}

.btn-outline:hover {
  background: var(--bg-elevated);
  color: var(--text-white);
  border-color: var(--border-light);
}

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

.btn--danger:hover {
  background: rgba(255, 102, 102, 0.1);
}

.btn--sm {
  font-size: 11px;
  padding: var(--space-4) var(--space-12);
}

/* --------------------------------------------------------------------------
   FORMS
   -------------------------------------------------------------------------- */

.form-row {
  margin-bottom: var(--space-16);
}

.form-label {
  display: block;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: var(--space-8);
}

.form-input {
  display: block;
  width: 100%;
  padding: 10px var(--space-16);
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-white);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  outline: none;
  transition: border-color var(--transition-fast);
  box-sizing: border-box;
}

.form-input:focus {
  border-color: var(--accent-teal);
}

.form-input:disabled {
  color: var(--text-dim);
  cursor: not-allowed;
  opacity: 0.6;
}

.form-input::placeholder {
  color: var(--text-dim);
}

.form-select {
  display: inline-block;
  padding: var(--space-8) var(--space-12);
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-white);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23666' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

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

.form-hint {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: var(--space-4);
}

/* --------------------------------------------------------------------------
   CHECKBOX
   -------------------------------------------------------------------------- */

.checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-teal);
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   FILTER BAR
   -------------------------------------------------------------------------- */

.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  margin-bottom: var(--space-24);
}

/* --------------------------------------------------------------------------
   ACTION BAR
   -------------------------------------------------------------------------- */

.action-bar {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  margin-bottom: var(--space-20);
  padding: var(--space-12) var(--space-16);
  background: rgba(14, 165, 233, 0.05);
  border: 1px solid rgba(14, 165, 233, 0.15);
}

.action-bar__count {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-teal);
  margin-right: auto;
}

/* --------------------------------------------------------------------------
   PAGINATION
   -------------------------------------------------------------------------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-16);
  padding: var(--space-16) var(--space-24);
  border-top: 1px solid var(--border);
}

.pagination__info {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

.pagination__btn {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-gray);
  text-decoration: none;
  padding: var(--space-4) var(--space-12);
  border: 1px solid var(--border);
  background: transparent;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.pagination__btn:hover {
  background: var(--bg-elevated);
  color: var(--text-white);
}

.pagination__btn--disabled {
  pointer-events: none;
  opacity: 0.3;
}

.pagination__pages {
  display: flex;
  gap: var(--space-4);
}

.pagination__page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-gray);
  text-decoration: none;
  border: 1px solid var(--border);
  background: transparent;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.pagination__page:hover {
  background: var(--bg-elevated);
  color: var(--text-white);
}

.pagination__page.active {
  background: var(--accent-teal);
  border-color: var(--accent-teal);
  color: var(--bg-black);
}

.pagination__per-page {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  font-size: 12px;
  color: var(--text-dim);
}

.pagination__per-page select {
  padding: var(--space-4) var(--space-8);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-white);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  outline: none;
}

/* --------------------------------------------------------------------------
   ALERTS
   -------------------------------------------------------------------------- */

.alert {
  padding: var(--space-12) var(--space-16);
  font-size: 13px;
  border: 1px solid var(--border);
  margin-bottom: var(--space-20);
}

.alert--success {
  color: var(--color-success);
  border-color: var(--color-success);
  background: rgba(34, 197, 94, 0.08);
}

.alert--error {
  color: var(--color-error);
  border-color: var(--color-error);
  background: rgba(255, 102, 102, 0.08);
}

/* --------------------------------------------------------------------------
   EMPTY STATE
   -------------------------------------------------------------------------- */

.empty-state {
  padding: var(--space-48) var(--space-24);
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
}

/* --------------------------------------------------------------------------
   CARDS
   -------------------------------------------------------------------------- */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: var(--space-24);
  margin-bottom: var(--space-24);
}

.card-full {
  width: 100%;
}

.card-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-gray);
  margin-bottom: var(--space-16);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-24);
}

.separator {
  height: 1px;
  background: var(--border);
  margin: var(--space-24) 0;
}

/* --------------------------------------------------------------------------
   TOKEN USAGE CARD
   -------------------------------------------------------------------------- */

.token-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
}

.token-card__info {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.token-card__numbers {
  display: flex;
  align-items: baseline;
  gap: var(--space-8);
}

.token-card__used {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 28px;
  color: var(--text-white);
  line-height: 1;
}

.token-card__limit {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
}

.token-card__bar {
  width: 100%;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-elevated);
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  transition: width var(--transition-base);
}

.progress-bar__fill--green {
  background: var(--color-success);
}

.progress-bar__fill--yellow {
  background: #EAB308;
}

.progress-bar__fill--red {
  background: var(--color-error);
}

/* --------------------------------------------------------------------------
   PROFILE FORM / PASSWORD SECTION
   -------------------------------------------------------------------------- */

.profile-form {
  display: flex;
  flex-direction: column;
}

.password-section {
  margin-top: var(--space-16);
}

.collapsible-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-gray);
  padding: var(--space-8) 0;
  user-select: none;
}

.collapsible-toggle .chevron {
  transition: transform var(--transition-base);
}

.collapsible-toggle.open .chevron {
  transform: rotate(180deg);
}

.collapsible-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.collapsible-body.open {
  max-height: 500px;
}

.password-form {
  padding-top: var(--space-16);
}

/* --------------------------------------------------------------------------
   PROJECT NAME / SLUG
   -------------------------------------------------------------------------- */

.project-name {
  font-weight: 500;
  color: var(--text-white);
}

.project-slug {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

/* --------------------------------------------------------------------------
   TEXT HELPERS
   -------------------------------------------------------------------------- */

.text-muted {
  color: var(--text-muted);
}

.text-dim {
  color: var(--text-dim);
}

.text-gray {
  color: var(--text-gray);
}

.font-mono {
  font-family: var(--font-mono);
}

/* --------------------------------------------------------------------------
   CHAT BUBBLES
   -------------------------------------------------------------------------- */

.chat-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
}

.chat-bubble {
  max-width: 75%;
  padding: var(--space-12) var(--space-16);
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid var(--border);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.chat-bubble--user {
  align-self: flex-end;
  background: rgba(14, 165, 233, 0.06);
  color: var(--text-white);
  border-color: rgba(14, 165, 233, 0.15);
}

.chat-bubble--bot {
  align-self: flex-start;
  background: var(--bg-card);
  color: var(--text-gray);
  border-color: var(--border);
}

.chat-bubble__meta,
.chat-meta {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  margin-top: var(--space-8);
}

.chat-bubble__tool {
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent-blue);
  margin-bottom: var(--space-8);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* --------------------------------------------------------------------------
   CONVO PAGE LAYOUT (3-column)
   -------------------------------------------------------------------------- */

.convo-page {
  margin: 0;
  padding: 0;
  background: var(--bg-black);
  color: var(--text-white);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}

.convo-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   CONVO CHAT PANEL
   -------------------------------------------------------------------------- */

.convo-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  border-right: 1px solid var(--border);
}

.convo-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-16) var(--space-24);
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  flex-shrink: 0;
}

.convo-chat__user {
  display: flex;
  align-items: center;
  gap: var(--space-12);
}

.convo-chat__user-name {
  font-weight: 500;
  font-size: 14px;
  color: var(--text-white);
}

.convo-chat__user-phone {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

.convo-chat__actions {
  display: flex;
  gap: var(--space-8);
}

.convo-chat__actions button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-gray);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.convo-chat__actions button:hover {
  background: var(--bg-elevated);
  color: var(--text-white);
}

.convo-chat__actions button svg,
.convo-chat__actions button i {
  width: 16px;
  height: 16px;
}

.convo-chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-24);
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
}

.convo-chat__input {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  padding: var(--space-12) var(--space-24);
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  flex-shrink: 0;
}

.convo-chat__input-attach,
.convo-chat__input-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-gray);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.convo-chat__input-attach:hover,
.convo-chat__input-send:hover {
  background: var(--bg-elevated);
  color: var(--text-white);
}

.convo-chat__input-send {
  background: var(--accent-teal);
  border-color: var(--accent-teal);
  color: var(--bg-black);
}

.convo-chat__input-send:hover {
  background: #0d93ce;
  border-color: #0d93ce;
  color: var(--bg-black);
}

.convo-chat__input-attach svg,
.convo-chat__input-attach i,
.convo-chat__input-send svg,
.convo-chat__input-send i {
  width: 16px;
  height: 16px;
}

.convo-chat__input-field {
  flex: 1;
  padding: 10px var(--space-16);
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-white);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  outline: none;
}

.convo-chat__input-field:focus {
  border-color: var(--accent-teal);
}

.convo-chat__input-field::placeholder {
  color: var(--text-dim);
}

.convo-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: var(--space-12);
  color: var(--text-dim);
}

.convo-empty__icon {
  width: 40px;
  height: 40px;
  color: var(--text-dim);
}

.convo-empty__text {
  font-size: 13px;
}

/* --------------------------------------------------------------------------
   WORKSPACE PANEL
   -------------------------------------------------------------------------- */

.convo-workspace {
  width: var(--workspace-width);
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  flex-shrink: 0;
}

.workspace-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 14px;
    border-bottom: 1px solid #222;
}

.workspace-header__label {
    font-family: var(--font-heading, 'Space Grotesk', sans-serif);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-dim, #666);
}

.workspace-header__actions {
  display: flex;
  gap: var(--space-8);
}

.workspace-header__actions button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-gray);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.workspace-header__actions button:hover {
  background: var(--bg-elevated);
  color: var(--text-white);
}

.workspace-header__actions button svg,
.workspace-header__actions button i {
  width: 14px;
  height: 14px;
}

.workspace-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.workspace-tab {
  flex: 1;
  text-align: center;
  padding: var(--space-12) var(--space-16);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.workspace-tab:hover {
  color: var(--text-gray);
}

.workspace-tab.active {
  color: var(--text-white);
  border-bottom-color: var(--accent-teal);
}

.workspace-body {
  flex: 1;
  overflow-y: auto;
}

.workspace-path {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  padding: var(--space-12) var(--space-20);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}

.workspace-path svg,
.workspace-path i {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.workspace-file-list {
  display: flex;
  flex-direction: column;
}

.workspace-file {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  padding: var(--space-8) var(--space-20);
  font-size: 13px;
  color: var(--text-gray);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.workspace-file:hover {
  background: var(--bg-elevated);
}

.workspace-file__icon {
  width: 16px;
  height: 16px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.workspace-file__icon--folder {
  color: var(--accent-teal);
}

.workspace-file__name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace-file__size {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.workspace-file__type {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  width: 40px;
  text-align: right;
  flex-shrink: 0;
}

.workspace-preview {
  padding: var(--space-24);
}

.workspace-preview__empty {
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  padding: var(--space-48) 0;
}

/* --------------------------------------------------------------------------
   RESPONSIVE: 1024px
   -------------------------------------------------------------------------- */

@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .convo-workspace {
    display: none;
  }

  .page-body {
    padding: var(--space-24);
  }

  .page-header {
    padding: var(--space-24) var(--space-24) var(--space-16);
  }

  .col-truncate {
    max-width: 200px;
  }
}

/* --------------------------------------------------------------------------
   RESPONSIVE: 768px
   -------------------------------------------------------------------------- */

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -100%;
    transition: left var(--transition-base);
    width: 240px;
  }

  .sidebar.open {
    left: 0;
  }

  .main-content {
    margin-left: 0;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .page-header {
    padding: var(--space-20) var(--space-16) var(--space-12);
  }

  .page-title {
    font-size: 18px;
  }

  .page-body {
    padding: var(--space-16);
  }

  .data-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .data-table {
    min-width: 600px;
  }

  .action-bar {
    flex-wrap: wrap;
  }

  .filter-bar {
    flex-wrap: wrap;
  }

  .convo-layout {
    flex-direction: column;
  }

  .convo-layout .sidebar {
    display: none;
  }

  .convo-chat {
    height: 100vh;
    border-right: none;
  }

  .convo-workspace {
    display: none;
  }

  .chat-bubble {
    max-width: 90%;
  }

  .pagination {
    flex-wrap: wrap;
    gap: var(--space-8);
  }

  .pagination__per-page {
    display: none;
  }
}


/* --------------------------------------------------------------------------
   DIALOGUE CHOICES — Chips
   -------------------------------------------------------------------------- */

.choice-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.choice-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--accent-teal, #1D9E75);
    background: rgba(14, 165, 233, 0.08);
    border: 1px solid rgba(14, 165, 233, 0.25);
    border-radius: 0;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.choice-chip:hover {
    background: rgba(14, 165, 233, 0.15);
    border-color: var(--accent-teal, #1D9E75);
}

.choice-chip__num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
    font-size: 10px;
    font-weight: 600;
    color: var(--bg-black, #000);
    background: var(--accent-teal, #1D9E75);
}

/* --------------------------------------------------------------------------
   DIALOGUE CHOICES — Cards
   -------------------------------------------------------------------------- */

.choice-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.choice-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-elevated, #1A1A1A);
    border: 1px solid var(--border, #222);
    border-radius: 0;
    cursor: pointer;
    text-align: left;
    font-family: var(--font-body);
    transition: border-color 0.15s, background 0.15s;
}

.choice-card:hover {
    border-color: var(--accent-teal, #1D9E75);
    background: rgba(14, 165, 233, 0.05);
}

.choice-card__num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
    font-size: 11px;
    font-weight: 600;
    color: var(--bg-black, #000);
    background: var(--accent-teal, #1D9E75);
    flex-shrink: 0;
}

.choice-card__body {
    flex: 1;
    min-width: 0;
}

.choice-card__label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-white, #fff);
}

.choice-card__desc {
    font-size: 11px;
    color: var(--text-dim, #999);
    margin-top: 2px;
}

.choice-card__badge {
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
    font-size: 9px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-teal, #1D9E75);
    padding: 2px 6px;
    border: 1px solid rgba(14, 165, 233, 0.3);
    flex-shrink: 0;
}

/* Disabled choices (historical) */
.choice-chips--disabled .choice-chip,
.choice-cards--disabled .choice-card {
    cursor: default;
    opacity: 0.5;
    pointer-events: none;
}


/* --------------------------------------------------------------------------
   AGENT TOOLSET SUMMARY
   -------------------------------------------------------------------------- */

.toolset-summary {
    display: flex;
    gap: 24px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border, #222);
}

.toolset-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.toolset-stat__label {
    font-size: 11px;
    color: var(--text-dim, #999);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.toolset-stat__value {
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-white, #fff);
}


/* --------------------------------------------------------------------------
   WORKSPACE DROPDOWN (Sidebar)
   -------------------------------------------------------------------------- */

.sidebar-workspace {
    padding: 6px 12px 2px;
}

.ws-dropdown {
    position: relative;
}

.ws-dropdown__trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 12px;
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--text-dim, #666);
    background: transparent;
    border: 1px solid var(--border, #222);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.ws-dropdown__trigger:hover {
    border-color: #333;
    color: var(--text-white, #fff);
}

.ws-dropdown__trigger svg,
.ws-dropdown__trigger i {
    flex-shrink: 0;
    color: var(--text-dim, #444);
}

.ws-dropdown__label {
    flex: 1;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-heading, 'Space Grotesk', sans-serif);
    font-weight: 500;
    font-size: 12px;
    letter-spacing: 0.03em;
    color: var(--text-white, #fff);
}

.ws-dropdown__menu {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    background: #111;
    border: 1px solid #222;
    z-index: 100;
    max-height: 240px;
    overflow-y: auto;
}

button.ws-dropdown__item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--text-dim, #999);
    background: transparent;
    border: none;
    border-bottom: 1px solid #1a1a1a;
    cursor: pointer;
    text-align: left;
    transition: background 0.1s;
}

button.ws-dropdown__item:hover {
    background: #1a1a1a;
    color: var(--text-white, #fff);
}

button.ws-dropdown__item.active {
    color: var(--accent-teal, #1D9E75);
    background: rgba(14, 165, 233, 0.05);
}

button.ws-dropdown__item.ws-dropdown__item--new {
    color: var(--accent-teal, #1D9E75);
    border-bottom: none;
}

.ws-dropdown__divider {
    height: 1px;
    background: #222;
    margin: 0;
}


/* --------------------------------------------------------------------------
   REPORTS PANEL (Right column in convo)
   -------------------------------------------------------------------------- */

.reports-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 16px;
    color: var(--text-dim, #666);
    font-size: 12px;
    text-align: center;
    gap: 4px;
}

.report-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #1a1a1a;
    transition: background 0.1s;
}

.report-item:hover {
    background: #111;
}

.report-item__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 18px;
    padding: 0 5px;
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
    font-size: 8px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: #000;
    flex-shrink: 0;
}

.report-item__info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.report-item__name {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-white, #ccc);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.report-item:hover .report-item__name {
    color: #fff;
}

.report-item__meta {
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
    font-size: 10px;
    color: var(--text-dim, #444);
}

.report-preview-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid #222;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-white, #fff);
}

.report-preview-header button {
    color: var(--text-dim, #666);
    cursor: pointer;
    padding: 4px;
}

.report-preview-header button:hover {
    color: var(--text-white, #fff);
}


/* --------------------------------------------------------------------------
   REPORT DELETE BUTTON
   -------------------------------------------------------------------------- */

.report-item__delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    color: #333;
    background: transparent;
    border: none;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.report-item:hover .report-item__delete {
    opacity: 1;
}

.report-item__delete:hover {
    color: #ef4444;
}

/* --------------------------------------------------------------------------
   CONFIRMATION MODAL
   -------------------------------------------------------------------------- */

.confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.confirm-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.confirm-modal__box {
    position: relative;
    width: 340px;
    background: #111;
    border: 1px solid #222;
    padding: 0;
}

.confirm-modal__title {
    font-family: var(--font-heading, 'Space Grotesk', sans-serif);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--text-white, #fff);
    padding: 16px 20px 12px;
    border-bottom: 1px solid #1a1a1a;
}

.confirm-modal__body {
    font-size: 13px;
    color: var(--text-dim, #999);
    padding: 16px 20px;
    line-height: 1.5;
}

.confirm-modal__body strong {
    color: var(--text-white, #fff);
    font-weight: 500;
    word-break: break-all;
}

.confirm-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px 16px;
}

button.confirm-modal__btn {
    padding: 7px 16px;
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid #222;
    transition: background 0.15s, border-color 0.15s;
}

button.confirm-modal__btn--cancel {
    color: var(--text-dim, #999);
    background: transparent;
}

button.confirm-modal__btn--cancel:hover {
    background: #1a1a1a;
    color: var(--text-white, #fff);
}

button.confirm-modal__btn--danger {
    color: #fff;
    background: #ef4444;
    border-color: #ef4444;
}

button.confirm-modal__btn--danger:hover {
    background: #dc2626;
    border-color: #dc2626;
}

button.confirm-modal__btn--danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Report preview download button */
.report-preview-download {
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: var(--text-dim, #666);
    text-decoration: none;
    transition: color 0.15s;
}

.report-preview-download:hover {
    color: var(--accent-teal, #1D9E75);
}


/* --------------------------------------------------------------------------
   PANEL RESIZE HANDLE
   -------------------------------------------------------------------------- */

.panel-resize-handle {
    width: 4px;
    cursor: col-resize;
    background: transparent;
    position: relative;
    flex-shrink: 0;
    z-index: 10;
    transition: background 0.15s;
}

.panel-resize-handle::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 4px;
    background: transparent;
    transition: background 0.15s;
}

.panel-resize-handle:hover::after,
.panel-resize-handle.active::after {
    background: var(--accent-teal, #1D9E75);
}


/* --------------------------------------------------------------------------
   SIDEBAR — Active Projects Section
   -------------------------------------------------------------------------- */

.sidebar-section {
    padding: 0 12px;
}

.sidebar-section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0 8px;
}

.sidebar-section__title {
    font-family: var(--font-heading, 'Space Grotesk', sans-serif);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-dim, #666);
}

.sidebar-section__action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: #444;
    text-decoration: none;
    transition: color 0.15s;
}

.sidebar-section__action:hover {
    color: var(--accent-teal, #1D9E75);
}

.sidebar-section__empty {
    font-size: 11px;
    color: #444;
    padding: 8px 0 12px;
    line-height: 1.6;
}

.sidebar-section__empty a {
    color: var(--accent-teal, #1D9E75);
    text-decoration: none;
}

.sidebar-section__empty a:hover {
    text-decoration: underline;
}

.sidebar-project-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-bottom: 8px;
}

.sidebar-project {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 0;
}

.sidebar-project__name {
    flex: 1;
    font-size: 12px;
    color: #ccc;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-project__type {
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
    font-size: 8px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: #444;
    flex-shrink: 0;
}


/* Chat links */
.chat-link {
    color: var(--accent-teal, #1D9E75);
    text-decoration: none;
    border-bottom: 1px solid rgba(14, 165, 233, 0.3);
    transition: border-color 0.15s;
}

.chat-link:hover {
    border-color: var(--accent-teal, #1D9E75);
}

/* Sidebar Sources */
.sidebar-source-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-bottom: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.sidebar-source {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    position: relative;
}

.sidebar-source:hover {
    background: rgba(255,255,255,0.03);
}

.sidebar-source__name {
    flex: 1;
    font-size: 12px;
    color: #ccc;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-source__actions {
    display: none;
    gap: 2px;
    flex-shrink: 0;
}

.sidebar-source:hover .sidebar-source__actions {
    display: flex;
}

.sidebar-source__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: transparent;
    border: none;
    color: #555;
    cursor: pointer;
    padding: 0;
}

.sidebar-source__btn:hover {
    color: var(--accent-teal, #1D9E75);
}

.sidebar-source__btn[title="Delete"]:hover {
    color: #ef4444;
}

/* Source URL modal form */
.src-modal__field {
    margin-bottom: 14px;
}

.src-modal__label {
    display: block;
    font-family: var(--font-heading, 'Space Grotesk', sans-serif);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--text-dim, #999);
    margin-bottom: 6px;
}

.src-modal__input {
    width: 100%;
    padding: 8px 12px;
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 13px;
    color: var(--text-white, #fff);
    background: var(--bg-black, #000);
    border: 1px solid #222;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.src-modal__input:focus {
    border-color: var(--accent-teal, #1D9E75);
}

.src-modal__input::placeholder {
    color: #444;
}

.src-modal__error {
    font-size: 12px;
    color: #ef4444;
    padding: 4px 0 0;
}

/* Primary button variant for modals */
button.confirm-modal__btn--primary {
    color: var(--bg-black, #000);
    background: var(--accent-teal, #1D9E75);
    border-color: var(--accent-teal, #1D9E75);
}

button.confirm-modal__btn--primary:hover {
    background: #0d93ce;
    border-color: #0d93ce;
}

button.confirm-modal__btn--primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Quick Generate footer */
.quickgen {
    flex-shrink: 0;
    border-top: 1px solid #222;
    padding: 12px 14px 14px;
}

.quickgen__label {
    font-family: var(--font-heading, 'Space Grotesk', sans-serif);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #444;
    margin-bottom: 10px;
}

.quickgen__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.quickgen__btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    background: transparent;
    border: 1px solid #222;
    color: #555;
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 11px;
    font-weight: 500;
    cursor: not-allowed;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.quickgen__btn i,
.quickgen__btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.quickgen__btn:not(:disabled) {
    color: #999;
    border-color: #333;
    cursor: pointer;
}

.quickgen__btn:not(:disabled):hover {
    background: rgba(14, 165, 233, 0.08);
    border-color: rgba(14, 165, 233, 0.3);
    color: var(--accent-teal, #1D9E75);
}

.quickgen__btn:not(:disabled):active {
    background: rgba(14, 165, 233, 0.15);
}
