/* ================================================================
   WA.Link Admin Panel — Custom CSS
   Bootstrap 5 base + WhatsApp-inspired green theme
   ================================================================ */

:root {
  --wa-green:        #25D366;
  --wa-green-dark:   #128C7E;
  --wa-green-light:  #DCF8C6;
  --sidebar-bg:      #1a1f36;
  --sidebar-width:   250px;
  --topbar-height:   60px;
  --text-muted-2:    #8898aa;
}

/* ── Reset / Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f4f6fb;
  color: #2d3748;
  margin: 0;
}

/* ── Layout wrapper ──────────────────────────────────────────── */
.admin-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.admin-sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform 0.25s ease;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 22px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: var(--wa-green);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 18px;
  flex-shrink: 0;
}
.sidebar-logo .logo-text {
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.sidebar-nav {
  padding: 16px 0;
  flex: 1;
}
.nav-section-label {
  padding: 10px 22px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.3);
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 22px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: 0;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}
.sidebar-nav a.active {
  background: rgba(37,211,102,0.12);
  color: var(--wa-green);
  border-left-color: var(--wa-green);
}
.sidebar-nav a i { width: 18px; text-align: center; font-size: 15px; }

.sidebar-footer {
  padding: 16px 22px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.sidebar-footer a {
  color: rgba(255,255,255,0.5);
  font-size: 13px;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color 0.15s;
}
.sidebar-footer a:hover { color: #fff; }

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

/* ── Topbar ──────────────────────────────────────────────────── */
.admin-topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e8ecf1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.topbar-left .page-heading {
  font-size: 17px;
  font-weight: 700;
  color: #1a1f36;
  margin: 0;
}
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-user {
  display: flex; align-items: center; gap: 9px;
  font-size: 14px; font-weight: 500; color: #2d3748;
  cursor: pointer;
}
.topbar-user .avatar {
  width: 34px; height: 34px;
  background: var(--wa-green);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; font-weight: 700;
}

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

/* ── Stat cards ──────────────────────────────────────────────── */
.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 22px 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid #eef0f5;
  transition: box-shadow 0.2s;
}
.stat-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
.stat-icon {
  width: 50px; height: 50px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-icon.green  { background: rgba(37,211,102,0.12); color: var(--wa-green-dark); }
.stat-icon.blue   { background: rgba(59,130,246,0.12); color: #3b82f6; }
.stat-icon.orange { background: rgba(249,115,22,0.12); color: #f97316; }
.stat-icon.red    { background: rgba(239,68,68,0.12);  color: #ef4444; }
.stat-icon.purple { background: rgba(139,92,246,0.12); color: #8b5cf6; }
.stat-body h2 {
  font-size: 26px; font-weight: 800; color: #1a1f36; margin: 0 0 2px;
  line-height: 1;
}
.stat-body p {
  font-size: 13px; color: var(--text-muted-2); margin: 0;
}

/* ── Content cards ───────────────────────────────────────────── */
.content-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  border: 1px solid #eef0f5;
  overflow: hidden;
}
.content-card .card-header {
  padding: 18px 22px;
  border-bottom: 1px solid #eef0f5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
}
.content-card .card-header h5 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #1a1f36;
}
.content-card .card-body { padding: 22px; }

/* ── Tables ──────────────────────────────────────────────────── */
.table { font-size: 14px; }
.table th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted-2);
  border-top: none;
  background: #f8fafd;
  padding: 10px 14px;
}
.table td { padding: 12px 14px; vertical-align: middle; }
.table tbody tr:hover { background: #f8fafd; }

/* ── Username badge ─────────────────────────────────────────── */
.username-badge {
  font-family: 'Courier New', monospace;
  background: #f0fdf4;
  color: var(--wa-green-dark);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
}

/* ── Short link copy ─────────────────────────────────────────── */
.short-link-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 260px;
}
.short-link-wrap input {
  font-size: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 4px 8px;
  background: #f8fafd;
  color: #555;
  flex: 1;
  min-width: 0;
}
.btn-copy {
  background: none;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--text-muted-2);
  transition: all 0.15s;
  font-size: 13px;
  white-space: nowrap;
}
.btn-copy:hover { background: var(--wa-green); color: #fff; border-color: var(--wa-green); }
.btn-copy.copied { background: var(--wa-green); color: #fff; border-color: var(--wa-green); }

/* ── Status badges ───────────────────────────────────────────── */
.badge-active   { background: #d1fae5; color: #065f46; font-size: 11px; padding: 3px 8px; border-radius: 20px; font-weight: 600; }
.badge-inactive { background: #fee2e2; color: #991b1b; font-size: 11px; padding: 3px 8px; border-radius: 20px; font-weight: 600; }
.badge-none     { background: #e0f2fe; color: #0369a1; font-size: 11px; padding: 3px 8px; border-radius: 20px; font-weight: 600; }
.badge-blacklist{ background: #fef3c7; color: #92400e; font-size: 11px; padding: 3px 8px; border-radius: 20px; font-weight: 600; }
.badge-whitelist{ background: #dcfce7; color: #166534; font-size: 11px; padding: 3px 8px; border-radius: 20px; font-weight: 600; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-wa {
  background: var(--wa-green);
  color: #fff;
  border: none;
  font-weight: 600;
  transition: background 0.15s;
}
.btn-wa:hover { background: var(--wa-green-dark); color: #fff; }
.btn-wa:focus { box-shadow: 0 0 0 3px rgba(37,211,102,0.3); }

/* ── Forms ───────────────────────────────────────────────────── */
.form-label { font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 5px; }
.form-control, .form-select {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  padding: 9px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--wa-green);
  box-shadow: 0 0 0 3px rgba(37,211,102,0.15);
}
.form-text { font-size: 12px; color: var(--text-muted-2); }

/* ── Block mode toggle ───────────────────────────────────────── */
.block-mode-card {
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.block-mode-card:hover { border-color: var(--wa-green); }
.block-mode-card.selected { border-color: var(--wa-green); background: #f0fdf4; }
.block-mode-card .bmc-title { font-size: 14px; font-weight: 700; }
.block-mode-card .bmc-desc  { font-size: 12px; color: var(--text-muted-2); margin-top: 3px; }

/* ── Rule tags ───────────────────────────────────────────────── */
.rule-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 13px;
  margin: 3px;
}
.rule-tag .remove-rule {
  cursor: pointer;
  color: #ef4444;
  font-size: 12px;
  text-decoration: none;
  line-height: 1;
}
.rule-tag .remove-rule:hover { color: #b91c1c; }

/* ── Chart container ─────────────────────────────────────────── */
.chart-wrap { min-height: 280px; }

/* ── Login page ──────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1f36 0%, #0f1626 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: #fff;
  border-radius: 18px;
  padding: 42px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo .icon-circle {
  width: 60px; height: 60px;
  background: var(--wa-green);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  margin-bottom: 12px;
}
.login-logo h2 { font-size: 22px; font-weight: 800; color: #1a1f36; margin: 0; }
.login-logo p  { font-size: 13px; color: var(--text-muted-2); margin: 4px 0 0; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .admin-sidebar {
    transform: translateX(-100%);
  }
  .admin-sidebar.open {
    transform: translateX(0);
  }
  .admin-main {
    margin-left: 0;
  }
  .admin-content { padding: 16px; }
}

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Flash messages ──────────────────────────────────────────── */
.flash-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 18px;
}
.flash-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 18px;
}

/* ── Source/device colour dots ───────────────────────────────── */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.dot-fb       { background: #1877f2; }
.dot-google   { background: #ea4335; }
.dot-twitter  { background: #1da1f2; }
.dot-tiktok   { background: #010101; }
.dot-instagram{ background: #e1306c; }
.dot-direct   { background: #6b7280; }
.dot-other    { background: #9ca3af; }
.dot-mobile   { background: var(--wa-green); }
.dot-desktop  { background: #3b82f6; }
.dot-tablet   { background: #f59e0b; }
