/* =============================================================
   Components — buttons, cards, forms, tables, tabs, modals, toasts
   ============================================================= */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: var(--r-sm);
  font-size: var(--fs-base); font-weight: 600; white-space: nowrap;
  transition: transform var(--t-fast), box-shadow var(--t), background var(--t), border-color var(--t), color var(--t);
  border: 1px solid transparent;
}
.btn svg { width: 17px; height: 17px; }
.btn:active { transform: translateY(1px); }

.btn-gold { background: var(--grad-gold); color: var(--on-gold); box-shadow: 0 2px 8px rgba(201,135,10,.25); }
.btn-gold:hover { box-shadow: var(--sh-gold); transform: translateY(-1px); }

.btn-espresso { background: var(--grad-espresso); color: var(--text-on-dark); }
.btn-espresso:hover { box-shadow: var(--sh-md); transform: translateY(-1px); }

.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold-deep); background: var(--gold-tint); }

.btn-soft { background: var(--gold-tint); color: var(--gold-deep); }
.btn-soft:hover { background: var(--gold-tint-2); }

.btn-danger { background: var(--surface); border-color: var(--line); color: var(--red); }
.btn-danger:hover { background: var(--red-tint); border-color: var(--red); }

.btn-sm { height: 32px; padding: 0 12px; font-size: var(--fs-sm); }
.btn-sm svg { width: 15px; height: 15px; }
.btn-lg { height: 46px; padding: 0 24px; font-size: var(--fs-md); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; pointer-events: none; }

/* icon-only round button */
.icon-btn {
  width: 38px; height: 38px; border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-2); background: transparent; border: 1px solid transparent;
  transition: var(--t); position: relative;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { background: var(--gold-tint); color: var(--gold-deep); }
.icon-btn .dot {
  position: absolute; top: 7px; inset-inline-end: 8px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--red); border: 2px solid var(--surface);
}

/* ---------- Card ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--sh-sm);
  transition: box-shadow var(--t), border-color var(--t), transform var(--t);
}
.card-pad { padding: 20px; }
.card-hover:hover { box-shadow: var(--sh-lg); border-color: var(--gold); transform: translateY(-2px); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head h3 { font-size: var(--fs-lg); display: flex; align-items: center; gap: 9px; }
.card-head h3 .si {
  width: 32px; height: 32px; border-radius: var(--r-xs); display: grid; place-items: center;
  background: var(--gold-tint); color: var(--gold-deep); flex-shrink: 0;
}
.card-head h3 .si svg { width: 17px; height: 17px; }
.card-sub { color: var(--text-2); font-size: var(--fs-sm); margin-top: -10px; margin-bottom: 16px; }

/* ---------- Stat card ---------- */
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px; box-shadow: var(--sh-sm); transition: var(--t); position: relative; overflow: hidden; }
.stat:hover { box-shadow: var(--sh-md); border-color: var(--gold); transform: translateY(-2px); }
.stat .si { width: 42px; height: 42px; border-radius: var(--r-sm); display: grid; place-items: center; margin-bottom: 14px; }
.stat .si svg { width: 20px; height: 20px; }
.stat .si.g { background: var(--gold-tint); color: var(--gold-deep); }
.stat .si.green { background: var(--green-tint); color: var(--green); }
.stat .si.ai { background: var(--ai-tint); color: var(--ai); }
.stat .si.blue { background: var(--blue-tint); color: var(--blue); }
.stat .si.red { background: var(--red-tint); color: var(--red); }
.stat .sv { font-size: var(--fs-3xl); font-weight: 800; line-height: 1.05; letter-spacing: -.02em; font-family: var(--font-display); }
[dir="ltr"] .stat .sv { font-family: var(--font-ui); }
.stat .sl { color: var(--text-2); font-size: var(--fs-sm); margin-top: 6px; }
@media (max-width: 560px) {
  .stat { padding: 14px; display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; }
  .stat .si { margin-bottom: 0; width: 38px; height: 38px; grid-row: span 2; }
  .stat .sv { font-size: var(--fs-xl); grid-column: 2; align-self: end; }
  .stat .sl { grid-column: 2; margin-top: 0; align-self: start; font-size: var(--fs-xs); }
  .stat .trend { grid-column: 1 / -1; margin-top: 6px; justify-self: start; }
  .card-pad { padding: 14px; }
}
.stat .trend { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-xs); font-weight: 700; margin-top: 9px; padding: 3px 8px; border-radius: var(--r-pill); }
.stat .trend svg { width: 12px; height: 12px; }
.stat .trend.up { color: var(--green); background: var(--green-tint); }
.stat .trend.down { color: var(--red); background: var(--red-tint); }

/* ---------- Badges / tags ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 700; line-height: 1.5; white-space: nowrap; }
.badge svg { width: 11px; height: 11px; }
.badge.gold { background: var(--gold-tint); color: var(--gold-deep); }
.badge.green { background: var(--green-tint); color: var(--green); }
.badge.blue { background: var(--blue-tint); color: var(--blue); }
.badge.red { background: var(--red-tint); color: var(--red); }
.badge.ai { background: var(--ai-tint); color: var(--ai); }
.badge.amber { background: var(--amber-tint); color: var(--gold-deep); }
.badge.gray { background: var(--bg-2); color: var(--text-2); }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.lang-chip { font-size: var(--fs-xs); font-weight: 700; padding: 2px 7px; border-radius: var(--r-xs); background: var(--bg-2); color: var(--text-2); }

/* ---------- Avatars ---------- */
.av { width: 40px; height: 40px; border-radius: var(--r-sm); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: var(--fs-md); flex-shrink: 0; position: relative; }
.av.sm { width: 32px; height: 32px; font-size: var(--fs-sm); border-radius: var(--r-xs); }
.av.lg { width: 52px; height: 52px; font-size: var(--fs-xl); }
.av .ind { position: absolute; bottom: -1px; inset-inline-end: -1px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--surface); }
.av .ind.on { background: var(--green); }
.av .ind.off { background: var(--text-3); }

/* number source dot */
.num-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.num-dot.main { background: var(--green); }
.num-dot.second { background: var(--blue); }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field > label, .label { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--text); margin-bottom: 7px; }
.label .opt { color: var(--text-3); font-weight: 500; }
.input, .select, .textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 0 13px; height: 42px; color: var(--text);
  font-size: var(--fs-base); transition: border-color var(--t), box-shadow var(--t);
}
.textarea { height: auto; padding: 11px 13px; line-height: 1.7; resize: vertical; min-height: 90px; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--gold); box-shadow: var(--sh-focus); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239A876A' stroke-width='2.2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 13px center; padding-inline-end: 36px; cursor: pointer; }
[dir="ltr"] .select { background-position: right 13px center; padding-inline-end: 36px; }
.input-icon { position: relative; }
.input-icon > [data-icon], .input-icon > svg { position: absolute; inset-inline-start: 13px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-icon > [data-icon] svg, .input-icon > svg { width: 17px; height: 17px; }
.input-icon .input { padding-inline-start: 40px; }
.field-hint { font-size: var(--fs-xs); color: var(--text-2); margin-top: 7px; line-height: 1.6; }

/* searchable contact picker (used in "new conversation" modal) */
.contact-picker { display: flex; flex-direction: column; gap: 8px; }
.contact-list { max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); padding: 4px; }
.contact-opt { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-xs); cursor: pointer; transition: background var(--t-fast); }
.contact-opt:hover { background: var(--gold-tint); }
.contact-opt.sel { background: var(--gold-tint); outline: 2px solid var(--gold); outline-offset: -2px; }
.contact-opt .co-body { flex: 1; min-width: 0; line-height: 1.3; }
.contact-opt .co-body strong { display: block; font-size: var(--fs-sm); font-weight: 600; }
.contact-opt .co-body span { font-size: var(--fs-xs); color: var(--text-2); }

/* search bar */
.search { position: relative; display: flex; align-items: center; }
.search > [data-icon], .search > svg { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; line-height: 0; }
.search > [data-icon] svg, .search > svg { width: 16px; height: 16px; }
.search input { width: 100%; height: 40px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); padding-inline-start: 38px; padding-inline-end: 14px; font-size: var(--fs-sm); transition: var(--t); }
.search input:focus { border-color: var(--gold); box-shadow: var(--sh-focus); }

/* switch */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--line-2); border-radius: var(--r-pill); transition: var(--t); }
.switch .track::before { content: ""; position: absolute; height: 18px; width: 18px; inset-inline-start: 3px; top: 3px; background: #fff; border-radius: 50%; transition: var(--t); box-shadow: var(--sh-xs); }
.switch input:checked + .track { background: var(--gold); }
.switch input:checked + .track::before { transform: translateX(calc(18px * var(--dir, 1))); }

/* toggle row */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.toggle-row:last-child { border-bottom: none; }
.toggle-row .tr-txt strong { font-size: var(--fs-base); font-weight: 600; display: block; }
.toggle-row .tr-txt span { font-size: var(--fs-sm); color: var(--text-2); }

/* radio / choice cards */
.choice { display: flex; align-items: center; gap: 11px; padding: 13px 15px; border: 1px solid var(--line); border-radius: var(--r-sm); cursor: pointer; transition: var(--t); margin-bottom: 9px; }
.choice:hover { border-color: var(--gold); background: var(--gold-tint); }
.choice input { accent-color: var(--gold); width: 17px; height: 17px; }
.choice.sel { border-color: var(--gold); background: var(--gold-tint); }
.choice .ch-txt strong { display: block; font-size: var(--fs-base); }
.choice .ch-txt span { font-size: var(--fs-sm); color: var(--text-2); }

/* segmented control */
.segment { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.segment button { padding: 6px 14px; border-radius: var(--r-xs); font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); transition: var(--t); white-space: nowrap; }
.segment button.active { background: var(--surface); color: var(--gold-deep); box-shadow: var(--sh-xs); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { padding: 11px 16px; font-size: var(--fs-base); font-weight: 600; color: var(--text-2); position: relative; white-space: nowrap; transition: color var(--t); }
.tabs button::after { content: ""; position: absolute; inset-inline: 12px; bottom: -1px; height: 2.5px; background: var(--gold); border-radius: 2px; transform: scaleX(0); transition: transform var(--t); }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--gold-deep); }
.tabs button.active::after { transform: scaleX(1); }

/* pill filter tabs */
.pills { display: flex; gap: 7px; flex-wrap: wrap; }
.pills button { padding: 6px 13px; border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); background: var(--bg-2); border: 1px solid transparent; transition: var(--t); }
.pills button:hover { color: var(--text); border-color: var(--line); }
.pills button.active { background: var(--gold-tint); color: var(--gold-deep); border-color: var(--gold); }
.pills button .cnt { font-size: var(--fs-xs); opacity: .7; margin-inline-start: 3px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th { text-align: start; font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); padding: 11px 14px; background: var(--bg-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tbl th:first-child { border-start-start-radius: var(--r-sm); }
table.tbl th:last-child { border-start-end-radius: var(--r-sm); }
table.tbl td { padding: 13px 14px; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); vertical-align: middle; }
table.tbl tbody tr { transition: background var(--t-fast); }
table.tbl tbody tr:hover { background: var(--gold-tint); }
table.tbl tbody tr:last-child td { border-bottom: none; }
.cell-main { display: flex; align-items: center; gap: 11px; }
.cell-main .cm-txt strong { font-weight: 600; display: block; }
.cell-main .cm-txt span { color: var(--text-2); font-size: var(--fs-xs); }

/* row action menu */
.row-act { position: relative; }
.row-act-btn { width: 30px; height: 30px; border-radius: var(--r-xs); display: grid; place-items: center; color: var(--text-3); transition: var(--t); }
.row-act-btn:hover { background: var(--bg-2); color: var(--text); }
.row-act-btn svg { width: 16px; height: 16px; }

/* ---------- Dropdown menu ---------- */
.menu { position: absolute; inset-inline-end: 0; top: calc(100% + 8px); min-width: 210px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--sh-lg); padding: 7px; z-index: var(--z-dropdown); animation: pop var(--t-fast) both; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 11px; border-radius: var(--r-xs); font-size: var(--fs-sm); color: var(--text); transition: var(--t-fast); text-align: start; }
.menu-item svg { width: 17px; height: 17px; color: var(--text-3); flex-shrink: 0; }
.menu-item:hover { background: var(--gold-tint); }
.menu-item.danger { color: var(--red); } .menu-item.danger svg { color: var(--red); }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menu-label { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); padding: 8px 11px 4px; }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(30, 19, 8, .5); backdrop-filter: blur(3px); z-index: var(--z-modal); display: grid; place-items: center; padding: 20px; animation: fadeIn var(--t-fast) both; }
.modal { width: 100%; max-width: 480px; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-lg); max-height: 90vh; overflow-y: auto; animation: slideUp var(--t) both; }
.modal.wide { max-width: 620px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 22px 0; }
.modal-head h3 { font-size: var(--fs-xl); font-family: var(--font-display); }
[dir="ltr"] .modal-head h3 { font-family: var(--font-latin-display); }
.modal-head p { color: var(--text-2); font-size: var(--fs-sm); margin-top: 4px; }
.modal-head .x { width: 34px; height: 34px; border-radius: var(--r-xs); display: grid; place-items: center; color: var(--text-3); flex-shrink: 0; transition: var(--t); }
.modal-head .x:hover { background: var(--bg-2); color: var(--text); }
.modal-head .x svg { width: 18px; height: 18px; }
.modal-body { padding: 18px 22px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 0 22px 22px; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; bottom: 22px; inset-inline-end: 22px; z-index: var(--z-toast); display: flex; flex-direction: column; gap: 10px; }
.toast { display: flex; align-items: center; gap: 11px; background: var(--surface); border: 1px solid var(--line); border-inline-start: 3px solid var(--green); border-radius: var(--r-sm); box-shadow: var(--sh-lg); padding: 13px 17px; font-size: var(--fs-sm); font-weight: 600; min-width: 240px; animation: slideUp var(--t) both; }
.toast svg { width: 18px; height: 18px; color: var(--green); flex-shrink: 0; }
.toast.info { border-inline-start-color: var(--gold); } .toast.info svg { color: var(--gold); }
.toast.ai { border-inline-start-color: var(--ai); } .toast.ai svg { color: var(--ai); }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--text-2); }
.empty .ec { width: 64px; height: 64px; border-radius: 50%; background: var(--gold-tint); color: var(--gold-deep); display: grid; place-items: center; margin: 0 auto 16px; }
.empty .ec svg { width: 28px; height: 28px; }
.empty h4 { font-size: var(--fs-lg); color: var(--text); margin-bottom: 5px; }

/* progress */
.bar { height: 7px; background: var(--bg-2); border-radius: var(--r-pill); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--grad-gold); border-radius: var(--r-pill); transition: width var(--t-slow); }

/* divider */
.hr { height: 1px; background: var(--line); border: none; margin: 16px 0; }
