/* ============================================================
   APIChat Hub - Modern College Project Stylesheet
   Designed with CSS Custom Properties, Glassmorphism & Responsive Layout
   ============================================================ */

:root {
  /* Color Palette - Dark Theme (Default) */
  --bg-app: #0c0f17;
  --bg-sidebar: #121722;
  --bg-surface: #182030;
  --bg-surface-elevated: #1f293d;
  --bg-input: #101622;
  --border-subtle: #243048;
  --border-focus: #3b82f6;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.25);

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);

  --user-bubble-bg: linear-gradient(135deg, #2563eb, #1d4ed8);
  --bot-bubble-bg: #161e2e;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --font-main: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-code: 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --transition-fast: 0.15s ease;
  --transition-smooth: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
}

/* Light Theme Variables */
body.light-theme {
  --bg-app: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-input: #f8fafc;
  --border-subtle: #e2e8f0;
  --border-focus: #2563eb;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-glow: rgba(37, 99, 235, 0.2);

  --user-bubble-bg: linear-gradient(135deg, #2563eb, #1d4ed8);
  --bot-bubble-bg: #ffffff;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Layout Container */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Header */
.app-header {
  height: 60px;
  background-color: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 30;
  flex-shrink: 0;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 0 16px var(--accent-glow);
}

.brand-text h1 {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.2;
}

.badge-project {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
  padding: 2px 7px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.tagline {
  font-size: 11px;
  color: var(--text-muted);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 5px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

.status-dot {
  width: 8px;
  height: 8px;
  background-color: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--success);
  animation: pulseDot 2s infinite ease-in-out;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  box-shadow: 0 0 12px var(--accent-glow);
}

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

.btn-secondary:hover {
  background-color: var(--bg-surface-elevated);
  border-color: var(--text-dim);
}

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

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

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  color: var(--text-main);
  background: var(--bg-surface-elevated);
  border-color: var(--text-dim);
}

.mobile-only {
  display: none;
}

.hidden {
  display: none !important;
}

/* Workspace Layout */
.workspace-body {
  display: flex;
  flex: 1;
  height: calc(100vh - 60px);
  overflow: hidden;
  position: relative;
}

/* Sidebar Configurator */
.config-sidebar {
  width: 360px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100%;
  overflow-y: auto;
  z-index: 20;
  transition: transform var(--transition-smooth);
}

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

.sidebar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}

.sidebar-title h2 {
  font-size: 14px;
  font-weight: 700;
}

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

.btn-lock {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-lock:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  border-color: var(--text-dim);
}

.btn-lock.is-locked-state {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fbbf24;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.2);
}

/* Locked Alert Banner */
.locked-banner {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(217, 119, 6, 0.1));
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  animation: bannerFadeIn 0.25s ease;
}

@keyframes bannerFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.locked-banner-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.locked-pulse-icon {
  font-size: 16px;
  animation: lockPulse 2s infinite ease-in-out;
}

@keyframes lockPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.locked-banner-text {
  display: flex;
  flex-direction: column;
}

.locked-banner-text strong {
  font-size: 12px;
  color: #fef3c7;
}

.locked-banner-text small {
  font-size: 10px;
  color: #fde68a;
}

.btn-unlock-sm {
  background: rgba(245, 158, 11, 0.25);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #fef08a;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-unlock-sm:hover {
  background: #f59e0b;
  color: #000;
  border-color: #f59e0b;
}

/* Locked Form Styling */
.config-sidebar.is-locked .form-input:disabled,
.config-sidebar.is-locked .form-select:disabled,
.config-sidebar.is-locked .form-textarea:disabled {
  background-color: rgba(15, 23, 42, 0.6);
  border-color: rgba(245, 158, 11, 0.25);
  color: #cbd5e1;
  cursor: not-allowed;
  opacity: 0.85;
}

.config-sidebar.is-locked .switch input:disabled + .slider {
  opacity: 0.5;
  cursor: not-allowed;
}

.sidebar-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Form Controls */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row {
  display: flex;
  gap: 10px;
}

.col-7 { flex: 7; }
.col-5 { flex: 5; }

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.form-label .req {
  color: var(--danger);
}

.label-hint {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
}

.field-help {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.4;
}

.field-help code {
  font-family: var(--font-code);
  background: var(--bg-surface);
  padding: 1px 4px;
  border-radius: 4px;
  color: var(--accent);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-family: var(--font-main);
  font-size: 13px;
  color: var(--text-main);
  transition: all var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg2+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.form-textarea {
  font-family: var(--font-code);
  font-size: 11px;
  resize: vertical;
}

/* Accordion */
.advanced-settings-accordion {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.accordion-header {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  list-style: none;
}

.accordion-header::-webkit-details-marker {
  display: none;
}

.accordion-header:hover {
  color: var(--text-main);
  background: var(--bg-surface-elevated);
}

.accordion-header .chevron {
  transition: transform var(--transition-fast);
}

details[open] .accordion-header .chevron {
  transform: rotate(180deg);
}

.accordion-body {
  padding: 14px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: var(--bg-sidebar);
}

/* Switch Toggle */
.toggle-group {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.toggle-info {
  display: flex;
  flex-direction: column;
}

.toggle-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

.toggle-desc {
  font-size: 10px;
  color: var(--text-dim);
}

.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-subtle);
  transition: .3s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent);
}

input:checked + .slider:before {
  transform: translateX(16px);
}

/* Quick Samples */
.quick-samples-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.samples-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.chip-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sample-chip {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-family: var(--font-code);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sample-chip:hover {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* Request Preview */
.request-preview-card {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 11px;
}

.preview-label {
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 10px;
}

.request-preview-card code {
  font-family: var(--font-code);
  color: var(--accent);
  word-break: break-all;
  display: block;
}

/* Main Chat Container */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: var(--bg-app);
  position: relative;
  overflow: hidden;
}

.chat-header-bar {
  height: 48px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background-color: var(--bg-surface);
  flex-shrink: 0;
}

.chat-active-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.pulse-indicator {
  width: 6px;
  height: 6px;
  background-color: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--accent);
}

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

.query-count-badge {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-app);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

/* Chat Messages Stream */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

/* Empty Hero State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: auto;
  max-width: 580px;
  padding: 40px 20px;
}

.empty-icon-ring {
  width: 76px;
  height: 76px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  margin-bottom: 20px;
  box-shadow: 0 0 24px var(--accent-glow);
}

.empty-state h2 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--text-main);
}

.empty-state p {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 28px;
}

.feature-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  width: 100%;
}

.step-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-card strong {
  font-size: 13px;
  color: var(--text-main);
}

.step-card span {
  font-size: 11px;
  color: var(--text-muted);
}

/* Chat Messages Bubble Layout */
.message-row {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 900px;
  animation: messageSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.message-row.user-row {
  justify-content: flex-end;
  margin-left: auto;
}

.message-row.bot-row {
  justify-content: flex-start;
  margin-right: auto;
}

/* Avatars */
.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 700;
  font-size: 13px;
}

.user-avatar {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: white;
}

.bot-avatar {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--accent);
}

/* Message Content Box */
.msg-content-wrapper {
  max-width: 82%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-row .msg-content-wrapper {
  align-items: flex-end;
}

.msg-bubble {
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.user-bubble {
  background: var(--user-bubble-bg);
  color: #ffffff;
  border-top-right-radius: 4px;
}

.user-query-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  font-family: var(--font-code);
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-query-meta {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.8);
  margin-top: 4px;
}

/* Bot Bubble Structure */
.bot-bubble {
  background: var(--bot-bubble-bg);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  border-top-left-radius: 4px;
  width: 100%;
}

.response-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}

.status-pills-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.http-status-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.status-2xx {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-4xx {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-5xx {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.latency-pill {
  font-size: 11px;
  font-family: var(--font-code);
  color: var(--text-muted);
  background: var(--bg-surface-elevated);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

.response-url-tag {
  font-size: 11px;
  font-family: var(--font-code);
  color: var(--text-dim);
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Smart Info Cards Grid */
.smart-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.smart-card-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.smart-card-key {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
}

.smart-card-val {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  word-break: break-word;
}

/* JSON Code Block */
.json-viewer-box {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-top: 10px;
}

.json-viewer-header {
  background: var(--bg-surface);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.json-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.json-code-content {
  font-family: var(--font-code);
  font-size: 12px;
  line-height: 1.5;
  padding: 12px;
  max-height: 320px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Syntax Highlighting Colors */
.json-key { color: #a78bfa; font-weight: 500; }
.json-string { color: #34d399; }
.json-number { color: #f59e0b; }
.json-boolean { color: #60a5fa; font-weight: 600; }
.json-null { color: #f43f5e; font-style: italic; }

/* Bot Action Toolbar */
.bot-action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.action-chip-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all var(--transition-fast);
}

.action-chip-btn:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  border-color: var(--text-dim);
}

.msg-timestamp {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 3px;
  padding: 0 4px;
}

/* Typing / Loader Animation */
.typing-indicator-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.typing-bubble {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 12px 18px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.dots-wrapper {
  display: flex;
  gap: 5px;
}

.dot {
  width: 7px;
  height: 7px;
  background-color: var(--accent);
  border-radius: 50%;
  animation: bounceDot 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounceDot {
  0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
  40% { transform: scale(1); opacity: 1; }
}

.typing-text {
  font-size: 12px;
  color: var(--text-muted);
}

/* Bottom Sticky Input Bar */
.chat-input-wrapper {
  padding: 16px 20px 20px 20px;
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
  z-index: 10;
}

.query-form {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-container {
  display: flex;
  align-items: center;
  background-color: var(--bg-input);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 4px 6px 4px 14px;
  gap: 10px;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.input-container:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.input-icon-prefix {
  color: var(--text-dim);
  display: flex;
  align-items: center;
}

.number-input-field {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-code);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1px;
}

.number-input-field:focus {
  outline: none;
}

.number-input-field::placeholder {
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--text-dim);
}

.input-status-badge {
  display: flex;
  align-items: center;
}

.digit-counter {
  font-family: var(--font-code);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  color: var(--text-dim);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
}

.digit-counter.complete {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.4);
}

.digit-counter.typing {
  color: var(--warning);
}

.send-btn {
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.send-btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 14px var(--accent-glow);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.input-footer-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
  padding: 0 4px;
}

.shortcut-hint kbd {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  padding: 1px 4px;
  font-family: var(--font-code);
  font-size: 10px;
}

/* Modal Overlay & Window */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-window {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  max-width: 760px;
  width: 100%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title-group h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
}

.modal-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.modal-content {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.doc-section h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

.doc-section p {
  color: var(--text-muted);
  line-height: 1.6;
}

.architecture-diagram {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.arch-box {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 150px;
}

.arch-tag {
  font-size: 9px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--accent);
}

.arch-box strong {
  font-size: 12px;
}

.arch-box small {
  font-size: 10px;
  color: var(--text-muted);
}

.arch-arrow {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-align: center;
}

.feature-checklist {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feature-checklist li {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.feature-checklist strong {
  color: var(--text-main);
}

.viva-qa {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.qa-item {
  background: var(--bg-surface);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.qa-item strong {
  display: block;
  font-size: 13px;
  color: var(--text-main);
  margin-bottom: 4px;
}

.qa-item p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  background: var(--bg-surface);
}

/* Telegram Bot Integration Styles */
.status-dot-mini {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  margin-left: 4px;
}

.status-dot-mini.online {
  background-color: var(--success);
  box-shadow: 0 0 6px var(--success);
}

.status-dot-mini.offline {
  background-color: var(--text-dim);
}

.telegram-status-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  gap: 14px;
  align-items: center;
}

.tg-status-icon-wrapper {
  width: 44px;
  height: 44px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  flex-shrink: 0;
}

.tg-status-icon-wrapper.connected {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--success);
}

.tg-status-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.tg-status-info h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.tg-status-info p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.setup-steps-list {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.setup-steps-list li strong {
  color: var(--accent);
}

.setup-steps-list code {
  font-family: var(--font-code);
  background: var(--bg-surface);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 12px;
}

.telegram-origin-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(0, 136, 204, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 2px 6px;
  border-radius: var(--radius-full);
  margin-bottom: 4px;
}

/* Telegram Authorization & Access Control Box */
.tg-auth-management-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 10px;
}

.auth-box-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
}

.auth-box-title h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.badge-role {
  font-size: 11px;
  font-weight: 700;
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.auth-owner-config {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

/* Pending Requests Card */
.pending-requests-card {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pending-header {
  font-size: 12px;
  font-weight: 700;
  color: #fbbf24;
}

.pending-list-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 140px;
  overflow-y: auto;
}

.pending-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12px;
}

.pending-item-info {
  display: flex;
  gap: 8px;
  align-items: center;
}

.pending-actions {
  display: flex;
  gap: 6px;
}

/* Manual Auth Bar */
.manual-auth-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

.manual-auth-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.manual-auth-inputs {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Authorized Users List */
.auth-users-table-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.table-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.btn-text-sm {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
}

.btn-text-sm:hover {
  text-decoration: underline;
}

.auth-users-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}

.auth-user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
}

.auth-user-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quota-pill {
  font-family: var(--font-code);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.quota-pill.unlimited {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
  border-color: rgba(59, 130, 246, 0.3);
}

.quota-pill.exhausted {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

/* Responsive Media Queries */
@media (max-width: 900px) {
  .config-sidebar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .config-sidebar.open {
    transform: translateX(0);
  }

  .mobile-only {
    display: inline-flex;
  }

  .feature-steps {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   ADMIN AUTHENTICATION & SECURE LOGIN GATEWAY STYLES
   ============================================================ */

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: radial-gradient(circle at 50% 25%, rgba(37, 99, 235, 0.2) 0%, rgba(10, 14, 23, 0.96) 80%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.25s ease-out;
}

body.light-theme .login-overlay {
  background: radial-gradient(circle at 50% 25%, rgba(37, 99, 235, 0.12) 0%, rgba(245, 247, 250, 0.96) 80%);
}

.login-card {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.05);
  max-width: 420px;
  width: 100%;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
  animation: loginScaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes loginScaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.login-card-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.login-brand-icon {
  width: 58px;
  height: 58px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.4);
  margin-bottom: 6px;
}

.login-card-header h2 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-main);
}

.login-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.login-badge-lock {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(37, 99, 235, 0.1);
  border: 1px solid rgba(37, 99, 235, 0.25);
  color: var(--accent);
  padding: 8px 14px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon .field-icon {
  position: absolute;
  left: 12px;
  color: var(--text-dim);
  pointer-events: none;
}

.input-with-icon .form-input {
  padding-left: 38px;
}

.login-error {
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  color: #fca5a5;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.login-error.success-style {
  background: var(--success-bg);
  border: 1px solid var(--success);
  color: #86efac;
}

.btn-block {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  height: 42px;
  font-size: 14px;
  font-weight: 600;
}

.login-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}

.login-hint code {
  font-family: var(--font-code);
  background: var(--bg-surface);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

/* User Profile & Dropdown in App Header */
.user-profile-menu {
  position: relative;
}

.user-badge-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  border-color: var(--border-subtle);
}

.user-avatar-mini {
  font-size: 13px;
  line-height: 1;
}

.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 210px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 1000;
  animation: fadeIn 0.15s ease-out;
}

.dropdown-header {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dropdown-role {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  font-weight: 700;
}

.dropdown-header strong {
  font-size: 13px;
  color: var(--text-main);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-main);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast);
  text-align: left;
  width: 100%;
}

.dropdown-item:hover {
  background: var(--bg-surface-elevated);
}

.dropdown-logout {
  color: var(--danger);
  border-top: 1px solid var(--border-subtle);
  margin-top: 2px;
  padding-top: 8px;
}

.dropdown-logout:hover {
  background: var(--danger-bg);
}


/* ==========================================
   MULTI-API TABS STRIP
   ========================================== */
.api-tabs-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
  scrollbar-width: thin;
}

.api-tabs-scroll {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  overflow-x: auto;
  padding-bottom: 2px;
}

.api-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
  user-select: none;
}

.api-tab-btn:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  border-color: var(--border-focus);
}

.api-tab-btn.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.16), rgba(99, 102, 241, 0.16));
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.25);
}

.api-tab-btn .tab-icon {
  font-size: 15px;
  line-height: 1;
}

.api-tab-btn .tab-badge {
  font-size: 10px;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-surface-elevated);
  color: var(--text-dim);
}

.api-tab-btn.active .tab-badge {
  background: var(--accent);
  color: #fff;
}

.api-tab-btn .tab-del-btn {
  padding: 2px 4px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  border-radius: 3px;
  cursor: pointer;
  margin-left: 2px;
  display: inline-flex;
  align-items: center;
}

.api-tab-btn .tab-del-btn:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.btn-add-api {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--accent);
  background: rgba(59, 130, 246, 0.06);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.btn-add-api:hover {
  background: var(--accent);
  color: #fff;
  border-style: solid;
}

/* Vehicle card styling in chat responses */
.vehicle-info-card {
  margin: 12px 0;
  padding: 16px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  border-left: 4px solid #10b981;
}

.vehicle-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-main);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.vehicle-reg-tag {
  font-family: var(--font-code);
  background: #10b981;
  color: #000;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 800;
  letter-spacing: 1px;
}

.vehicle-props-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 14px;
}

.v-prop-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.v-prop-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  font-weight: 600;
}

.v-prop-value {
  font-size: 13px;
  color: var(--text-main);
  font-weight: 600;
}
