/* ============================================
   TOOLSLAB — COMPONENT PRIMITIVES
   Reusable building blocks used across sidebar,
   chat, sheets, and settings.
   ============================================ */

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--sp-2);
  height: 44px;
  padding: 0 var(--sp-5);
  border-radius: var(--r-md);
  font-size: var(--fs-base);
  font-weight: 500;
  transition: transform var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-text-on);
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--sh-sm); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-surface-2); color: var(--text-primary); }

.btn-icon {
  width: 40px; height: 40px; padding: 0;
  border-radius: var(--r-full);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn-icon:hover { background: var(--bg-surface-2); color: var(--text-primary); }
.btn-icon:active { transform: scale(0.92); }
.btn-icon svg { width: 20px; height: 20px; }

/* primary circular action (send button) */
.btn-send {
  width: 36px; height: 36px;
  border-radius: var(--r-full);
  background: var(--bg-surface-3);
  color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn-send.is-ready {
  background: var(--accent);
  color: var(--accent-text-on);
}
.btn-send:active { transform: scale(0.90); }
.btn-send svg { width: 18px; height: 18px; }

/* ---------- CHIPS (tool selector, tags) ---------- */
.chip {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  height: 34px;
  padding: 0 var(--sp-4) 0 var(--sp-3);
  border-radius: var(--r-full);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-primary);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
  white-space: nowrap;
}
.chip:hover { background: var(--bg-surface-3); border-color: var(--border-med); }
.chip .chip-icon { width: 16px; height: 16px; color: var(--accent); flex-shrink: 0; }
.chip .chip-chevron { width: 14px; height: 14px; color: var(--text-muted); }
.chip.chip-sm { height: 30px; font-size: var(--fs-xs); padding: 0 var(--sp-3) 0 var(--sp-2); }
.chip.chip-xs { height: 26px; font-size: 11px; padding: 0 var(--sp-2); }

/* ---------- TOGGLE SWITCH ---------- */
.toggle {
  width: 44px; height: 26px;
  border-radius: var(--r-full);
  background: var(--bg-surface-3);
  position: relative;
  flex-shrink: 0;
  transition: background var(--dur-base) var(--ease);
}
.toggle::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: transform var(--dur-base) var(--ease), background var(--dur-base) var(--ease);
}
.toggle.is-on { background: var(--accent); }
.toggle.is-on::after {
  transform: translateX(18px);
  background: var(--text-inverse);
}

/* ---------- LIST ROW (settings, sheet options) ---------- */
.list-row {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; text-align: left;
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.list-row:hover { background: var(--bg-surface-2); }
.list-row:active { background: var(--bg-surface-2); transform: scale(0.98); }
.list-row-icon {
  width: 36px; height: 36px;
  border-radius: var(--r-full);
  background: var(--bg-surface-3);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.list-row-icon svg { width: 18px; height: 18px; }
.list-row-body { flex: 1; min-width: 0; }
.list-row-title { font-size: var(--fs-base); font-weight: 500; color: var(--text-primary); }
.list-row-subtitle { font-size: var(--fs-xs); color: var(--text-muted); margin-top: var(--sp-1); }
.list-row-subtitle-pro { font-size: 11px; color: var(--text-primary); opacity: 0.85; font-weight: 600; margin-top: 2px; }
.model-tag-inline { font-size: 10px; opacity: 0.5; font-weight: 400; margin-left: 6px; }
.list-row-trail { display: flex; align-items: center; gap: var(--sp-2); color: var(--text-muted); font-size: var(--fs-sm); flex-shrink: 0; }
.list-row-chevron { width: 16px; height: 16px; color: var(--text-muted); }
.list-row.is-disabled { opacity: 0.5; cursor: not-allowed; }
.pill-soon { background: var(--warning); color: var(--bg-app); border-radius: var(--r-full); font-size: 10px; font-weight: 700; padding: 2px 6px; letter-spacing: 0.5px; margin-left: auto; }
.pill-muted { background: var(--bg-surface-3); color: var(--text-muted); border-radius: var(--r-full); font-size: 10px; font-weight: 600; padding: 2px 6px; letter-spacing: 0.5px; }

/* ---------- CARD ---------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
}

/* ---------- SECTION LABEL ---------- */
.section-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 var(--sp-2);
  margin-bottom: var(--sp-2);
}

.sheet-group-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--bg-surface-2);
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 12px;
  border-radius: var(--r-full);
  margin-top: var(--sp-4);
  margin-bottom: var(--sp-2);
  margin-left: var(--sp-3); /* align with row padding */
}

/* ---------- SKELETON LOADER ---------- */
.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--bg-surface-2) 25%, var(--bg-surface-3) 37%, var(--bg-surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ---------- TYPING DOTS ---------- */
.typing-dots { display: inline-flex; gap: 4px; align-items: center; padding: var(--sp-2) 0; }
.typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-muted);
  animation: dotPulse 1.2s ease infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dotPulse {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ---------- SCALE-IN (modals, sheets content) ---------- */
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ---------- PULL TO REFRESH ---------- */
.ptr-indicator {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-20px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.ptr-indicator.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.ptr-indicator.is-refreshing .ptr-spinner {
  animation: rotate 2s linear infinite;
}
.ptr-indicator.is-refreshing .ptr-spinner .path {
  stroke: var(--accent);
  stroke-dasharray: 1, 200;
  stroke-dashoffset: 0;
  animation: dash 1.5s ease-in-out infinite;
}
.ptr-spinner {
  width: 32px;
  height: 32px;
  background: var(--bg-surface-2);
  border-radius: 50%;
  padding: 6px;
  box-shadow: var(--sh-md);
  border: 1px solid var(--border-subtle);
}
.ptr-spinner .path {
  stroke: var(--text-muted);
  stroke-linecap: round;
  transition: stroke 0.3s ease;
}
@keyframes rotate {
  100% { transform: rotate(360deg); }
}
@keyframes dash {
  0% { stroke-dasharray: 1, 200; stroke-dashoffset: 0; }
  50% { stroke-dasharray: 89, 200; stroke-dashoffset: -35px; }
  100% { stroke-dasharray: 89, 200; stroke-dashoffset: -124px; }
}

/* =========================================
   SCROLL TO BOTTOM BUTTON
   ========================================= */
.scroll-bottom-btn {
  position: absolute;
  bottom: 80px; /* Right above the input zone */
  right: 20px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-elevated, #fff);
  border: 1px solid var(--border, #e5e5e5);
  color: var(--text-main, #333);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.scroll-bottom-btn.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.scroll-bottom-btn:hover {
  background: var(--bg-hover, #f5f5f5);
}
.scroll-bottom-btn svg {
  width: 20px;
  height: 20px;
}

/* AI Status Indicator Glow */
.ai-status-glow {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #10b981; /* Green connected color */
  box-shadow: 0 0 4px #10b981, 0 0 6px #10b981;
  animation: pulse-glow 2s infinite alternate;
  margin-right: 4px;
  vertical-align: middle;
}

@keyframes pulse-glow {
  0% {
    transform: scale(0.9);
    box-shadow: 0 0 4px #10b981, 0 0 8px #10b981;
    opacity: 0.8;
  }
  100% {
    transform: scale(1.1);
    box-shadow: 0 0 12px #10b981, 0 0 20px #10b981;
    opacity: 1;
  }
}
