/* ═══════════════════════════════════════════════════════════
   WA Gateway Panel — NiceAdmin Theme (Bootstrap 5)
   Base: NiceAdmin design system + Bootstrap 5
   ═══════════════════════════════════════════════════════════ */

:root {
  /* WA Colors */
  --wa-green: #128C7E;
  --wa-green-dark: #075E54;
  --wa-light: #25D366;

  /* NiceAdmin Colors */
  --na-primary: #4154f1;
  --na-secondary: #717ff5;
  --na-sidebar-bg: var(--wa-green-dark);
  --na-sidebar-color: rgba(255,255,255,0.82);
  --na-header-bg: #fff;
  --na-body-bg: #f6f9ff;

  /* Status Colors */
  --green: #1cc88a;
  --blue: #36b9cc;
  --yellow: #f6c23e;
  --red: #e74a3b;
  --purple: #6f42c1;

  /* Text */
  --text: #3a3b45;
  --text-muted: #858796;
  --text-bright: #1a1c23;

  /* Borders & Surfaces */
  --border: #e3e6f0;
  --bg-hover: #f8f9fc;
  --bg-surface: #ffffff;

  /* Semantic Lights */
  --green-light: #eaf7f0;
  --red-light: #fdecea;
  --blue-light: #eaf7fa;
  --yellow-light: #fdf6e3;

  /* Radius */
  --radius: 10px;
  --radius-sm: 6px;
  --radius-xs: 4px;

  /* Sidebar */
  --sidebar-width: 300px;
}

/* ─── Reset / Base ──────────────────────────────────────── */
body {
  font-family: 'Open Sans', 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--na-body-bg);
  color: var(--text);
}

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

.hidden { display: none !important; }

/* ─── WA Theme Colors ─────────────────────────────────────── */
.text-wa { color: var(--wa-green) !important; }
.text-wa-dark { color: var(--wa-green-dark) !important; }
.bg-wa { background-color: var(--wa-green) !important; }
.bg-wa-light { background-color: var(--green-light) !important; }

.btn-wa {
  color: #fff !important;
  background-color: var(--wa-green);
  border-color: var(--wa-green);
  font-weight: 700;
  border-radius: var(--radius-sm);
}
.btn-wa:hover, .btn-wa:focus {
  color: #fff;
  background-color: var(--wa-green-dark);
  border-color: var(--wa-green-dark);
}
.btn-wa:disabled { opacity: .65; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-bright); }
.btn-xs { padding: .15rem .45rem; font-size: .7rem; border-radius: .3rem; }

.badge-wa { background-color: var(--green-light) !important; color: var(--wa-green-dark) !important; }
.text-wa-logout { color: #ff8a80 !important; }

/* ─── NiceAdmin: Header ─────────────────────────────────── */
#header {
  transition: all 0.5s;
  z-index: 997;
  height: 60px;
  box-shadow: 0 2px 20px rgba(1,41,112,0.1);
  background-color: var(--na-header-bg);
  padding-left: 20px;
}

#header .logo {
  display: flex;
  align-items: center;
  line-height: 1;
  padding: 0;
  text-decoration: none;
}
#header .logo span {
  font-family: 'Nunito', sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--wa-green-dark);
  margin-left: 0.5rem;
}
#header .logo i {
  color: var(--wa-light);
  font-size: 1.5rem;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toggle-sidebar-btn {
  background: none;
  border: none;
  font-size: 1.35rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: color 0.2s;
  line-height: 1;
}
.toggle-sidebar-btn:hover { color: var(--wa-green); }

/* ─── NiceAdmin: Sidebar ───────────────────────────────── */
#sidebar {
  position: fixed;
  top: 60px;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  z-index: 996;
  transition: all 0.3s ease;
  padding: 20px 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
  background: linear-gradient(180deg, var(--wa-green-dark) 0%, var(--wa-green) 100%);
}

#sidebar::-webkit-scrollbar { width: 5px; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }

.sidebar-nav {
  padding: 0;
  margin: 0;
  list-style: none;
}

.sidebar-nav li { padding: 0 8px; }

.sidebar-nav .nav-item { margin-bottom: 2px; }

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--na-sidebar-color);
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  transition: all 0.2s ease;
  cursor: pointer;
  text-decoration: none;
  gap: 0.5rem;
  -webkit-tap-highlight-color: transparent;
}

.sidebar-nav .nav-link i {
  font-size: 1.05rem;
  width: 20px;
  text-align: center;
  color: rgba(255,255,255,0.75);
  flex-shrink: 0;
  transition: transform 0.2s ease, color 0.2s ease;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link:focus {
  color: #fff;
  background: rgba(255,255,255,0.1);
  transform: translateX(3px);
}
.sidebar-nav .nav-link:hover i { color: var(--wa-light); transform: scale(1.15); }

.sidebar-nav .nav-link.active {
  color: #fff !important;
  background: linear-gradient(90deg, rgba(37,211,102,0.22) 0%, rgba(255,255,255,0.06) 100%) !important;
  border-left: 4px solid var(--wa-light) !important;
  font-weight: 700 !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.sidebar-nav .nav-link.active i { color: var(--wa-light) !important; }

.sidebar-nav .nav-heading {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.09rem;
  text-transform: uppercase;
  color: rgba(255,255,255,0.45);
  padding: 10px 16px 6px;
}

/* WA Status badge dalam sidebar */
.wa-status-badge {
  background: rgba(0,0,0,.25);
  border-radius: 2rem;
  padding: .4rem 1rem;
  color: #fff;
  gap: .5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 10px 16px;
}

/* ─── NiceAdmin: Main Content ──────────────────────────── */
#main {
  margin-left: var(--sidebar-width);
  padding: 20px 30px;
  transition: all 0.3s ease;
  min-height: 100vh;
}

.pagetitle {
  padding: 10px 0 20px;
}
.pagetitle h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--wa-green-dark);
  margin-bottom: 0;
}
.pagetitle .breadcrumb {
  font-size: 0.78rem;
  margin-bottom: 0;
  padding: 0;
  background: transparent;
}
.pagetitle .breadcrumb a { color: var(--wa-green); }


/* ─── NiceAdmin: Sidebar Toggle ────────────────────────── */
body.toggle-sidebar #sidebar {
  left: calc(0px - var(--sidebar-width));
}
body.toggle-sidebar #main {
  margin-left: 0;
}

/* ─── NiceAdmin: Cards ──────────────────────────────────── */
.card {
  margin-bottom: 24px;
  border: none;
  border-radius: var(--radius);
  box-shadow: 0 0 30px rgba(1,41,112,0.07);
  background: var(--bg-surface);
}
.card-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius) var(--radius) 0 0 !important;
  font-weight: 700;
}
.card-header h5, .card-header h6 {
  font-weight: 700;
  color: var(--wa-green-dark);
  margin: 0;
}
.card-footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius) !important;
}

/* Stat Cards (Dashboard) */
.stat-card {
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 0 30px rgba(1,41,112,0.07);
  background: var(--bg-surface);
  border: none;
  margin-bottom: 24px;
}
.stat-card .stat-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-card .stat-info h6 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.stat-card .stat-info .stat-number {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-bright);
  line-height: 1;
}

.stat-icon.green { background: var(--green-light); color: var(--wa-green); }
.stat-icon.red   { background: var(--red-light);   color: var(--red); }
.stat-icon.blue  { background: var(--blue-light);  color: #0e7490; }
.stat-icon.yellow{ background: var(--yellow-light);color: #8a6d00; }

/* ─── Login Screen ────────────────────────────────────────── */
.wa-login-screen {
  position: fixed;
  inset: 0;
  z-index: 2500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--wa-green-dark) 0%, var(--wa-green) 55%, var(--wa-light) 100%);
  overflow-y: auto;
  padding: 20px 0;
}
.wa-login-card { border-radius: 1rem; border: none; }
.wa-login-icon {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--green-light);
  color: var(--wa-green);
  font-size: 2.2rem;
  display: flex; align-items: center; justify-content: center;
}

/* ─── Page Switching ──────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; animation: waFadeIn .25s ease; }
@keyframes waFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ─── Status Dots & Pills ─────────────────────────────────── */
.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  background: #b7b9cc;
  flex-shrink: 0;
}
.status-dot.connected    { background: var(--green); box-shadow: 0 0 0 3px rgba(28,200,138,.25); }
.status-dot.disconnected { background: #b7b9cc; }
.status-dot.connecting   { background: var(--blue);  animation: waPulse 1s infinite; }
.status-dot.qr_pending   { background: var(--yellow); animation: waPulse 1.2s infinite; }
.status-dot.banned       { background: var(--red);   box-shadow: 0 0 0 3px rgba(231,74,59,.25); }
@keyframes waPulse { 50% { opacity: .35; } }

.connection-pill {
  display: flex; align-items: center; gap: .45rem;
  padding: .3rem .85rem;
  border-radius: 2rem;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
}
.connection-pill.connected   { background: var(--green-light); border-color: var(--green); color: var(--wa-green-dark); }
.connection-pill.banned      { background: var(--red-light);   border-color: var(--red); color: var(--red); }
.connection-pill.qr_pending,
.connection-pill.connecting  { background: var(--yellow-light); border-color: var(--yellow); color: #8a6d00; }

.status-badge-big {
  display: inline-flex; align-items: center; gap: .6rem;
  padding: .6rem 1.4rem;
  border-radius: 2rem;
  font-size: 1rem;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.status-badge-big.connected  { background: var(--green-light); border-color: var(--green); color: var(--wa-green-dark); }
.status-badge-big.banned     { background: var(--red-light);   border-color: var(--red); color: var(--red); }
.status-badge-big.qr_pending,
.status-badge-big.connecting { background: var(--yellow-light); border-color: var(--yellow); color: #8a6d00; }

.user-avatar {
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--green-light);
  color: var(--wa-green-dark);
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* ─── Log Console ─────────────────────────────────────────── */
.log-container {
  max-height: 420px;
  min-height: 220px;
  overflow-y: auto;
  padding: 14px 18px;
  background: #10131a;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.9;
  border-radius: 0 0 var(--radius) var(--radius);
}
.log-entry { color: #d1d5db; word-break: break-word; }
.log-time { color: #6b7280; margin-right: 6px; }
.log-empty { color: #6b7280; }
.log-container::-webkit-scrollbar { width: 8px; }
.log-container::-webkit-scrollbar-thumb { background: #374151; border-radius: 4px; }

/* ─── QR Area ─────────────────────────────────────────────── */
.qr-wrapper {
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 0;
}
.qr-placeholder {
  width: 260px; height: 260px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 2px dashed var(--border);
  border-radius: 12px;
  gap: 10px;
}
.qr-card-container {
  position: relative;
  width: 260px; height: 260px;
  padding: 10px;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 .35rem 1rem rgba(0,0,0,.12);
  overflow: hidden;
}
.qr-image { width: 100%; height: 100%; image-rendering: pixelated; }
.qr-scanner-line {
  position: absolute; left: 8%; right: 8%;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--wa-light), transparent);
  border-radius: 2px;
  animation: waScan 2.4s ease-in-out infinite;
}
@keyframes waScan { 0%, 100% { top: 10%; } 50% { top: 88%; } }
.qr-connected-info { text-align: center; }
.qr-connected-avatar { position: relative; width: 84px; height: 84px; margin: 0 auto 10px; }
.qr-connected-avatar img {
  width: 84px; height: 84px; border-radius: 50%; object-fit: cover;
  border: 3px solid var(--wa-light);
}
.qr-connected-avatar-fallback {
  width: 84px; height: 84px; border-radius: 50%;
  background: var(--green-light); color: var(--wa-green);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
}
.qr-connected-name { font-weight: 800; margin-bottom: 2px; color: var(--text-bright); }
.qr-connected-number { color: var(--text-muted); font-family: 'JetBrains Mono', monospace; margin-bottom: 8px; }

/* ─── WhatsApp Preview Bubble ─────────────────────────────── */
.wa-preview-container { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.wa-preview-header {
  background: var(--bg-hover);
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.wa-chat-box {
  background: #e5ddd5;
  background-image: radial-gradient(rgba(0,0,0,.035) 1px, transparent 1px);
  background-size: 14px 14px;
  padding: 22px 16px;
  min-height: 220px;
  display: flex;
  justify-content: flex-end;
}
.wa-bubble {
  max-width: 85%;
  background: #d9fdd3;
  border-radius: 10px 10px 0 10px;
  padding: 10px 12px;
  font-size: 13.5px;
  color: #111b21;
  box-shadow: 0 1px 1px rgba(0,0,0,.15);
  word-break: break-word;
}
.wa-bubble-img { max-width: 100%; border-radius: 8px; margin-bottom: 6px; }
.wa-bubble-footer {
  display: flex; justify-content: flex-end; gap: 6px;
  font-size: 11px; color: #667781;
  margin-top: 4px;
}
.wa-ticks { color: #53bdeb; }

/* ─── Device Grid ─────────────────────────────────────────── */
.device-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}
.device-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--bg-surface);
  transition: box-shadow .15s, border-color .15s;
}
.device-card.active-device {
  border-color: var(--wa-green);
  box-shadow: 0 0 0 3px rgba(18,140,126,.15);
}
.device-card-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.device-name { font-weight: 800; color: var(--text-bright); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-badge {
  font-size: 10.5px; font-weight: 700;
  padding: 3px 10px; border-radius: 2rem;
  background: var(--bg-hover); color: var(--text-muted);
  white-space: nowrap;
}
.device-badge.connected  { background: var(--green-light); color: var(--wa-green-dark); }
.device-badge.qr_pending { background: var(--yellow-light); color: #8a6d00; }
.device-badge.banned     { background: var(--red-light);    color: var(--red); }
.device-phone { font-size: 12.5px; color: var(--text-muted); margin-bottom: 10px; font-family: 'JetBrains Mono', monospace; }
.device-apikey-box {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  margin-bottom: 10px;
}
.device-apikey-box code { color: var(--wa-green); background: transparent; }
.device-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ─── Feature List ────────────────────────────────────────── */
.feature-list { list-style: none; padding: 0; margin: 0; }
.feature-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 0;
  color: var(--text);
  font-size: 13.5px;
}
.feature-list .check {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--green-light);
  color: var(--wa-green);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px;
  flex-shrink: 0;
}

/* ─── Toggle Switch ───────────────────────────────────────── */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
}
.toggle-info { text-align: left; }
.toggle-info strong { font-size: 14px; color: var(--text-bright); }
.toggle-info small { font-size: 12px; }
.toggle-switch { position: relative; display: inline-block; flex-shrink: 0; margin: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  display: block;
  width: 46px; height: 24px;
  border-radius: 2rem;
  background: #d1d3e2;
  transition: background .2s;
  cursor: pointer;
  position: relative;
}
.toggle-track::after {
  content: '';
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .2s;
}
.toggle-switch input:checked + .toggle-track { background: var(--wa-green); }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(22px); }

/* ─── Queue Progress ──────────────────────────────────────── */
.queue-progress-bar { display: flex; align-items: center; gap: 12px; }
.progress-track {
  flex: 1; height: 10px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 2rem;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--wa-green), var(--wa-light));
  border-radius: 2rem;
  transition: width .4s ease;
}
.progress-label { white-space: nowrap; }

/* ─── Collapsible (Add Contact) ───────────────────────────── */
.collapsible { display: none; }
.collapsible.open { display: block; animation: waFadeIn .2s ease; }

/* ─── Misc Components ─────────────────────────────────────── */
.form-hint { display: block; font-size: 11.5px; margin-top: 4px; }
.char-counter { font-size: 11.5px; margin-top: 4px; }
.number-count-badge { font-size: 11px; }
.blast-preview {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--green-light);
  border: 1px solid var(--wa-green);
  border-radius: 8px;
  padding: 14px 18px;
  font-size: 13.5px;
  color: var(--wa-green-dark);
}
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-row { text-align: center; }

.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: waSpin .7s linear infinite;
  vertical-align: -3px;
}
.spinner-sm { width: 13px; height: 13px; }
@keyframes waSpin { to { transform: rotate(360deg); } }

/* ─── Status Badges (queue/history) ───────────────────────── */
.badge-sent    { background: var(--green-light);  color: var(--wa-green-dark); border: 1px solid var(--green); }
.badge-failed  { background: var(--red-light);    color: var(--red);           border: 1px solid var(--red); }
.badge-queued  { background: var(--bg-hover);     color: var(--text-muted);    border: 1px solid var(--border); }
.badge-sending { background: var(--blue-light);   color: #0e7490;              border: 1px solid var(--blue); }
.badge-received{ background: var(--yellow-light); color: #8a6d00;              border: 1px solid var(--yellow); }

/* ─── Alert overrides ─────────────────────────────────────── */
.alert-error {
  color: #721c24;
  background-color: #f8d7da;
  border: 1px solid #f5c6cb;
  border-radius: var(--radius-sm);
  padding: .75rem 1.25rem;
}

/* ─── Markdown Docs ───────────────────────────────────────── */
.markdown-body { line-height: 1.65; color: var(--text); padding: 6px; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 {
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-top: 24px;
  color: var(--wa-green-dark);
  font-weight: 700;
}
.markdown-body pre {
  background: var(--bg-hover);
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow-x: auto;
  font-family: 'JetBrains Mono', monospace;
}
.markdown-body code {
  background: var(--bg-hover);
  padding: 3px 8px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--purple);
  font-size: 13px;
}
.markdown-body a { color: var(--wa-green); text-decoration: none; font-weight: 600; }
.markdown-body table { border-collapse: collapse; margin: 12px 0; }
.markdown-body table td, .markdown-body table th { border: 1px solid var(--border); padding: 6px 12px; }

/* ─── NiceAdmin: Back to Top ──────────────────────────────── */
.back-to-top {
  position: fixed;
  visibility: hidden;
  opacity: 0;
  right: 15px;
  bottom: 15px;
  z-index: 99999;
  background: var(--wa-green);
  width: 40px;
  height: 40px;
  border-radius: 4px;
  transition: all 0.4s;
  color: #fff;
  font-size: 1.2rem;
}
.back-to-top.active { visibility: visible; opacity: 1; }
.back-to-top:hover { background: var(--wa-green-dark); color: #fff; }

/* ─── NiceAdmin: Sidebar Overlay (mobile) ─────────────────── */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11,15,25,0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 995;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  cursor: pointer;
}
body.sidebar-open .sidebar-backdrop { opacity: 1; visibility: visible; }

/* ─── Dark Theme Overrides ────────────────────────────────── */
[data-theme="dark"] {
  --text: #d1d5db;
  --text-muted: #9ca3af;
  --text-bright: #f9fafb;
  --border: #2d3140;
  --bg-hover: #232734;
  --bg-surface: #1e222d;
  --na-body-bg: #171a21;
  --na-header-bg: #1e222d;
  --green-light: rgba(28,200,138,.12);
  --red-light: rgba(231,74,59,.12);
  --blue-light: rgba(54,185,204,.12);
  --yellow-light: rgba(246,194,62,.12);
}

[data-theme="dark"] body { background-color: #171a21; }
[data-theme="dark"] #header { background: #1e222d; box-shadow: 0 2px 20px rgba(0,0,0,0.3); }
[data-theme="dark"] #header .logo span { color: var(--wa-light); }
[data-theme="dark"] .toggle-sidebar-btn { color: #9ca3af; }
[data-theme="dark"] #main { background: #171a21; }
[data-theme="dark"] .card { background-color: #1e222d; }
[data-theme="dark"] .card-header, [data-theme="dark"] .card-footer { background-color: #232734 !important; border-color: #2d3140 !important; }
[data-theme="dark"] .stat-card { background: #1e222d; }
[data-theme="dark"] .pagetitle h1 { color: var(--wa-light); }
[data-theme="dark"] .form-control, [data-theme="dark"] .form-select {
  background-color: #232734;
  border-color: #2d3140;
  color: #e5e7eb;
}
[data-theme="dark"] .form-control:focus, [data-theme="dark"] .form-select:focus { background-color: #232734; color: #e5e7eb; }
[data-theme="dark"] .form-control::placeholder { color: #6b7280; }
[data-theme="dark"] .table { color: #d1d5db; }
[data-theme="dark"] .table td, [data-theme="dark"] .table th { border-color: #2d3140; }
[data-theme="dark"] .table thead th { border-bottom-color: #2d3140; color: #9ca3af; }
[data-theme="dark"] .table-hover tbody tr:hover { background-color: rgba(255,255,255,.04); }
[data-theme="dark"] .bg-light { background-color: #232734 !important; }
[data-theme="dark"] .border { border-color: #2d3140 !important; }
[data-theme="dark"] .input-group-text { background: #232734; border-color: #2d3140; color: #9ca3af; }
[data-theme="dark"] .connection-pill { background: #232734; border-color: #2d3140; }
[data-theme="dark"] .status-badge-big { background: #232734; border-color: #2d3140; }
[data-theme="dark"] .qr-card-container { background: #fff; }
[data-theme="dark"] .btn-ghost { border-color: #2d3140; color: #9ca3af; }
[data-theme="dark"] .btn-ghost:hover { background: #232734; color: #e5e7eb; }
[data-theme="dark"] .btn-outline-secondary { color: #9ca3af; border-color: #2d3140; }
[data-theme="dark"] .btn-outline-secondary:hover { background: #232734; color: #e5e7eb; }
[data-theme="dark"] .markdown-body { color: #d1d5db; }
[data-theme="dark"] .markdown-body h1, [data-theme="dark"] .markdown-body h2, [data-theme="dark"] .markdown-body h3 { color: var(--wa-light); }
[data-theme="dark"] .toggle-info strong { color: #e5e7eb; }
[data-theme="dark"] .device-card { background: #232734; }
[data-theme="dark"] .device-name { color: #e5e7eb; }
[data-theme="dark"] .alert-success { background: rgba(28,200,138,.15); color: #7ee2b8; border-color: rgba(28,200,138,.4); }
[data-theme="dark"] .alert-info    { background: rgba(54,185,204,.15); color: #93e2ec; border-color: rgba(54,185,204,.4); }
[data-theme="dark"] .alert-error   { background: #3b1219; color: #f5b5bd; border-color: #5c1a24; }
[data-theme="dark"] .back-to-top   { background: var(--wa-green); }
[data-theme="dark"] .clock-display { color: #9ca3af; }
[data-theme="dark"] .wa-preview-header { background: #232734; border-color: #2d3140; }
[data-theme="dark"] .wa-preview-container { border-color: #2d3140; }
[data-theme="dark"] .breadcrumb-item.active { color: #9ca3af; }

/* ─── Responsive (Desktop mini sidebar via toggle) ─────────── */
@media (min-width: 1200px) {
  /* optional: keep sidebar always visible by default, nothing extra needed */
}

@media (max-width: 1199px) {
  /* Sidebar off-canvas on tablet and below */
  #sidebar {
    left: calc(0px - var(--sidebar-width));
  }
  #main {
    margin-left: 0;
  }
  body.toggle-sidebar #sidebar {
    left: 0;
  }
  body.toggle-sidebar .sidebar-backdrop {
    opacity: 1;
    visibility: visible;
  }
}

/* ─── Responsive: Tablet ──────────────────────────────────── */
@media (max-width: 767.98px) {
  #main { padding: 15px 15px; }
  .truncate { max-width: 140px; }
  .wa-chat-box { min-height: 160px; }
  .toggle-row { flex-wrap: wrap; gap: 10px; }
  .toggle-info { flex: 1 1 220px; min-width: 0; }
  .device-apikey-box { overflow-x: auto; }
  .device-apikey-box code { white-space: nowrap; }
  .pagetitle h1 { font-size: 1.1rem; }
  .topbar-info-bar #clock { display: none !important; }
}

/* ─── Responsive: Mobile ──────────────────────────────────── */
@media (max-width: 575.98px) {
  #main { padding: 10px 12px; }
  .wa-login-card .card-body { padding: 1.6rem 1.1rem !important; }
  .card-header.d-flex.justify-content-between {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }
  .card-header.d-flex.justify-content-between > *:last-child:not(input):not(a) {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .card-header input.w-auto { width: 100% !important; }
  .topbar-info-bar #topbarStatus { display: none !important; }
  .connection-pill { padding: 0.3rem 0.65rem; }
  .btn-lg { width: 100%; margin: 0.25rem 0; }
  .blast-preview { padding: 12px 14px; }
  .status-badge-big { font-size: 0.85rem; padding: 0.5rem 1rem; }
  .wa-bubble { max-width: 95%; }
  .markdown-body { padding: 0; }
  .markdown-body pre { max-width: 100%; }

  /* Dashboard stats 2 kolom */
  #page-dashboard .row > [class*="col-xl-3"],
  #page-dashboard .row > [class*="col-md-6"] {
    flex: 0 0 50%;
    max-width: 50%;
  }
}

/* ─── AI Chat Page Styling ─────────────────────────────────── */
.ai-chat-box {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background-color: #efeae2 !important;
  background-image: radial-gradient(#d1d7db 1px, transparent 1px);
  background-size: 16px 16px;
}

.ai-msg-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  width: 100%;
}

.ai-msg-row.user {
  justify-content: flex-end;
}

.ai-msg-row.bot {
  justify-content: flex-start;
}

.ai-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.ai-avatar.bot {
  background-color: #128C7E;
  color: white;
}

.ai-avatar.user {
  background-color: #4154f1;
  color: white;
}

.ai-bubble {
  position: relative;
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.ai-bubble.user {
  background-color: #d9fdd3;
  color: #111b21;
  border-top-right-radius: 2px;
}

.ai-bubble.bot {
  background-color: #ffffff;
  color: #111b21;
  border-top-left-radius: 2px;
  border: 1px solid #e9edef;
}

.ai-bubble pre {
  background-color: #1e1e1e;
  color: #d4d4d4;
  padding: 10px 12px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 12px;
  margin: 8px 0;
}

.ai-bubble code {
  font-family: 'JetBrains Mono', Consolas, monospace;
}

.ai-bubble p:last-child {
  margin-bottom: 0;
}

.ai-msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
  font-size: 10px;
  color: #667781;
}

.ai-copy-btn {
  background: transparent;
  border: none;
  color: #667781;
  font-size: 11px;
  padding: 0 4px;
  cursor: pointer;
  border-radius: 3px;
}

.ai-copy-btn:hover {
  color: #128C7E;
  background-color: rgba(0,0,0,0.05);
}
