/* src/web/views/style.css — Design system cho Affiliate Dashboard.
   Bảng màu lấy theo tinh thần Shopee (cam #ee4d2d) + nền sáng. */

:root {
  --primary: #ee4d2d;
  --primary-dark: #d04022;
  --primary-light: #fff3ed;
  --primary-50: #fff8f3;
  --gradient: linear-gradient(135deg, #ee4d2d 0%, #f76b1c 100%);

  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e5e7eb;
  --border-light: #f1f3f5;
  --text: #111827;
  --text-2: #4b5563;
  --muted: #6b7280;
  --faint: #9ca3af;

  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --info: #3b82f6;
  --info-bg: #eff6ff;

  --shadow-sm: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow-md: 0 4px 12px rgba(15,23,42,.06), 0 2px 4px rgba(15,23,42,.04);
  --shadow-lg: 0 12px 28px rgba(15,23,42,.08), 0 4px 10px rgba(15,23,42,.04);
  --radius: 10px;
  --radius-sm: 7px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.55 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ============================================================ đăng nhập */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--gradient);
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  width: 56px; height: 56px;
  margin: 0 auto 18px;
  border-radius: 14px;
  background: var(--primary-light);
  color: var(--primary);
  display: grid; place-items: center;
}
.auth-logo svg { width: 28px; height: 28px; }

.auth-title {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  text-align: center;
}
.auth-subtitle {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.auth-links {
  margin-top: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}
.auth-links a { color: var(--primary); cursor: pointer; font-weight: 500; }
.auth-links a:hover { text-decoration: underline; }

.auth-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fecaca;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
}
.auth-ok {
  background: var(--success-bg);
  color: #047857;
  border: 1px solid #a7f3d0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
}

/* ============================================================ form */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(238,77,45,.1);
}
textarea.form-control { min-height: 84px; resize: vertical; font-family: ui-monospace, monospace; font-size: 12px; }
.help-text { font-size: 12px; color: var(--faint); margin-top: 4px; }

/* ============================================================ nút */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: #f9fafb; border-color: #d1d5db; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { background: var(--danger-bg); border-color: #fecaca; color: var(--danger); }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.auth-btn { margin-top: 6px; padding: 11px; }

/* ============================================================ khung trang */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 22px;
  display: flex; align-items: center; gap: 18px;
  height: 58px;
  position: sticky; top: 0; z-index: 50;
}
.logo { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px; }
.logo-icon {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--primary-light); color: var(--primary);
  display: grid; place-items: center;
}
.logo-icon svg { width: 17px; height: 17px; }
.logo b { color: var(--primary); }

.nav-buttons { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 11px; border-radius: 20px;
  background: var(--bg); font-size: 13px; color: var(--text-2);
}
.user-chip b { color: var(--text); }

.container { max-width: 1500px; margin: 0 auto; padding: 20px 22px 60px; }

/* ============================================================ tab */
.main-tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  overflow-x: auto;
}
.main-tab-btn {
  padding: 11px 16px;
  border: none; background: none;
  color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
.main-tab-btn svg { width: 15px; height: 15px; }
.main-tab-btn:hover { color: var(--text); }
.main-tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

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

.tab-container { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tab-btn {
  padding: 7px 13px; border: 1px solid var(--border);
  border-radius: 20px; background: var(--surface);
  font: inherit; font-size: 12px; color: var(--text-2);
  cursor: pointer;
}
.tab-btn.active { background: var(--primary-light); border-color: var(--primary); color: var(--primary); font-weight: 600; }

/* ============================================================ thẻ / số liệu */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px;
  box-shadow: var(--shadow-sm);
}
.stat-label {
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .4px;
  margin-bottom: 6px;
}
.stat-value { font-size: 21px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-value.money { color: var(--primary); }
.stat-sub { font-size: 12px; color: var(--faint); margin-top: 4px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  overflow: hidden;
}
.panel-head {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 13px;
}
.panel-head .spacer { margin-left: auto; }
.panel-body { padding: 16px; }

/* ============================================================ bảng */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  padding: 9px 11px;
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .3px;
  white-space: nowrap;
  position: sticky; top: 0;
}
tbody td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
tbody tr:hover { background: #fafbfc; }
tbody tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.money { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.mono { font-family: ui-monospace, monospace; font-size: 12px; color: var(--text-2); }
tfoot td {
  padding: 11px;
  border-top: 2px solid var(--border);
  font-weight: 700;
  background: #fafbfc;
}

/* ============================================================ nhãn trạng thái */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.badge.ok { background: var(--success-bg); color: #047857; }
.badge.warn { background: var(--warning-bg); color: #b45309; }
.badge.bad { background: var(--danger-bg); color: #b91c1c; }
.badge.info { background: var(--info-bg); color: #1d4ed8; }
.badge.gray { background: var(--bg); color: var(--muted); }

/* ============================================================ modal */
.modal {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15,23,42,.45);
  display: none;
  align-items: flex-start; justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
}
.modal.active { display: flex; }
.modal-content {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 620px;
  margin: auto;
}
.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  font-weight: 600;
}
.modal-head button {
  margin-left: auto; background: none; border: none;
  font-size: 20px; color: var(--muted); cursor: pointer; line-height: 1;
}
.modal-body { padding: 20px; }
.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
}

/* ============================================================ khác */
.loading {
  text-align: center; padding: 40px; color: var(--muted); font-size: 13px;
}
.spinner {
  display: inline-block; width: 17px; height: 17px;
  border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: -3px; margin-right: 7px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty-state .icon { font-size: 34px; margin-bottom: 10px; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff;
  padding: 11px 18px; border-radius: 9px;
  font-size: 13px; z-index: 300;
  box-shadow: var(--shadow-lg);
  max-width: 90vw;
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--success); }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1; min-width: 140px; }
.mt { margin-top: 12px; }
.faint { color: var(--faint); font-size: 12px; }
.hidden { display: none !important; }

.chip-account {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 20px;
  background: var(--primary-50); border: 1px solid #fed7aa;
  color: var(--primary-dark); font-size: 12px; font-weight: 500;
}
.chip-account button {
  background: none; border: none; color: var(--primary);
  cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px;
}
