/* VOCA Web Portal - light theme design system (component classes; layout uses Tailwind utilities) */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e5e8ef;
  --border-strong: #d4d9e3;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #64748b;
  --brand: #4f46e5;
  --brand-600: #4338ca;
  --brand-50: #eef2ff;
  --brand-100: #e0e7ff;
  --ok: #059669;
  --warn: #d97706;
  --danger: #e11d48;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .05);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .16);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}
.mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; }
::selection { background: var(--brand-100); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cfd5e1; border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
[hidden] { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid transparent;
  font-size: 13px; font-weight: 600; line-height: 1; white-space: nowrap; cursor: pointer; user-select: none;
  transition: background-color .15s var(--ease), border-color .15s, color .15s, box-shadow .15s, transform .08s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 14px; }
.btn-icon { width: 34px; padding: 0; }
.btn-sm.btn-icon { width: 30px; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(79, 70, 229, .3); }
.btn-primary:hover:not(:disabled) { background: var(--brand-600); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: #c3cad8; }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: #eef1f6; color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #be123c; }
.btn-success { background: var(--ok); color: #fff; }
.btn-success:hover:not(:disabled) { background: #047857; }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover:not(:disabled) { background: #d97706; }
.btn-soft { background: var(--brand-50); color: var(--brand-600); }
.btn-soft:hover:not(:disabled) { background: var(--brand-100); }
.btn .spinner { width: 14px; height: 14px; border-width: 2px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 14px; font-weight: 650; color: var(--text); display: flex; align-items: center; gap: 8px; }
.card-sub { font-size: 12px; color: var(--text-3); }
.card-body { padding: 18px; }
.card-hover { transition: box-shadow .2s var(--ease), border-color .2s, transform .2s var(--ease); }
.card-hover:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }

.stat { padding: 16px 18px; }
.stat-label { font-size: 12px; color: var(--text-3); font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-hint { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.stat-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 16px; }

/* ---------- Forms ---------- */
.label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.label .req { color: var(--danger); margin-left: 2px; }
.hint { font-size: 12px; color: var(--text-3); margin-top: 5px; }
.input, .select, .textarea {
  width: 100%; background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 0 12px; height: 38px; font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s; outline: none;
}
.textarea { height: auto; padding: 9px 12px; resize: vertical; min-height: 76px; line-height: 1.5; }
.select { appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
.input:hover, .select:hover, .textarea:hover { border-color: #b9c1d0; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }
.input::placeholder, .textarea::placeholder { color: #9aa4b5; }
.input-sm, .select-sm { height: 32px; font-size: 12.5px; border-radius: 8px; }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #94a3b8; font-size: 13px; pointer-events: none; }
.input-icon > .input { padding-left: 34px; }
.field-error { font-size: 12px; color: var(--danger); margin-top: 6px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }

/* toggle switch */
.switch { position: relative; display: inline-flex; width: 36px; height: 20px; flex-shrink: 0; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cbd5e1; border-radius: 99px; transition: background .2s; }
.switch span::after { content: ''; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; background: #fff; border-radius: 50%; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .2s var(--ease); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(16px); }

/* segmented control */
.segmented { display: inline-flex; background: #eef1f6; border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented button { height: 30px; padding: 0 12px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--text-2); transition: all .15s; display: inline-flex; align-items: center; gap: 6px; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented .count { font-size: 11px; background: #e2e6ee; color: var(--text-2); border-radius: 99px; padding: 1px 7px; }
.segmented button.active .count { background: var(--brand-50); color: var(--brand-600); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge-dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-gray { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }
.b-red { background: #fff1f2; color: #be123c; border-color: #fecdd3; }
.b-orange { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.b-amber { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.b-green { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.b-blue { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.b-sky { background: #f0f9ff; color: #0369a1; border-color: #bae6fd; }
.b-violet { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.b-indigo { background: var(--brand-50); color: var(--brand-600); border-color: var(--brand-100); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th { text-align: left; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); background: var(--surface-2); padding: 10px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid #eef1f5; vertical-align: middle; color: var(--text-2); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #fafbfd; }
.table tr.clickable { cursor: pointer; }
.table-compact th, .table-compact td { padding: 8px 10px; }
/* pagination + per-column filters (assets/js/table-tools.js) */
.table thead tr.pager-filter-row th { padding: 6px 8px 8px; text-transform: none; letter-spacing: 0; font-weight: 400; }
.table .pager-filter { min-width: 64px; width: 100%; height: 30px; font-size: 12.5px; text-transform: none; }
.pager { position: sticky; left: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-3); }
.pager .select { width: auto; display: inline-block; height: 30px; padding-top: 2px; padding-bottom: 2px; }
.pager-nav { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.pager-page { color: var(--text-2); font-weight: 600; white-space: nowrap; }
.table .strong { color: var(--text); font-weight: 600; }

/* ---------- App shell ---------- */
.sidebar { width: 260px; background: var(--surface); border-right: 1px solid var(--border); }
.nav-section { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: #94a3b8; padding: 16px 12px 6px; }
.nav-item { display: flex; align-items: center; gap: 11px; width: 100%; height: 38px; padding: 0 12px; border-radius: 9px; font-size: 13.5px; font-weight: 500; color: var(--text-2); transition: background .15s, color .15s; position: relative; }
.nav-item i { width: 18px; text-align: center; color: #94a3b8; transition: color .15s; }
.nav-item:hover { background: #f2f4f8; color: var(--text); }
.nav-item.active { background: var(--brand-50); color: var(--brand-600); font-weight: 600; }
.nav-item.active i { color: var(--brand); }
.nav-item .nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.topbar { height: 64px; background: rgba(255, 255, 255, .85); backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid var(--border); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px; font-weight: 700; color: #fff; flex-shrink: 0; }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.live-pill { display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 11px; border-radius: 99px; font-size: 12px; font-weight: 600; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; }
.live-dot.on { background: #10b981; box-shadow: 0 0 0 0 rgba(16, 185, 129, .5); animation: pulse 2s infinite; }
.live-dot.off { background: #f59e0b; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(16,185,129,.45); } 70% { box-shadow: 0 0 0 8px rgba(16,185,129,0); } 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); } }

.menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 60; transform-origin: top right; animation: pop .14s var(--ease); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 8px; font-size: 13px; color: var(--text-2); text-align: left; }
.menu-item i { width: 16px; color: #94a3b8; }
.menu-item:hover { background: #f2f4f8; color: var(--text); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger i { color: var(--danger); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }

.page-enter { animation: fadeUp .25s var(--ease); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { background: #eef2ff; } 100% { background: transparent; } }

/* ---------- Overlays: modal, drawer, toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .38); backdrop-filter: blur(2px); z-index: 80; opacity: 0; transition: opacity .2s var(--ease); }
.overlay.show { opacity: 1; }
.overlay-top { z-index: 90; }
.modal { position: fixed; inset: 0; z-index: 91; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow-y: auto; }
.modal-panel { width: 100%; max-width: 520px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(10px) scale(.98); transition: opacity .2s var(--ease), transform .2s var(--ease); }
.modal.show .modal-panel { opacity: 1; transform: none; }
.modal-panel.lg { max-width: 760px; }
.modal-panel.sm { max-width: 420px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-desc { font-size: 13px; color: var(--text-3); margin-top: 3px; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 16px 16px; }
.form-error { display: flex; gap: 8px; align-items: flex-start; background: #fff1f2; border: 1px solid #fecdd3; color: #be123c; padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 100vw); background: var(--surface); z-index: 81; box-shadow: var(--shadow-lg); transform: translateX(100%); transition: transform .28s var(--ease); display: flex; flex-direction: column; }
.drawer.show { transform: none; }
.drawer-wide { width: min(1080px, 100vw); z-index: 91; }

.toast-stack { position: fixed; right: 20px; top: 76px; z-index: 100; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 11px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-left-width: 4px; border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow-lg); font-size: 13px; color: var(--text-2); animation: toastIn .25s var(--ease); }
.toast.hide { animation: toastOut .2s var(--ease) forwards; }
.toast .t-title { font-weight: 650; color: var(--text); margin-bottom: 1px; }
.toast-success { border-left-color: #10b981; } .toast-success > i { color: #10b981; }
.toast-error { border-left-color: var(--danger); } .toast-error > i { color: var(--danger); }
.toast-warning { border-left-color: #f59e0b; } .toast-warning > i { color: #f59e0b; }
.toast-info { border-left-color: var(--brand); } .toast-info > i { color: var(--brand); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(16px); } }

/* ---------- Feedback states ---------- */
.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(79, 70, 229, .2); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
.btn-primary .spinner, .btn-danger .spinner, .btn-success .spinner, .btn-warning .spinner { border-color: rgba(255,255,255,.35); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, #eef1f6 25%, #f6f8fb 37%, #eef1f6 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.empty { text-align: center; padding: 44px 20px; color: var(--text-3); }
.empty .e-icon { width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 12px; background: #f1f4f9; color: #94a3b8; display: grid; place-items: center; font-size: 20px; }
.empty .e-title { font-weight: 650; color: var(--text); font-size: 14px; }
.empty .e-hint { font-size: 13px; margin-top: 4px; }

/* ---------- Timeline ---------- */
.timeline { position: relative; }
.timeline::before { content: ''; position: absolute; left: 15px; top: 6px; bottom: 6px; width: 2px; background: #eceff4; }
.tl-item { position: relative; display: flex; gap: 12px; padding: 0 0 16px; }
.tl-icon { position: relative; z-index: 1; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; flex-shrink: 0; border: 3px solid var(--surface); }

/* ---------- Dialpad ---------- */
.dial-key { height: 56px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); font-size: 20px; font-weight: 600; color: var(--text); transition: background .12s, transform .08s; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.dial-key small { font-size: 9.5px; letter-spacing: .12em; color: #94a3b8; font-weight: 600; margin-top: 3px; }
.dial-key:hover { background: #eef1f6; }
.dial-key:active { transform: scale(.96); background: var(--brand-50); }

/* ---------- Charts ---------- */
.bar-track { height: 8px; background: #eef1f6; border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; transition: width .6s var(--ease); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Call-flow builder (Drawflow, light theme) ---------- */
#drawflow { cursor: grab; }
#drawflow:active { cursor: grabbing; }
#drawflow .drawflow-node { cursor: pointer; }
#drawflow { background-color: #f8fafc; background-image: radial-gradient(#d6dce7 1px, transparent 1px); background-size: 22px 22px; }
.drawflow .drawflow-node { background: #fff; border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow-sm);
  padding: 0; width: 240px; min-height: 0; color: var(--text); font-family: inherit; }
.drawflow .drawflow-node:hover { box-shadow: var(--shadow); }
.drawflow .drawflow-node.selected { background: #fff; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, .18); color: var(--text); }
.drawflow .drawflow-node .drawflow_content_node { width: 100%; }
.drawflow .drawflow-node .input, .drawflow .drawflow-node .output { width: 15px !important; height: 15px !important; min-width: 15px; flex: 0 0 15px;
  border-radius: 50%; border: 2px solid #94a3b8; background: #fff; box-sizing: border-box; padding: 0; }
.drawflow .drawflow-node .inputs { left: -8px; position: absolute; }
.drawflow .drawflow-node .outputs { right: -8px; position: absolute; }
.drawflow .drawflow-node .input { left: 0; }
.drawflow .drawflow-node .output { right: 0; margin-bottom: 9px; }
.drawflow .drawflow-node .output:hover, .drawflow .drawflow-node .input:hover { background: var(--brand); border-color: var(--brand); }
.drawflow .drawflow-node .outputs .output[data-label]::after { content: attr(data-label); position: absolute; left: 16px; top: -4px; white-space: nowrap;
  font-size: 10.5px; font-weight: 600; line-height: 18px; background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 0 6px;
  color: var(--text-2); pointer-events: none; box-shadow: var(--shadow-sm); }
.drawflow .connection .main-path { stroke: #94a3b8; stroke-width: 2.5px; }
.drawflow .connection .main-path:hover, .drawflow .connection .main-path.selected { stroke: var(--brand); }
.drawflow-delete { background: var(--danger); color: #fff; border: 2px solid #fff; box-shadow: var(--shadow); font-family: inherit; line-height: 26px; }
.fn-head { display: flex; gap: 8px; align-items: center; padding: 8px 12px; font-weight: 650; font-size: 13px; border-bottom: 1px solid var(--border);
  border-radius: 11px 11px 0 0; background: color-mix(in srgb, var(--c) 9%, #fff); }
.fn-head i { color: var(--c); }
.fn-body { padding: 8px 12px 10px; font-size: 12px; color: var(--text-2); line-height: 1.45; word-break: break-word; }
.fn-palette { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border: 1px solid var(--border); border-left: 3px solid var(--c);
  border-radius: 9px; font-size: 13px; font-weight: 500; background: #fff; cursor: grab; user-select: none; transition: box-shadow .15s, transform .1s; }
.fn-palette:hover { box-shadow: var(--shadow); transform: translateX(2px); }
.fn-palette i { color: var(--c); width: 16px; text-align: center; }
