/* ── Google Font & Reset ───────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

:root {
  --sidebar-bg:     #0f172a;
  --sidebar-hover:  #1e293b;
  --sidebar-active: rgba(99, 102, 241, 0.18);
  --accent:         #6366f1;
  --accent-dark:    #4f46e5;
  --accent-light:   rgba(99, 102, 241, 0.1);
  --green:          #22c55e;
  --green-dark:     #16a34a;
  --orange:         #f59e0b;
  --red:            #ef4444;
  --red-dark:       #dc2626;
  --blue:           #3b82f6;
  --bg:             #f1f5f9;
  --card-bg:        #ffffff;
  --text:           #1e293b;
  --text-muted:     #64748b;
  --border:         #e2e8f0;
  --border-light:   #f1f5f9;
  --radius:         10px;
  --radius-sm:      7px;
  --shadow:         0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:      0 4px 16px rgba(0,0,0,0.10);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: 250px;
  min-width: 250px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 200;
  overflow: hidden;
  border-right: 1px solid rgba(255,255,255,0.04);
  transition: width 0.3s ease, min-width 0.3s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.minimized {
  width: 80px;
  min-width: 80px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  height: 85px;
  overflow: hidden;
  white-space: nowrap;
}

.main-brand-logo {
  height: 38px;
  width: auto;
  max-width: 170px;
  object-fit: contain;
  transition: opacity 0.25s ease;
}

.min-brand-logo {
  height: 38px;
  width: 38px;
  object-fit: contain;
  display: none;
}

.sidebar.minimized .main-brand-logo {
  display: none;
}

.sidebar.minimized .min-brand-logo {
  display: block;
  margin: 0 auto;
}

.mobile-close-btn {
  display: none;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  margin-left: auto;
  padding: 4px;
}

.sidebar-nav {
  flex: 1;
  padding: 14px 10px;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.nav-section-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #475569;
  padding: 8px 10px 4px;
  white-space: nowrap;
  transition: opacity 0.25s ease;
}

.sidebar.minimized .nav-section-label {
  opacity: 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #ffffff;
  text-decoration: none;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.18s, color 0.18s, justify-content 0.3s ease, padding 0.3s ease;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.minimized .nav-link {
  padding: 10px 0;
  justify-content: center;
}

.sidebar.minimized .nav-text {
  display: none;
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
}

.nav-link.active {
  background: var(--sidebar-active);
  color: #a5b4fc;
  font-weight: 600;
}

.nav-link.active .nav-icon { stroke: #a5b4fc; }

.nav-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  stroke: #ffffff;
  transition: stroke 0.18s;
  margin: 0 4px;
}

.nav-link:hover .nav-icon { stroke: #ffffff; }

/* ── Email section icon tint ─────────────────────────────────────────────── */
.nav-icon-email { stroke: #818cf8 !important; }
.nav-link:hover .nav-icon-email { stroke: #a5b4fc !important; }
.nav-link.active .nav-icon-email { stroke: #a5b4fc !important; }

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 0.72rem;
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: space-between;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.minimized .sidebar-version {
  display: none;
}

.sidebar-toggle-btn {
  background: rgba(255,255,255,0.05);
  border: none;
  color: #94a3b8;
  cursor: pointer;
  border-radius: 6px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
}

.sidebar.minimized .sidebar-toggle-btn {
  margin: 0 auto;
}

.sidebar-toggle-btn:hover {
  background: rgba(255,255,255,0.1);
  color: #e2e8f0;
}

/* ── Sidebar Overlay Mobile ───────────────────────────────────────────────── */
.sidebar-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* ── Main Content ─────────────────────────────────────────────────────────── */
.main-content {
  margin-left: 250px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-content.expanded {
  margin-left: 80px;
}

/* ── Top Bar ──────────────────────────────────────────────────────────────── */
.top-bar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 var(--border);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
}

.page-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

/* ── Page Content ─────────────────────────────────────────────────────────── */
.page-content {
  padding: 28px;
  flex: 1;
}

/* ── Alerts / Flash ───────────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 20px;
  animation: slideDown 0.25s ease;
  position: relative;
}

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

.alert-success {
  background: rgba(34, 197, 94, 0.1);
  color: #15803d;
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.alert-danger {
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  opacity: 0.6;
  color: inherit;
  flex-shrink: 0;
  padding: 0 2px;
}

.alert-close:hover { opacity: 1; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

/* ── Stats Grid ───────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 22px 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow 0.2s, transform 0.2s;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-icon {
  width: 50px; height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.purple { background: rgba(99, 102, 241, 0.1); }
.stat-icon.green  { background: rgba(34, 197, 94, 0.1); }
.stat-icon.orange { background: rgba(245, 158, 11, 0.1); }
.stat-icon.blue   { background: rgba(59, 130, 246, 0.1); }

.stat-info h3 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-info p {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Quick Actions ────────────────────────────────────────────────────────── */
.section-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 14px;
}

.qa-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

@media (max-width: 1200px) {
  .qa-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 900px) {
  .qa-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .qa-grid {
    grid-template-columns: 1fr;
  }
}

.qa-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
  box-shadow: var(--shadow);
}

.qa-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.08), var(--shadow-md);
  transform: translateY(-2px);
}

.qa-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.qa-icon.purple { background: rgba(99, 102, 241, 0.1); }
.qa-icon.green  { background: rgba(34, 197, 94, 0.1); }
.qa-icon.orange { background: rgba(245, 158, 11, 0.1); }
.qa-icon.blue   { background: rgba(59, 130, 246, 0.1); }

.qa-card h4 { font-size: 0.875rem; font-weight: 600; }
.qa-card p  { font-size: 0.78rem;  color: var(--text-muted); margin-top: 2px; }

/* ── Table ────────────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; margin: 0 -24px; padding: 0 24px; }

table { width: 100%; border-collapse: collapse; }

thead th {
  background: #f8fafc;
  padding: 10px 14px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 13px 14px;
  font-size: 0.875rem;
  color: var(--text);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

tbody tr:hover { background: #fafbfd; }
tbody tr:last-child td { border-bottom: none; }

.row-num {
  display: inline-flex;
  width: 24px; height: 24px;
  align-items: center; justify-content: center;
  background: var(--border-light);
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.email-link {
  color: var(--accent);
  text-decoration: none;
}
.email-link:hover { text-decoration: underline; }

.text-muted { color: var(--text-muted); }

.template-name { display: flex; align-items: center; gap: 8px; }
.template-badge { font-size: 1rem; }

.action-btns { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid transparent;
  text-decoration: none;
  transition: all 0.18s ease;
  white-space: nowrap;
  font-family: inherit;
  line-height: 1.4;
}

.btn-sm  { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg  { padding: 11px 22px; font-size: 0.95rem; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  box-shadow: 0 4px 14px rgba(99,102,241,0.35);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}
.btn-success:hover {
  background: var(--green-dark);
  border-color: var(--green-dark);
  box-shadow: 0 4px 14px rgba(34,197,94,0.3);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}
.btn-danger:hover {
  background: var(--red-dark);
  border-color: var(--red-dark);
}

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-outline:hover {
  background: var(--bg);
  border-color: #cbd5e1;
}

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-primary { background: var(--accent-light); color: var(--accent); }

/* ── Form Styles ──────────────────────────────────────────────────────────── */
.form-container      { max-width: 700px; }
.form-container.wide { max-width: 900px; }

.form-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 28px;
}

.form-card-header { margin-bottom: 24px; }
.form-card-header h3 { font-size: 1.05rem; font-weight: 700; }
.form-card-header p  { font-size: 0.83rem; color: var(--text-muted); margin-top: 4px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.required { color: var(--red); font-size: 0.8rem; }

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--text);
  background: var(--card-bg);
  transition: border-color 0.18s, box-shadow 0.18s;
  font-family: inherit;
  appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

textarea.form-control { resize: vertical; min-height: 180px; }

.form-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 20px;
}

.form-hint code {
  background: #e8eaf6;
  color: var(--accent);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.8rem;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

/* ── Empty State ──────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted);
}
.empty-icon  { font-size: 3rem; margin-bottom: 14px; }
.empty-state h3 { font-size: 1.05rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-state p  { font-size: 0.875rem; }

/* ── Send Email Page ──────────────────────────────────────────────────────── */
.send-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  align-items: start;
}

.send-col { display: flex; flex-direction: column; }

.template-preview {
  background: #fafafa;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
  min-height: 220px;
}

.preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 180px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.preview-subject {
  font-size: 0.875rem;
  color: var(--text);
  margin-bottom: 12px;
}

.preview-divider {
  height: 1px;
  background: var(--border);
  margin-bottom: 12px;
}

.preview-body {
  font-size: 0.82rem;
  color: var(--text);
  max-height: 260px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Recipient selection */
.recipient-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  background: #fafafa;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
}

.checkbox-label input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.selected-count {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
}

.customer-list {
  max-height: 360px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 2px;
  margin-bottom: 16px;
}

.customer-list::-webkit-scrollbar { width: 5px; }
.customer-list::-webkit-scrollbar-track { background: transparent; }
.customer-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

.customer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.customer-item:hover { background: #f8fafc; border-color: #c7d2fe; }

.customer-item input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.customer-item-info { flex: 1; min-width: 0; }
.customer-item-name  { font-weight: 500; font-size: 0.875rem; color: var(--text); }
.customer-item-email { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.send-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.send-actions .btn-lg { flex: 1; justify-content: center; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .send-grid  { grid-template-columns: 1fr; }
  .form-row   { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); width: 280px; min-width: 280px; }
  .sidebar.mobile-open { transform: translateX(0); }
  .mobile-close-btn { display: block; }
  
  .main-content { margin-left: 0; }
  .main-content.expanded { margin-left: 0; }
  .page-content { padding: 18px; }
  .qa-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }

  .mobile-menu-btn { display: block; }
  .btn-text { display: none; }
  
  .sidebar-toggle-btn { display: none; }
}

/* ── Modals ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(2px);
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}
.modal-content {
  background: var(--card-bg);
  width: 100%;
  max-width: 500px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  transform: translateY(-20px) scale(0.98);
  transition: transform 0.3s ease;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-overlay.active .modal-content {
  transform: translateY(0) scale(1);
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}
.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: background 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close-btn:hover {
  background: var(--bg);
  color: var(--text);
}
.modal-content form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 20px;
}
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
}
.page-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.page-btn:disabled {
  background: var(--bg);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.7;
}

/* ── Filters ──────────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  align-items: center;
  flex-wrap: wrap;
}
.filter-search {
  flex: 1;
  max-width: 300px;
  position: relative;
}
.filter-search input {
  width: 100%;
  padding: 8px 14px 8px 36px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  background: var(--card-bg);
}
.filter-search i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 16px; height: 16px;
}

/* ── Select2 Customization ────────────────────────────────────────────────── */
.select2-container--default .select2-selection--single {
  height: 42px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  display: flex;
  align-items: center;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: normal;
  color: var(--text);
  padding-left: 12px;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}
.select2-container--default .select2-selection--single .select2-selection__clear {
  float: none;
  order: 2;
  margin-left: auto;
  margin-right: 34px;
  color: #94a3b8;
  font-size: 1.1rem;
  line-height: 1;
  transition: color 0.15s;
  position: relative;
  z-index: 10;
}
.select2-container--default .select2-selection--single .select2-selection__clear:hover {
  color: var(--red);
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 40px;
  right: 8px;
}
.select2-dropdown {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  margin-top: 4px;
}
.select2-search--dropdown {
  padding: 10px;
}
.select2-search--dropdown .select2-search__field {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.select2-search--dropdown .select2-search__field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
.select2-results__option {
  padding: 8px 12px;
  font-size: 0.85rem;
}
.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
  background-color: var(--accent);
  color: white;
}

/* ══════════════════════════════════════════════════════════════════════════════
   WHATSAPP INTEGRATION STYLES
   ══════════════════════════════════════════════════════════════════════════════ */

:root {
  --wa-green:       #25D366;
  --wa-green-dark:  #128C7E;
  --wa-green-light: rgba(37, 211, 102, 0.1);
  --wa-teal:        #075E54;
  --wa-light-green: #DCF8C6;
  --wa-chat-bg:     #ECE5DD;
}

/* ── Sidebar WhatsApp nav links — white text + green icons ────────────────── */
.nav-icon-wa { stroke: #25D366 !important; }
.nav-link:hover .nav-icon-wa { stroke: #25D366 !important; }
.nav-link.active .nav-icon-wa { stroke: #25D366 !important; }

.nav-link .nav-icon-wa ~ .nav-text { color: #ffffff; }
.nav-link:hover .nav-icon-wa ~ .nav-text { color: #ffffff; }
.nav-link.active .nav-icon-wa ~ .nav-text { color: #ffffff; }

/* ── WhatsApp Button ─────────────────────────────────────────────────────── */
.btn-whatsapp {
  background: var(--wa-green);
  color: #fff;
  border-color: var(--wa-green);
}
.btn-whatsapp:hover {
  background: var(--wa-green-dark);
  border-color: var(--wa-green-dark);
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.35);
  transform: translateY(-1px);
}
.btn-whatsapp:disabled {
  background: #94a3b8;
  border-color: #94a3b8;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* ── Settings Page Grid ──────────────────────────────────────────────────── */
.wa-settings-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 22px;
  align-items: start;
}

@media (max-width: 900px) {
  .wa-settings-grid { grid-template-columns: 1fr; }
}

/* ── Connection Card ─────────────────────────────────────────────────────── */
.wa-connection-card { min-height: 320px; }

/* ── Status Badge ────────────────────────────────────────────────────────── */
.wa-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.wa-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.wa-status-ready { background: rgba(37,211,102,0.12); color: #128C7E; }
.wa-status-ready .wa-status-dot { background: #25D366; box-shadow: 0 0 6px #25D366; animation: waPulse 2s infinite; }
.wa-status-qr { background: rgba(245,158,11,0.12); color: #d97706; }
.wa-status-qr .wa-status-dot { background: #f59e0b; animation: waPulse 1.5s infinite; }
.wa-status-connecting { background: rgba(59,130,246,0.12); color: #2563eb; }
.wa-status-connecting .wa-status-dot { background: #3b82f6; animation: waPulse 1s infinite; }
.wa-status-disconnected { background: rgba(100,116,139,0.12); color: #64748b; }
.wa-status-disconnected .wa-status-dot { background: #94a3b8; }

@keyframes waPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

/* ── Connect Prompt ──────────────────────────────────────────────────────── */
.wa-connect-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 40px 24px;
}
.wa-connect-icon {
  width: 90px; height: 90px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.wa-connect-prompt h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
.wa-connect-prompt p { font-size: 0.85rem; color: var(--text-muted); max-width: 340px; }

.wa-error-msg {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  padding: 8px 14px;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: var(--radius-sm);
  color: #b91c1c;
  font-size: 0.82rem;
}

/* ── QR Code Section ─────────────────────────────────────────────────────── */
.wa-qr-section {
  display: flex;
  align-items: flex-start;
  gap: 28px;
  padding: 20px 0;
}
@media (max-width: 600px) {
  .wa-qr-section { flex-direction: column; align-items: center; }
}

.wa-qr-wrapper {
  flex-shrink: 0;
  width: 280px; height: 280px;
  border: 2px solid var(--border);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  overflow: hidden;
  position: relative;
}
.wa-qr-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  animation: qrFadeIn 0.5s ease;
}
@keyframes qrFadeIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.wa-qr-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.wa-qr-instructions h4 { font-size: 1rem; font-weight: 600; margin-bottom: 12px; }
.wa-qr-instructions ol {
  padding-left: 20px;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 2;
}
.wa-qr-instructions li strong { color: var(--text); }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.wa-spinner, .wa-spinner-lg {
  border: 3px solid var(--border);
  border-top-color: var(--wa-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.wa-spinner { width: 32px; height: 32px; }
.wa-spinner-lg { width: 48px; height: 48px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Connected Info ──────────────────────────────────────────────────────── */
.wa-connected-info {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px 0;
  flex-wrap: wrap;
}
.wa-avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--wa-green-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.wa-account-details h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 4px; }
.wa-phone, .wa-platform {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.wa-connected-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Info Steps ──────────────────────────────────────────────────────────── */
.wa-info-list { display: flex; flex-direction: column; gap: 16px; }
.wa-info-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.wa-info-step {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--wa-green-light);
  color: var(--wa-green-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  flex-shrink: 0;
}
.wa-info-item h4 { font-size: 0.875rem; font-weight: 600; margin-bottom: 2px; }
.wa-info-item p { font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; }
.wa-info-item p code {
  background: #e8eaf6;
  color: var(--accent);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.78rem;
}

/* ── Not Connected Banner ────────────────────────────────────────────────── */
.wa-not-connected-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.25);
  border-radius: var(--radius);
  margin-bottom: 20px;
  animation: slideDown 0.3s ease;
}
.wa-not-connected-banner strong { font-size: 0.875rem; color: #92400e; }
.wa-not-connected-banner p { font-size: 0.8rem; color: #a16207; margin-top: 2px; }
.wa-not-connected-banner .btn { margin-left: auto; flex-shrink: 0; }

/* ── WhatsApp Icon Circle ────────────────────────────────────────────────── */
.wa-icon-circle {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--wa-green-light);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── WhatsApp Preview Phone ──────────────────────────────────────────────── */
.wa-preview-phone {
  border: 1.5px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--wa-chat-bg);
}
.wa-preview-header {
  background: var(--wa-teal);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
}
.wa-preview-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.wa-preview-body {
  padding: 16px;
  min-height: 140px;
}
.wa-preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 120px;
  color: var(--text-muted);
  font-size: 0.82rem;
  text-align: center;
}

/* ── Chat Bubble ─────────────────────────────────────────────────────────── */
.wa-bubble {
  background: var(--wa-light-green);
  padding: 10px 14px;
  border-radius: 8px 8px 0 8px;
  font-size: 0.85rem;
  line-height: 1.55;
  color: #1a1a1a;
  max-width: 90%;
  margin-left: auto;
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  word-break: break-word;
}
.wa-bubble::after {
  content: '';
  position: absolute;
  right: -6px;
  bottom: 0;
  width: 0; height: 0;
  border: 6px solid transparent;
  border-left-color: var(--wa-light-green);
  border-bottom-color: var(--wa-light-green);
}

/* ── WhatsApp Upload Area ────────────────────────────────────────────────── */
.wa-upload-area {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}
.wa-upload-area:hover,
.wa-upload-area.dragover {
  border-color: var(--wa-green);
  background: rgba(37, 211, 102, 0.04);
}
.wa-upload-area.has-file {
  border-color: var(--wa-green);
  border-style: solid;
  background: rgba(37, 211, 102, 0.06);
}
.wa-upload-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.wa-upload-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.wa-upload-content p {
  font-size: 0.85rem;
  color: var(--text);
  margin: 0;
}
.wa-upload-content span {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.wa-upload-file-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--wa-green-dark);
}
