/* BizCore — Shared Styles */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:     #2563eb;
  --blue-h:   #1d4ed8;
  --green:    #16a34a;
  --red:      #dc2626;
  --amber:    #d97706;
  --gray-50:  #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --sidebar:  #1e2330;
  --white:    #ffffff;
}

html, body {
  height: 100%;
  font-family: 'Inter', sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.hide-scroll { scrollbar-width: none; }
.hide-scroll::-webkit-scrollbar { display: none; }

/* ── LAYOUT ── */
.app  { display: flex; height: 100vh; overflow: hidden; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.page-body { flex: 1; overflow-y: auto; padding: 24px; }

/* ── SIDEBAR ── */
.sidebar {
  width: 228px; flex-shrink: 0;
  background: #0f172a;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.s-nav { padding: 10px 8px; flex: 1; overflow-y: auto; min-height: 0; }
.s-logo {
  padding: 18px 16px;
  display: flex; align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  text-decoration: none; flex-shrink: 0;
}
.s-logo-name {
  position: relative;
  display: inline-flex; align-items: baseline; gap: 0.04em;
  padding-bottom: 0.26rem;
  line-height: 1;
}
.s-logo-name::after {
  content: "";
  position: absolute;
  left: 0.06rem; right: 0.06rem; bottom: -0.14rem;
  height: 1px;
  background: linear-gradient(90deg, rgba(96,165,250,0), rgba(96,165,250,0.24), rgba(165,180,252,0.4), rgba(96,165,250,0));
}
.s-logo-biz {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.06em;
  color: #ffffff;
}
.s-logo-core {
  font-family: 'Inter', sans-serif;
  font-size: 1.18rem;
  font-weight: 800;
  letter-spacing: -0.05em;
  background: linear-gradient(135deg, #93c5fd 0%, #dbeafe 48%, #c4b5fd 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
}
.s-logo-core-initial {
  font-size: 1.3em;
  line-height: 1;
  vertical-align: -0.02em;
  margin-right: -0.04em;
  display: inline-block;
}

.s-workspace {
  margin: 12px 12px 0;
  padding: 10px 12px;
  background: rgba(255,255,255,0.05);
  border-radius: 9px;
  border: 1px solid rgba(255,255,255,0.06);
}
.s-ws-label { font-size: 9px; color: rgba(255,255,255,0.3); text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; }
.s-ws-name  { font-size: 13px; font-weight: 600; color: #fff; margin-top: 3px; }
.s-ws-slug  { font-size: 11px; color: rgba(255,255,255,0.3); margin-top: 1px; }

.s-nav-section {
  font-size: 9px; color: rgba(255,255,255,0.2);
  text-transform: uppercase; letter-spacing: 0.12em; font-weight: 700;
  padding: 10px 10px 4px; margin-top: 2px;
}
.s-nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 8px;
  font-size: 13px; font-weight: 500; color: rgba(255,255,255,0.5);
  text-decoration: none; transition: all 0.15s;
  margin-bottom: 1px;
}
.s-nav a:hover  { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.9); }
.s-nav a.active {
  background: rgba(37,99,235,0.2);
  color: #93c5fd;
  border: 1px solid rgba(37,99,235,0.25);
}
.s-nav a svg    { width: 16px; height: 16px; flex-shrink: 0; }
.s-nav-badge {
  margin-left: auto;
  background: #2563eb; color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 1px 7px; border-radius: 10px;
  min-width: 19px; text-align: center;
}

.s-counts {
  margin: 0 12px 12px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
}
.s-count {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px; padding: 9px 10px;
}
.s-count-label { font-size: 10px; color: rgba(255,255,255,0.3); text-transform: uppercase; letter-spacing: 0.08em; }
.s-count-val   { font-size: 20px; font-weight: 700; color: #fff; margin-top: 3px; line-height: 1; }

.s-user {
  margin: 12px;
  padding: 11px 12px; border-radius: 9px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.06);
}
.s-user-name  { font-size: 13px; font-weight: 600; color: #fff; }
.s-user-email { font-size: 11px; color: rgba(255,255,255,0.3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s-logout {
  display: block; width: 100%; margin-top: 8px;
  padding: 7px; border-radius: 7px; border: 1px solid rgba(255,255,255,0.08);
  background: transparent; color: rgba(255,255,255,0.35);
  font-size: 12px; font-family: inherit; cursor: pointer; font-weight: 500;
  transition: all 0.15s;
}
.s-logout:hover { color: #fff; border-color: rgba(255,255,255,0.2); background: rgba(255,255,255,0.05); }
.s-support-btn {
  display: flex; align-items: center; gap: 7px; margin: 0 0 8px;
  padding: 8px 10px; border-radius: 8px;
  color: rgba(255,255,255,0.45); font-size: 12px; font-weight: 500;
  text-decoration: none; transition: all 0.15s;
  border: 1px solid rgba(255,255,255,0.06);
}
.s-support-btn:hover { color: #fff; background: rgba(255,255,255,0.07); border-color: rgba(255,255,255,0.15); }

.s-powered-by {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 16px 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
  text-decoration: none; flex-shrink: 0;
  opacity: 0.55; transition: opacity 0.15s;
}
.s-powered-by:hover { opacity: 1; }
.s-powered-mark {
  width: 20px; height: 20px; border-radius: 6px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  box-shadow: 0 1px 5px rgba(37,99,235,0.35);
}
.s-powered-text {
  font-size: 11px; color: rgba(255,255,255,0.5);
  letter-spacing: 0.01em; line-height: 1;
}
.s-powered-text strong { font-weight: 700; color: rgba(255,255,255,0.75); letter-spacing: -0.01em; }
.s-powered-by:hover .s-powered-text { color: rgba(255,255,255,0.65); }
.s-powered-by:hover .s-powered-text strong { color: #fff; }

/* ── TOPBAR ── */
.topbar {
  height: 54px; padding: 0 20px; flex-shrink: 0;
  background: var(--white);
  border-bottom: 1px solid #eef0f4;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.topbar-title   { font-size: 15px; font-weight: 700; color: #0f172a; letter-spacing: -0.01em; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.live-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 20px;
  background: #dcfce7; color: #15803d;
  font-size: 12px; font-weight: 600;
  border: 1px solid #bbf7d0;
}
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: #16a34a; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── BUTTONS ── */
.btn {
  padding: 7px 15px; border-radius: 8px;
  font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: all 0.15s; border: 1px solid transparent;
  display: inline-flex; align-items: center; gap: 6px;
  letter-spacing: -0.01em;
}
.btn-outline  { background: #fff; border-color: #e2e8f0; color: #334155; }
.btn-outline:hover  { border-color: #94a3b8; color: #0f172a; background: #f8fafc; }
.btn-primary  { background: linear-gradient(135deg, #2563eb, #1d4ed8); color: #fff; border-color: transparent; box-shadow: 0 2px 8px rgba(37,99,235,.25); }
.btn-primary:hover  { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,.35); }
.btn-danger   { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-danger:hover   { background: #b91c1c; }
.btn-ghost    { background: transparent; border-color: transparent; color: #64748b; }
.btn-ghost:hover    { background: #f1f5f9; color: #334155; }
.btn-sm       { padding: 5px 11px; font-size: 12px; border-radius: 7px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ── FILTER PILLS ── */
.filters { display: flex; gap: 4px; }
.filter {
  padding: 4px 11px; border-radius: 20px; border: 1px solid var(--gray-200);
  font-size: 12px; font-weight: 500; font-family: inherit;
  background: var(--white); color: var(--gray-500); cursor: pointer;
  transition: all 0.1s;
}
.filter.active          { background: var(--gray-900); color: #fff; border-color: var(--gray-900); }
.filter:hover:not(.active) { border-color: var(--gray-400); color: var(--gray-700); }

/* ── STATUS PILLS ── */
.pill { padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 500; display: inline-block; }
.pill-open       { background: #dcfce7; color: var(--green); }
.pill-resolved   { background: var(--gray-100); color: var(--gray-500); }
.pill-pending    { background: #fef9c3; color: var(--amber); }
.pill-lead       { background: #ede9fe; color: #7c3aed; }
.pill-active     { background: #dcfce7; color: var(--green); }
.pill-closed     { background: var(--gray-100); color: var(--gray-500); }
.pill-in_progress{ background: #dbeafe; color: var(--blue); }
.pill-urgent     { background: #fee2e2; color: var(--red); }
.pill-high       { background: #ffedd5; color: #c2410c; }
.pill-medium     { background: #fef9c3; color: var(--amber); }
.pill-low        { background: var(--gray-100); color: var(--gray-500); }
.pill-owner      { background: #dbeafe; color: var(--blue); }
.pill-admin      { background: #ede9fe; color: #7c3aed; }
.pill-agent      { background: var(--gray-100); color: var(--gray-600); }
.pill-pending-invite { background: #fef9c3; color: var(--amber); }

/* ── SEARCH BOX ── */
.search-box { position: relative; }
.search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: #94a3b8; pointer-events: none; }
.search-box input {
  width: 100%; padding: 8px 10px 8px 32px;
  border: 1.5px solid #e2e8f0; border-radius: 9px;
  background: #f8fafc; font-size: 13px; font-family: inherit;
  color: #0f172a; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.search-box input:focus { border-color: #2563eb; background: #fff; box-shadow: 0 0 0 3px rgba(37,99,235,.08); }
.search-box input::placeholder { color: #94a3b8; }

/* ── FORMS ── */
.form-group { margin-bottom: 14px; }
.form-label { font-size: 12px; font-weight: 600; color: #334155; margin-bottom: 5px; display: block; }
.form-input {
  width: 100%; padding: 9px 13px;
  border: 1.5px solid #e2e8f0; border-radius: 9px;
  font-size: 13px; font-family: inherit;
  color: #0f172a; background: #f8fafc; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.form-input:focus   { border-color: #2563eb; background: #fff; box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-select        { appearance: auto; padding-right: 8px; }
.form-textarea      { resize: vertical; min-height: 80px; }
.form-hint          { font-size: 11px; color: #94a3b8; margin-top: 4px; }
.form-row           { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.5); backdrop-filter: blur(6px);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.hidden { display: none !important; }
.modal-box {
  background: #fff;
  border-radius: 18px; padding: 26px;
  width: 100%; max-width: 480px;
  box-shadow: 0 32px 80px rgba(0,0,0,.22);
  border: 1px solid #eef0f4;
}
.modal-title   { font-size: 17px; font-weight: 700; color: #0f172a; margin-bottom: 20px; letter-spacing: -0.02em; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ── CARD ── */
.card {
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: 10px; padding: 16px;
}
.card-label { font-size: 10px; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 3px; }
.card-val   { font-size: 13px; font-weight: 500; color: var(--gray-700); }

/* ── AVATAR ── */
.avatar {
  border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; color: var(--gray-600); background: var(--gray-200);
}
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-md { width: 36px; height: 36px; font-size: 14px; }
.avatar-lg { width: 44px; height: 44px; font-size: 17px; }

/* ── TABLE ── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 10px 14px;
  font-size: 11px; font-weight: 600; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: 0.07em;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
}
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px; color: var(--gray-700);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--gray-50); }
.data-table tbody tr { cursor: pointer; }

/* ── EMPTY STATE ── */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 60px 20px; text-align: center;
  color: #94a3b8;
}
.empty-state svg { width: 42px; height: 42px; margin-bottom: 14px; color: #cbd5e1; }
.empty-state p   { font-size: 13px; font-weight: 500; color: #94a3b8; line-height: 1.6; }

/* ── SECTION HEADER ── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.section-title { font-size: 14px; font-weight: 600; color: var(--gray-900); }
.section-desc  { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

/* ── DIVIDER ── */
.divider { border: none; border-top: 1px solid var(--gray-200); margin: 20px 0; }

/* ── TOAST ── */
#toast-root {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 11px 16px; border-radius: 10px; border: 1px solid;
  font-size: 13px; font-weight: 500;
  animation: toast-slide 0.22s ease;
  max-width: 320px; pointer-events: all;
}
.toast-success { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.toast-error   { background: #fef2f2; border-color: #fecaca; color: var(--red); }
.toast-info    { background: #eff6ff; border-color: #bfdbfe; color: var(--blue); }
@keyframes toast-slide {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── COLOR SWATCH ── */
.color-swatch {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.1); flex-shrink: 0;
  display: inline-block;
}

/* ── SNIPPET PRE ── */
.snippet-pre {
  font-family: 'Courier New', monospace;
  font-size: 11px; line-height: 1.7;
  background: var(--gray-900); color: #93c5fd;
  padding: 12px; border-radius: 8px;
  white-space: pre-wrap; word-break: break-all;
}

/* ── MOBILE / RESPONSIVE ─────────────────────────────────────────────────── */

/* Sidebar overlay backdrop */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 399;
  background: rgba(0,0,0,0.45);
  cursor: pointer;
}
.sidebar-overlay.active { display: block; }

/* Hamburger button — hidden on desktop, shown on mobile */
.menu-btn {
  display: none;
  width: 36px; height: 36px; flex-shrink: 0;
  align-items: center; justify-content: center;
  border: 1px solid var(--gray-200); border-radius: 7px;
  background: var(--white); cursor: pointer;
  color: var(--gray-600);
}
.menu-btn:hover { background: var(--gray-50); }
.menu-btn svg   { width: 18px; height: 18px; }

/* Mobile back button — hidden on desktop */
.mobile-back-btn {
  display: none;
  align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: 7px; border: 1px solid var(--gray-200);
  background: var(--white); cursor: pointer;
  font-size: 12px; font-weight: 500; color: var(--gray-600);
  font-family: inherit; flex-shrink: 0;
}
.mobile-back-btn:hover { background: var(--gray-50); }
.mobile-back-btn svg   { width: 14px; height: 14px; }

@media (max-width: 768px) {
  /* Show mobile controls */
  .menu-btn        { display: flex; }
  .mobile-back-btn { display: flex; }

  /* Sidebar: slide in from left as overlay — must be above fixed chat panel (z:200) and customer drawer (z:501) */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 400;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(.4, 0, .2, 1);
  }
  .sidebar.is-open { transform: translateX(0); }

  /* Topbar: shrink padding */
  .topbar { padding: 0 12px; gap: 8px; }

  /* Page body: reduce padding */
  .page-body { padding: 16px; }

  /* Forms: single column on small screens */
  .form-row { grid-template-columns: 1fr; }

  /* Modal: full-width on small screens */
  .modal-box { padding: 18px; border-radius: 12px; }
}

/* Tablet: hide right panels (customer panel etc.) */
@media (max-width: 1100px) and (min-width: 769px) {
  /* Inner pages with 2-col layouts: tighten left column */
  .content[style*="300px"] { /* fallback handled per-page */ }
}
