/* STWB Affiliate — Frontend CSS */

/*
 * Przywróć semantykę atrybutu hidden.
 * User-agent stylesheet ma [hidden] { display: none }, ale autor CSS
 * (display: flex/grid itp.) ma wyższy priorytet i go nadpisuje.
 */
.stwb-aff [hidden] { display: none !important; }

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

.stwb-aff__tabs {
    display: flex;
    flex-wrap: wrap;
    border-bottom: 2px solid #e2e2e2;
    margin: 0 0 28px;
    padding: 0;
    gap: 0;
    list-style: none;
}

.stwb-aff__tab {
    display: inline-block;
    padding: 10px 20px;
    text-decoration: none;
    color: #767676;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
    line-height: 1.4;
}

.stwb-aff__tab:hover {
    color: #333;
    text-decoration: none;
}

.stwb-aff__tab--active {
    color: #7f54b3;
    border-bottom-color: #7f54b3;
}

.stwb-aff__tab-badge {
    display: inline-block;
    min-width: 18px;
    padding: 1px 5px;
    margin-left: 5px;
    font-size: 11px;
    font-weight: 700;
    line-height: 16px;
    color: #fff;
    background: #7f54b3;
    border-radius: 9px;
    vertical-align: middle;
}

/* ============================================================
   Stat cards (Panel: Przegląd)
   ============================================================ */

.stwb-aff__stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stwb-aff__stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 18px;
    background: #fff;
    border: 1px solid #e2e2e2;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.stwb-aff__stat-card-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stwb-aff__stat-card-icon svg {
    width: 22px;
    height: 22px;
}

.stwb-aff__stat-card--earned .stwb-aff__stat-card-icon {
    background: #e8f7ee;
    color: #1a7a39;
}

.stwb-aff__stat-card--pending .stwb-aff__stat-card-icon {
    background: #fff8e1;
    color: #b07800;
}

.stwb-aff__stat-card--orders .stwb-aff__stat-card-icon {
    background: #e8f1fd;
    color: #1a5abf;
}

.stwb-aff__stat-card--volume .stwb-aff__stat-card-icon {
    background: #f3eefb;
    color: #6b39a8;
}

.stwb-aff__stat-card-body {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.stwb-aff__stat-card-value {
    font-size: 20px;
    font-weight: 700;
    color: #333;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stwb-aff__stat-card-label {
    font-size: 13px;
    font-weight: 600;
    color: #444;
    line-height: 1.3;
}

.stwb-aff__stat-card-sub {
    font-size: 11px;
    color: #888;
    line-height: 1.3;
}

.stwb-aff__commission-rate-info {
    font-size: 13px;
    color: #555;
    margin-top: 4px;
}

/* ============================================================
   Filtr okresu (Panel: Zamówienia)
   ============================================================ */

.stwb-aff__filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stwb-aff__filter-select {
    padding: 7px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    color: #333;
    cursor: pointer;
    min-width: 130px;
}

.stwb-aff__filter-select:focus {
    outline: none;
    border-color: #7f54b3;
    box-shadow: 0 0 0 2px rgba(127, 84, 179, 0.15);
}

/* Loading */

.stwb-aff__loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 0;
    color: #767676;
    font-size: 14px;
}

.stwb-aff__spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #e0e0e0;
    border-top-color: #7f54b3;
    border-radius: 50%;
    animation: stwb-spin 0.7s linear infinite;
    flex-shrink: 0;
}

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

/* Podsumowanie okresu */

.stwb-aff__period-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
    padding: 16px;
    background: #f9f9f9;
    border: 1px solid #e2e2e2;
    border-radius: 6px;
}

.stwb-aff__period-summary-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 16px;
    border-right: 1px solid #e2e2e2;
}

.stwb-aff__period-summary-item:last-child {
    border-right: none;
}

.stwb-aff__period-summary-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #888;
    font-weight: 600;
}

.stwb-aff__period-summary-value {
    font-size: 18px;
    font-weight: 700;
    color: #333;
    line-height: 1.2;
}

.stwb-aff__period-summary-sub {
    font-size: 11px;
    color: #aaa;
}

.stwb-aff__period-summary-item--active .stwb-aff__period-summary-value {
    color: #1a7a39;
}

.stwb-aff__period-summary-item--cancelled .stwb-aff__period-summary-value {
    color: #888;
}

/* ============================================================
   Tabel prowizji i faktur
   ============================================================ */

.stwb-aff__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    margin-bottom: 24px;
}

.stwb-aff__table th,
.stwb-aff__table td {
    padding: 9px 10px;
    text-align: left;
    border-bottom: 1px solid #e2e2e2;
    vertical-align: middle;
}

.stwb-aff__table thead th {
    background: #f7f7f7;
    font-weight: 600;
    white-space: nowrap;
    color: #555;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stwb-aff__col-number {
    text-align: right;
}

.stwb-aff__month-block {
    margin-bottom: 32px;
}

.stwb-aff__month-heading {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 10px;
    color: #333;
}

.stwb-aff__month-summary {
    font-size: 13px;
    font-weight: 400;
    color: #666;
}

.stwb-aff__commission-row--cancelled {
    opacity: 0.55;
}

/* Status badges */

.stwb-aff-status {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    white-space: nowrap;
}

.stwb-aff-status--pending          { background: #fff8e1; color: #856404; }
.stwb-aff-status--approved         { background: #e8f7ee; color: #1a7a39; }
.stwb-aff-status--paid             { background: #e8f1fd; color: #1a5abf; }
.stwb-aff-status--cancelled        { background: #f4f4f4; color: #888; }
.stwb-aff-status--invoice-submitted { background: #fff8e1; color: #856404; }
.stwb-aff-status--invoice-reviewed  { background: #e8f1fd; color: #1a5abf; }
.stwb-aff-status--invoice-paid      { background: #e8f7ee; color: #1a7a39; }

/* ============================================================
   Panel: Linki — kod afiliacyjny
   ============================================================ */

.stwb-aff__code-block {
    margin-bottom: 28px;
}

.stwb-aff__code-block h3 {
    font-size: 15px;
    margin: 0 0 10px;
}

.stwb-aff__code-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.stwb-aff__code {
    display: inline-block;
    padding: 6px 14px;
    background: #f4f4f4;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 15px;
    letter-spacing: 0.04em;
    color: #333;
}

.stwb-aff__code-lock {
    font-size: 12px;
    color: #888;
    font-style: italic;
}

.stwb-aff__code-sub {
    font-size: 13px;
    color: #666;
}

.stwb-aff__code-temp {
    font-size: 13px;
    color: #555;
    margin-bottom: 12px;
}

/* Generator linków */

.stwb-aff__link-generator {
    margin-top: 28px;
}

.stwb-aff__link-generator h3 {
    font-size: 15px;
    margin: 0 0 12px;
}

.stwb-aff__generator-mode {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
}

.stwb-aff__radio-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
}

.stwb-aff__radio-label input[type="radio"] {
    margin-top: 3px;
    flex-shrink: 0;
}

.stwb-aff__radio-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.stwb-aff__radio-hint {
    font-size: 11px;
    font-weight: 400;
    color: #888;
    font-family: monospace;
}

.stwb-aff__generator-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.stwb-aff__generator-row input {
    flex: 1;
    min-width: 200px;
}

.stwb-aff__generated-link {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.stwb-aff__generated-link input {
    flex: 1;
    min-width: 200px;
    background: #f8f8f8;
}

/* ============================================================
   Formularz faktury — wiersz z selectami okresu
   ============================================================ */

.stwb-aff__invoice-period-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.stwb-aff__amount-hint {
    font-size: 12px;
    font-weight: 400;
    color: #46b450;
    margin-left: 4px;
}

.stwb-aff__invoice-notes {
    font-size: 13px;
    color: #555;
    max-width: 200px;
    word-break: break-word;
}

/* ============================================================
   Formularz ogólny
   ============================================================ */

.stwb-aff__form .stwb-aff__form-row {
    margin-bottom: 16px;
}

.stwb-aff__form label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 13px;
    color: #444;
}

.stwb-aff__form input[type="text"],
.stwb-aff__form input[type="email"],
.stwb-aff__form input[type="tel"],
.stwb-aff__form input[type="url"],
.stwb-aff__form input[type="number"],
.stwb-aff__form input[type="month"],
.stwb-aff__form textarea {
    width: 100%;
    max-width: 480px;
}

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

.stwb-aff__notice {
    padding: 12px 16px;
    border-left: 4px solid #0073aa;
    margin-bottom: 16px;
    background: #f0f6fc;
    font-size: 14px;
}

.stwb-aff__notice--info    { border-color: #0073aa; background: #f0f6fc; }
.stwb-aff__notice--success { border-color: #46b450; background: #f0fff0; }
.stwb-aff__notice--warning { border-color: #ffb900; background: #fffbe6; }
.stwb-aff__notice--error   { border-color: #dc3232; background: #fff0f0; }

/* ============================================================
   Formularz zgłoszeniowy (application-form.php)
   ============================================================ */

.stwb-aff__social-entry {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.stwb-aff__social-entry input {
    flex: 1;
}
