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

:root {
  --bg-dark: #0d0f14;
  --bg-card: #161b24;
  --bg-card2: #1e2535;
  --sidebar-w: 260px;
  --accent: #25D366;
  --accent2: #128C7E;
  --accent-dark: #075E54;
  --accent-glow: rgba(37, 211, 102, 0.15);
  --blue: #4F8EF7;
  --purple: #7C5CFA;
  --orange: #F97316;
  --red: #EF4444;
  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #4B5563;
  --border: rgba(255,255,255,0.07);
  --border-hover: rgba(255,255,255,0.14);
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

/* ===================== LOGIN PAGE ===================== */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at 20% 50%, rgba(37, 211, 102, 0.08) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 20%, rgba(79, 142, 247, 0.06) 0%, transparent 60%),
              var(--bg-dark);
}

.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px;
  width: 420px;
  max-width: 95vw;
  box-shadow: 0 32px 80px rgba(0,0,0,0.6), 0 0 0 1px var(--border);
  animation: fadeUp 0.5s ease;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.login-logo .logo-icon {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 20px rgba(37,211,102,0.3);
}

.login-logo h1 { font-size: 20px; font-weight: 700; }
.login-logo p { font-size: 12px; color: var(--text-secondary); }

.login-box h2 { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.login-box .subtitle { color: var(--text-secondary); margin-bottom: 32px; font-size: 14px; }

/* ===================== LAYOUT ===================== */
#app { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: var(--transition);
}

.sidebar-logo {
  padding: 24px 20px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(37,211,102,0.25);
}

.sidebar-logo .logo-text { font-size: 13px; font-weight: 700; line-height: 1.2; }
.sidebar-logo .logo-sub { font-size: 10px; color: var(--text-secondary); }

.sidebar-nav { flex: 1; padding: 8px 12px; overflow-y: auto; }

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 16px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  transition: var(--transition);
  margin-bottom: 2px;
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 600;
}
.nav-item.active .nav-icon { color: var(--accent); }
.nav-icon { font-size: 16px; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.user-info:hover { background: rgba(255,255,255,0.05); }
.user-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--purple), var(--blue));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text-secondary); }

/* MAIN CONTENT */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.top-bar {
  height: 64px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 90;
  backdrop-filter: blur(12px);
}

.top-bar h2 { font-size: 18px; font-weight: 700; flex: 1; }
.top-bar-actions { display: flex; align-items: center; gap: 10px; }

.page-content { padding: 28px; flex: 1; }

/* ===================== COMPONENTS ===================== */

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: var(--transition);
}
.card:hover { border-color: var(--border-hover); }

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

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 60px; height: 60px;
  border-radius: 50%;
  opacity: 0.1;
}
.stat-card.green::before { background: var(--accent); box-shadow: 0 0 30px var(--accent); }
.stat-card.blue::before { background: var(--blue); box-shadow: 0 0 30px var(--blue); }
.stat-card.purple::before { background: var(--purple); box-shadow: 0 0 30px var(--purple); }
.stat-card.orange::before { background: var(--orange); box-shadow: 0 0 30px var(--orange); }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-icon { font-size: 24px; margin-bottom: 12px; }
.stat-value { font-size: 28px; font-weight: 800; line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.stat-card.green .stat-value { color: var(--accent); }
.stat-card.blue .stat-value { color: var(--blue); }
.stat-card.purple .stat-value { color: var(--purple); }
.stat-card.orange .stat-value { color: var(--orange); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #000;
  box-shadow: 0 2px 12px rgba(37,211,102,0.3);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 20px rgba(37,211,102,0.5);
  transform: translateY(-1px);
}

.btn-secondary { background: var(--bg-card2); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-card2); border-color: var(--border-hover); }

.btn-danger { background: rgba(239,68,68,0.15); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,0.25); }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,0.05); color: var(--text-primary); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

/* Forms */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  transition: var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-control::placeholder { color: var(--text-muted); }

select.form-control { cursor: pointer; }
select.form-control option { background: var(--bg-card); }

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

.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

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

/* Tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }

table { width: 100%; border-collapse: collapse; }
thead { background: var(--bg-card2); }
th { padding: 12px 16px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); text-align: left; white-space: nowrap; }
td { padding: 13px 16px; border-top: 1px solid var(--border); font-size: 13.5px; }
tr:hover td { background: rgba(255,255,255,0.02); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green { background: rgba(37,211,102,0.15); color: var(--accent); }
.badge-blue { background: rgba(79,142,247,0.15); color: var(--blue); }
.badge-orange { background: rgba(249,115,22,0.15); color: var(--orange); }
.badge-red { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-gray { background: rgba(255,255,255,0.07); color: var(--text-secondary); }
.badge-purple { background: rgba(124,92,250,0.15); color: var(--purple); }

/* Search & Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.search-wrap { position: relative; flex: 1; min-width: 200px; }
.search-wrap input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13.5px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: var(--transition);
}
.search-wrap input:focus { border-color: var(--accent); }
.search-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 15px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 32px 80px rgba(0,0,0,0.7);
  animation: slideUp 0.2s ease;
}
.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1100px; }
.modal-header {
  display: flex;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; flex: 1; }
.modal-body { padding: 24px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* Alert / Toast */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInRight 0.3s ease;
  box-shadow: var(--shadow);
}
.toast-success { background: rgba(37,211,102,0.15); border: 1px solid rgba(37,211,102,0.3); color: var(--accent); }
.toast-error { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3); color: var(--red); }
.toast-info { background: rgba(79,142,247,0.15); border: 1px solid rgba(79,142,247,0.3); color: var(--blue); }

/* Canvas Editor */
.canvas-editor-wrap {
  position: relative;
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.canvas-container {
  position: relative;
  flex: 1;
  min-width: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px dashed var(--border);
  background: #111;
  cursor: crosshair;
}
.canvas-container canvas { display: block; max-width: 100%; }
.canvas-controls {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Progress */
.progress-bar-wrap { background: var(--bg-dark); border-radius: 4px; height: 6px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--blue)); border-radius: 4px; transition: width 0.5s ease; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; color: var(--text-primary); }
.empty-state p { font-size: 13px; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px 0 0;
}
.page-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  transition: var(--transition);
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #000; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
  margin-bottom: -1px;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* Checkbox */
.checkbox-wrap { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.checkbox-wrap input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Upload Zone */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.upload-zone .upload-icon { font-size: 36px; margin-bottom: 12px; opacity: 0.5; }
.upload-zone p { color: var(--text-secondary); font-size: 13px; }
.upload-zone strong { color: var(--accent); }

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.animate-fadeIn { animation: fadeIn 0.3s ease; }
.animate-pulse { animation: pulse 2s infinite; }

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card2) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Color picker inline */
.color-row { display: flex; align-items: center; gap: 10px; }
.color-row input[type="color"] {
  width: 40px; height: 36px;
  padding: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-dark);
  cursor: pointer;
}

/* Split layout */
.split-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.split-layout-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* Contact count badge on nav */
.nav-badge {
  margin-left: auto;
  background: var(--accent-glow);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* Responsive */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-260px); width: 260px; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .split-layout, .form-row { grid-template-columns: 1fr; }
}

/* WA Link Row in send list */
.wa-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  transition: var(--transition);
}
.wa-link-row:hover { border-color: var(--border-hover); }
.wa-link-name { font-weight: 600; font-size: 13px; min-width: 150px; }
.wa-link-phone { color: var(--text-secondary); font-size: 12px; min-width: 130px; }
.wa-link-url { flex: 1; font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.wa-status-dot.sent { background: var(--accent); }
.wa-status-dot.pending { background: var(--text-muted); }
.wa-status-dot.failed { background: var(--red); }
