/* Affiliate Panel — design system */

:root {
  --ap-primary: #4f46e5;
  --ap-primary-dark: #4338ca;
  --ap-primary-light: #818cf8;
  --ap-secondary: #0ea5e9;
  --ap-bg: #f7f8fa;
  --ap-surface: #ffffff;
  --ap-border: #e5e7eb;
  --ap-text-muted: #6b7280;
  --ap-radius: 0.75rem;
  --ap-radius-sm: 0.5rem;
  --ap-shadow-sm: 0 1px 3px rgba(17, 24, 39, 0.06), 0 1px 2px rgba(17, 24, 39, 0.04);
  --ap-shadow-md: 0 8px 24px rgba(17, 24, 39, 0.08);
  --ap-shadow-lg: 0 20px 45px rgba(17, 24, 39, 0.12);
}

* {
  scrollbar-width: thin;
}

html, body {
  height: 100%;
}

body {
  background: var(--ap-bg);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1f2330;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Navbar ---------- */
.ap-navbar {
  background: var(--ap-primary);
}

.ap-navbar .navbar-brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ap-navbar .navbar-brand .ap-logo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.6rem;
  background: rgba(255, 255, 255, 0.18);
  font-size: 1rem;
}

.ap-navbar .nav-link {
  font-weight: 500;
  border-radius: var(--ap-radius-sm);
  padding: 0.5rem 0.9rem;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.ap-navbar .nav-link:hover,
.ap-navbar .nav-link.active {
  background-color: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.ap-user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  font-size: 0.8rem;
  font-weight: 600;
  margin-right: 0.4rem;
}

/* ---------- Layout ---------- */
main {
  animation: ap-fade-in 0.35s ease;
}

@keyframes ap-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.ap-page-header {
  margin-bottom: 1.75rem;
}

.ap-page-header h1 {
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ---------- Cards ---------- */
.card {
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius);
  box-shadow: var(--ap-shadow-sm);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

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

.card-header {
  border-top-left-radius: var(--ap-radius) !important;
  border-top-right-radius: var(--ap-radius) !important;
  font-weight: 600;
}

/* Stat cards */
.ap-stat-card {
  border-radius: var(--ap-radius);
  border: 1px solid var(--ap-border);
  background: var(--ap-surface);
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  box-shadow: var(--ap-shadow-sm);
}

.ap-stat-card .ap-stat-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.ap-stat-card .ap-stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.1;
}

.ap-stat-card .ap-stat-label {
  color: var(--ap-text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ap-bg-indigo { background: #eef0fd; color: #4f46e5; }
.ap-bg-sky { background: #e3f4fd; color: #0ea5e9; }
.ap-bg-emerald { background: #e3f9ef; color: #059669; }
.ap-bg-amber { background: #fef4e3; color: #d97706; }

/* ---------- Buttons ---------- */
.btn {
  border-radius: var(--ap-radius-sm);
  font-weight: 500;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--ap-primary);
  border: none;
}

.btn-primary:hover {
  background: var(--ap-primary-dark);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.22);
}

.btn-outline-primary {
  border-color: var(--ap-primary);
  color: var(--ap-primary);
}

.btn-outline-primary:hover {
  background: var(--ap-primary);
  border-color: var(--ap-primary);
}

/* ---------- Tables ---------- */
.table-responsive {
  border-radius: var(--ap-radius-sm);
}

.table thead th {
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--ap-text-muted);
  background-color: #f9fafb;
  border-bottom: 2px solid var(--ap-border);
  padding: 0.75rem 1rem;
}

.table td {
  padding: 0.65rem 1rem;
  vertical-align: middle;
}

.table td,
.table th {
  border-right: 1px solid var(--ap-border);
}

.table td:last-child,
.table th:last-child {
  border-right: none;
}

.table-hover tbody tr {
  transition: background-color 0.12s ease;
}

.table-hover tbody tr:hover {
  background-color: #f5f6fd;
}

.badge {
  font-weight: 600;
  padding: 0.4em 0.7em;
  border-radius: 999px;
}

/* ---------- Dashboard widgets ---------- */
.ap-widget-icon {
  width: 3rem;
  height: 3rem;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

/* ---------- Empty states ---------- */
.ap-empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--ap-text-muted);
}

.ap-empty-state .ap-empty-icon {
  font-size: 2.5rem;
  color: var(--ap-primary-light);
  margin-bottom: 0.75rem;
}

/* ---------- How-it-works steps ---------- */
.ap-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.ap-step {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  flex: 1 1 220px;
}

.ap-step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: #eef0fd;
  color: var(--ap-primary);
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* ---------- Auth pages ---------- */
.ap-auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top left, #6366f1 0%, #4338ca 45%, #1e1b4b 100%);
  padding: 1.5rem;
}

body:has(.ap-auth-shell) main {
  padding: 0;
}

body:has(.ap-auth-shell) main .container-lg {
  max-width: 100%;
  padding: 0;
}

.ap-auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--ap-surface);
  border-radius: 1.1rem;
  box-shadow: var(--ap-shadow-lg);
  overflow: hidden;
}

.ap-auth-logo {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 1rem;
  background: linear-gradient(135deg, var(--ap-primary), var(--ap-secondary));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin: 0 auto 1rem;
}

.ap-auth-card .form-control {
  border-radius: var(--ap-radius-sm);
  padding: 0.65rem 0.9rem;
}

.ap-auth-card .form-control:focus {
  border-color: var(--ap-primary-light);
  box-shadow: 0 0 0 0.2rem rgba(79, 70, 229, 0.15);
}

/* ---------- Toasts ---------- */
#toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1080;
}

/* ---------- Pagination ---------- */
.pagination .page-link {
  color: var(--ap-primary);
  border-color: var(--ap-border);
}

.pagination .page-item.active .page-link {
  background-color: var(--ap-primary);
  border-color: var(--ap-primary);
}

.pagination .page-link:hover {
  background-color: #eef0fd;
  color: var(--ap-primary-dark);
}

.ap-pagination-bar {
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ---------- Responsive tweaks ---------- */
@media (max-width: 768px) {
  .ap-page-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.75rem;
  }

  .ap-page-header .d-flex.gap-2,
  .ap-page-header > div:last-child {
    width: 100%;
  }

  .ap-stat-card {
    width: 100%;
  }
}
