/* =========================================================
   Broadcast — Design System
   Palette: cool light neutrals, deep emerald primary,
   muted indigo secondary. Inter for UI, JetBrains Mono
   for IDs/numbers/codes (data-heavy ERP context).
   ========================================================= */

:root {
  --bg: #F5F7F8;
  --surface: #FFFFFF;
  --surface-2: #FAFBFC;
  --border: #E7EAEE;
  --border-strong: #D7DCE2;

  --text: #16211E;
  --text-muted: #6B7680;
  --text-faint: #9AA3AC;

  --primary: #0F6B58;
  --primary-dark: #0A4E40;
  --primary-light: #E6F3EF;
  --primary-soft: #D1EAE2;

  --accent: #3E5BA6;
  --accent-light: #EAEEF8;

  --success: #1E9D63;
  --success-light: #E5F6ED;
  --warning: #C77D19;
  --warning-light: #FBF0E1;
  --danger: #D64545;
  --danger-light: #FBEAEA;
  --info: #3E5BA6;
  --info-light: #EAEEF8;
  --purple: #7C5CBF;
  --purple-light: #F1ECFA;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 22, 0.04);
  --shadow: 0 2px 8px rgba(16, 24, 22, 0.06), 0 1px 2px rgba(16,24,22,0.04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 22, 0.10);

  --sidebar-w: 248px;
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
}

code, .mono, .table td.mono {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.85em;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ---------- Topbar ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 64px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar .navbar-brand {
  color: var(--text) !important;
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
}

.topbar .navbar-brand i {
  color: var(--primary);
  background: var(--primary-light);
  padding: 7px;
  border-radius: 10px;
  font-size: 0.95rem;
}

.sidebar-toggle-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  margin-right: 8px;
}
.sidebar-toggle-btn:hover { background: var(--surface-2); color: var(--text); }

.topbar-search { position: relative; width: 320px; }
.topbar-search input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px 8px 36px;
  font-size: 0.87rem;
  width: 100%;
  color: var(--text);
}
.topbar-search input:focus { outline: none; border-color: var(--primary); background: var(--surface); }
.topbar-search i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-faint); font-size: 0.85rem; }

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.user-chip .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.8rem;
}
.user-chip .name { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.user-chip .role { font-size: 0.72rem; color: var(--text-muted); }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  min-height: calc(100vh - 64px);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  flex-shrink: 0;
  transition: margin-left 0.2s ease;
}
.sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-w)); }

.sidebar .nav-section-label {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-faint);
  padding: 6px 12px; margin-top: 10px;
}

.sidebar .nav-link {
  color: var(--text-muted); font-weight: 500; font-size: 0.9rem;
  border-radius: var(--radius-sm); padding: 9px 12px; margin-bottom: 2px;
  display: flex; align-items: center; gap: 10px;
  transition: background 0.12s, color 0.12s;
}
.sidebar .nav-link i { width: 18px; text-align: center; color: var(--text-faint); font-size: 0.92rem; }
.sidebar .nav-link:hover { background: var(--surface-2); color: var(--text); }
.sidebar .nav-link.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }
.sidebar .nav-link.active i { color: var(--primary); }

/* ---------- Content ---------- */
.content-area { min-height: calc(100vh - 64px); padding: 28px 32px; }

.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-header h4 { margin-bottom: 2px; font-size: 1.35rem; }
.page-header .subtitle { color: var(--text-muted); font-size: 0.88rem; }

/* ---------- Cards ---------- */
.card { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); background: var(--surface); }
.card-header { background: transparent; border-bottom: 1px solid var(--border); font-weight: 650; font-size: 0.92rem; padding: 14px 18px; }
.card-body { padding: 18px; }

/* ---------- Stat cards ---------- */
.stat-card {
  border-radius: var(--radius); padding: 18px 20px;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat-card .stat-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; margin-bottom: 12px;
}
.stat-card .stat-value { font-size: 1.7rem; font-weight: 700; font-family: 'JetBrains Mono', monospace; line-height: 1; color: var(--text); }
.stat-card .stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }
.stat-card .stat-trend { font-size: 0.74rem; font-weight: 600; padding: 2px 7px; border-radius: 999px; position: absolute; top: 18px; right: 18px; }
.stat-trend.up { background: var(--success-light); color: var(--success); }
.stat-trend.down { background: var(--danger-light); color: var(--danger); }

.stat-icon.emerald { background: var(--primary-light); color: var(--primary); }
.stat-icon.indigo { background: var(--info-light); color: var(--info); }
.stat-icon.amber { background: var(--warning-light); color: var(--warning); }
.stat-icon.rose { background: var(--danger-light); color: var(--danger); }
.stat-icon.violet { background: var(--purple-light); color: var(--purple); }

/* ---------- Tables ---------- */
.table { margin-bottom: 0; font-size: 0.87rem; }
.table thead th {
  background: var(--surface-2); color: var(--text-muted); font-weight: 600;
  font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border); padding: 11px 14px; white-space: nowrap;
}
.table td { padding: 11px 14px; vertical-align: middle; border-bottom: 1px solid var(--border); color: var(--text); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }

/* ---------- Badges ---------- */
.badge { font-weight: 600; font-size: 0.72rem; padding: 4px 9px; border-radius: 999px; }
.badge-soft-success { background: var(--success-light); color: var(--success); }
.badge-soft-warning { background: var(--warning-light); color: var(--warning); }
.badge-soft-danger { background: var(--danger-light); color: var(--danger); }
.badge-soft-info { background: var(--info-light); color: var(--info); }
.badge-soft-gray { background: #EEF0F2; color: var(--text-muted); }

.badge-status-sent { background: var(--info-light); color: var(--info); }
.badge-status-delivered { background: var(--success-light); color: var(--success); }
.badge-status-read { background: var(--purple-light); color: var(--purple); }
.badge-status-failed { background: var(--danger-light); color: var(--danger); }
.badge-status-queued { background: #EEF0F2; color: var(--text-muted); }

/* ---------- Buttons ---------- */
.btn { border-radius: var(--radius-sm); font-weight: 600; font-size: 0.86rem; padding: 8px 16px; }
.btn-success { background: var(--primary); border-color: var(--primary); }
.btn-success:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline-secondary { border-color: var(--border-strong); color: var(--text-muted); }
.btn-outline-secondary:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn-sm { padding: 5px 11px; font-size: 0.78rem; }

/* ---------- Forms ---------- */
.form-control, .form-select {
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 0.88rem; padding: 9px 12px; background: var(--surface);
}
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.form-label { font-weight: 600; font-size: 0.83rem; color: var(--text); margin-bottom: 6px; }
.form-text { font-size: 0.78rem; color: var(--text-muted); }

/* ---------- Alerts ---------- */
.alert { border-radius: var(--radius); border: 1px solid transparent; font-size: 0.85rem; }
.alert-info { background: var(--info-light); color: var(--accent); border-color: #D6DEF0; }
.alert-success { background: var(--success-light); color: #146B44; }
.alert-danger { background: var(--danger-light); color: #A62F2F; }

/* ---------- Toasts ---------- */
.toast-stack { position: fixed; top: 76px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; }
.toast-item {
  min-width: 280px; max-width: 360px; background: var(--surface);
  border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  padding: 12px 14px; font-size: 0.85rem;
  display: flex; align-items: flex-start; gap: 10px;
  animation: toastIn 0.18s ease-out;
}
.toast-item.danger { border-left-color: var(--danger); }
.toast-item.success { border-left-color: var(--success); }
.toast-item i { margin-top: 2px; }
.toast-item .toast-close { margin-left: auto; cursor: pointer; color: var(--text-faint); border: none; background: none; }
@keyframes toastIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }

/* ---------- WhatsApp bubble preview (signature element) ---------- */
.wa-preview {
  background: #E9EDE3;
  border-radius: var(--radius);
  padding: 20px 16px;
  min-height: 160px;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.wa-bubble {
  background: #fff; border-radius: 0 10px 10px 10px;
  padding: 9px 11px 16px; max-width: 88%;
  font-size: 0.85rem; line-height: 1.45; color: #1a1a1a;
  box-shadow: 0 1px 1px rgba(0,0,0,0.08);
  position: relative; white-space: pre-wrap; word-break: break-word;
}
.wa-bubble .wa-time { position: absolute; bottom: 5px; right: 9px; font-size: 0.68rem; color: #8b9a8b; }
.wa-bubble .wa-var { background: var(--primary-soft); color: var(--primary-dark); padding: 1px 4px; border-radius: 4px; font-weight: 600; }

/* ---------- Login ---------- */
.login-wrapper {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #0A4E40 0%, #0F6B58 45%, #14806A 100%);
  padding: 20px;
}
.login-card { border-radius: var(--radius-lg); width: 400px; border: none; box-shadow: var(--shadow-lg); padding: 8px; }
.login-card .brand-icon {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; margin: 0 auto 14px;
}

/* ---------- Empty states ---------- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state i { font-size: 2rem; color: var(--text-faint); margin-bottom: 10px; display: block; }

/* ---------- Misc ---------- */
.divider-y { border-left: 1px solid var(--border); height: 24px; }
.progress-thin { height: 6px; border-radius: 999px; background: var(--surface-2); }
.progress-thin .progress-bar { border-radius: 999px; background: var(--primary); }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 64px; z-index: 50; margin-left: calc(-1 * var(--sidebar-w)); }
  .sidebar.show { margin-left: 0; box-shadow: var(--shadow-lg); }
  .content-area { padding: 20px; }
  .topbar-search { display: none; }
}
