/* ============================================================================
   msg-collector — UI Kit shared styles
   Used by both ui_kits/tenant-dashboard and ui_kits/operator-console.
   Requires ../../colors_and_type.css to be loaded first.
   ============================================================================ */

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--canvas);
  color: var(--fg);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.mono { font-family: var(--font-mono); font-feature-settings: "tnum" 1, "zero" 1; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: var(--tracking-wider); text-transform: uppercase; color: var(--fg-subtle); }
button { font-family: inherit; }
[data-lucide] { stroke-width: 1.75; }

/* ---- App shell -------------------------------------------------------- */
.app { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar { width: 240px; flex: 0 0 240px; background: var(--sidebar); display: flex; flex-direction: column; padding: 14px 12px; overflow: hidden; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; }
.sidebar-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--primary); display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.sidebar-mark svg { width: 18px; height: 18px; color: #fff; }
.sidebar-word { font-family: var(--font-mono); font-size: 15px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.1; white-space: nowrap; }
.sidebar-word .a { color: rgba(255,255,255,.5); } .sidebar-word .b { color: #fff; }
.sidebar-word .role { display: block; font-family: var(--font-sans); font-size: 10px; font-weight: 500; letter-spacing: .04em; color: rgba(255,255,255,.4); text-transform: uppercase; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-section { font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--sidebar-fg-dim); padding: 14px 8px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--sidebar-fg); font-size: 13px; font-weight: 500; cursor: pointer; transition: background .12s, color .12s; border: none; background: none; width: 100%; text-align: left; }
.nav-item svg { width: 16px; height: 16px; flex: 0 0 auto; opacity: .9; }
.nav-item:hover { background: var(--sidebar-active-bg); color: #fff; }
.nav-item.active { background: var(--sidebar-active-bg); color: #fff; }
.nav-item.active svg { color: var(--blue-400); opacity: 1; }
.nav-item .badge { margin-left: auto; font-family: var(--font-mono); font-size: 11px; font-weight: 700; background: rgba(255,255,255,.12); color: #fff; padding: 1px 7px; border-radius: var(--radius-full); }
.nav-item .badge.alert { background: var(--danger-solid); }
.sidebar-foot { margin-top: auto; padding: 12px 8px 4px; border-top: 1px solid var(--sidebar-border); display: flex; align-items: center; gap: 8px; }
.sidebar-foot .pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--success-solid); box-shadow: 0 0 0 3px rgba(34,197,94,.18); flex: 0 0 auto; }
.sidebar-foot .txt { font-size: 11px; color: var(--sidebar-fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .sidebar-foot .txt span { display: block; font-size: 10px; color: var(--sidebar-fg-dim); font-family: var(--font-mono); }

/* Main column */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 56px; flex: 0 0 56px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 14px; padding: 0 22px; }
.topbar .crumb { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--fg-subtle); }
.topbar .crumb .cur { color: var(--fg); font-weight: 600; }
.topbar .crumb svg { width: 14px; height: 14px; color: var(--fg-faint); }
.topbar .crumb .crumb-link { font: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; border-radius: var(--radius-xs); transition: color .12s; }
.topbar .crumb .crumb-link:hover { color: var(--fg); }
.topbar .spacer { flex: 1; }
.topbar .topsearch { position: relative; display: flex; align-items: center; }
.topbar .topsearch svg { position: absolute; left: 10px; width: 15px; height: 15px; color: var(--fg-faint); }
.topbar .topsearch input { height: 34px; width: 240px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 0 11px 0 32px; font-size: 13px; outline: none; background: var(--surface); color: var(--fg); }
.topbar .topsearch input:focus { border-color: var(--primary); box-shadow: var(--ring); }
.iconbtn { width: 34px; height: 34px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--fg-muted); position: relative; transition: background .12s; }
.iconbtn:hover { background: var(--surface-hover); color: var(--fg); }
.iconbtn svg { width: 16px; height: 16px; }
.iconbtn .ping { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; background: var(--danger-solid); border: 1.5px solid #fff; border-radius: 50%; }
.avatar-sm { width: 32px; height: 32px; border-radius: 50%; background: var(--blue-500); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex: 0 0 auto; }

/* Content scroll area */
.content { flex: 1; overflow-y: auto; }
.page { padding: 22px 24px 40px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 18px; gap: 16px; }
.page-title { font-size: 22px; font-weight: 600; letter-spacing: -0.015em; margin: 0; display: flex; align-items: center; gap: 10px; }
.page-sub { font-size: 13px; color: var(--fg-subtle); margin: 4px 0 0; }

/* ---- Buttons ---------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; line-height: 1; padding: 0 13px; height: 34px; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; transition: all .13s ease; white-space: nowrap; }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { background: var(--primary-active); }
.btn-secondary { background: var(--surface); color: var(--fg); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-hover); }
.btn-ghost { background: transparent; color: var(--fg-muted); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--fg); }
.btn-danger { background: var(--surface); color: var(--danger-fg); border-color: var(--danger-border); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { height: 28px; font-size: 12px; padding: 0 10px; gap: 5px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Inputs ----------------------------------------------------------- */
.input { height: 34px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); padding: 0 11px; font-family: var(--font-sans); font-size: 13px; color: var(--fg); outline: none; }
.input:focus { border-color: var(--primary); box-shadow: var(--ring); }
.input::placeholder { color: var(--fg-faint); }
.field-search { position: relative; display: inline-flex; align-items: center; }
.field-search svg { position: absolute; left: 10px; width: 15px; height: 15px; color: var(--fg-faint); pointer-events: none; }
.field-search .input { padding-left: 32px; }
.select { display: inline-flex; align-items: center; justify-content: space-between; gap: 8px; height: 34px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); padding: 0 11px; font-size: 13px; color: var(--fg); cursor: pointer; transition: background .12s; }
.select:hover { background: var(--surface-hover); }
.select svg { width: 15px; height: 15px; color: var(--fg-subtle); }
.select .ph { color: var(--fg-subtle); }

/* Filter bar */
.filterbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 16px; }
.filterbar .lbl { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-subtle); }

/* ---- Tags ------------------------------------------------------------- */
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: var(--radius-full); font-size: 11px; font-weight: 600; border: 1px solid; white-space: nowrap; }
.tag .dot { width: 6px; height: 6px; border-radius: 50%; }
.tag.success { background: var(--success-bg); color: var(--success-fg); border-color: var(--success-border); }
.tag.warning { background: var(--warning-bg); color: var(--warning-fg); border-color: var(--warning-border); }
.tag.danger  { background: var(--danger-bg);  color: var(--danger-fg);  border-color: var(--danger-border); }
.tag.info    { background: var(--info-bg);    color: var(--info-fg);    border-color: var(--info-border); }
.tag.neutral { background: var(--neutral-bg); color: var(--neutral-tag-fg); border-color: var(--border); }
.tag.telegram { background: var(--telegram-bg); color: var(--telegram); border-color: #bce3f4; }
.tag.whatsapp { background: var(--whatsapp-bg); color: #1a7a44; border-color: #bdebd0; }
.count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-full); background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; font-family: var(--font-mono); }
.count.gray { background: var(--neutral-200); color: var(--fg-muted); }

/* ---- Cards ------------------------------------------------------------ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-xs); }
.stat-grid { display: grid; gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 16px; box-shadow: var(--shadow-xs); }
.stat .eyebrow { display: block; margin-bottom: 10px; }
.stat .stat-row { display: flex; align-items: flex-end; justify-content: space-between; }
.stat .num { font-size: 28px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; font-family: var(--font-mono); color: var(--fg); }
.stat .chip { width: 34px; height: 34px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; }
.stat .chip svg { width: 17px; height: 17px; }
.stat .foot { font-size: 11px; font-family: var(--font-mono); color: var(--fg-faint); margin-top: 8px; }

/* ---- Tables ----------------------------------------------------------- */
.tbl-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; overflow-x: auto; }
.tbl-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.tbl-head h2 { font-size: 15px; font-weight: 600; margin: 0; display: flex; align-items: center; gap: 8px; }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: var(--tracking-wider); text-transform: uppercase; color: var(--fg-subtle); background: var(--surface-subtle); padding: 9px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; z-index: 1; }
table.tbl td { font-size: 13px; color: var(--fg); padding: 11px 16px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr { cursor: pointer; transition: background .1s; }
table.tbl tbody tr:hover td { background: var(--surface-hover); }
table.tbl tbody tr.warn td { background: var(--warning-bg); }
table.tbl tbody tr.warn:hover td { background: #fef3cd; }
table.tbl .right { text-align: right; }
table.tbl .muted { color: var(--fg-subtle); }
table.tbl .pri { color: var(--primary); }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--fg-subtle); }
.pager .pg { display: flex; gap: 4px; }
.pager .pg button { width: 28px; height: 28px; border: 1px solid var(--border-strong); background: var(--surface); border-radius: var(--radius-xs); cursor: pointer; color: var(--fg-muted); display: flex; align-items: center; justify-content: center; }
.pager .pg button:hover { background: var(--surface-hover); }
.pager .pg button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---- Avatars ---------------------------------------------------------- */
.avatar { border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; flex: 0 0 auto; }
.avatar.n { background: var(--neutral-200); color: var(--fg-muted); }

/* ---- Tabs ------------------------------------------------------------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab { padding: 8px 13px; font-size: 13px; font-weight: 500; color: var(--fg-subtle); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; background: none; border-top: none; border-left: none; border-right: none; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab:not(.active):hover { color: var(--fg); }

/* ---- Drawer ----------------------------------------------------------- */
.scrim { position: fixed; inset: 0; background: rgba(16,16,19,.45); z-index: 40; animation: fade .16s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 420px; max-width: 92vw; background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); z-index: 41; display: flex; flex-direction: column; animation: slidein .2s ease; }
@keyframes slidein { from { transform: translateX(28px); } to { transform: translateX(0); } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px; }

/* ---- Modal ------------------------------------------------------------ */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(16,16,19,.45); animation: fade .16s ease; }
.modal-card { width: 440px; max-width: 92vw; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); animation: pop .18s ease; overflow: hidden; }
@keyframes pop { from { transform: scale(.97); opacity: .5; } to { transform: scale(1); opacity: 1; } }

/* ---- Misc ------------------------------------------------------------- */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 56px 20px; text-align: center; color: var(--fg-subtle); }
.empty .ic { width: 44px; height: 44px; border: 1px solid var(--border); border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; color: var(--fg-faint); background: var(--surface); }
.empty .t { font-size: 14px; font-weight: 600; color: var(--fg); }
.empty .s { font-size: 13px; }
.confbar { height: 5px; border-radius: 3px; background: var(--neutral-200); overflow: hidden; width: 100%; }
.confbar > span { display: block; height: 100%; background: var(--primary); border-radius: 3px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--fg-subtle); } .kv dd { margin: 0; color: var(--fg); }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ---- Toggle switch ---------------------------------------------------- */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; flex: 0 0 auto; }
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.switch .track { width: 34px; height: 20px; border-radius: var(--radius-full); background: var(--neutral-300); position: relative; transition: background .16s ease; flex: 0 0 auto; }
.switch .thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .16s ease; }
.switch input:checked + .track { background: var(--success-solid); }
.switch input:checked + .track .thumb { transform: translateX(14px); }
.switch input:focus-visible + .track { box-shadow: var(--ring); }
.switch:hover .track { filter: brightness(.97); }
.switch .switch-lbl { font-size: 12px; font-weight: 500; color: var(--fg-muted); min-width: 52px; }

/* ---- Segmented control (radio group) ---------------------------------- */
.seg { display: inline-flex; align-items: center; gap: 2px; padding: 2px; background: var(--surface-subtle); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); }
.seg button { appearance: none; border: none; background: transparent; font: inherit; font-size: 12px; font-weight: 500; color: var(--fg-muted); padding: 4px 12px; border-radius: 4px; cursor: pointer; line-height: 1; height: 24px; display: inline-flex; align-items: center; gap: 5px; transition: all .12s ease; }
.seg button:hover { color: var(--fg); }
.seg button.on { background: var(--primary); color: #fff; box-shadow: var(--shadow-xs); }
.seg button.on.tg { background: var(--telegram); }
.seg button.on.wa { background: var(--whatsapp); }

/* ---- Range slider ----------------------------------------------------- */
.slider-wrap { display: inline-flex; align-items: center; gap: 9px; }
.slider { -webkit-appearance: none; appearance: none; width: 120px; height: 5px; border-radius: 3px; background: var(--neutral-200); outline: none; cursor: pointer; }
.slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--primary); border: 2px solid #fff; box-shadow: var(--shadow-sm); cursor: pointer; }
.slider::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--primary); border: 2px solid #fff; box-shadow: var(--shadow-sm); cursor: pointer; }
.slider:focus-visible { box-shadow: var(--ring); }
.slider-val { font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--fg); min-width: 38px; text-align: right; }

/* ---- Date range ------------------------------------------------------- */
.daterange { display: inline-flex; align-items: center; gap: 7px; }
.daterange .input { width: 142px; }
.daterange .sep { color: var(--fg-faint); }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--neutral-300); border-radius: 6px; border: 3px solid var(--canvas); }
.content::-webkit-scrollbar-thumb { border-color: var(--canvas); }
