/* ============================================================
   WA BLAST CRM - Premium Dark Mode Design System
   ============================================================ */

:root {
  /* Color palette */
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a2233;
  --bg-card-hover: #1f2b3e;
  --bg-input: #0f1623;
  --bg-glass: rgba(26, 34, 51, 0.7);

  --border: #1e293b;
  --border-focus: #3b82f6;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.3);

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --info: #06b6d4;
  --info-bg: rgba(6, 182, 212, 0.1);
  --purple: #8b5cf6;
  --purple-bg: rgba(139, 92, 246, 0.1);

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #3b82f6, #8b5cf6);
  --gradient-success: linear-gradient(135deg, #10b981, #06b6d4);
  --gradient-danger: linear-gradient(135deg, #ef4444, #f59e0b);
  --gradient-dark: linear-gradient(135deg, #1a2233, #111827);

  /* Sizing */
  --sidebar-width: 260px;
  --sidebar-collapsed: 70px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px var(--accent-glow);

  /* Transitions */
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-primary);
  z-index: 1000;
}

.login-container {
  position: relative;
  width: 100%; max-width: 420px;
  padding: 20px;
}

.login-glow {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 400px; height: 400px;
  background: radial-gradient(circle, var(--accent-glow), transparent 70%);
  filter: blur(60px);
  animation: pulse-glow 4s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.4; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 0.7; transform: translate(-50%, -50%) scale(1.1); }
}

.login-card {
  position: relative;
  background: var(--bg-glass);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-lg);
  animation: slide-up 0.6s ease;
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-logo { text-align: center; margin-bottom: 32px; }
.logo-icon { font-size: 48px; margin-bottom: 12px; }
.login-logo h1 {
  font-size: 24px; font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-subtitle { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

.form-group { margin-bottom: 20px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); margin-bottom: 6px;
}

input, select, textarea {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit; font-size: 14px;
  transition: var(--transition);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
input::placeholder { color: var(--text-muted); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px;
  border: none; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 2px 8px var(--accent-glow);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #0ea572; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }

.btn-warning { background: var(--warning); color: #1a1a1a; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

.btn-loader {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.main-app {
  display: flex; height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: var(--transition);
  overflow: hidden;
  flex-shrink: 0;
  z-index: 100;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .user-info,
.sidebar.collapsed .sidebar-footer .nav-text { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 16px 8px; }
.sidebar.collapsed .sidebar-user { justify-content: center; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px; }

.sidebar-header {
  display: flex; align-items: center; gap: 12px;
  padding: 20px; border-bottom: 1px solid var(--border);
}
.sidebar-logo { font-size: 28px; }
.sidebar-title {
  font-size: 16px; font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.sidebar-toggle {
  margin-left: auto;
  background: none; border: none;
  color: var(--text-muted); font-size: 18px;
  cursor: pointer; padding: 4px;
}

.sidebar-user {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.user-avatar {
  width: 36px; height: 36px;
  background: var(--gradient-primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}
.user-name { font-size: 14px; font-weight: 600; }
.user-role {
  font-size: 11px; font-weight: 700;
  color: var(--accent); letter-spacing: 0.5px;
}

.nav-menu {
  list-style: none;
  padding: 12px 8px;
  flex: 1; overflow-y: auto;
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px; font-weight: 500;
  transition: var(--transition);
  margin-bottom: 2px;
}
.nav-item:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 600;
}
.nav-icon { font-size: 18px; flex-shrink: 0; width: 24px; text-align: center; }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
}
.sidebar-footer .btn { justify-content: flex-start; }

/* ============================================================
   CONTENT AREA
   ============================================================ */
.content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-primary);
}

.page-container { padding: 24px; max-width: 1400px; }

.page-header {
  margin-bottom: 24px;
}
.page-header h2 {
  font-size: 24px; font-weight: 800;
  margin-bottom: 4px;
}
.page-header p { color: var(--text-muted); font-size: 14px; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: var(--transition);
}
.card:hover { border-color: rgba(59, 130, 246, 0.2); }

.card-title {
  font-size: 14px; font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.kpi-card.blue::before { background: var(--gradient-primary); }
.kpi-card.green::before { background: var(--gradient-success); }
.kpi-card.red::before { background: var(--gradient-danger); }
.kpi-card.purple::before { background: linear-gradient(135deg, #8b5cf6, #ec4899); }
.kpi-card.yellow::before { background: linear-gradient(135deg, #f59e0b, #ef4444); }

.kpi-icon {
  font-size: 32px; margin-bottom: 12px;
}
.kpi-value {
  font-size: 32px; font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}
.kpi-label {
  font-size: 13px; color: var(--text-muted); font-weight: 500;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
thead { background: var(--bg-secondary); }
th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
tr:hover td { background: var(--bg-card-hover); }
tr:last-child td { border-bottom: none; }

/* ============================================================
   BADGES / STATUS CHIPS
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-fresh { background: var(--success-bg); color: var(--success); }
.badge-used { background: var(--warning-bg); color: var(--warning); }
.badge-blacklist { background: var(--danger-bg); color: var(--danger); }
.badge-regis { background: var(--info-bg); color: var(--info); }
.badge-aktif { background: var(--success-bg); color: var(--success); }
.badge-inaktif { background: var(--purple-bg); color: var(--purple); }
.badge-pending { background: var(--warning-bg); color: var(--warning); }
.badge-approved { background: var(--success-bg); color: var(--success); }
.badge-rejected { background: var(--danger-bg); color: var(--danger); }
.badge-executed { background: var(--info-bg); color: var(--info); }
.badge-failed { background: var(--danger-bg); color: var(--danger); }
.badge-master { background: linear-gradient(135deg, rgba(239,68,68,0.15), rgba(245,158,11,0.15)); color: #f59e0b; }
.badge-admin { background: var(--info-bg); color: var(--info); }
.badge-marketing { background: var(--purple-bg); color: var(--purple); }
.badge-blaster { background: var(--success-bg); color: var(--success); }

/* ============================================================
   FILTERS BAR
   ============================================================ */
.filters-bar {
  display: flex; gap: 12px; flex-wrap: wrap;
  margin-bottom: 20px; align-items: flex-end;
}
.filters-bar .form-group { margin-bottom: 0; flex: 1; min-width: 160px; }
.filters-bar select, .filters-bar input { padding: 10px 12px; font-size: 13px; }

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress-bar {
  width: 100%; height: 8px;
  background: var(--bg-input);
  border-radius: 4px; overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: 4px;
  transition: width 0.6s ease;
}
.progress-fill.high { background: var(--gradient-danger); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: fade-in 0.2s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%; max-width: 540px;
  max-height: 80vh;
  overflow: hidden;
  animation: modal-in 0.3s ease;
  display: flex; flex-direction: column;
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-close {
  background: none; border: none;
  color: var(--text-muted); font-size: 24px;
  cursor: pointer; padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.modal-close:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.modal-body {
  padding: 24px;
  overflow-y: auto; flex: 1;
}
.modal-footer {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 2000;
  display: flex; flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.3s ease;
  display: flex; align-items: center; gap: 10px;
  max-width: 380px;
  border-left: 3px solid var(--accent);
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast-exit {
  animation: toast-out 0.3s ease forwards;
}
@keyframes toast-out {
  to { opacity: 0; transform: translateX(40px); }
}

/* ============================================================
   UPLOAD AREA
   ============================================================ */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}
.upload-area:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.upload-area.dragover {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.upload-icon { font-size: 48px; margin-bottom: 12px; }
.upload-text { font-size: 15px; color: var(--text-secondary); margin-bottom: 4px; }
.upload-hint { font-size: 12px; color: var(--text-muted); }

/* ============================================================
   STATS GRID
   ============================================================ */
.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-text { font-size: 16px; font-weight: 500; }

/* ============================================================
   LOADING SPINNER
   ============================================================ */
.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ============================================================
   ERROR MSG
   ============================================================ */
.error-msg {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-top: 12px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -100%;
    height: 100vh;
    z-index: 200;
    transition: left 0.3s ease;
  }
  .sidebar.mobile-open { left: 0; }

  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .stats-row { grid-template-columns: 1fr; }
  .filters-bar { flex-direction: column; }
  .page-container { padding: 16px; }
}

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

/* ============================================================
   GRID LAYOUTS
   ============================================================ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 768px) { .grid-2 { grid-template-columns: 1fr; } }

/* Number formatting */
.num { font-variant-numeric: tabular-nums; }

/* Action buttons in tables */
td .btn { padding: 4px 10px; font-size: 12px; }
td .btn-group { gap: 4px; }

/* Pagination */
.pagination {
  display: flex; gap: 8px; align-items: center; justify-content: center;
  margin-top: 20px;
}
.pagination .btn { min-width: 36px; }
.pagination .page-info { color: var(--text-muted); font-size: 13px; }
