/* ─── Biodicas Affiliates — Frontend Styles ─────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800&family=Inter:wght@400;500;600&display=swap');

:root {
  --aff-primary:      #1e3a8a;
  --aff-primary-dark: #162d6e;
  --aff-accent:       #f59e0b;
  --aff-accent-dark:  #d97706;
  --aff-success:      #059669;
  --aff-danger:       #dc2626;
  --aff-warning:      #d97706;
  --aff-text:         #1e293b;
  --aff-text-muted:   #64748b;
  --aff-border:       #e2e8f0;
  --aff-bg:           #f8fafc;
  --aff-white:        #ffffff;
  --aff-radius:       12px;
  --aff-shadow:       0 4px 24px rgba(30,58,138,0.08);
  --aff-shadow-sm:    0 2px 8px rgba(30,58,138,0.06);
}

/* ─── Wrapper ────────────────────────────────────────────────────────────── */
.aff-wrap {
  font-family: 'Inter', sans-serif;
  color: var(--aff-text);
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
  box-sizing: border-box;
}

/* ─── Card ───────────────────────────────────────────────────────────────── */
.aff-card {
  background: var(--aff-white);
  border-radius: var(--aff-radius);
  box-shadow: var(--aff-shadow);
  padding: 24px;
  margin-bottom: 16px;
}

.aff-card-title {
  font-family: 'Nunito', sans-serif;
  font-size: 18px;
  font-weight: 800;
  color: var(--aff-primary);
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Logo / Header ──────────────────────────────────────────────────────── */
.aff-logo-wrap {
  text-align: center;
  padding: 32px 0 24px;
}

.aff-logo-wrap img {
  height: 48px;
  object-fit: contain;
}

.aff-page-title {
  font-family: 'Nunito', sans-serif;
  font-size: 26px;
  font-weight: 800;
  color: var(--aff-primary);
  text-align: center;
  margin: 0 0 8px;
}

.aff-page-subtitle {
  font-size: 14px;
  color: var(--aff-text-muted);
  text-align: center;
  margin: 0 0 28px;
}

/* ─── Form ───────────────────────────────────────────────────────────────── */
.aff-form-group {
  margin-bottom: 16px;
}

.aff-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--aff-text);
  margin-bottom: 6px;
}

.aff-label span.req {
  color: var(--aff-danger);
  margin-left: 2px;
}

.aff-input,
.aff-select,
.aff-textarea {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--aff-border);
  border-radius: 8px;
  font-size: 15px;
  font-family: 'Inter', sans-serif;
  color: var(--aff-text);
  background: var(--aff-white);
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
  outline: none;
  appearance: none;
}

.aff-input:focus,
.aff-select:focus,
.aff-textarea:focus {
  border-color: var(--aff-primary);
  box-shadow: 0 0 0 3px rgba(30,58,138,0.1);
}

.aff-input[readonly],
.aff-input:disabled {
  background: var(--aff-bg);
  color: var(--aff-text-muted);
  cursor: not-allowed;
}

.aff-input-readonly-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--aff-bg);
  border: 2px solid var(--aff-border);
  border-radius: 8px;
  font-size: 15px;
  color: var(--aff-text-muted);
}

.aff-input-readonly-badge .lock-icon {
  font-size: 14px;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.aff-btn {
  display: block;
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
}

.aff-btn-primary {
  background: var(--aff-primary);
  color: var(--aff-white);
}

.aff-btn-primary:hover {
  background: var(--aff-primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(30,58,138,0.3);
}

.aff-btn-accent {
  background: var(--aff-accent);
  color: var(--aff-white);
}

.aff-btn-accent:hover {
  background: var(--aff-accent-dark);
  transform: translateY(-1px);
}

.aff-btn-outline {
  background: transparent;
  color: var(--aff-primary);
  border: 2px solid var(--aff-primary);
}

.aff-btn-outline:hover {
  background: var(--aff-primary);
  color: var(--aff-white);
}

.aff-btn-danger {
  background: var(--aff-danger);
  color: var(--aff-white);
}

.aff-btn-sm {
  padding: 8px 16px;
  font-size: 13px;
  width: auto;
  display: inline-block;
}

.aff-btn:disabled,
.aff-btn.loading {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none !important;
}

/* ─── Toggle (remember me) ───────────────────────────────────────────────── */
.aff-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.aff-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.aff-toggle input { opacity: 0; width: 0; height: 0; }

.aff-toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--aff-border);
  border-radius: 24px;
  cursor: pointer;
  transition: 0.3s;
}

.aff-toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}

.aff-toggle input:checked + .aff-toggle-slider { background: var(--aff-primary); }
.aff-toggle input:checked + .aff-toggle-slider::before { transform: translateX(20px); }

.aff-toggle-label { font-size: 14px; color: var(--aff-text-muted); }

/* ─── Links ──────────────────────────────────────────────────────────────── */
.aff-link {
  color: var(--aff-primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}

.aff-link:hover { text-decoration: underline; }

.aff-text-center { text-align: center; }

/* ─── Alert/Message ──────────────────────────────────────────────────────── */
.aff-alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
  display: none;
}

.aff-alert.show { display: block; }

.aff-alert-success {
  background: #d1fae5;
  color: #065f46;
  border-left: 4px solid var(--aff-success);
}

.aff-alert-error {
  background: #fee2e2;
  color: #991b1b;
  border-left: 4px solid var(--aff-danger);
}

.aff-alert-info {
  background: #dbeafe;
  color: #1e40af;
  border-left: 4px solid var(--aff-primary);
}

/* ─── Badges / Status ────────────────────────────────────────────────────── */
.aff-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}

.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-reversed { background: #fee2e2; color: #991b1b; }
.badge-paid     { background: #dbeafe; color: #1e40af; }
.badge-active   { background: #d1fae5; color: #065f46; }
.badge-suspended{ background: #fee2e2; color: #991b1b; }

/* ─── Stats Grid ─────────────────────────────────────────────────────────── */
.aff-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.aff-stat-item {
  background: var(--aff-bg);
  border-radius: 10px;
  padding: 14px 10px;
  text-align: center;
}

.aff-stat-value {
  font-family: 'Nunito', sans-serif;
  font-size: 20px;
  font-weight: 800;
  color: var(--aff-primary);
  display: block;
}

.aff-stat-label {
  font-size: 11px;
  color: var(--aff-text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
  display: block;
}

/* ─── Commission Stats ───────────────────────────────────────────────────── */
.aff-commission-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.aff-comm-item {
  background: var(--aff-bg);
  border-radius: 8px;
  padding: 12px 8px;
  text-align: center;
}

.aff-comm-value {
  font-family: 'Nunito', sans-serif;
  font-size: 16px;
  font-weight: 800;
  color: var(--aff-primary);
  display: block;
}

.aff-comm-label {
  font-size: 11px;
  color: var(--aff-text-muted);
  font-weight: 600;
  display: block;
  margin-top: 2px;
}

/* ─── Link copy box ──────────────────────────────────────────────────────── */
.aff-link-box {
  background: var(--aff-bg);
  border: 2px solid var(--aff-border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.aff-link-box-url {
  font-size: 12px;
  color: var(--aff-primary);
  word-break: break-all;
  margin-bottom: 8px;
  font-family: monospace;
}

.aff-copy-btn {
  background: var(--aff-primary);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.aff-copy-btn:hover  { background: var(--aff-primary-dark); }
.aff-copy-btn.copied { background: var(--aff-success); }

/* ─── Menu list (dashboard) ──────────────────────────────────────────────── */
.aff-menu-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.aff-menu-list li {
  border-bottom: 1px solid var(--aff-border);
}

.aff-menu-list li:last-child { border-bottom: none; }

.aff-menu-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  text-decoration: none;
  color: var(--aff-text);
  font-size: 15px;
  font-weight: 600;
  transition: color 0.2s;
}

.aff-menu-list a:hover { color: var(--aff-primary); }

.aff-menu-list .arrow { color: var(--aff-text-muted); }

/* ─── Table ──────────────────────────────────────────────────────────────── */
.aff-table-wrap { overflow-x: auto; }

.aff-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.aff-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--aff-bg);
  color: var(--aff-text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--aff-border);
}

.aff-table td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--aff-border);
  vertical-align: middle;
}

.aff-table tr:last-child td { border-bottom: none; }
.aff-table tr:hover td { background: var(--aff-bg); }

/* ─── Pagination ─────────────────────────────────────────────────────────── */
.aff-pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.aff-pagination a,
.aff-pagination span {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  border: 2px solid var(--aff-border);
  color: var(--aff-text);
  transition: all 0.2s;
}

.aff-pagination a:hover {
  border-color: var(--aff-primary);
  color: var(--aff-primary);
}

.aff-pagination span.current {
  background: var(--aff-primary);
  border-color: var(--aff-primary);
  color: white;
}

/* ─── Detail rows ────────────────────────────────────────────────────────── */
.aff-detail-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--aff-border);
  font-size: 14px;
}

.aff-detail-row:last-child { border-bottom: none; }
.aff-detail-label { color: var(--aff-text-muted); font-weight: 500; }
.aff-detail-value { font-weight: 700; color: var(--aff-text); text-align: right; }

/* ─── Comprovante image ──────────────────────────────────────────────────── */
.aff-comprovante-img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--aff-border);
  margin-top: 8px;
}

/* ─── PIX type selector ──────────────────────────────────────────────────── */
.aff-pix-type-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.aff-pix-type-option {
  position: relative;
}

.aff-pix-type-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.aff-pix-type-label {
  display: block;
  padding: 10px 12px;
  border: 2px solid var(--aff-border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--aff-text);
  transition: all 0.2s;
  text-align: center;
}

.aff-pix-type-option input:checked + .aff-pix-type-label {
  border-color: var(--aff-primary);
  background: rgba(30,58,138,0.05);
  color: var(--aff-primary);
}

/* ─── Helper text ────────────────────────────────────────────────────────── */
.aff-helper {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: #eff6ff;
  border-radius: 8px;
  font-size: 13px;
  color: #1e40af;
  margin-bottom: 16px;
  line-height: 1.5;
}

.aff-helper .icon { flex-shrink: 0; font-size: 16px; }

/* ─── Status indicator ───────────────────────────────────────────────────── */
.aff-status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}

.aff-status-dot::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.aff-status-dot.active  { color: var(--aff-success); }
.aff-status-dot.suspended { color: var(--aff-danger); }

/* ─── Welcome page ───────────────────────────────────────────────────────── */
.aff-welcome-wrap {
  text-align: center;
  padding: 40px 24px;
}

.aff-welcome-icon {
  font-size: 72px;
  margin-bottom: 16px;
  animation: bounce 1s ease 0.3s both;
}

@keyframes bounce {
  0%   { transform: scale(0.5); opacity: 0; }
  70%  { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

.aff-welcome-title {
  font-family: 'Nunito', sans-serif;
  font-size: 28px;
  font-weight: 800;
  color: var(--aff-primary);
  margin: 0 0 8px;
}

.aff-welcome-sub {
  color: var(--aff-text-muted);
  font-size: 15px;
  margin: 0 0 32px;
}

.aff-progress-bar {
  background: var(--aff-border);
  border-radius: 20px;
  height: 6px;
  overflow: hidden;
  margin-bottom: 12px;
}

.aff-progress-fill {
  height: 100%;
  background: var(--aff-primary);
  border-radius: 20px;
  animation: progress var(--timer, 5s) linear forwards;
}

@keyframes progress {
  from { width: 0%; }
  to   { width: 100%; }
}

/* ─── Ref-link page ──────────────────────────────────────────────────────── */
.aff-ref-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 100%);
}

.aff-ref-card {
  background: var(--aff-white);
  border-radius: 20px;
  padding: 40px 32px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(30,58,138,0.12);
  text-align: center;
}

.aff-ref-invite {
  font-size: 14px;
  color: var(--aff-text-muted);
  margin-bottom: 4px;
}

.aff-ref-name {
  font-family: 'Nunito', sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: var(--aff-primary);
  margin: 0 0 24px;
}

.aff-ref-description {
  color: var(--aff-text-muted);
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 32px;
}

/* ─── Checkbox ───────────────────────────────────────────────────────────── */
.aff-checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 20px;
}

.aff-checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  accent-color: var(--aff-primary);
  flex-shrink: 0;
}

.aff-checkbox-row label {
  font-size: 13px;
  color: var(--aff-text-muted);
  line-height: 1.5;
}

/* ─── Divider ────────────────────────────────────────────────────────────── */
.aff-divider {
  border: none;
  border-top: 1px solid var(--aff-border);
  margin: 20px 0;
}

/* ─── Loading spinner ────────────────────────────────────────────────────── */
.aff-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

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

/* ─── Back button ────────────────────────────────────────────────────────── */
.aff-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--aff-text-muted);
  text-decoration: none;
  margin-bottom: 16px;
  font-weight: 600;
}

.aff-back-btn:hover { color: var(--aff-primary); }

/* ─── Summary box ────────────────────────────────────────────────────────── */
.aff-summary-box {
  background: linear-gradient(135deg, var(--aff-primary) 0%, #2563eb 100%);
  border-radius: var(--aff-radius);
  padding: 20px;
  color: white;
  margin-bottom: 16px;
}

.aff-summary-box .aff-stat-value { color: white; font-size: 24px; }
.aff-summary-box .aff-stat-label { color: rgba(255,255,255,0.7); }

/* ─── Empty state ────────────────────────────────────────────────────────── */
.aff-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--aff-text-muted);
}

.aff-empty-icon { font-size: 48px; margin-bottom: 12px; }
.aff-empty-text { font-size: 15px; }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 380px) {
  .aff-stats-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .aff-stat-value { font-size: 16px; }
  .aff-commission-grid { grid-template-columns: repeat(3, 1fr); }
}
