@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ==========================================================================
   ENTERPRISE DESIGN SYSTEM & TOKENS
   Crafted with precision: Modern SaaS, Glassmorphism, WhatsApp Emerald Theme
   ========================================================================== */

:root {
  /* Core Palette - WhatsApp Business Inspired */
  --wa-emerald: #10b981;
  --wa-emerald-deep: #059669;
  --wa-emerald-light: #ecfdf5;
  --wa-emerald-glow: rgba(16, 185, 129, 0.25);
  
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-gradient: linear-gradient(135deg, #10b981 0%, #047857 100%);
  --primary-glow: 0 4px 20px -2px rgba(16, 185, 129, 0.35);

  --accent-blue: #3b82f6;
  --accent-blue-hover: #2563eb;
  --accent-indigo: #6366f1;
  --accent-purple: #8b5cf6;

  /* Surfaces & Canvas */
  --bg-color: #f8fafc;
  --bg-subtle: #f1f5f9;
  --sidebar-bg: #ffffff;
  --sidebar-border: #e2e8f0;
  --card-bg: #ffffff;
  --card-bg-elevated: #ffffff;

  /* Typography */
  --text-main: #0f172a;
  --text-body: #334155;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  /* Borders & Dividers */
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;
  --border-focus: #10b981;

  /* Semantic Alerts */
  --success: #10b981;
  --success-bg: #dcfce7;
  --success-text: #15803d;

  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-bg: #fee2e2;
  --danger-text: #b91c1c;

  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --warning-text: #b45309;

  --info: #0284c7;
  --info-bg: #e0f2fe;
  --info-text: #0369a1;

  /* Secondary & Neutral Elements */
  --secondary: #f8fafc;
  --secondary-hover: #f1f5f9;

  /* Shadows - Elevation Hierarchy */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 2px 6px -1px rgba(15, 23, 42, 0.05), 0 1px 3px -1px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 6px 16px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 16px 32px -4px rgba(15, 23, 42, 0.08), 0 4px 12px -2px rgba(15, 23, 42, 0.03);
  --shadow-xl: 0 24px 48px -12px rgba(15, 23, 42, 0.16);
  --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.03);

  /* Radii */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Layout dimensions */
  --topbar-height: 70px;
  --sidebar-width: 270px;
}

/* ==========================================================================
   RESET & GLOBAL BASE STYLES
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Selection */
::selection {
  background: rgba(16, 185, 129, 0.2);
  color: #065f46;
}

/* ==========================================================================
   TOPBAR COMPONENT
   ========================================================================== */

.topbar {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: var(--topbar-height);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 4px 20px -5px rgba(15, 23, 42, 0.03);
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text-main);
  letter-spacing: -0.02em;
  user-select: none;
}

.wa-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.wa-icon:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(37, 211, 102, 0.45);
}

.wa-icon svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}

.topbar-badge {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

#userBalance {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #0f172a !important;
  font-weight: 700;
  padding-right: 12px;
  border-right: 1px solid #e2e8f0;
}

#userBalance::before {
  content: '💳';
  font-size: 14px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  position: relative;
}

.dot-green {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
  animation: pulseGreen 2s infinite ease-in-out;
}

@keyframes pulseGreen {
  0%, 100% {
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.1);
  }
}

.topbar-badge button {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: #475569 !important;
  font-weight: 600 !important;
  padding: 5px 12px !important;
  border-radius: var(--radius-sm) !important;
  font-size: 12px !important;
  cursor: pointer;
  transition: all 0.2s ease !important;
}

.topbar-badge button:hover {
  background: #fee2e2 !important;
  color: #dc2626 !important;
  border-color: #fca5a5 !important;
}

/* Impersonation Banner */
#impersonationBanner {
  background: linear-gradient(90deg, #1e40af 0%, #3b82f6 100%) !important;
  color: white !important;
  padding: 10px 20px !important;
  text-align: center !important;
  font-weight: 600 !important;
  font-size: 13px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(30, 64, 175, 0.25);
  position: relative;
  z-index: 60;
}

#impersonationBanner button {
  background: #ffffff !important;
  color: #1e40af !important;
  font-weight: 700 !important;
  border-radius: 6px !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  transition: transform 0.2s;
}

#impersonationBanner button:hover {
  transform: translateY(-1px);
}

/* ==========================================================================
   APP LAYOUT & SIDEBAR
   ========================================================================== */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: calc(100vh - var(--topbar-height));
  background: var(--bg-color);
}

.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  padding: 1.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow-y: auto;
  max-height: calc(100vh - var(--topbar-height));
  position: sticky;
  top: var(--topbar-height);
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 1rem;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-body);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  user-select: none;
}

.nav-item:hover {
  background: #f1f5f9;
  color: var(--text-main);
  transform: translateX(3px);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12) 0%, rgba(5, 150, 105, 0.08) 100%);
  color: var(--wa-emerald-deep);
  font-weight: 700;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 18%;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--wa-emerald);
}

.nav-icon {
  font-size: 16px;
  width: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-count {
  margin-left: auto;
  font-size: 11px;
  background: #e2e8f0;
  color: #475569;
  padding: 2px 7px;
  border-radius: 9999px;
  font-weight: 700;
}

.nav-item.active .nav-count {
  background: var(--wa-emerald);
  color: #ffffff;
}

/* ==========================================================================
   MAIN CONTENT & PAGES
   ========================================================================== */

.main-content {
  padding: 2rem 2.5rem;
  overflow-y: auto;
  min-height: calc(100vh - var(--topbar-height));
  background: var(--bg-color);
}

.page {
  display: none;
  animation: pageEnter 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.page.active {
  display: block;
}

@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

h1 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.03em;
  margin-bottom: 0.25rem;
}

.subtitle {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 400;
  margin-bottom: 1.75rem;
}

/* ==========================================================================
   CARDS & CONTAINERS
   ========================================================================== */

.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
  position: relative;
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.01em;
}

.card-title span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #f1f5f9;
  font-size: 14px;
}

/* ==========================================================================
   METRICS & KPI STATS GRID
   ========================================================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--border-color);
  transition: background 0.25s ease;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: #cbd5e1;
}

.stat-card:hover::after {
  background: var(--wa-emerald);
}

.stat-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

.stat-value {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat-value.green {
  color: var(--success);
}

.stat-value.red {
  color: var(--danger);
}

/* ==========================================================================
   FORMS, INPUTS, AND CONTROLS
   ========================================================================== */

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-body);
  margin-bottom: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="date"],
input[type="email"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text-main);
  font-family: inherit;
  background: #ffffff;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-xs);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--wa-emerald);
  box-shadow: 0 0 0 3.5px rgba(16, 185, 129, 0.15);
}

input::placeholder,
textarea::placeholder {
  color: #94a3b8;
}

textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.5;
}

/* ==========================================================================
   BUTTONS & ACTIONS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  text-decoration: none;
  line-height: 1.2;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* Primary Button (WhatsApp Emerald) */
.btn-primary {
  background: var(--primary-gradient);
  color: #ffffff !important;
  border: none;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.28);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.4);
  transform: translateY(-1px);
}

/* Secondary Button (Neutral) */
.btn-secondary {
  background: #ffffff;
  color: #334155;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover:not(:disabled) {
  background: #f8fafc;
  color: var(--text-main);
  border-color: #cbd5e1;
}

/* Danger Button (Rose) */
.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.28);
}

.btn-danger:hover:not(:disabled) {
  box-shadow: 0 6px 16px rgba(239, 68, 68, 0.38);
  transform: translateY(-1px);
}

.btn-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* ==========================================================================
   TABLES & DATA DISPLAY
   ========================================================================== */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #ffffff;
  box-shadow: var(--shadow-xs);
}

table, .table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13.5px;
}

th {
  background: #f8fafc;
  padding: 12px 16px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-body);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background 0.15s ease;
}

tbody tr:hover {
  background: #f8fafc;
}

/* ==========================================================================
   STATUS BADGES
   ========================================================================== */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.status-badge.sent,
.status-badge.delivered,
.status-badge.read,
.status-badge.connected,
.status-badge.approved {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.status-badge.sent::before,
.status-badge.delivered::before,
.status-badge.read::before,
.status-badge.connected::before,
.status-badge.approved::before {
  background: #10b981;
}

.status-badge.failed,
.status-badge.disconnected,
.status-badge.rejected {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
.status-badge.failed::before,
.status-badge.disconnected::before,
.status-badge.rejected::before {
  background: #ef4444;
}

.status-badge.queued,
.status-badge.connecting,
.status-badge.pending {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}
.status-badge.queued::before,
.status-badge.connecting::before,
.status-badge.pending::before {
  background: #f59e0b;
}

/* ==========================================================================
   TABS & NAVIGATION
   ========================================================================== */

.tab-row {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
}

.tab {
  padding: 10px 18px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  user-select: none;
}

.tab:hover {
  color: var(--text-main);
  background: #f8fafc;
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
}

.tab.active {
  color: var(--wa-emerald);
  border-bottom-color: var(--wa-emerald);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: pageEnter 0.25s ease;
}

/* ==========================================================================
   TEMPLATE CARDS & PREVIEWS
   ========================================================================== */

.preview-box {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
  padding: 18px;
  font-size: 13.5px;
  color: #166534;
  white-space: pre-wrap;
  line-height: 1.6;
  box-shadow: inset 0 2px 4px rgba(16, 185, 129, 0.05);
  font-family: inherit;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.template-card {
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  background: #ffffff;
  box-shadow: var(--shadow-xs);
  position: relative;
}

.template-card:hover {
  border-color: var(--wa-emerald);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.template-card.selected {
  border-color: var(--wa-emerald);
  background: #f0fdf4;
  box-shadow: 0 0 0 2px var(--wa-emerald);
}

.template-card h4 {
  margin-bottom: 6px;
  color: var(--text-main);
  font-size: 15px;
  font-weight: 700;
}

.template-card p {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.4;
}

.template-card .badge {
  font-size: 11px;
  background: #f1f5f9;
  padding: 3px 9px;
  border-radius: 9999px;
  color: #475569;
  font-weight: 600;
}

/* Progress bar */
.progress-bar {
  width: 100%;
  height: 8px;
  background: #f1f5f9;
  border-radius: 9999px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-fill {
  height: 100%;
  background: var(--primary-gradient);
  width: 0%;
  transition: width 0.35s ease-out;
}

.recipient-list {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #ffffff;
}

.recipient-item {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  transition: background 0.15s ease;
}

.recipient-item:hover {
  background: #f8fafc;
}

.recipient-item:last-child {
  border-bottom: none;
}

/* ==========================================================================
   MODAL SYSTEM & OVERLAYS (GLASSMORPHISM)
   ========================================================================== */

.modal,
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  z-index: 99999 !important;
  align-items: center;
  justify-content: center;
}

.modal-content,
.modal-overlay > div {
  background: #ffffff !important;
  border-radius: var(--radius-xl) !important;
  padding: 2.25rem !important;
  width: 92% !important;
  max-width: 560px !important;
  box-shadow: var(--shadow-xl) !important;
  max-height: 90vh !important;
  overflow-y: auto !important;
  position: relative !important;
  border: 1px solid rgba(255, 255, 255, 0.8) !important;
  animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  0% {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-close,
.close-btn {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: #f1f5f9;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #64748b;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.modal-close:hover,
.close-btn:hover {
  background: #fee2e2;
  color: #dc2626;
}

/* ==========================================================================
   LIVE CHAT & WHATSAPP INTERFACE
   ========================================================================== */

#chatHistory {
  background: #efeae2 !important;
  background-image: radial-gradient(#d1d7db 1px, transparent 1px) !important;
  background-size: 20px 20px !important;
}

#chatHistory .chat-bubble {
  max-width: 75%;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.4;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  position: relative;
  word-wrap: break-word;
}

#chatHistory .chat-bubble.outbound {
  background: #d9fdd3;
  align-self: flex-end;
  border-top-right-radius: 2px;
}

#chatHistory .chat-bubble.inbound {
  background: #ffffff;
  align-self: flex-start;
  border-top-left-radius: 2px;
}

/* ==========================================================================
   RESPONSIVE DESIGN (TABLET & MOBILE)
   ========================================================================== */

@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 220px 1fr;
  }
  .main-content {
    padding: 1.5rem;
  }
}

@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .topbar {
    padding: 0 1rem;
  }
  .main-content {
    padding: 1rem;
  }
}

/* ==========================================================================
   DATE PRESETS & RECENT MESSAGES FILTER TOOLBAR
   ========================================================================== */

.filter-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 16px;
}

.preset-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.preset-pill {
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.preset-pill:hover {
  background: #f1f5f9;
  color: var(--text-main);
  border-color: #cbd5e1;
}

.preset-pill.active {
  background: var(--wa-emerald);
  color: #ffffff;
  border-color: var(--wa-emerald);
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.25);
}

.filter-controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  width: 100%;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid #e2e8f0;
}

.filter-date-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.filter-date-group input[type="date"] {
  width: 140px;
  padding: 6px 10px;
  font-size: 12.5px;
}