/* JaxoVoice shared components */

/* ======================== BUTTONS ======================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  font-size: var(--fs-14);
  font-weight: var(--fw-medium);
  line-height: 1;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn .icon { width: 16px; height: 16px; flex: 0 0 16px; }

.btn-sm { height: 30px; padding: 0 10px; font-size: var(--fs-13); }
.btn-lg { height: 44px; padding: 0 20px; font-size: var(--fs-15); }
.btn-xl { height: 52px; padding: 0 26px; font-size: var(--fs-16); border-radius: var(--r-lg); }

.btn-primary { background: var(--primary); color: var(--text-invert); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

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

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

.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary-soft); }

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

.btn-danger { background: var(--red-600); color: white; border-color: var(--red-600); }
.btn-danger:hover { background: var(--red-700); border-color: var(--red-700); }

.btn-icon { width: 32px; height: 32px; padding: 0; }

/* ======================== INPUTS ======================== */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: var(--fs-13); font-weight: var(--fw-medium); color: var(--text); }
.field-hint { font-size: var(--fs-12); color: var(--text-subtle); }
.field-error { font-size: var(--fs-12); color: var(--red-600); }

.input, .textarea, .select {
  width: 100%;
  padding: 8px 12px;
  font-size: var(--fs-14);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color 120ms ease, box-shadow 120ms ease;
  font-family: inherit;
}
.input { height: 36px; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: var(--shadow-focus); }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.textarea { resize: vertical; min-height: 80px; line-height: var(--lh-base); }
.input.mono, .textarea.mono { font-family: var(--font-mono); font-size: var(--fs-13); }
.select {
  height: 36px;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.input-group { position: relative; }
.input-group .input { padding-left: 34px; }
.input-group .input-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-faint); pointer-events: none; }

/* Switch */
.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex: 0 0 36px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--slate-300); border-radius: 999px; transition: background 150ms ease; cursor: pointer; }
.switch .thumb { position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; background: white; border-radius: 50%; transition: transform 150ms ease; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track .thumb { transform: translateX(16px); }
[data-theme="dark"] .switch .track { background: var(--slate-700); }

/* Checkbox */
.checkbox { width: 16px; height: 16px; appearance: none; border: 1.5px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: all 120ms ease; flex: 0 0 16px; }
.checkbox:checked { background: var(--accent); border-color: var(--accent); }
.checkbox:checked::after { content: ''; width: 10px; height: 10px; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'/></svg>"); background-size: contain; background-repeat: no-repeat; }

/* Radio */
.radio { width: 16px; height: 16px; appearance: none; border: 1.5px solid var(--border-strong); border-radius: 50%; background: var(--surface); cursor: pointer; transition: all 120ms ease; flex: 0 0 16px; }
.radio:checked { border-color: var(--accent); border-width: 5px; }

/* ======================== BADGES & CHIPS ======================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
  border-radius: var(--r-full);
  background: var(--bg-subtle);
  color: var(--text-muted);
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--green-50); color: var(--green-700); }
.badge-danger  { background: var(--red-50);   color: var(--red-700); }
.badge-warn    { background: var(--amber-50); color: var(--amber-700); }
.badge-info    { background: var(--cyan-50);  color: var(--cyan-700); }
.badge-primary { background: var(--navy-50);  color: var(--navy-700); }
.badge-neutral { background: var(--slate-100);color: var(--slate-700); }

[data-theme="dark"] .badge-success { background: rgba(34,197,94,0.12); color: #4ADE80; }
[data-theme="dark"] .badge-danger  { background: rgba(239,68,68,0.12); color: #F87171; }
[data-theme="dark"] .badge-warn    { background: rgba(245,158,11,0.12); color: #FBBF24; }
[data-theme="dark"] .badge-info    { background: rgba(34,211,238,0.15); color: var(--cyan-300); }
[data-theme="dark"] .badge-primary { background: rgba(59,91,255,0.18);  color: #93B4FF; }
[data-theme="dark"] .badge-neutral { background: var(--slate-800);     color: var(--slate-300); }

.badge-pulse .dot { animation: pulse-dot 1.6s ease-in-out infinite; }
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.6); }
  50% { box-shadow: 0 0 0 4px rgba(34, 211, 238, 0); }
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  font-size: var(--fs-13);
  font-weight: var(--fw-medium);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 120ms ease;
}
.chip:hover { background: var(--surface-hover); color: var(--text); }
.chip.active { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.chip-removable { padding-right: 4px; }
.chip-x { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; border-radius: 4px; }
.chip-x:hover { background: var(--bg-subtle); }

/* ======================== CARD ======================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xs);
}
.card-header {
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
}
.card-title { font-size: var(--fs-16); font-weight: var(--fw-semi); }
.card-subtitle { font-size: var(--fs-13); color: var(--text-muted); margin-top: 2px; }
.card-body { padding: var(--sp-6); }
.card-footer { padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-3); }

/* ======================== TABLE ======================== */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); overflow: hidden; box-shadow: var(--shadow-xs); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-13); }
.table thead th {
  text-align: left;
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
  color: var(--text-subtle);
  padding: 10px 16px;
  background: var(--bg-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-transform: none;
  letter-spacing: 0.01em;
}
.table thead th.sortable { cursor: pointer; user-select: none; }
.table thead th.sortable:hover { color: var(--text); }
.table thead th .sort-icon { display: inline-block; margin-left: 4px; opacity: 0.4; }
.table thead th.sorted .sort-icon { opacity: 1; color: var(--accent); }
.table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
  vertical-align: middle;
  color: var(--text);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--bg-muted); }
.table tbody tr.selected td { background: var(--cyan-50); }
[data-theme="dark"] .table tbody tr.selected td { background: rgba(34,211,238,0.06); }

.table-toolbar { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; }
.table-toolbar-spacer { flex: 1; }
.table-pagination { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--border); background: var(--surface); font-size: var(--fs-13); color: var(--text-muted); }

.cell-mono { font-family: var(--font-mono); font-size: var(--fs-13); }
.cell-link { color: var(--text); font-weight: var(--fw-medium); }
.cell-link:hover { color: var(--accent); text-decoration: none; }

/* ======================== TABS ======================== */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); }
.tab {
  padding: 10px 14px;
  font-size: var(--fs-14);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* ======================== AVATAR ======================== */
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--navy-100);
  color: var(--navy-700);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-12);
  font-weight: var(--fw-semi);
  flex: 0 0 auto;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-lg { width: 40px; height: 40px; font-size: var(--fs-14); }
.avatar-xl { width: 56px; height: 56px; font-size: var(--fs-18); }

/* ======================== UTILS ======================== */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-5 { gap: 20px; } .gap-6 { gap: 24px; } .gap-8 { gap: 32px; }
.flex-1 { flex: 1; }
.text-muted { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.text-faint  { color: var(--text-faint); }
.text-success{ color: var(--green-600); }
.text-danger { color: var(--red-600); }
.text-warn   { color: var(--amber-600); }
.text-accent { color: var(--accent); }
.text-primary{ color: var(--primary); }
.fs-12 { font-size: var(--fs-12); } .fs-13 { font-size: var(--fs-13); } .fs-14 { font-size: var(--fs-14); } .fs-15 { font-size: var(--fs-15); } .fs-16 { font-size: var(--fs-16); } .fs-18 { font-size: var(--fs-18); } .fs-20 { font-size: var(--fs-20); } .fs-24 { font-size: var(--fs-24); } .fs-28 { font-size: var(--fs-28); } .fs-32 { font-size: var(--fs-32); } .fs-40 { font-size: var(--fs-40); } .fs-48 { font-size: var(--fs-48); }
.fw-medium { font-weight: var(--fw-medium); } .fw-semi { font-weight: var(--fw-semi); } .fw-bold { font-weight: var(--fw-bold); }
.tnum { font-variant-numeric: tabular-nums; }

/* ======================== PROGRESS ======================== */
.progress { height: 6px; background: var(--bg-subtle); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 999px; transition: width 300ms ease; }
.progress-bar-success { background: var(--green-500); }

/* ======================== KEYBOARD ======================== */
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
}

/* ======================== TOOLTIP ======================== */
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--slate-900);
  color: white;
  font-size: var(--fs-12);
  padding: 4px 8px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  pointer-events: none;
  z-index: 100;
}
[data-theme="dark"] [data-tip]:hover::after { background: var(--slate-700); }

/* ======================== ANIMATIONS ======================== */
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fade-in 200ms ease forwards; }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 700ms linear infinite; }

/* ======================== FLAG ======================== */
.flag {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 13px; border-radius: 2px; overflow: hidden;
  font-size: 10px; font-weight: var(--fw-bold);
  background: var(--slate-200); color: var(--slate-700);
  flex: 0 0 auto;
}
