/* ========================================================
   CloudPulse WhatsApp SaaS - Modern 2026 UI Design System
   Mobile-First | Clean | Fast | Dark & Light Modes
   ======================================================== */

:root {
  --font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  
  /* Color Palette - Light Theme */
  --bg-body: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-card: #ffffff;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  
  --border-color: #e2e8f0;
  --border-focus: #10b981;
  
  --primary: #10b981; /* WhatsApp Emerald */
  --primary-hover: #059669;
  --primary-glow: rgba(16, 185, 129, 0.25);
  --primary-contrast: #ffffff;
  
  --secondary: #6366f1; /* Indigo */
  --secondary-hover: #4f46e5;
  
  --success: #10b981;
  --success-bg: #ecfdf5;
  --success-text: #065f46;
  
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --warning-text: #92400e;
  
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --danger-text: #991b1b;
  
  --info: #0ea5e9;
  --info-bg: #f0f9ff;
  --info-text: #075985;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 20px rgba(16, 185, 129, 0.2);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --sidebar-width: 270px;
  --header-height: 68px;
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg-body: #090d16;
  --bg-surface: #111827;
  --bg-surface-elevated: #162032;
  --bg-subtle: #1e293b;
  --bg-card: rgba(17, 24, 39, 0.85);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #34d399;
  
  --primary: #10b981;
  --primary-hover: #34d399;
  --primary-glow: rgba(16, 185, 129, 0.35);
  --primary-contrast: #090d16;
  
  --success-bg: rgba(16, 185, 129, 0.15);
  --success-text: #34d399;
  
  --warning-bg: rgba(245, 158, 11, 0.15);
  --warning-text: #fbbf24;
  
  --danger-bg: rgba(239, 68, 68, 0.15);
  --danger-text: #f87171;
  
  --info-bg: rgba(14, 165, 233, 0.15);
  --info-text: #38bdf8;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.5);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

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

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-main);
}
.text-muted { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }

/* Layout Shell */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform var(--transition-normal), width var(--transition-normal);
  backdrop-filter: blur(12px);
}

.sidebar-header {
  height: var(--header-height);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
}
.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 14px;
}

.nav-section-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  font-weight: 700;
  padding: 12px 14px 6px;
}

.sidebar-nav {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}
.nav-item a:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
  transform: translateX(3px);
}
.nav-item.active a {
  background: var(--primary);
  color: var(--primary-contrast);
  font-weight: 600;
  box-shadow: 0 4px 12px var(--primary-glow);
}
.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Main Area */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

/* Header */
.app-header {
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
  backdrop-filter: blur(12px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
}

/* Content Area */
.content-wrapper {
  padding: 28px;
  flex: 1;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-normal), border-color var(--transition-normal);
  backdrop-filter: blur(8px);
}
.card:hover {
  border-color: rgba(16, 185, 129, 0.3);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-color);
}
.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

/* KPI / Metric Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}
.stat-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.stat-info .stat-label {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.stat-info .stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.03em;
}
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-icon-green { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.stat-icon-indigo { background: rgba(99, 102, 241, 0.12); color: #6366f1; }
.stat-icon-amber { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.stat-icon-rose { background: rgba(239, 68, 68, 0.12); color: #ef4444; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  user-select: none;
  position: relative;
  overflow: hidden;
}
.btn:active {
  transform: scale(0.97);
}
.btn-primary {
  background: var(--primary);
  color: var(--primary-contrast);
  box-shadow: 0 4px 12px var(--primary-glow);
}
.btn-primary:hover {
  background: var(--primary-hover);
  color: var(--primary-contrast);
  box-shadow: 0 6px 16px var(--primary-glow);
}
.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background: var(--bg-subtle);
  border-color: var(--text-subtle);
}
.btn-outline-glow {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.15);
}
.btn-outline-glow:hover {
  background: var(--primary);
  color: var(--primary-contrast);
  box-shadow: 0 0 18px var(--primary-glow);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: #dc2626;
}
.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
}
.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-dot-success { background: var(--success); }

.badge-warning, .badge-pending { background: var(--warning-bg); color: var(--warning-text); }
.badge-dot-warning, .badge-dot-pending { background: var(--warning); }

.badge-danger, .badge-suspended, .badge-blocked { background: var(--danger-bg); color: var(--danger-text); }
.badge-dot-danger, .badge-dot-suspended, .badge-dot-blocked { background: var(--danger); }

.badge-info { background: var(--info-bg); color: var(--info-text); }
.badge-dot-info { background: var(--info); }

/* Forms */
.form-group {
  margin-bottom: 18px;
}
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}
.form-control, .form-select {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.92rem;
  font-family: inherit;
  color: var(--text-main);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
textarea.form-control {
  min-height: 90px;
  resize: vertical;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}
.table th {
  padding: 12px 16px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
.table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}
.table tr:hover td {
  background: var(--bg-subtle);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity var(--transition-normal);
}
.modal-backdrop.active {
  display: flex;
  opacity: 1;
}
.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 550px;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform var(--transition-normal);
  overflow: hidden;
}
.modal-backdrop.active .modal-dialog {
  transform: scale(1);
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-body {
  padding: 24px;
  max-height: 75vh;
  overflow-y: auto;
}
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}
.btn-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 400px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-main);
  animation: toastSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}
@keyframes toastSlideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Alerts */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  font-size: 0.9rem;
}
.alert-success { background: var(--success-bg); color: var(--success-text); border: 1px solid var(--success); }
.alert-danger { background: var(--danger-bg); color: var(--danger-text); border: 1px solid var(--danger); }
.alert-warning { background: var(--warning-bg); color: var(--warning-text); border: 1px solid var(--warning); }
.alert-info { background: var(--info-bg); color: var(--info-text); border: 1px solid var(--info); }
.alert-close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  color: inherit;
  opacity: 0.7;
}

/* Auth Page Layout */
.auth-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 30px 16px;
  background: radial-gradient(circle at 50% 0%, rgba(16, 185, 129, 0.12) 0%, transparent 60%), var(--bg-body);
}
.auth-card-wrapper {
  width: 100%;
  max-width: 480px;
}
.auth-card-wide {
  max-width: 720px;
}

/* Utility Helpers */
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.flex-column { flex-direction: column; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.gap-4 { gap: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.w-100 { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Responsive Mobile Navigation */
@media (max-width: 991px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.sidebar-open {
    transform: translateX(0);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
  }
  .app-main {
    margin-left: 0;
  }
  .menu-toggle {
    display: inline-flex;
  }
  .content-wrapper {
    padding: 16px;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
}
