/* Kontener główny panelu */
.wap-affiliate-dashboard {
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #e5e5e5;
  padding: 24px;
  margin-bottom: 30px;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.05);
}

/* Nagłówki */
.wap-affiliate-dashboard h1,
.wap-affiliate-dashboard h2 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 24px;
  font-weight: 600;
}

.wap-affiliate-dashboard h3 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 18px;
  font-weight: 600;
}

/* Sekcje */
.wap-section {
  padding: 18px 0;
  border-top: 1px solid #f1f5f9;
}

.wap-section:first-of-type {
  border-top: none;
}

/* Reflink + przyciski */
.wap-ref-link-wrapper {
  display: flex;
  gap: 10px;
  align-items: center;
}

.wap-ref-link-wrapper input[type="text"] {
  flex: 1;
  border-radius: 8px;
}

/* Kafelki statystyk */
.wap-stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.wap-stat-box {
  border-radius: 10px;
  padding: 10px 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
}

.wap-stat-box .wap-label {
  display: block;
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 4px;
}

.wap-stat-box .wap-value {
  font-weight: 700;
  font-size: 17px;
  color: #111827;
}

/* Wykres */
.wap-chart-controls {
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.wap-chart-controls select {
  max-width: 180px;
}

#wapp-stats-chart,
#wap-stats-chart {
  border-radius: 12px;
}

/* Tabelki */
.wap-coupons-table,
.wap-referrals-table {
  width: 100%;
}

.wap-coupons-table td,
.wap-coupons-table th,
.wap-referrals-table td,
.wap-referrals-table th {
  vertical-align: middle;
}

/* Mobilne tabelki – scroll poziomy */
@media (max-width: 768px) {
  .wap-coupons-table,
  .wap-referrals-table {
    display: block;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
}

/* Formularz wypłat */
.wap-payout-form {
  margin-top: 14px;
}

/* Widok admina – lekka różnica */
.wap-admin-view {
  margin-top: 15px;
}

/* ===================== MODAL WYPŁAT ===================== */

body.wap-modal-open {
  overflow: hidden;
}

#wap-payout-modal {
  position: fixed;
  inset: 0;
  z-index: 999999;
}

#wap-payout-modal .wap-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  z-index: 1;
}

#wap-payout-modal .wap-modal {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(720px, calc(100% - 28px));
  background: #fff;
  border-radius: 16px;
  padding: 18px 18px 14px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.28);
  z-index: 2;
}

#wap-payout-modal .wap-buyer-box {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px;
  margin: 10px 0 14px;
  line-height: 1.45;
}

#wap-payout-modal .wap-warning-box {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 12px;
  padding: 12px;
  margin: 10px 0 14px;
}

#wap-payout-modal .wap-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
}

/* Zielony przycisk "Gotowe" */
#wap-payout-request-form button[type="submit"] {
  background: #16a34a !important;
  border-color: #16a34a !important;
  color: #fff !important;
}

#wap-payout-request-form button[type="submit"]:hover {
  filter: brightness(0.95);
}

#wap-payout-request-form button[type="submit"].is-loading {
  opacity: 0.8;
  pointer-events: none;
}

#wap-payout-modal .wap-modal-msg {
  margin-top: 10px;
  font-weight: 600;
}

#wap-payout-modal .wap-modal-msg.is-ok { color: #16a34a; }
#wap-payout-modal .wap-modal-msg.is-err { color: #dc2626; }

/* ======== RESPONSYWNOŚĆ ======== */

/* <= 1024px */
@media (max-width: 1024px) {
  .wap-stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .wap-affiliate-dashboard {
    padding: 20px;
  }
}

/* <= 768px */
@media (max-width: 768px) {
  .wap-affiliate-dashboard {
    padding: 16px;
    border-radius: 0;
    border-left: none;
    border-right: none;
    margin-left: -15px;
    margin-right: -15px;
  }

  .wap-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .wap-ref-link-wrapper {
    flex-direction: column;
    align-items: stretch;
  }

  .wap-ref-link-wrapper .button {
    width: 100%;
    text-align: center;
  }

  .wap-affiliate-dashboard h1,
  .wap-affiliate-dashboard h2 {
    font-size: 20px;
  }

  .wap-affiliate-dashboard h3 {
    font-size: 16px;
  }

  #wap-payout-modal .wap-modal {
    top: 54%;
  }
}

/* <= 480px */
@media (max-width: 480px) {
  .wap-stats-grid {
    grid-template-columns: 1fr;
  }

  .wap-stat-box {
    padding: 10px;
  }

  .wap-stat-box .wap-value {
    font-size: 15px;
  }

  .wap-chart-controls {
    flex-direction: column;
    align-items: flex-start;
  }

  .wap-chart-controls select {
    width: 100%;
    max-width: 100%;
  }
}
