:root {
  --sidebar-width: 250px;
  --brand: #0d6efd;
  --brand-dark: #0a58ca;
  --surface: #f4f6f9;
}

[data-bs-theme="dark"] {
  --surface: #1a1d21;
}

body {
  background: var(--surface);
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bs-body-bg);
  position: sticky;
  top: 0;
  flex-shrink: 0;
  transition: margin-left .2s ease;
}

.sidebar-logo {
  max-height: 40px;
  max-width: 100%;
}

.sidebar .nav-link {
  color: var(--bs-body-color);
  border-radius: .5rem;
  margin-bottom: .15rem;
  padding: .55rem .75rem;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
  background: rgba(13, 110, 253, .12);
  color: var(--brand);
}

.sidebar.collapsed {
  margin-left: calc(var(--sidebar-width) * -1);
}

#page-content {
  min-width: 0;
}

.stat-card {
  border: 0;
  border-radius: .75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

.stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.table-card {
  border: 0;
  border-radius: .75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  overflow: hidden;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  background:
    radial-gradient(ellipse at top left, rgba(13,110,253,.15), transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(25,135,84,.12), transparent 50%),
    var(--surface);
}

.login-card {
  border: 0;
  border-radius: 1rem;
  box-shadow: 0 8px 30px rgba(0,0,0,.08);
}

.badge-due-soon { background: #ffc107; color: #212529; }

@media (max-width: 991.98px) {
  .sidebar {
    position: fixed;
    z-index: 1040;
    margin-left: calc(var(--sidebar-width) * -1);
  }
  .sidebar.show {
    margin-left: 0;
  }
}

.customer-portal {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.wa-float {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1050;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #25d366;
  color: #fff;
  font-size: 1.5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
  text-decoration: none;
}
.wa-float:hover { color: #fff; transform: scale(1.05); }

/* Ticket chat */
.ticket-chat-card {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 180px);
  min-height: 480px;
}
.ticket-chat-body {
  flex: 1;
  overflow-y: auto;
  background:
    radial-gradient(circle at 1px 1px, rgba(0,0,0,.04) 1px, transparent 0);
  background-size: 16px 16px;
  padding: 1rem !important;
}
[data-bs-theme="dark"] .ticket-chat-body {
  background:
    radial-gradient(circle at 1px 1px, rgba(255,255,255,.05) 1px, transparent 0);
  background-size: 16px 16px;
}
.chat-row {
  display: flex;
  margin-bottom: .75rem;
}
.chat-row-staff { justify-content: flex-end; }
.chat-row-customer { justify-content: flex-start; }
.chat-bubble {
  max-width: min(85%, 520px);
  border-radius: .85rem;
  padding: .65rem .9rem;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.bubble-staff, .bubble-mine {
  background: #0d6efd;
  color: #fff;
  border-bottom-right-radius: .25rem;
}
.bubble-staff .chat-meta,
.bubble-mine .chat-meta { color: rgba(255,255,255,.8); }
.bubble-customer, .bubble-support {
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-bottom-left-radius: .25rem;
}
.chat-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: .72rem;
  margin-bottom: .25rem;
}
.chat-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: .95rem;
}
.font-monospace { letter-spacing: .03em; }

.chat-bubble.chat-new {
  animation: chatIn .25s ease-out;
}
@keyframes chatIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
#chatLiveDot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #198754;
  display: inline-block;
  margin-right: .35rem;
  vertical-align: middle;
}
#chatLiveDot.pulse {
  box-shadow: 0 0 0 0 rgba(25, 135, 84, .6);
  animation: livePulse .8s ease-out;
}
@keyframes livePulse {
  to { box-shadow: 0 0 0 10px rgba(25, 135, 84, 0); }
}

