/* Affiliate Commission Manager — Frontend Portal Styles */

*, *::before, *::after { box-sizing: border-box; }

.afm-portal {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #222;
  line-height: 1.5;
  max-width: 960px;
  margin: 0 auto;
}

/* ============================================================
   Auth Screen (Login / Signup)
   ============================================================ */

.afm-auth-screen {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 16px;
}

.afm-auth-box {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 36px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
}

.afm-auth-box h2 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
}

.afm-auth-box .afm-auth-subtitle {
  margin: 0 0 24px;
  color: #666;
  font-size: 14px;
}

.afm-auth-toggle {
  margin-top: 20px;
  text-align: center;
  font-size: 13px;
  color: #666;
}

.afm-auth-toggle a {
  color: #0066cc;
  text-decoration: none;
  font-weight: 500;
}

.afm-auth-toggle a:hover { text-decoration: underline; }

/* ============================================================
   Forms
   ============================================================ */

.afm-field {
  margin-bottom: 16px;
}

.afm-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 5px;
}

.afm-field input,
.afm-field select,
.afm-field textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  color: #222;
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
  appearance: none;
}

.afm-field input:focus,
.afm-field select:focus,
.afm-field textarea:focus {
  border-color: #0066cc;
  outline: none;
  box-shadow: 0 0 0 3px rgba(0,102,204,.12);
}

.afm-field .afm-help {
  font-size: 11px;
  color: #888;
  margin-top: 4px;
}

/* ============================================================
   Buttons
   ============================================================ */

.afm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity .15s, transform .1s;
  line-height: 1;
}

.afm-btn:hover { opacity: .88; transform: translateY(-1px); }
.afm-btn:active { transform: none; }
.afm-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.afm-btn-primary   { background: #0066cc; color: #fff; border-color: #0066cc; }
.afm-btn-secondary { background: #fff;    color: #222; border-color: #ddd; }
.afm-btn-danger    { background: #dc3545; color: #fff; border-color: #dc3545; }
.afm-btn-ghost     { background: none;    color: #0066cc; border-color: transparent; padding-left: 0; }
.afm-btn-block     { width: 100%; }
.afm-btn-sm        { padding: 6px 13px; font-size: 12px; }

/* ============================================================
   Dashboard Layout
   ============================================================ */

.afm-dashboard {
  padding: 24px 0;
}

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

.afm-dashboard-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.afm-affiliate-code-display {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f0f6ff;
  border: 1px solid #c2d8f5;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 14px;
}

.afm-affiliate-code-display strong {
  color: #0066cc;
  font-size: 16px;
  font-family: monospace;
  letter-spacing: 1px;
}

.afm-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ============================================================
   Stats Strip
   ============================================================ */

.afm-stats-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.afm-stat-card {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 18px 12px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}

.afm-stat-value {
  font-size: 26px;
  font-weight: 700;
  color: #0066cc;
  line-height: 1;
  margin-bottom: 6px;
}

.afm-stat-label {
  font-size: 11px;
  color: #777;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.afm-stat-pending .afm-stat-value  { color: #e6a817; }
.afm-stat-paid    .afm-stat-value  { color: #22863a; }

/* ============================================================
   Tabs
   ============================================================ */

.afm-tab-nav {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #ddd;
  margin-bottom: 24px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.afm-tab-btn {
  padding: 10px 20px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color .15s;
}

.afm-tab-btn:hover   { color: #0066cc; }
.afm-tab-btn.active  { color: #0066cc; border-bottom-color: #0066cc; font-weight: 700; }

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

/* ============================================================
   Table
   ============================================================ */

.afm-table-wrap { overflow-x: auto; }

.afm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.afm-table th,
.afm-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.afm-table th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #777;
  background: #fafafa;
}

.afm-table tbody tr:hover { background: #f9faff; }

/* ============================================================
   Status badges
   ============================================================ */

.afm-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.afm-badge-pending   { background: #fff3cd; color: #856404; }
.afm-badge-paid      { background: #d4edda; color: #155724; }
.afm-badge-flagged   { background: #fff3cd; color: #856404; }
.afm-badge-cancelled { background: #f8d7da; color: #721c24; }

/* ============================================================
   Share Tab
   ============================================================ */

.afm-share-section {
  max-width: 560px;
}

.afm-share-link-row {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.afm-share-link-row input {
  flex: 1;
  font-family: monospace;
  font-size: 13px;
  padding: 10px 13px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #f5f5f5;
  color: #444;
}

.afm-qr-container {
  margin-bottom: 20px;
}

.afm-qr-container canvas,
.afm-qr-container img {
  display: block;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 8px;
  background: #fff;
}

.afm-whatsapp-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.afm-whatsapp-row a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: #25d366;
  color: #fff;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: opacity .15s;
}

.afm-whatsapp-row a:hover { opacity: .88; }

/* ============================================================
   Bank Details Tab
   ============================================================ */

.afm-bank-form {
  max-width: 480px;
}

/* ============================================================
   Notices
   ============================================================ */

.afm-notice {
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 14px;
}

.afm-notice-success { background: #d4edda; color: #155724; }
.afm-notice-error   { background: #f8d7da; color: #721c24; }
.afm-notice-info    { background: #d1ecf1; color: #0c5460; }

/* ============================================================
   Pagination
   ============================================================ */

.afm-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  font-size: 13px;
  color: #666;
}

.afm-pagination-nav {
  display: flex;
  gap: 6px;
}

.afm-pagination-nav button {
  padding: 5px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
}

.afm-pagination-nav button:disabled { opacity: .4; cursor: default; }
.afm-pagination-nav button:hover:not(:disabled) { background: #f5f5f5; }

/* ============================================================
   Settings Modal (password, logout)
   ============================================================ */

.afm-settings-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.afm-settings-modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.afm-settings-modal {
  background: #fff;
  border-radius: 10px;
  padding: 28px 32px;
  width: 95%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
  transform: translateY(16px);
  transition: transform .2s;
}

.afm-settings-modal-overlay.active .afm-settings-modal { transform: translateY(0); }

/* ============================================================
   Empty State
   ============================================================ */

.afm-empty {
  text-align: center;
  padding: 48px 20px;
  color: #aaa;
}

.afm-empty p { margin: 0; font-size: 14px; }

/* ============================================================
   Loading spinner
   ============================================================ */

.afm-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #ddd;
  border-top-color: #0066cc;
  border-radius: 50%;
  animation: afm-spin .6s linear infinite;
  vertical-align: middle;
}

@keyframes afm-spin { to { transform: rotate(360deg); } }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 700px) {
  .afm-stats-strip {
    grid-template-columns: repeat(2, 1fr);
  }
  .afm-dashboard-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .afm-auth-box {
    padding: 24px 20px;
  }
  .afm-share-link-row { flex-direction: column; }
}

@media (max-width: 420px) {
  .afm-stats-strip { grid-template-columns: 1fr 1fr; }
}
