/* ============================================================
   Affiliate Subscription Tracker — Premium SaaS Theme
   Color Palette: Dark Sidebar #0d1117 | Gold #D4AF37 | White #fff | Gray #f8f9fa
   ============================================================ */

:root {
  --sidebar-bg:     #0d1117;
  --sidebar-border: #1f2937;
  --sidebar-width:  260px;
  --gold:           #D4AF37;
  --gold-dark:      #b8960c;
  --gold-light:     #f0d060;
  --gold-glow:      rgba(212,175,55,0.15);
  --text-primary:   #1a202c;
  --text-muted:     #6b7280;
  --bg-main:        #f4f6f9;
  --bg-card:        #ffffff;
  --border-color:   #e5e7eb;
  --danger:         #ef4444;
  --success:        #10b981;
  --warning:        #f59e0b;
  --info:           #3b82f6;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:      0 4px 12px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:      0 10px 30px rgba(0,0,0,.12);
  --radius:         10px;
  --radius-sm:      6px;
  --transition:     all .2s ease;
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  font-size: .9rem;
  line-height: 1.6;
  overflow-x: hidden;
}
a { text-decoration: none; transition: var(--transition); }
img { max-width: 100%; }

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

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

/* ── Sidebar ──────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1000;
  transition: transform .3s ease;
  overflow-y: auto;
  border-right: 1px solid var(--sidebar-border);
}

.sidebar-logo {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.sidebar-logo .logo-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: #000;
  flex-shrink: 0;
}
.sidebar-logo .logo-text { color: #fff; font-weight: 700; font-size: .95rem; line-height: 1.2; }
.sidebar-logo .logo-text small { color: #6b7280; font-size: .7rem; font-weight: 400; display: block; }

/* Nav sections */
.nav-section-title {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #4b5563;
  padding: 1.25rem 1.25rem .4rem;
}
.sidebar-nav { list-style: none; margin: 0; padding: 0; }
.sidebar-nav .nav-item { margin: 1px 8px; }
.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1rem;
  border-radius: var(--radius-sm);
  color: #9ca3af;
  font-size: .85rem;
  font-weight: 500;
  transition: var(--transition);
}
.sidebar-nav .nav-link:hover {
  color: #fff;
  background: rgba(255,255,255,.06);
}
.sidebar-nav .nav-link.active {
  color: var(--gold);
  background: var(--gold-glow);
  border: 1px solid rgba(212,175,55,.2);
}
.sidebar-nav .nav-link i { width: 18px; text-align: center; font-size: .9rem; flex-shrink: 0; }
.sidebar-nav .nav-link .badge-count {
  margin-left: auto;
  background: var(--gold);
  color: #000;
  font-size: .65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 1rem;
  border-top: 1px solid var(--sidebar-border);
}
.admin-card {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .75rem;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.04);
}
.admin-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #000; font-weight: 700; font-size: .85rem; flex-shrink: 0;
}
.admin-info .admin-name { color: #fff; font-weight: 600; font-size: .8rem; }
.admin-info .admin-role { color: #6b7280; font-size: .7rem; }

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

/* ── Top Navbar ───────────────────────────────────────────── */
.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky; top: 0;
  z-index: 900;
  box-shadow: var(--shadow-sm);
}
.topbar-toggle {
  display: none;
  background: none; border: none;
  color: var(--text-muted); font-size: 1.2rem; cursor: pointer;
}
.topbar-title { font-weight: 700; font-size: 1rem; color: var(--text-primary); flex: 1; }
.topbar-title small { font-weight: 400; color: var(--text-muted); font-size: .78rem; }
.topbar-actions { display: flex; align-items: center; gap: .5rem; }
.topbar-btn {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: none; display: flex; align-items: center;
  justify-content: center; color: var(--text-muted);
  cursor: pointer; position: relative; transition: var(--transition);
}
.topbar-btn:hover { background: var(--bg-main); color: var(--text-primary); }
.topbar-btn .notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--danger); border-radius: 50%;
  border: 2px solid #fff;
}
.notif-count {
  position: absolute; top: 4px; right: 4px;
  background: var(--gold); color: #000;
  font-size: .6rem; font-weight: 700;
  width: 16px; height: 16px;
  border-radius: 50%; display: flex;
  align-items: center; justify-content: center;
  border: 1px solid #fff;
}

/* ── Page Body ────────────────────────────────────────────── */
.page-body { padding: 1.5rem; flex: 1; }
.page-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: .75rem;
}
.page-header h1 {
  font-size: 1.3rem; font-weight: 700;
  color: var(--text-primary); margin: 0;
}
.breadcrumb-bar { color: var(--text-muted); font-size: .8rem; }
.breadcrumb-bar a { color: var(--gold); }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  font-weight: 700; font-size: .9rem;
  background: transparent;
}
.card-body { padding: 1.25rem; }

/* ── Stat Cards ───────────────────────────────────────────── */
.stat-card {
  border-radius: var(--radius);
  padding: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0;
  width: 4px; height: 100%;
  background: var(--accent, var(--gold));
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .stat-icon {
  width: 46px; height: 46px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; margin-bottom: .75rem;
  background: var(--icon-bg, var(--gold-glow));
  color: var(--icon-color, var(--gold));
}
.stat-card .stat-value {
  font-size: 1.6rem; font-weight: 800;
  color: var(--text-primary); line-height: 1;
  margin-bottom: .25rem;
}
.stat-card .stat-label { color: var(--text-muted); font-size: .78rem; font-weight: 500; }
.stat-card .stat-change {
  position: absolute; top: 1rem; right: 1rem;
  font-size: .72rem; font-weight: 600;
  padding: 2px 8px; border-radius: 20px;
}

/* ── Tables ───────────────────────────────────────────────── */
.table-card { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.data-table {
  width: 100%; border-collapse: separate;
  border-spacing: 0; font-size: .85rem;
}
.data-table thead th {
  background: #f9fafb;
  padding: .75rem 1rem;
  font-weight: 700; font-size: .75rem;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}
.data-table tbody td {
  padding: .8rem 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafbff; }

/* ── Affiliate avatar chip ───────────────────────────────── */
.aff-chip { display: flex; align-items: center; gap: .65rem; }
.aff-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem; color: #000; flex-shrink: 0;
}
.aff-name { font-weight: 600; color: var(--text-primary); font-size: .85rem; }
.aff-id { color: var(--text-muted); font-size: .72rem; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: #000 !important; font-weight: 700; border: none;
  transition: var(--transition);
}
.btn-gold:hover {
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  transform: translateY(-1px); box-shadow: 0 4px 12px rgba(212,175,55,.4);
}
.btn-outline-gold {
  border: 1.5px solid var(--gold);
  color: var(--gold) !important;
  background: transparent;
  font-weight: 600;
  transition: var(--transition);
}
.btn-outline-gold:hover {
  background: var(--gold-glow); transform: translateY(-1px);
}
.btn-icon {
  width: 32px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); font-size: .8rem;
}

/* ── Badges ───────────────────────────────────────────────── */
.badge { font-size: .72rem; font-weight: 600; padding: .3em .65em; }

/* ── Progress ─────────────────────────────────────────────── */
.progress-stack { }
.progress { height: 8px; border-radius: 4px; background: #e5e7eb; }
.progress-label { display: flex; justify-content: space-between; margin-bottom: 4px; font-size: .75rem; }

/* ── Forms ────────────────────────────────────────────────── */
.form-label { font-weight: 600; font-size: .82rem; color: var(--text-primary); margin-bottom: .35rem; }
.form-control, .form-select {
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: .55rem .85rem;
  font-size: .875rem;
  transition: var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212,175,55,.15);
}
.form-section-title {
  font-size: .75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--gold);
  margin: 1.25rem 0 .75rem;
  padding-bottom: .4rem;
  border-bottom: 1.5px solid var(--gold-glow);
}

/* ── Notes ────────────────────────────────────────────────── */
.note-item {
  border-left: 3px solid var(--gold);
  padding: .75rem 1rem;
  background: #fffdf0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: .75rem;
}
.note-item.pinned { border-left-color: var(--danger); background: #fff5f5; }
.note-meta { font-size: .72rem; color: var(--text-muted); margin-top: .3rem; }

/* ── Profile page ─────────────────────────────────────────── */
.profile-header {
  background: linear-gradient(135deg, var(--sidebar-bg) 0%, #1f2937 100%);
  color: #fff; padding: 2rem;
  border-radius: var(--radius);
  position: relative; overflow: hidden;
}
.profile-header::after {
  content: '';
  position: absolute; top: -30px; right: -30px;
  width: 150px; height: 150px;
  background: var(--gold-glow);
  border-radius: 50%;
}
.profile-avatar-lg {
  width: 70px; height: 70px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; font-weight: 800; color: #000;
  border: 3px solid rgba(255,255,255,.2);
  flex-shrink: 0;
}
.profile-info .affiliate-id-badge {
  background: rgba(212,175,55,.2);
  color: var(--gold); font-size: .72rem;
  font-weight: 700; letter-spacing: .05em;
  padding: .2em .7em; border-radius: 20px;
  border: 1px solid rgba(212,175,55,.3);
}

/* ── Due status ───────────────────────────────────────────── */
.due-indicator {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .75rem; font-weight: 600; padding: .25em .65em;
  border-radius: 20px;
}
.due-current   { background: #d1fae5; color: #065f46; }
.due-warning   { background: #fef3c7; color: #92400e; }
.due-overdue   { background: #fee2e2; color: #991b1b; }

/* ── Rule engine ──────────────────────────────────────────── */
.rule-card {
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  transition: var(--transition);
}
.rule-card:hover { border-color: var(--gold); box-shadow: var(--shadow-md); }
.rule-card.active-rule { border-color: var(--gold); }
.rule-threshold-badge {
  font-size: 1.4rem; font-weight: 900;
  color: var(--gold); line-height: 1;
}

/* ── Reminder widget ──────────────────────────────────────── */
.reminder-box {
  background: #fffdf0; border: 1.5px dashed var(--gold);
  border-radius: var(--radius); padding: 1.25rem;
  white-space: pre-line; font-size: .88rem;
  font-family: monospace; color: var(--text-primary);
  min-height: 160px;
}

/* ── Activity timeline ────────────────────────────────────── */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before {
  content: ''; position: absolute;
  left: .65rem; top: 0; bottom: 0;
  width: 2px; background: var(--border-color);
}
.timeline-item { position: relative; margin-bottom: 1rem; }
.timeline-item::before {
  content: ''; position: absolute;
  left: -1.65rem; top: .35rem;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid #fff;
  box-shadow: var(--shadow-sm);
}
.timeline-body { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: .65rem .9rem; font-size: .82rem; }
.timeline-time { font-size: .7rem; color: var(--text-muted); margin-top: .2rem; }

/* ── Search bar ───────────────────────────────────────────── */
.search-wrapper { position: relative; }
.search-wrapper .search-icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search-wrapper input { padding-left: 2.25rem; }

/* ── Login page ───────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute; width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(212,175,55,.08) 0%, transparent 70%);
  top: -150px; right: -150px;
}
.login-page::after {
  content: '';
  position: absolute; width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(212,175,55,.05) 0%, transparent 70%);
  bottom: -100px; left: -100px;
}
.login-card {
  background: #161b25;
  border: 1px solid rgba(212,175,55,.2);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%; max-width: 420px;
  box-shadow: 0 25px 60px rgba(0,0,0,.5);
  position: relative; z-index: 1;
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo .logo-icon-lg {
  width: 60px; height: 60px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.5rem; color: #000; margin-bottom: .75rem;
}
.login-logo h4 { color: #fff; font-weight: 800; margin: 0; font-size: 1.1rem; }
.login-logo p { color: #6b7280; font-size: .8rem; margin: .2rem 0 0; }
.login-card .form-label { color: #9ca3af; }
.login-card .form-control {
  background: #0d1117; border-color: #2d3748;
  color: #fff;
}
.login-card .form-control:focus {
  background: #0d1117; color: #fff;
  border-color: var(--gold);
}
.login-card .form-control::placeholder { color: #4b5563; }

/* ── Notification dropdown ────────────────────────────────── */
.notif-dropdown {
  width: 340px;
  max-height: 400px;
  overflow-y: auto;
}
.notif-item {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition);
}
.notif-item:hover { background: var(--bg-main); }
.notif-item.unread { background: #fffdf0; }
.notif-item .notif-title { font-weight: 600; font-size: .82rem; }
.notif-item .notif-msg { font-size: .78rem; color: var(--text-muted); }
.notif-item .notif-time { font-size: .7rem; color: var(--text-muted); margin-top: .2rem; }

/* ── Toast ────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; }
.toast { border-radius: var(--radius-sm); }
.toast.gold-toast { border-left: 4px solid var(--gold); }

/* ── Charts (canvas) ─────────────────────────────────────── */
.chart-container { position: relative; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 992px) {
  #sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  #sidebar.open { transform: translateX(0); }
  #main-content { margin-left: 0; }
  .topbar-toggle { display: block; }
  .sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.5); z-index: 999;
  }
  .sidebar-overlay.show { display: block; }
}
@media (max-width: 576px) {
  .page-body { padding: 1rem; }
  .stat-card .stat-value { font-size: 1.3rem; }
}

/* ── Utilities ────────────────────────────────────────────── */
.text-gold { color: var(--gold) !important; }
.bg-gold-subtle { background: var(--gold-glow) !important; }
.border-gold { border-color: var(--gold) !important; }
.font-mono { font-family: 'Courier New', monospace; }
.fw-800 { font-weight: 800; }
.gap-2 { gap: .5rem; }

/* ── Animation ────────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in-up { animation: fadeInUp .35s ease forwards; }
