/* Custom Layout & Ultra-Clean Light Theme for WhatsApp Gateway */
:root {
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 70px;
  --topbar-height: 68px;
  --wa-primary: #25D366;
  --wa-primary-hover: #1EBE5D;
  --wa-secondary: #128C7E;
  --wa-dark: #075E54;
  --wa-bg: #EFEAE2;
  --wa-bubble-in: #FFFFFF;
  --wa-bubble-out: #D9FDD3;
  --sidebar-bg: #ffffff;
  --sidebar-border: #e2e8f0;
  --sidebar-hover: #f1f5f9;
  --sidebar-active-bg: #ecfdf5;
  --sidebar-active-text: #059669;
  --sidebar-text: #475569;
  --sidebar-text-muted: #94a3b8;
  --sidebar-text-active: #059669;
}

body {
  font-family: 'Be Vietnam Pro', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: #f8fafc;
  color: #1e293b;
  overflow-x: hidden;
  min-height: 100vh;
}

/* Pagination SVG Safety & Layout */
nav[role="navigation"] svg,
.pagination svg {
  width: 1rem !important;
  height: 1rem !important;
  max-width: 1.25rem !important;
  max-height: 1.25rem !important;
  display: inline-block;
  vertical-align: middle;
}

/* Page Layout */
.page-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Sidebar (Clean Light Theme) */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  min-height: 100vh;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1000;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 8px rgba(0,0,0,0.02);
}

.sidebar-brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--sidebar-border);
  background-color: #ffffff;
}

.sidebar-brand a {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #0f172a;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.3px;
}

.brand-icon-wrapper {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.25rem;
  box-shadow: 0 4px 12px rgba(37,211,102,0.25);
}

.sidebar-menu-wrapper {
  flex: 1;
  padding: 0.75rem 0;
  overflow-y: auto;
}

.menu-header {
  padding: 1rem 1.5rem 0.4rem 1.5rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 700;
  color: var(--sidebar-text-muted);
}

.sidebar-nav {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-item {
  margin: 2px 10px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  padding: 0.65rem 0.95rem;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.2s ease;
  position: relative;
}

.sidebar-link i {
  font-size: 1rem;
  margin-right: 12px;
  width: 22px;
  text-align: center;
  color: #64748b;
  transition: transform 0.2s, color 0.2s;
}

.sidebar-link:hover {
  background-color: var(--sidebar-hover);
  color: #0f172a;
}

.sidebar-link:hover i {
  transform: scale(1.1);
  color: var(--wa-primary);
}

.sidebar-link.active {
  background-color: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 600;
}

.sidebar-link.active i {
  color: #059669;
}

.sidebar-submenu {
  list-style: none;
  padding-left: 2.25rem;
  margin-top: 4px;
}

.sidebar-submenu .sidebar-link {
  font-size: 0.82rem;
  padding: 0.45rem 0.75rem;
}

/* Page Content & Topbar */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s ease;
}

.app-topbar {
  height: var(--topbar-height);
  background-color: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.app-content {
  flex: 1;
  padding: 1.75rem;
}

.app-footer {
  background-color: #ffffff;
  border-top: 1px solid #e2e8f0;
  padding: 1rem 1.75rem;
  font-size: 0.82rem;
  color: #64748b;
}

/* Collapsed Sidebar on Small Devices */
@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.show {
    transform: translateX(0);
  }
  .main-wrapper {
    margin-left: 0;
  }
  .sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 998;
    display: none;
  }
  .sidebar-backdrop.show {
    display: block;
  }
}

/* Pulse animation for live status */
.pulse-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  animation: pulse-green 1.8s infinite;
}

.pulse-dot.disconnected {
  background-color: #ef4444;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  animation: pulse-red 1.8s infinite;
}

.pulse-dot.warning {
  background-color: #f59e0b;
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
  animation: pulse-yellow 1.8s infinite;
}

@keyframes pulse-green {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

@keyframes pulse-red {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

@keyframes pulse-yellow {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

/* Card & Widget styling */
.card {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  background-color: #ffffff;
}

.card-header {
  background-color: transparent;
  border-bottom: 1px solid #e2e8f0;
  padding: 1.1rem 1.35rem;
  font-weight: 600;
}

.card-body {
  padding: 1.35rem;
}

.stat-card {
  position: relative;
  overflow: hidden;
}

.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
}

/* Chat bubble styling for preview */
.chat-preview-box {
  background: var(--wa-bg);
  background-image: radial-gradient(rgba(0,0,0,0.04) 1px, transparent 0);
  background-size: 20px 20px;
  border-radius: 12px;
  padding: 1.25rem;
  min-height: 250px;
}

.chat-bubble {
  max-width: 80%;
  padding: 0.65rem 0.95rem;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  font-size: 0.88rem;
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  line-height: 1.45;
}

.chat-bubble.out {
  background-color: var(--wa-bubble-out);
  margin-left: auto;
  border-top-right-radius: 2px;
}

.chat-bubble.in {
  background-color: var(--wa-bubble-in);
  margin-right: auto;
  border-top-left-radius: 2px;
}

.chat-time {
  font-size: 0.7rem;
  color: #667781;
  text-align: right;
  margin-top: 4px;
}

/* Spintax Helper Badges */
.spintax-pill {
  display: inline-block;
  background: #e0f2fe;
  color: #0369a1;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-family: monospace;
  cursor: pointer;
  border: 1px solid #bae6fd;
  transition: all 0.15s;
}

.spintax-pill:hover {
  background: #bae6fd;
}
