/* ═══════════════════════════════════════════════════
   KAPISH WEB — Components
   ═══════════════════════════════════════════════════ */

/* ── Page header ─────────────────────────────────── */
.page-header {
  margin-bottom: var(--space-6);
}
.page-header-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--space-4); flex-wrap: wrap;
}
.page-title {
  font-family: var(--font-display);
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 800; color: var(--text);
  letter-spacing: -.02em;
}
.page-subtitle { font-size: 13px; color: var(--text-3); margin-top: 4px; }
.page-actions { display: flex; gap: var(--space-2); flex-shrink: 0; flex-wrap: wrap; }

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2);
  padding: 9px var(--space-4);
  border-radius: var(--radius-md);
  font-size: 13px; font-weight: 700;
  transition: var(--transition);
  white-space: nowrap; cursor: pointer;
}
.btn-primary {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 4px 16px rgba(138,100,255,.3);
}
.btn-primary:hover { opacity: .88; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(138,100,255,.4); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border-2);
}
.btn-secondary:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-3); }

.btn-ghost {
  color: var(--text-3);
  padding: 9px var(--space-3);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text-2); }

.btn-danger {
  background: rgba(239,68,68,.12);
  color: #ef4444;
  border: 1px solid rgba(239,68,68,.25);
}
.btn-danger:hover { background: rgba(239,68,68,.2); }

.btn-sm { padding: 6px var(--space-3); font-size: 12px; }
.btn-lg { padding: 12px var(--space-6); font-size: 15px; }
.btn-icon { padding: 8px; border-radius: var(--radius-md); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none !important; }

/* ── Cards ───────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  transition: var(--transition);
}
.card-hover:hover {
  border-color: var(--border-3);
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-4);
  gap: var(--space-3);
}
.card-title {
  font-family: var(--font-display);
  font-size: 15px; font-weight: 800; color: var(--text);
}
.card-subtitle { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ── Stat cards ──────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-4);
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  position: relative; overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 2px;
  background: var(--grad);
  opacity: 0; transition: opacity .2s;
}
.stat-card:hover::after { opacity: 1; }
.stat-label {
  font-size: 10px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-3);
  margin-bottom: var(--space-2);
  display: flex; align-items: center; gap: var(--space-1);
}
.stat-value {
  font-family: var(--font-display);
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 800; color: var(--text);
  letter-spacing: -.02em;
}
.stat-delta {
  font-size: 11px; color: var(--text-3);
  margin-top: 4px;
}
.stat-delta.up   { color: var(--green); }
.stat-delta.down { color: var(--red);   }

/* ── Form inputs ─────────────────────────────────── */
.form-group { margin-bottom: var(--space-4); }
.form-label {
  display: block;
  font-size: 12px; font-weight: 700; color: var(--text-2);
  letter-spacing: .04em; text-transform: uppercase;
  margin-bottom: var(--space-2);
}
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1.5px solid var(--border-2);
  border-radius: var(--radius-md);
  padding: 10px var(--space-3);
  font-size: 14px; color: var(--text);
  transition: var(--transition);
  outline: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(138,100,255,.15);
  background: var(--surface-3);
}
.form-input::placeholder { color: var(--text-4); }
.form-textarea { min-height: 100px; resize: vertical; }
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238a64ff' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.form-hint { font-size: 11px; color: var(--text-3); margin-top: var(--space-1); }
.form-error { font-size: 11px; color: var(--red); margin-top: var(--space-1); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

/* ── Upload zone ─────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border-2);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-6);
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--surface-2);
}
.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--violet);
  background: rgba(138,100,255,.06);
}
.upload-icon { font-size: 32px; margin-bottom: var(--space-3); }
.upload-title { font-size: 14px; font-weight: 700; color: var(--text-2); margin-bottom: var(--space-1); }
.upload-hint { font-size: 12px; color: var(--text-3); }

/* ── Table ───────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead { background: var(--surface-2); }
thead th {
  padding: 10px var(--space-4);
  text-align: left;
  font-size: 10px; font-weight: 800;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-3);
  white-space: nowrap;
}
tbody tr {
  border-top: 1px solid var(--border);
  transition: background .12s;
}
tbody tr:hover { background: var(--surface-2); }
tbody td {
  padding: 12px var(--space-4);
  font-size: 13px; color: var(--text-2);
}
.td-bold { font-weight: 700; color: var(--text); }
.td-mono { font-family: var(--font-mono); font-size: 12px; }

/* ── Badges ──────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 8px; border-radius: 20px;
  font-size: 10px; font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase;
}
.badge-violet  { background: rgba(138,100,255,.15); color: var(--violet); }
.badge-green   { background: rgba(34,197,94,.12);   color: var(--green);  }
.badge-red     { background: rgba(239,68,68,.12);   color: var(--red);    }
.badge-amber   { background: rgba(245,158,11,.12);  color: var(--amber);  }
.badge-cyan    { background: rgba(6,182,212,.12);   color: var(--cyan);   }
.badge-muted   { background: var(--surface-2); color: var(--text-3); }

/* ── Modal ───────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-4);
  opacity: 0; transition: opacity .2s;
  pointer-events: none;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-box {
  background: var(--card);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-2xl);
  width: 100%; max-width: 520px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  transform: scale(.95) translateY(10px);
  transition: transform .25s cubic-bezier(.25,.8,.25,1), opacity .2s;
  opacity: 0;
}
.modal-overlay.open .modal-box { transform: scale(1) translateY(0); opacity: 1; }
.modal-box--sm { max-width: 380px; }
.modal-box--lg { max-width: 700px; }
.modal-box--xl { max-width: 900px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-family: var(--font-display); font-size: 17px; font-weight: 800; }
.modal-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); font-size: 14px;
  color: var(--text-3); transition: var(--transition);
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: var(--space-5); overflow-y: auto; flex: 1; }
.modal-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: var(--space-2);
  flex-shrink: 0;
  background: var(--card);
}

/* ── Tabs ────────────────────────────────────────── */
.tabs {
  display: flex; gap: 2px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 3px;
  overflow-x: auto;
}
.tab {
  padding: 7px var(--space-4);
  border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 700;
  color: var(--text-3); cursor: pointer;
  white-space: nowrap; transition: var(--transition);
}
.tab.active {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.tab:hover:not(.active) { color: var(--text-2); }

/* ── Empty state ─────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--text-3);
}
.empty-icon { font-size: 40px; margin-bottom: var(--space-4); opacity: .6; }
.empty-title { font-size: 15px; font-weight: 700; color: var(--text-2); margin-bottom: var(--space-2); }
.empty-desc  { font-size: 13px; }

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

/* ── Toast ───────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  padding: 10px var(--space-4);
  font-size: 13px; font-weight: 600;
  color: var(--text);
  box-shadow: var(--shadow-lg);
  min-width: 200px; max-width: 320px;
  pointer-events: all;
  animation: toastIn .25s cubic-bezier(.25,.8,.25,1) forwards;
}
.toast.success { border-color: rgba(34,197,94,.3); }
.toast.error   { border-color: rgba(239,68,68,.3); }
.toast.removing { animation: toastOut .2s forwards; }
@keyframes toastIn  { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform: translateX(0); } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; transform: translateX(20px); } }

/* ── Divider ─────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: var(--space-4) 0; }
.divider-label {
  display: flex; align-items: center; gap: var(--space-3);
  color: var(--text-3); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
}
.divider-label::before, .divider-label::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Search bar ──────────────────────────────────── */
.search-bar {
  position: relative; flex: 1; min-width: 200px;
}
.search-bar-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  font-size: 14px; color: var(--text-3); pointer-events: none;
}
.search-bar input {
  width: 100%;
  background: var(--surface-2);
  border: 1.5px solid var(--border-2);
  border-radius: var(--radius-md);
  padding: 9px 12px 9px 36px;
  font-size: 13px; color: var(--text);
  outline: none; transition: var(--transition);
}
.search-bar input:focus { border-color: var(--violet); background: var(--surface-3); }
.search-bar input::placeholder { color: var(--text-4); }

/* ── Skeleton loader ─────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-md);
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── AI Brain chat bubble ────────────────────────── */
.brain-bubble {
  background: var(--grad-subtle);
  border: 1px solid var(--border-3);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  font-size: 13px; line-height: 1.7;
  color: var(--text-2);
  white-space: pre-wrap;
}
.brain-bubble.user {
  background: var(--surface-2);
  border-color: var(--border);
  margin-left: var(--space-10);
}

/* ── Responsive grid helpers ─────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════
   BizSwitcher Component
   ═══════════════════════════════════════════════════ */

.biz-switcher {
  position: relative;
}

.biz-switcher__pill {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 9px var(--space-3);
  background: var(--surface-2);
  border: 1.5px solid var(--border-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}
.biz-switcher__pill:hover { border-color: var(--border-3); }

.biz-switcher__avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.biz-switcher__info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.biz-switcher__name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.biz-switcher__type {
  font-size: 10px;
  color: var(--text-3);
}
.biz-switcher__chevron {
  font-size: 9px;
  color: var(--text-3);
  flex-shrink: 0;
  transition: transform var(--transition);
}
.biz-switcher__pill[aria-expanded="true"] .biz-switcher__chevron {
  transform: rotate(180deg);
}

/* Dropdown */
.biz-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 500;
  overflow: hidden;
  animation: dropDown .18s ease;
  min-width: 200px;
}
@keyframes dropDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.biz-dropdown__item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 10px 14px;
  background: none;
  border: none;
  cursor: pointer;
  transition: background .1s;
  text-align: left;
}
.biz-dropdown__item:hover { background: var(--surface-2); }
.biz-dropdown__item--active { background: rgba(138,100,255,.1); }

.biz-dropdown__item-icon {
  font-size: 16px;
  flex-shrink: 0;
}
.biz-dropdown__item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.biz-dropdown__item-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.biz-dropdown__item-type {
  font-size: 10px;
  color: var(--text-3);
}
.biz-dropdown__check {
  margin-left: auto;
  color: var(--green);
  font-weight: 800;
  font-size: 12px;
  flex-shrink: 0;
}

.biz-dropdown__divider {
  height: 1px;
  background: var(--border);
  margin: 2px 0;
}

.biz-dropdown__add {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 10px 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--green);
  transition: background .1s;
}
.biz-dropdown__add:hover { background: rgba(34,197,94,.06); }
.biz-dropdown__add-icon {
  font-size: 16px;
  font-weight: 800;
}

/* ═══════════════════════════════════════════════════
   Auth page utility classes (replaces inline styles)
   ═══════════════════════════════════════════════════ */

.btn-full    { width: 100%; }
.btn-mt      { margin-top: var(--space-2); }

.spinner-sm  { width: 14px; height: 14px; border-width: 2px; }
.spinner-lg  { width: 36px; height: 36px; border-width: 3px; }

.auth-loading-state {
  text-align: center;
  padding: var(--space-10) 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}
.auth-loading-text {
  font-size: 14px;
  color: var(--text-3);
}

.resend-timer {
  font-size: 12px;
  color: var(--text-3);
  margin-left: var(--space-1);
}

.empty-state--error .empty-icon { color: var(--amber); }
