/* ==========================================================================
   web-admin.css — Giao Diện Trang Quản Trị Website, Thống Kê & Affiliate
   Phong cách Candy Gloss 3D Toy Chibi, màu biển đêm sang trọng, responsive
   ========================================================================== */

:root {
  --bg-dark: #07152f;
  --bg-gradient: radial-gradient(1200px 700px at 10% -10%, rgba(56, 189, 248, 0.25), transparent 60%),
                 radial-gradient(1000px 600px at 100% 10%, rgba(244, 114, 182, 0.2), transparent 50%),
                 linear-gradient(180deg, #0b2254 0%, #06132b 100%);
  --card-bg: rgba(13, 34, 77, 0.88);
  --card-border: rgba(255, 255, 255, 0.22);
  --card-border-active: #ffffff;
  --gloss: inset 0 3px 0 rgba(255, 255, 255, 0.35), inset 0 -4px 0 rgba(0, 0, 0, 0.25);
  --shadow-card: 0 16px 36px -12px rgba(0, 0, 0, 0.65);
  
  --title-font: 'Baloo 2', cursive, system-ui, sans-serif;
  --body-font: 'Be Vietnam Pro', system-ui, sans-serif;

  --accent-gold: #fde047;
  --accent-cyan: #38bdf8;
  --accent-orange: #fb923c;
  --accent-pink: #f472b6;
  --accent-green: #4ade80;
  --accent-purple: #c084fc;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body.web-admin-body {
  min-height: 100vh;
  font-family: var(--body-font);
  background: var(--bg-dark);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: #f1f5f9;
  line-height: 1.5;
  padding-bottom: 60px;
}

.admin-header {
  position: sticky;
  top: 0;
  z-index: 99;
  background: rgba(7, 21, 47, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 2px solid rgba(255, 255, 255, 0.16);
  padding: 12px 24px;
}

.admin-header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #fff;
}

.brand-badge-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(180deg, #38bdf8, #0284c7);
  border: 2.5px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: var(--gloss);
}

.brand-text-col strong {
  font-family: var(--title-font);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.3px;
  display: block;
  line-height: 1.1;
  color: #fff;
}

.brand-text-col span {
  font-size: 12.5px;
  color: #93c5fd;
  font-weight: 600;
}

.admin-nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 700;
  text-decoration: none;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  cursor: pointer;
  transition: all 0.18s ease;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: #fff;
  color: #fff;
  transform: translateY(-1px);
}

.nav-btn.primary {
  background: linear-gradient(180deg, #38bdf8, #0284c7);
  border-color: #fff;
  color: #fff;
  box-shadow: var(--gloss);
}

.nav-btn.orange {
  background: linear-gradient(180deg, #fb923c, #ea580c);
  border-color: #fff;
  color: #fff;
  box-shadow: var(--gloss);
}

/* Tabs switcher */
.admin-tabs-bar {
  max-width: 1400px;
  margin: 20px auto 0;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.admin-tabs-bar::-webkit-scrollbar { display: none; }

.tab-pill {
  padding: 10px 20px;
  border-radius: 999px;
  background: rgba(13, 34, 77, 0.65);
  border: 2.5px solid rgba(255, 255, 255, 0.25);
  color: #cbd5e1;
  font-family: var(--title-font);
  font-weight: 800;
  font-size: 17px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab-pill:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
}

.tab-pill.active {
  background: linear-gradient(180deg, #38bdf8, #0284c7);
  border-color: #ffffff;
  color: #ffffff;
  box-shadow: var(--gloss), 0 8px 20px rgba(2, 132, 199, 0.45);
}

/* Main Container */
.admin-main {
  max-width: 1400px;
  margin: 24px auto 0;
  padding: 0 20px;
}

.tab-content-panel {
  display: none;
}
.tab-content-panel.active {
  display: block;
}

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

.kpi-card {
  background: var(--card-bg);
  border: 3px solid var(--card-border);
  border-radius: 24px;
  padding: 20px 22px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.5);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
}
.kpi-card.cyan::before { background: var(--accent-cyan); }
.kpi-card.orange::before { background: var(--accent-orange); }
.kpi-card.pink::before { background: var(--accent-pink); }
.kpi-card.green::before { background: var(--accent-green); }

.kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-title {
  font-size: 14.5px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: rgba(255, 255, 255, 0.1);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
}

.kpi-num {
  font-family: var(--title-font);
  font-weight: 800;
  font-size: 38px;
  line-height: 1;
  color: #fff;
  letter-spacing: -0.5px;
}

.kpi-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #cbd5e1;
}

.trend-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: rgba(74, 222, 128, 0.2);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.4);
}

/* 2-column or 3-column layout */
.dashboard-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.candy-panel {
  background: var(--card-bg);
  border: 3px solid var(--card-border);
  border-radius: 26px;
  padding: 24px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(10px);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-title h3 {
  font-family: var(--title-font);
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  margin: 0;
}

.panel-title span {
  font-size: 13px;
  color: #93c5fd;
  font-weight: 600;
}

/* Time Filter Pills */
.time-filter-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.25);
  padding: 4px;
  border-radius: 999px;
  border: 1.5px solid rgba(255, 255, 255, 0.15);
}

.time-btn {
  padding: 5px 12px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.time-btn.active {
  background: linear-gradient(180deg, #38bdf8, #0284c7);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* SVG Chart Container */
.chart-container {
  width: 100%;
  height: 240px;
  position: relative;
  margin-bottom: 12px;
}

.chart-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  font-size: 13px;
  font-weight: 700;
  color: #cbd5e1;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.legend-dot.views { background: var(--accent-cyan); }
.legend-dot.refs { background: var(--accent-orange); }
.legend-dot.conv { background: var(--accent-green); }

/* Distribution list */
.dist-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dist-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dist-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 700;
}

.dist-bar-bg {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  position: relative;
}

.dist-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #38bdf8, #0284c7);
  transition: width 0.5s ease;
}
.dist-bar-fill.orange { background: linear-gradient(90deg, #fb923c, #ea580c); }
.dist-bar-fill.pink { background: linear-gradient(90deg, #f472b6, #db2777); }
.dist-bar-fill.green { background: linear-gradient(90deg, #4ade80, #16a34a); }
.dist-bar-fill.purple { background: linear-gradient(90deg, #c084fc, #9333ea); }

/* Form Card */
.form-card {
  background: rgba(18, 44, 98, 0.95);
  border: 3px solid rgba(255, 255, 255, 0.35);
  border-radius: 22px;
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--gloss);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: flex-end;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 700;
  color: #cbd5e1;
}

.form-input, .form-select {
  padding: 10px 14px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(5, 16, 40, 0.85);
  color: #fff;
  font-family: var(--body-font);
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.15s ease;
}

.form-input:focus, .form-select:focus {
  border-color: var(--accent-gold);
}

.btn-submit {
  padding: 11px 22px;
  border-radius: 14px;
  border: 2.5px solid #fff;
  background: linear-gradient(180deg, #fb923c, #ea580c);
  color: #fff;
  font-family: var(--title-font);
  font-weight: 800;
  font-size: 17px;
  cursor: pointer;
  box-shadow: var(--gloss);
  white-space: nowrap;
  transition: transform 0.15s ease;
}

.btn-submit:hover {
  transform: translateY(-2px);
}

/* Data Table */
.table-wrap {
  overflow-x: auto;
  border-radius: 18px;
  border: 2px solid rgba(255, 255, 255, 0.16);
  background: rgba(6, 17, 43, 0.6);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

.data-table th {
  padding: 14px 16px;
  background: rgba(14, 38, 87, 0.9);
  color: #93c5fd;
  font-weight: 800;
  border-bottom: 2px solid rgba(255, 255, 255, 0.18);
  white-space: nowrap;
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  vertical-align: middle;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.04);
}

.ref-code-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.15);
  border: 1.5px solid rgba(56, 189, 248, 0.45);
  color: #7dd3fc;
  font-family: monospace;
  font-size: 14px;
  font-weight: 700;
}

.btn-copy-ref {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 15px;
  color: #cbd5e1;
  transition: transform 0.1s ease;
}
.btn-copy-ref:hover {
  color: #fde047;
  transform: scale(1.15);
}

.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}
.status-badge.active { background: rgba(74, 222, 128, 0.2); color: #4ade80; border: 1px solid rgba(74, 222, 128, 0.4); }
.status-badge.paid { background: rgba(56, 189, 248, 0.2); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.4); }
.status-badge.pending { background: rgba(251, 146, 60, 0.2); color: #fb923c; border: 1px solid rgba(251, 146, 60, 0.4); }

.action-btn-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-action-sm {
  padding: 5px 10px;
  border-radius: 8px;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-action-sm:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: #fff;
}
.btn-action-sm.pay {
  background: linear-gradient(180deg, #22c55e, #15803d);
  border-color: #fff;
}
.btn-action-sm.danger {
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
  color: #fca5a5;
}

/* Toast */
.admin-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  padding: 12px 20px;
  border-radius: 14px;
  background: #0f172a;
  border: 2px solid #38bdf8;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  display: none;
  animation: slideUpToast 0.25s ease;
}
.admin-toast.show { display: block; }

@keyframes slideUpToast {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Responsive */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-row { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .admin-header-inner { flex-direction: column; align-items: flex-start; }
  .admin-nav-actions { width: 100%; justify-content: flex-start; overflow-x: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .candy-panel { padding: 16px; border-radius: 20px; }
  .kpi-num { font-size: 30px; }
}

