/*
 * TXI Lead Manager — component layer
 * Extends style.css. Uses the same tokens, so light/dark mode is automatic.
 */

/* ── Topbar & global search ─────────────────────────────────────── */
.txi-topbar { display:flex; align-items:center; gap:14px; margin-bottom:22px; padding-right:60px; }

.txi-search-wrap { position:relative; flex:1 1 auto; max-width:520px; display:flex; align-items:center; }
.txi-search-wrap svg { position:absolute; left:14px; color:var(--color-text-muted); pointer-events:none; }
.txi-search-input {
    width:100%; padding:10px 14px 10px 40px; border-radius:50px;
    border:1px solid var(--border-color); background:var(--bg-input);
    color:var(--color-text-main); font-size:13.5px; font-family:inherit;
    transition:all var(--transition-fast);
}
.txi-search-input:focus { outline:none; border-color:var(--color-primary); box-shadow:0 0 0 3px rgba(2,132,199,.13); }

.txi-search-results {
    display:none; position:absolute; top:calc(100% + 8px); left:0; right:0; z-index:900;
    background:var(--bg-card); border:1px solid var(--border-color); border-radius:12px;
    box-shadow:var(--card-shadow); max-height:420px; overflow-y:auto; padding:6px;
}
.txi-search-results.open { display:block; }
.txi-sr-group { font-size:10.5px; text-transform:uppercase; letter-spacing:.08em; font-weight:700;
    color:var(--color-text-muted); padding:10px 12px 6px; }
.txi-sr-item { display:flex; align-items:center; gap:10px; padding:9px 12px; border-radius:8px;
    text-decoration:none; color:var(--color-text-main); font-size:13.5px; }
.txi-sr-item:hover, .txi-sr-item.sel { background:var(--bg-th); }
.txi-sr-item small { color:var(--color-text-muted); font-size:11.5px; margin-left:auto; }

/* ── Mobile burger + sidebar ────────────────────────────────────── */
.txi-burger { display:none; position:fixed; top:20px; left:16px; z-index:9998;
    width:38px; height:38px; border-radius:50%; background:var(--bg-card);
    border:1px solid var(--border-color); color:var(--color-text-main);
    align-items:center; justify-content:center; cursor:pointer; box-shadow:0 2px 10px rgba(0,0,0,.10); }

.txi-nav-count { margin-left:auto; background:var(--error-color); color:#fff; font-size:10.5px;
    font-weight:700; border-radius:20px; padding:1px 7px; min-width:19px; text-align:center; }
.txi-nav-divider { height:1px; background:var(--border-color); margin:10px 6px; }

/* ── Badges ─────────────────────────────────────────────────────── */
.txi-badge { display:inline-block; padding:3px 9px; border-radius:20px; font-size:11px;
    font-weight:600; letter-spacing:.02em; white-space:nowrap; border:1px solid transparent; }
.txi-badge-blue   { background:rgba(59,130,246,.10);  color:#2563eb; border-color:rgba(59,130,246,.22); }
.txi-badge-cyan   { background:rgba(2,132,199,.10);   color:#0284c7; border-color:rgba(2,132,199,.22); }
.txi-badge-green  { background:rgba(16,185,129,.10);  color:#059669; border-color:rgba(16,185,129,.22); }
.txi-badge-amber  { background:rgba(245,158,11,.12);  color:#b45309; border-color:rgba(245,158,11,.25); }
.txi-badge-red    { background:rgba(220,38,38,.09);   color:#dc2626; border-color:rgba(220,38,38,.20); }
.txi-badge-violet { background:rgba(168,85,247,.10);  color:#9333ea; border-color:rgba(168,85,247,.22); }
.txi-badge-slate  { background:rgba(100,116,139,.10); color:#64748b; border-color:rgba(100,116,139,.20); }

body.dark-theme .txi-badge-blue   { color:#93c5fd; }
body.dark-theme .txi-badge-cyan   { color:#7dd3fc; }
body.dark-theme .txi-badge-green  { color:#6ee7b7; }
body.dark-theme .txi-badge-amber  { color:#fcd34d; }
body.dark-theme .txi-badge-red    { color:#fca5a5; }
body.dark-theme .txi-badge-violet { color:#d8b4fe; }
body.dark-theme .txi-badge-slate  { color:#cbd5e1; }

/* ── Avatars ────────────────────────────────────────────────────── */
.txi-avatar { display:inline-flex; align-items:center; justify-content:center;
    width:28px; height:28px; border-radius:50%; background:var(--bg-th);
    color:var(--color-primary); border:1px solid var(--border-color-active);
    font-size:10.5px; font-weight:700; flex-shrink:0; }
.txi-avatar-lg { width:44px; height:44px; font-size:14px; }
.txi-avatar-sm { width:22px; height:22px; font-size:9px; }

.txi-muted { color:var(--color-text-muted); }
.txi-mono  { font-variant-numeric:tabular-nums; }

/* ── Stat cards ─────────────────────────────────────────────────── */
.txi-stats { display:grid; grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); gap:16px; margin-bottom:24px; }
.txi-stat { background:var(--bg-card); border:1px solid var(--border-color); border-radius:14px;
    padding:18px 20px; box-shadow:var(--card-shadow); position:relative; overflow:hidden; }
.txi-stat::after { content:''; position:absolute; inset:0 auto 0 0; width:3px; background:var(--color-primary); opacity:.55; }
.txi-stat-label { font-size:11px; text-transform:uppercase; letter-spacing:.08em;
    font-weight:600; color:var(--color-text-muted); margin-bottom:8px; }
.txi-stat-value { font-family:'Outfit',sans-serif; font-size:26px; font-weight:700; color:var(--color-text-main); line-height:1.1; }
.txi-stat-sub { font-size:11.5px; color:var(--color-text-muted); margin-top:6px; }
.txi-up   { color:#059669; font-weight:600; }
.txi-down { color:#dc2626; font-weight:600; }

/* ── Filter bar ─────────────────────────────────────────────────── */
.txi-filters { display:flex; flex-wrap:wrap; gap:10px; align-items:flex-end; margin-bottom:18px; }
.txi-filters .txi-f { display:flex; flex-direction:column; gap:5px; }
.txi-filters label { margin:0; font-size:10.5px; text-transform:uppercase; letter-spacing:.07em; }
.txi-filters select, .txi-filters input[type="text"], .txi-filters input[type="date"] {
    min-width:150px; padding:8px 12px; border-radius:7px; border:1px solid var(--border-color);
    background:var(--bg-input); color:var(--color-text-main); font-size:13px; font-family:inherit; height:36px; }
.txi-filters .grow { flex:1 1 220px; }
.txi-filters .grow input { width:100%; }

.txi-chip { display:inline-flex; align-items:center; gap:6px; background:var(--bg-th);
    border:1px solid var(--border-color-active); color:var(--color-primary);
    border-radius:20px; padding:3px 10px; font-size:11.5px; font-weight:600; text-decoration:none; }
.txi-chip a { color:inherit; text-decoration:none; opacity:.7; }

/* ── Tables ─────────────────────────────────────────────────────── */
.data-table td a.txi-link { color:var(--color-primary); text-decoration:none; font-weight:600; }
.data-table td a.txi-link:hover { text-decoration:underline; }
.data-table th a { color:inherit; text-decoration:none; }
.data-table th a:hover { text-decoration:underline; }
.data-table tbody tr.txi-row { cursor:pointer; }
.txi-check { width:15px; height:15px; accent-color:var(--color-primary); cursor:pointer; }
.txi-col-tight { width:1%; white-space:nowrap; }

.txi-bulkbar { display:none; align-items:center; gap:12px; background:var(--bg-th);
    border:1px solid var(--border-color-active); border-radius:10px; padding:10px 16px; margin-bottom:14px; }
.txi-bulkbar.show { display:flex; }
.txi-bulkbar select { width:auto; min-width:160px; height:34px; padding:6px 10px; }
.txi-bulkbar span { font-size:13px; font-weight:600; }

/* ── Pagination ─────────────────────────────────────────────────── */
.txi-pager { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; margin-top:6px; }
.txi-pager-links { display:flex; gap:6px; }
.txi-pager-links a, .txi-pager-links span {
    display:inline-flex; align-items:center; justify-content:center; min-width:34px; height:34px;
    padding:0 10px; border-radius:7px; border:1px solid var(--border-color);
    background:var(--bg-card); color:var(--color-text-main); font-size:13px;
    text-decoration:none; font-weight:500; }
.txi-pager-links a:hover { border-color:var(--color-primary); color:var(--color-primary); }
.txi-pager-links .cur { background:var(--bg-th); border-color:var(--color-primary); color:var(--color-primary); font-weight:700; }
.txi-pager-links .off { opacity:.4; pointer-events:none; }
.txi-pager-info { font-size:12.5px; color:var(--color-text-muted); }

/* ── Empty state ────────────────────────────────────────────────── */
.txi-empty { text-align:center; padding:52px 20px; color:var(--color-text-muted); }
.txi-empty h4 { font-family:'Outfit',sans-serif; font-size:15px; color:var(--color-text-main); margin:0 0 6px; }
.txi-empty p { font-size:13px; margin:0 0 18px; }

/* ── Kanban ─────────────────────────────────────────────────────── */
.txi-kanban { display:flex; gap:14px; overflow-x:auto; padding-bottom:18px; align-items:flex-start; }
.txi-kcol { flex:0 0 282px; background:var(--bg-secondary); border:1px solid var(--border-color);
    border-radius:12px; display:flex; flex-direction:column; max-height:calc(100vh - 300px); }
.txi-kcol.drag-over { border-color:var(--color-primary); background:var(--bg-th); }
.txi-kcol-head { padding:13px 15px; border-bottom:1px solid var(--border-color); position:sticky; top:0;
    background:var(--bg-secondary); border-radius:12px 12px 0 0; z-index:2; }
.txi-kcol-title { display:flex; align-items:center; justify-content:space-between; gap:8px;
    font-size:12px; font-weight:700; text-transform:uppercase; letter-spacing:.06em; color:var(--color-primary); }
.txi-kcol-count { background:var(--bg-th); border:1px solid var(--border-color-active);
    border-radius:20px; padding:1px 8px; font-size:10.5px; }
.txi-kcol-sum { font-size:13px; font-weight:700; color:var(--color-text-main); margin-top:6px; font-variant-numeric:tabular-nums; }
.txi-kcol-body { padding:10px; display:flex; flex-direction:column; gap:9px; overflow-y:auto; flex:1; min-height:90px; }

.txi-kcard { background:var(--bg-card); border:1px solid var(--border-color); border-radius:10px;
    padding:13px 14px; cursor:grab; box-shadow:0 1px 2px rgba(15,23,42,.05);
    transition:border-color var(--transition-fast), transform var(--transition-fast); }
.txi-kcard:hover { border-color:var(--color-primary); transform:translateY(-1px); }
.txi-kcard.dragging { opacity:.45; }
.txi-kcard-title { font-size:13.5px; font-weight:600; color:var(--color-text-main);
    margin-bottom:5px; line-height:1.35; text-decoration:none; display:block; }
.txi-kcard-title:hover { color:var(--color-primary); }
.txi-kcard-meta { font-size:11.5px; color:var(--color-text-muted); margin-bottom:9px; }
.txi-kcard-foot { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.txi-kcard-amt { font-size:13px; font-weight:700; color:var(--color-primary); font-variant-numeric:tabular-nums; }

/* ── Record page ────────────────────────────────────────────────── */
.txi-record { display:grid; grid-template-columns:340px 1fr; gap:22px; align-items:start; }
.txi-rec-head { display:flex; align-items:flex-start; gap:14px; margin-bottom:18px; }
.txi-rec-head h3 { font-size:19px; margin:0 0 4px; }
.txi-rec-sub { font-size:12.5px; color:var(--color-text-muted); }
.txi-quick { display:flex; gap:8px; flex-wrap:wrap; margin-top:14px; }

.txi-fields { display:flex; flex-direction:column; gap:0; }
.txi-field { display:grid; grid-template-columns:118px 1fr; gap:10px; align-items:center;
    padding:9px 0; border-bottom:1px solid var(--table-cell-border); font-size:13px; }
.txi-field:last-child { border-bottom:none; }
.txi-field > span:first-child { font-size:11px; text-transform:uppercase; letter-spacing:.06em;
    font-weight:600; color:var(--color-text-muted); }
.txi-field a { color:var(--color-primary); text-decoration:none; }
.txi-field a:hover { text-decoration:underline; }

/* ── Tabs ───────────────────────────────────────────────────────── */
.txi-tabs { display:flex; gap:8px; border-bottom:1px solid var(--border-color); margin-bottom:18px; overflow-x:auto; }
.txi-tab { background:none; border:none; border-bottom:2px solid transparent; padding:9px 4px; margin-right:14px;
    color:var(--color-text-muted); font-size:13.5px; font-weight:600; font-family:inherit;
    cursor:pointer; white-space:nowrap; transition:all var(--transition-fast); }
.txi-tab:hover { color:var(--color-text-main); }
.txi-tab.active { color:var(--color-primary); border-bottom-color:var(--color-primary); }
.txi-tabpane { display:none; }
.txi-tabpane.active { display:block; animation:fadeIn var(--transition-normal); }

/* ── Timeline ───────────────────────────────────────────────────── */
.txi-timeline { position:relative; padding-left:26px; }
.txi-timeline::before { content:''; position:absolute; left:8px; top:6px; bottom:6px;
    width:1px; background:var(--border-color); }
.txi-tl-item { position:relative; padding:0 0 20px 0; }
.txi-tl-item:last-child { padding-bottom:0; }
.txi-tl-dot { position:absolute; left:-23px; top:3px; width:17px; height:17px; border-radius:50%;
    background:var(--bg-card); border:1px solid var(--border-color-active);
    display:flex; align-items:center; justify-content:center; color:var(--color-primary); }
.txi-tl-dot svg { width:9px; height:9px; }
.txi-tl-head { display:flex; align-items:center; gap:8px; flex-wrap:wrap; font-size:13px; font-weight:600; }
.txi-tl-time { font-size:11.5px; color:var(--color-text-muted); font-weight:400; margin-left:auto; }
.txi-tl-body { font-size:13px; color:var(--color-text-muted); line-height:1.6; margin-top:5px; white-space:pre-wrap; }

/* ── Task rows ──────────────────────────────────────────────────── */
.txi-task { display:flex; align-items:flex-start; gap:12px; padding:12px 0;
    border-bottom:1px solid var(--table-cell-border); }
.txi-task:last-child { border-bottom:none; }
.txi-task-main { flex:1; min-width:0; }
.txi-task-title { font-size:13.5px; font-weight:600; }
.txi-task.done .txi-task-title { text-decoration:line-through; color:var(--color-text-muted); }
.txi-task-meta { font-size:11.5px; color:var(--color-text-muted); margin-top:4px;
    display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
.txi-overdue { color:var(--error-color); font-weight:600; }

/* ── Forms in modals ────────────────────────────────────────────── */
.txi-form-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:14px; }
.txi-form-grid .full { grid-column:1/-1; }
textarea { width:100%; padding:9px 13px; border-radius:7px; border:1px solid var(--border-color);
    background:var(--bg-input); color:var(--color-text-main); font-size:13.5px;
    font-family:inherit; box-sizing:border-box; resize:vertical; min-height:80px;
    transition:all var(--transition-fast); }
textarea:focus { outline:none; border-color:var(--color-primary); box-shadow:0 0 0 3px rgba(2,132,199,.13); }
input[type="date"], input[type="datetime-local"], input[type="tel"], input[type="url"] {
    width:100%; padding:9px 13px; border-radius:7px; border:1px solid var(--border-color);
    background:var(--bg-input); color:var(--color-text-main); box-sizing:border-box;
    font-size:13.5px; font-family:inherit; transition:all var(--transition-fast); }
input[type="date"]:focus, input[type="datetime-local"]:focus, input[type="tel"]:focus, input[type="url"]:focus {
    outline:none; border-color:var(--color-primary); box-shadow:0 0 0 3px rgba(2,132,199,.13); }
body.dark-theme input[type="date"], body.dark-theme input[type="datetime-local"] { color-scheme:dark; }
.txi-form-actions { display:flex; justify-content:flex-end; gap:10px; margin-top:20px;
    padding-top:16px; border-top:1px solid var(--border-color); }

/* ── Modal ──────────────────────────────────────────────────────── */
.txi-modal-backdrop { display:none; position:fixed; inset:0; z-index:5000;
    background:rgba(15,23,42,.45); backdrop-filter:blur(3px); padding:24px; overflow-y:auto; }
.txi-modal-backdrop.open { display:flex; align-items:flex-start; justify-content:center; }
.txi-modal { background:var(--bg-card); border:1px solid var(--border-color); border-radius:16px;
    width:100%; max-width:640px; margin:auto; box-shadow:0 18px 50px rgba(0,0,0,.28);
    animation:fadeIn .22s ease; }
.txi-modal.wide { max-width:860px; }
.txi-modal-head { display:flex; align-items:center; justify-content:space-between;
    padding:18px 22px; border-bottom:1px solid var(--border-color); }
.txi-modal-head h3 { margin:0; font-size:16px; }
.txi-modal-x { background:none; border:none; font-size:24px; line-height:1; cursor:pointer;
    color:var(--color-text-muted); padding:0 4px; }
.txi-modal-x:hover { color:var(--color-text-main); }
.txi-modal-body { padding:22px; }

/* ── Toasts & flashes ───────────────────────────────────────────── */
.txi-toast-host { position:fixed; bottom:24px; right:24px; z-index:9000;
    display:flex; flex-direction:column; gap:10px; }
.txi-toast { background:var(--bg-card); border:1px solid var(--border-color); border-left:3px solid var(--color-primary);
    border-radius:10px; padding:12px 18px; font-size:13px; font-weight:500;
    box-shadow:0 8px 26px rgba(0,0,0,.18); animation:fadeIn .2s ease; min-width:220px; }
.txi-toast.err { border-left-color:var(--error-color); }
.txi-toast.ok  { border-left-color:var(--success-color); }

.txi-flash { display:flex; align-items:center; justify-content:space-between; gap:12px;
    border-radius:10px; padding:12px 16px; font-size:13px; margin-bottom:16px; font-weight:500; }
.txi-flash-success { background:rgba(16,185,129,.08); border:1px solid rgba(16,185,129,.22); color:#059669; }
.txi-flash-error   { background:rgba(220,38,38,.07);  border:1px solid rgba(220,38,38,.20); color:var(--error-color); }
.txi-flash-info    { background:rgba(2,132,199,.07);  border:1px solid rgba(2,132,199,.20); color:var(--color-primary); }
.txi-flash-x { background:none; border:none; font-size:19px; line-height:1; cursor:pointer; color:inherit; opacity:.6; }
body.dark-theme .txi-flash-success { color:#6ee7b7; }

/* ── Simple bar charts (no external libs) ───────────────────────── */
.txi-bars { display:flex; flex-direction:column; gap:11px; }
.txi-bar-row { display:grid; grid-template-columns:150px 1fr 74px; gap:12px; align-items:center; font-size:12.5px; }
.txi-bar-track { background:var(--bg-th); border-radius:20px; height:9px; overflow:hidden; }
.txi-bar-fill { height:100%; border-radius:20px; background:linear-gradient(90deg,var(--color-primary),var(--color-primary-light)); }
.txi-bar-val { text-align:right; font-weight:600; font-variant-numeric:tabular-nums; }
.txi-bar-label { color:var(--color-text-muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

.txi-cols { display:flex; align-items:flex-end; gap:10px; height:190px; padding-top:10px; }
.txi-col { flex:1; display:flex; flex-direction:column; justify-content:flex-end; align-items:center; gap:7px; height:100%; }
.txi-col-bar { width:100%; max-width:46px; border-radius:6px 6px 0 0;
    background:linear-gradient(180deg,var(--color-primary-light),var(--color-primary)); min-height:3px; }
.txi-col-bar.alt { background:linear-gradient(180deg,#94a3b8,#64748b); opacity:.65; }
.txi-col-label { font-size:10.5px; color:var(--color-text-muted); white-space:nowrap; }
.txi-col-value { font-size:11px; font-weight:700; }

.txi-legend { display:flex; gap:16px; font-size:11.5px; color:var(--color-text-muted); margin-top:12px; }
.txi-legend i { display:inline-block; width:10px; height:10px; border-radius:3px; margin-right:6px; }

.txi-grid-2 { display:grid; grid-template-columns:repeat(auto-fit,minmax(340px,1fr)); gap:20px; }

/* ── Utility ────────────────────────────────────────────────────── */
.txi-row-flex { display:flex; align-items:center; gap:10px; }
.txi-mt { margin-top:18px; }
.txi-nowrap { white-space:nowrap; }
.txi-hint { font-size:11.5px; color:var(--color-text-muted); margin-top:5px; }
.txi-divider { height:1px; background:var(--border-color); margin:18px 0; }
.btn-sm { height:30px !important; padding:5px 12px !important; font-size:12px !important; }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 980px) {
    .txi-record { grid-template-columns:1fr; }
    .txi-form-grid { grid-template-columns:1fr; }
}
@media (max-width: 760px) {
    .txi-burger { display:flex; }
    .sidebar { position:fixed; left:0; top:0; z-index:9990; transform:translateX(-100%);
        transition:transform var(--transition-normal); box-shadow:0 0 40px rgba(0,0,0,.3); }
    .sidebar.open { transform:translateX(0); }
    .main-content { padding:74px 18px 34px; max-height:none; }
    .txi-topbar { padding-right:0; }
    .section-header { padding-right:0; flex-wrap:wrap; gap:12px; }
    .txi-stats { grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); }
    .txi-field { grid-template-columns:1fr; gap:3px; }
}

@media print {
    .sidebar, .txi-topbar, .theme-toggle-btn, .section-actions, .txi-burger { display:none !important; }
    .main-content { padding:0; }
}
