/* ========================================
   Notification Gateway - Design System
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800&display=swap');

:root {
  /* New Premium Light Theme Colors */
  --primary-50: #f5f3ff;
  --primary-100: #ede9fe;
  --primary-200: #ddd6fe;
  --primary-300: #c4b5fd;
  --primary-400: #a78bfa;
  --primary-500: #8b5cf6; /* Vibrant Purple */
  --primary-600: #7c3aed;
  --primary-700: #6d28d9;
  --primary-800: #5b21b6;
  --primary-900: #4c1d95;

  --accent-400: #22d3ee;
  --accent-500: #06b6d4; /* Crisp Teal */
  --accent-600: #0891b2;

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  --bg-primary: #f1f5f9;
  --bg-secondary: #e2e8f0;
  --bg-card: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.7);
  --bg-glass-hover: rgba(255, 255, 255, 0.85);

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;

  --border-color: #e2e8f0;
  --border-active: #7c3aed;

  --gradient-primary: linear-gradient(135deg, #8b5cf6 0%, #06b6d4 100%);
  --gradient-card: linear-gradient(135deg, rgba(139, 92, 246, 0.05) 0%, rgba(6, 182, 212, 0.02) 100%);
  --gradient-bg: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
  --shadow-glow: 0 0 20px rgba(139, 92, 246, 0.05);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease;
}

/* ========== Reset ========== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Cairo', sans-serif;
  background: var(--gradient-bg);
  color: var(--text-primary);
  min-height: 100vh;
  direction: rtl;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ========== Animated Background ========== */
.bg-particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  background-color: var(--bg-primary);
}

.bg-particles::before,
.bg-particles::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.15;
  animation: float 20s ease-in-out infinite;
}

.bg-particles::before {
  width: 600px;
  height: 600px;
  background: var(--primary-300);
  top: -200px;
  right: -200px;
}

.bg-particles::after {
  width: 500px;
  height: 500px;
  background: var(--accent-400);
  bottom: -200px;
  left: -200px;
  animation-delay: -5s;
  animation-direction: reverse;
}

@keyframes float {
  0%, 100% {
    transform: translate(0, 0) scale(1.1);
  }
  50% {
    transform: translate(50px, 100px) scale(1);
  }
}

/* ========== Login Page ========== */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  position: relative;
  z-index: 1;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-card .btn-primary {
  width: 100%;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-logo {
  text-align: center;
  margin-bottom: 36px;
}

.login-logo .logo-icon {
  width: 64px;
  height: 64px;
  background: var(--gradient-primary);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 28px;
  box-shadow: 0 8px 16px rgba(139, 92, 246, 0.2);
  color: white;
}

.login-logo h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.login-logo p {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
}

/* ========== Form Elements ========== */
.form-group {
  margin-bottom: 20px;
  position: relative;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary-700);
  margin-bottom: 12px;
  text-align: center;
  background: white;
  padding: 6px 16px;
  border-radius: 50px;
  width: fit-content;
  margin-right: auto;
  margin-left: auto;
  border: 1px solid var(--primary-200);
  box-shadow: 0 2px 4px rgba(106, 61, 232, 0.1);
  letter-spacing: 0.3px;
}

.input-wrapper {
  position: relative;
}

.input-wrapper .input-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.1rem;
  transition: var(--transition-fast);
  pointer-events: none;
}

.form-control {
  width: 100%;
  padding: 12px 14px; /* Reduced right padding since we are centering */
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: 'Cairo', sans-serif;
  font-size: 0.95rem;
  transition: var(--transition);
  outline: none;
  text-align: center;
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-control:focus {
  border-color: var(--primary-500);
  background: #ffffff;
  box-shadow: 0 0 0 4px var(--primary-100);
}

select.form-control {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23a7a9be' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: left 14px center;
  background-size: 16px 12px;
  appearance: none;
  -webkit-appearance: none;
}

select.form-control option {
  background-color: #ffffff !important;
  color: var(--text-primary) !important;
  padding: 10px;
}

.form-control:focus+.input-icon,
.form-control:focus~.input-icon {
  color: var(--primary-400);
}

.password-toggle {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  transition: var(--transition-fast);
  pointer-events: all;
}

.password-toggle:hover {
  color: var(--primary-400);
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-md);
  font-family: 'Cairo', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(255, 255, 255, 0.1), transparent);
  opacity: 0;
  transition: var(--transition-fast);
}

.btn:hover::after {
  opacity: 1;
}

.btn-primary {
  background: var(--primary-600);
  color: white;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.25);
  border: 1px solid var(--primary-700);
}

.btn-primary:hover {
  background: var(--primary-700);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(124, 58, 237, 0.35);
}

.btn-secondary {
  background: white;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--bg-secondary);
  border-color: var(--text-muted);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.btn-accent {
  background: var(--accent-500);
  color: white;
  box-shadow: 0 4px 6px -1px rgba(6, 182, 212, 0.2);
  border: 1px solid var(--accent-600);
}

.btn-accent:hover {
  background: var(--accent-600);
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(6, 182, 212, 0.3);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-outline:hover {
  border-color: var(--primary-400);
  color: var(--primary-600);
  background: var(--primary-50);
}

/* ========== App Layout ========== */
.app-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

/* ========== Top Navbar ========== */
.navbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 0 32px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.navbar-brand .brand-icon {
  width: 36px;
  height: 36px;
  background: var(--gradient-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.navbar-brand h2 {
  font-size: 1.1rem;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ========== Navbar Menu ========== */
.navbar-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
  transition: var(--transition);
}

.nav-link:hover {
  background: var(--bg-glass);
  color: var(--text-primary);
}

.nav-link.active {
  background: rgba(106, 61, 232, 0.15);
  color: var(--primary-300);
}

.nav-link.active .nav-icon {
  filter: drop-shadow(0 0 8px var(--primary-500));
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--primary-50);
  border-radius: var(--radius-md);
  border: 1px solid var(--primary-100);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
}

.user-badge .user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: white;
  font-weight: 700;
}

.btn-logout {
  padding: 8px 16px;
  background: #fee2e2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  color: #b91c1c;
  font-family: 'Cairo', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-logout:hover {
  background: #fecaca;
  border-color: #fca5a5;
}


/* ========== Main Content ========== */
.main-content {
  flex: 1;
  padding: 28px 32px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.page-header {
  margin-bottom: 28px;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ========== Stats Cards ========== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.stat-card:hover {
  border-color: var(--primary-200);
  box-shadow: var(--shadow-md);
  transform: translateY(-4px);
}

.stat-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.stat-icon.sms {
  background: #eff6ff;
  color: #2563eb;
}

.stat-icon.whatsapp {
  background: #d1fae5;
  color: #065f46;
}

.stat-icon.email {
  background: #ede9fe;
  color: #5b21b6;
}

.stat-icon.total {
  background: #fef3c7;
  color: #92400e;
}

.stat-info h3 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
}

.stat-info span {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* ========== Tabs ========== */
.tabs-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.tabs-header {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  padding: 0 8px;
}

.tab-btn {
  flex: 1;
  padding: 16px 20px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-muted);
  font-family: 'Cairo', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  position: relative;
}

.tab-btn:hover {
  color: var(--primary-600);
  background: var(--primary-50);
}

.tab-btn.active {
  color: var(--primary-600);
  border-bottom-color: var(--primary-600);
  background: #ffffff;
}

.tab-btn .tab-icon {
  font-size: 1.1rem;
}

.tab-btn .tab-count {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 24px;
}

.tab-btn.active .tab-count {
  background: var(--primary-600);
  color: white;
}

/* ========== Search Bar ========== */
.search-bar {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar {
  padding: 20px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 0;
}

.toolbar-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
}

.search-wrapper {
  position: relative;
  flex: 1;
  max-width: 600px;
}

.search-wrapper .form-control {
  padding-right: 44px;
  height: 48px;
}

.search-wrapper .search-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.1rem;
  pointer-events: none;
}

.btn-search-ui {
  height: 48px;
  padding: 0 32px;
}

#addEmailBtn {
  height: 48px;
  padding: 0 32px;
}


.search-input-wrapper {
  flex: 1;
  min-width: 250px;
  position: relative;
}

.search-input-wrapper .search-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 12px 42px 12px 14px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: 'Cairo', sans-serif;
  font-size: 0.9rem;
  transition: var(--transition);
  outline: none;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 4px var(--primary-100);
}

.btn-search {
  padding: 12px 24px;
  background: var(--gradient-primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-family: 'Cairo', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-search:hover {
  box-shadow: 0 4px 16px rgba(106, 61, 232, 0.3);
  transform: translateY(-1px);
}

.btn-clear {
  padding: 12px 20px;
  background: var(--bg-glass);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: 'Cairo', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.btn-clear:hover {
  background: var(--bg-glass-hover);
  border-color: var(--text-muted);
}

/* ========== Table ========== */
.tab-content {
  display: none;
  padding: 0;
}

.tab-content.active {
  display: block;
}

/* ========== Toggle Switch ========== */
.switch-container {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
}

input:checked+.slider {
  background: var(--gradient-primary);
}

input:checked+.slider:before {
  transform: translateX(22px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

.table-wrapper {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

/* ========== Modal ========== */
.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
  background: #ffffff;
  margin: 0; /* Centered by parent flex */
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 650px;
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  position: relative;
  animation: modalPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@keyframes modalPop {
  0% { transform: scale(0.95); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 32px;
  border-bottom: 1px solid var(--border-color);
  background: white;
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  z-index: 10;
  text-align: center;
}

.modal-header h2 {
    flex: 1;
    text-align: center;
}

.close-modal {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  transition: var(--transition);
}

.close-modal:hover {
  color: var(--danger);
}

.modal-body {
  padding: 32px;
  overflow-y: auto;
  flex: 1;
}

form {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

#emailForm .form-group, #emailForm .form-row, 
#appForm .modal-body, #smsSettingForm .form-group, #smsSettingForm .form-row,
#waProviderForm .form-group, #waProviderForm .form-row,
#waBusinessAccountForm .form-group, #waBusinessAccountForm .form-row,
#waTemplateForm .form-group, #waTemplateForm .form-row {
  padding-left: 24px;
  padding-right: 24px;
}

#appForm .modal-body {
    padding-top: 24px;
    padding-bottom: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: center; /* Centered in popups */
  gap: 12px;
  padding: 24px 32px;
  border-top: 1px solid var(--border-color);
  background: #ffffff;
  z-index: 10;
  flex-shrink: 0;
}

/* Specific button adjustment */
#saveAppBtn, #cancelAppBtn, 
#emailForm .btn, #smsProviderForm .btn, #smsSettingForm .btn, 
#waProviderForm .btn, #waBusinessAccountForm .btn, #waTemplateForm .btn {
    min-width: 110px;
    padding: 10px 20px;
    font-size: 0.95rem;
}

.data-table thead th {
  padding: 16px 20px;
  text-align: center;
  font-size: 0.95rem; /* Larger */
  font-weight: 800; /* Extra Bolder */
  color: var(--text-primary); /* Darker/More active */
  text-transform: uppercase;
  border-bottom: 2px solid var(--primary-200); /* Distinctive border */
  border-left: 1px solid var(--border-color);
  white-space: nowrap;
  background: var(--bg-secondary);
}

.data-table thead th:last-child {
  border-left: none;
}

.data-table tbody tr {
  transition: var(--transition-fast);
}

.data-table tbody tr:hover {
  background: var(--primary-50);
}

.data-table tbody td {
  padding: 16px 20px;
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  border-left: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table tbody td:last-child {
  border-left: none;
}

.data-table tbody td:first-child {
  color: var(--text-primary);
  font-weight: 600;
}

/* ========== Status Badges ========== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-success {
  background: #d1fae5;
  color: #064e3b;
  border: 1px solid #a7f3d0;
}

.badge-danger {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.badge-info {
  background: #dbeafe;
  color: #1e3a8a;
  border: 1px solid #bfdbfe;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ========== Message Preview ========== */
.msg-preview {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ========== Empty State ========== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ========== Pagination ========== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  border-top: 1px solid var(--border-color);
}

.page-btn {
  min-width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: 'Cairo', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.page-btn:hover {
  border-color: var(--primary-500);
  color: var(--primary-400);
}

.page-btn.active {
  background: var(--primary-500);
  border-color: var(--primary-500);
  color: white;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ========== Loading Spinner ========== */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  gap: 12px;
  color: var(--text-muted);
}

/* ========== Alert / Toast ========== */
.alert {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: none;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.alert-error {
  background: #fee2e2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.alert-success {
  background: #ecfdf5;
  border: 1px solid #d1fae5;
  color: #065f46;
}

/* ========== Toast Notifications ========== */
.toast-container {
  position: fixed;
  top: 32px;
  left: 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 9999;
}

.toast {
  background: #ffffff;
  border: 1px solid var(--border-color);
  padding: 16px 24px;
  border-radius: var(--radius-md);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-primary);
  min-width: 320px;
  animation: slideInLeft 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-success {
  border-right: 4px solid var(--success);
}

.toast-error {
  border-right: 4px solid var(--danger);
}

.toast-icon {
  font-size: 1.2rem;
}

.toast-message {
  font-weight: 600;
  font-size: 0.95rem;
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
  }

  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .login-card {
    padding: 36px 24px;
    margin: 16px;
  }

  .navbar {
    padding: 0 16px;
  }

  .main-content {
    padding: 16px;
  }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .tabs-header {
    overflow-x: auto;
  }

  .tab-btn {
    padding: 14px 12px;
    font-size: 0.85rem;
    white-space: nowrap;
  }

  .search-bar {
    flex-direction: column;
  }

  .search-input-wrapper {
    min-width: 100%;
  }

  .btn-search,
  .btn-clear {
    width: 100%;
    justify-content: center;
  }
  .modal-content {
    margin: 20px auto;
    padding: 24px 20px;
    width: 95%;
    max-height: calc(100vh - 40px);
    border-radius: var(--radius-lg);
  }

  .modal-lg {
    max-width: 95%;
  }

  .form-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .form-row {
    flex-direction: column !important;
    gap: 12px !important;
  }

  .modal-footer {
    flex-direction: column-reverse;
    gap: 10px;
  }

  .modal-footer .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .stats-row {
    grid-template-columns: 1fr;
  }

  .user-badge span:not(.user-avatar) {
    display: none;
  }

  .page-header h1 {
    font-size: 1.4rem;
  }
}

/* WhatsApp Management Sub-tabs */
.whatsapp-management-nav {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  padding: 8px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  width: fit-content;
}

.sub-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
  font-weight: 600;
  font-size: 0.9rem;
}

.sub-tab-btn:hover {
  color: var(--primary-600);
}

.sub-tab-btn.active {
  background: #ffffff;
  color: var(--primary-600);
  box-shadow: var(--shadow-sm);
}

.sub-tab-content {
  display: none;
}

.sub-tab-content.active {
  display: block;
  animation: none;
}

.modal-lg {
  max-width: 900px;
  width: 95%;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-600);
  margin: 24px 0 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary-50);
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-divider {
  border: 0;
  border-top: 1px dashed var(--border-color);
  margin: 24px 0;
}

@media (max-width: 992px) {
  .modal-lg {
    max-width: 800px;
  }
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.form-row {
    display: flex;
    gap: 20px;
}

.form-row > * {
    flex: 1;
}

.rmq-form-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    position: relative;
    animation: fadeIn 0.3s ease;
}

.btn-close-sm {
    background: var(--bg-secondary);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition-fast);
    color: var(--text-muted);
}

.btn-close-sm:hover {
    background: var(--danger);
    color: white;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flex-center-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.font-weight-600 {
    font-weight: 600;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============ Message Preview & Bubbles ============ */
.msg-preview-container {
    padding: 1.5rem;
    background: #f0f2f5;
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    background-repeat: repeat;
    border-radius: 12px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    direction: ltr; /* WhatsApp bubbles are usually LTR even in RTL apps for consistency */
}

/* Force RTL for Arabic text inside bubbles if needed */
.wa-bubble span, .wa-bubble p {
    direction: rtl;
    display: block;
}

.wa-bubble {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 8px;
    position: relative;
    font-size: 0.95rem;
    line-height: 1.4;
    box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
    margin-bottom: 2px;
}

.wa-bubble.received {
    background: #ffffff;
    align-self: flex-start;
    border-top-left-radius: 0;
}

.wa-bubble.sent {
    background: #d9fdd3;
    align-self: flex-end;
    border-top-right-radius: 0;
}

.wa-time {
    display: block;
    text-align: left;
    font-size: 0.75rem;
    color: #667781;
    margin-top: 4px;
}

/* Invoice Card */
.invoice-card {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    padding: 10px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 4px solid #00a884;
    direction: rtl;
}

.invoice-icon {
    font-size: 1.5rem;
    background: white;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.invoice-info {
    flex: 1;
}

.invoice-name {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: #111b21;
    margin-bottom: 2px;
    word-break: break-all;
    text-align: right;
}

.invoice-meta {
    display: block;
    font-size: 0.7rem;
    color: #667781;
    text-align: right;
}

.btn-view-doc {
    background: none;
    border: none;
    color: #00a884;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 10px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    justify-content: center;
    border-top: 1px solid rgba(0,0,0,0.05);
    margin-top: 8px;
}

.btn-view-doc:hover {
    text-decoration: underline;
}

/* UI Helper classes */
.btn-preview {
    padding: 8px 24px;
    font-size: 0.9rem;
    border-radius: 8px;
    background: #00b894; /* Distinct Teal color */
    color: white;
    border: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 184, 148, 0.2);
}

.btn-preview:hover {
    background: #00a383;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 184, 148, 0.3);
}

.btn-preview:active {
    transform: translateY(0);
}

/* Date cell alignment helper */
.date-cell-ltr {
    direction: ltr;
    display: inline-block;
    unicode-bidi: embed;
    text-align: center;
    white-space: nowrap;
}


.preview-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.preview-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.preview-detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.preview-label {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.preview-value {
    color: var(--text-dark);
    font-size: 0.95rem;
    font-weight: 500;
}

/* Modal sizing for preview */
.modal-preview {
    z-index: 1100;
}

.modal-preview .modal-content {
    max-width: 550px;
    padding: 0;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.preview-modal-body {
    padding: 1.5rem;
    flex: 1;
    overflow-y: auto;
}

.preview-modal-footer {
    padding: 1rem 1.5rem;
    background: #f8f9fa;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}