/* =============================================================================
   WOS Helper — Bulk Redeem Stylesheet
   Depends on: redeem.css (provides :root token definitions)
   Covers:
     - Tab bar (wraps single-redeem + bulk tabs)
     - .wos-bulk-* layout, form, progress, table, summary
     - JS-injected classes: badges, validation cards, row states, pills
   ============================================================================= */


/* ── Tab Bar ─────────────────────────────────────────────────────────────────
   Sits above the existing .container (single) and .wos-bulk-wrap (bulk).
   The tab bar itself uses the same bg-secondary card style as the container.
   --------------------------------------------------------------------------- */

.wos-tab-bar {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 4px;
    margin-bottom: 20px;
    width: 100%;
}

.wos-tab {
    flex: 1;
    padding: 10px 16px;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    text-align: center;
    white-space: nowrap;
}

.wos-tab:hover {
    color: var(--text-primary);
    background: var(--hover-bg);
}

.wos-tab.active {
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.wos-tab-panel          { display: none; }
.wos-tab-panel.active   { display: block; animation: wbFadeIn 0.25s ease-out; }


/* ── Bulk Wrap & Sections ────────────────────────────────────────────────────
   .wos-bulk-wrap is the top-level container rendered by bulk-tab.php.
   .wos-bulk-section matches the visual style of .container in redeem.css.
   --------------------------------------------------------------------------- */

.wos-bulk-wrap {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.wos-bulk-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    animation: wbFadeIn 0.3s ease-out;
}

/* Sections start hidden — JS removes the `hidden` attribute to reveal them */
.wos-bulk-section[hidden] { display: none; }

@keyframes wbFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0);   }
}


/* ── Section Header ──────────────────────────────────────────────────────────*/

.wos-bulk-section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.wos-bulk-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}


/* ── Field Groups ────────────────────────────────────────────────────────────*/

.wos-bulk-field-group {
    margin-bottom: 20px;
}

.wos-bulk-label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.wos-bulk-label-hint {
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 6px;
}

.wos-bulk-code-input {
    width: 100%;
    padding: 13px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 1rem;
    font-family: 'Monaco', 'Courier New', monospace;
    letter-spacing: 1px;
    color: var(--text-primary);
    transition: border-color 0.2s ease, background 0.2s ease;
}

.wos-bulk-code-input:focus {
    outline: none;
    border-color: var(--text-primary);
    background: var(--bg-primary);
}

.wos-bulk-code-input::placeholder { color: var(--text-secondary); }

.wos-bulk-fids-input {
    width: 100%;
    padding: 13px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 0.875rem;
    font-family: 'Monaco', 'Courier New', monospace;
    color: var(--text-primary);
    resize: vertical;
    min-height: 160px;
    line-height: 1.6;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.wos-bulk-fids-input:focus {
    outline: none;
    border-color: var(--text-primary);
    background: var(--bg-primary);
}

.wos-bulk-fids-input::placeholder { color: var(--text-secondary); }

.wos-bulk-field-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 7px;
    line-height: 1.5;
}


/* ── Delay Info ──────────────────────────────────────────────────────────────*/

.wos-bulk-delay-info {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wos-bulk-settings-link {
    color: var(--text-secondary);
    text-decoration: underline;
    text-underline-offset: 2px;
    font-size: 0.8rem;
    transition: color 0.15s ease;
}

.wos-bulk-settings-link:hover { color: var(--text-primary); }


/* ── Action Buttons ──────────────────────────────────────────────────────────*/

.wos-bulk-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.wos-bulk-btn {
    flex: 1;
    min-width: 120px;
    padding: 13px 18px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    white-space: nowrap;
}

.wos-bulk-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none !important;
}

/* Primary — Start Bulk Redeem */
.wos-bulk-btn-primary {
    background: var(--text-primary);
    color: var(--bg-primary);
}

.wos-bulk-btn-primary:not(:disabled):hover {
    background: var(--text-secondary);
    transform: translateY(-1px);
}

.wos-bulk-btn-primary:not(:disabled):active { transform: translateY(0); }

/* Secondary — Validate, Download CSV */
.wos-bulk-btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.wos-bulk-btn-secondary:not(:disabled):hover {
    background: var(--hover-bg);
    border-color: var(--text-secondary);
    transform: translateY(-1px);
}

.wos-bulk-btn-secondary:not(:disabled):active { transform: translateY(0); }

/* Ghost — Clear */
.wos-bulk-btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
}

.wos-bulk-btn-ghost:not(:disabled):hover {
    color: var(--text-primary);
    border-color: var(--border-color);
}


/* ── Validation Results ──────────────────────────────────────────────────────*/

.wos-bulk-validation-summary {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.wos-bulk-validation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}

/* Injected by renderValidationGrid() */
.wos-bulk-validation-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 0.82rem;
    display: flex;
    flex-direction: column;
    gap: 3px;
    transition: border-color 0.2s ease;
}

.wos-bulk-card-valid   { border-left: 3px solid #4ade80; }
.wos-bulk-card-invalid { border-left: 3px solid #f87171; opacity: 0.65; }

.wos-bulk-card-fid {
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.wos-bulk-card-name {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wos-bulk-card-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.wos-bulk-card-error {
    font-size: 0.75rem;
    color: #f87171;
}


/* ── Progress Bar ────────────────────────────────────────────────────────────*/

.wos-bulk-progress-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.wos-bulk-progress-track {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 10px;
}

.wos-bulk-progress-fill {
    height: 100%;
    background: var(--text-primary);
    border-radius: 999px;
    transition: width 0.4s ease;
    min-width: 0;
}

/* Animate fill when job is running */
.wos-bulk-progress-fill.running {
    background: linear-gradient(90deg, #4ade80, #22d3ee, #a78bfa);
    background-size: 200% 100%;
    animation: wbShimmer 1.8s linear infinite;
}

@keyframes wbShimmer {
    0%   { background-position: 200% center; }
    100% { background-position: -200% center; }
}

.wos-bulk-eta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0;
    min-height: 1.2em;
}


/* ── Results Table ───────────────────────────────────────────────────────────*/

.wos-bulk-table-wrap {
    overflow-x: auto;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.wos-bulk-results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.wos-bulk-results-table thead th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 12px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color);
}

.wos-bulk-results-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s ease;
}

.wos-bulk-results-table tbody tr:last-child { border-bottom: none; }

.wos-bulk-results-table tbody tr:hover { background: var(--hover-bg); }

.wos-bulk-results-table td {
    padding: 10px 12px;
    vertical-align: middle;
    color: var(--text-primary);
}

/* Column widths */
.wos-bulk-col-num      { width: 36px;  color: var(--text-secondary); text-align: center; }
.wos-bulk-col-fid      { width: 110px; font-family: 'Monaco', 'Courier New', monospace; font-size: 0.78rem; }
.wos-bulk-col-nickname { min-width: 120px; }
.wos-bulk-col-status   { width: 130px; }
.wos-bulk-col-message  { min-width: 180px; color: var(--text-secondary); }
.wos-bulk-col-time     { width: 70px;  color: var(--text-secondary); white-space: nowrap; font-size: 0.78rem; }

/* Row states — JS toggles these classes */
.wos-bulk-row-pending    td { opacity: 0.4; }
.wos-bulk-row-processing { background: rgba(255, 255, 255, 0.025) !important; }
.wos-bulk-row-processing td { opacity: 1; }
.wos-bulk-row-done       td { opacity: 1; }

/* Status badges — injected by updateResultRow() */
.wos-bulk-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.wos-bulk-badge-processing  { background: rgba(163, 163, 163, 0.12); color: #a3a3a3; }
.wos-bulk-badge-success     { background: rgba(74, 222, 128, 0.12);  color: #4ade80; }
.wos-bulk-badge-duplicate   { background: rgba(96, 165, 250, 0.12);  color: #60a5fa; }
.wos-bulk-badge-expired     { background: rgba(245, 158, 11, 0.12);  color: #f59e0b; }
.wos-bulk-badge-vip         { background: rgba(192, 132, 252, 0.12); color: #c084fc; }
.wos-bulk-badge-not_found   { background: rgba(107, 114, 128, 0.12); color: #9ca3af; }
.wos-bulk-badge-too_frequent{ background: rgba(34, 211, 238, 0.12);  color: #22d3ee; }
.wos-bulk-badge-error       { background: rgba(248, 113, 113, 0.12); color: #f87171; }
.wos-bulk-badge-pending     { background: transparent; color: var(--text-secondary); }


/* ── Summary Bar ─────────────────────────────────────────────────────────────*/

.wos-bulk-summary-section { border-color: #2a2a2a; }

.wos-bulk-total-time {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.wos-bulk-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

/* Injected by renderSummary() */
.wos-bulk-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 600;
    border: 1px solid transparent;
}

.wos-bulk-pill-count {
    font-size: 1.1rem;
    font-weight: 700;
}

.wos-bulk-pill-success     { background: rgba(74, 222, 128, 0.1);  color: #4ade80;  border-color: rgba(74, 222, 128, 0.2);  }
.wos-bulk-pill-duplicate   { background: rgba(96, 165, 250, 0.1);  color: #60a5fa;  border-color: rgba(96, 165, 250, 0.2);  }
.wos-bulk-pill-expired     { background: rgba(245, 158, 11, 0.1);  color: #f59e0b;  border-color: rgba(245, 158, 11, 0.2);  }
.wos-bulk-pill-too_frequent{ background: rgba(34, 211, 238, 0.1);  color: #22d3ee;  border-color: rgba(34, 211, 238, 0.2);  }
.wos-bulk-pill-failed      { background: rgba(248, 113, 113, 0.1); color: #f87171;  border-color: rgba(248, 113, 113, 0.2); }
.wos-bulk-pill-total       { background: rgba(255, 255, 255, 0.06); color: var(--text-secondary); border-color: var(--border-color); }

.wos-bulk-summary-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.wos-bulk-summary-actions .wos-bulk-btn {
    flex: unset;
    min-width: 0;
}


/* ── Inline Spinner (processing row) ─────────────────────────────────────────
   Tiny spinner injected next to the FID while that row is being processed.
   --------------------------------------------------------------------------- */

.wos-bulk-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--border-color);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: wbSpin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 5px;
    flex-shrink: 0;
}

@keyframes wbSpin { to { transform: rotate(360deg); } }


/* ── Responsive ──────────────────────────────────────────────────────────────*/

@media (max-width: 600px) {
    .wos-bulk-section          { padding: 18px 16px; }
    .wos-bulk-actions          { flex-direction: column; }
    .wos-bulk-btn              { flex: unset; width: 100%; }
    .wos-bulk-summary-actions  { flex-direction: column; }
    .wos-bulk-summary-actions .wos-bulk-btn { width: 100%; }
    .wos-bulk-validation-grid  { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .wos-bulk-pills            { gap: 8px; }
    .wos-bulk-pill             { padding: 6px 12px; font-size: 0.82rem; }

    /* Collapse table to essential columns on very small screens */
    .wos-bulk-col-message,
    .wos-bulk-col-time         { display: none; }
}

@media (max-width: 360px) {
    .wos-tab { font-size: 0.82rem; padding: 9px 10px; }
    .wos-bulk-col-nickname     { display: none; }
}
