/* ════════════════════════════════════
   components.css — Buttons, badges, progress, table,
                    toast, tabs, platform selector, auth
   ════════════════════════════════════ */

/* ── Buttons ── */
.btn {
    padding: .75rem 1.5rem;
    border-radius: .5rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all .2s;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    gap: .45rem;
}

.btn-primary {
    width: 100%;
    justify-content: center;
    background: var(--primary);
    color: #000;
}

.btn-primary:hover {
    background: var(--primary-h);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    background: var(--border);
    cursor: not-allowed;
    transform: none;
}

.btn-dl {
    background: var(--green);
    color: #fff;
}

.btn-dl:hover {
    background: var(--green-h);
    transform: translateY(-1px);
}

.btn-prev {
    background: var(--purple);
    color: #fff;
}

.btn-prev:hover {
    background: var(--purple-h);
    transform: translateY(-1px);
}

.action-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1.25rem;
}

.action-row .btn {
    flex: 1;
    min-width: 160px;
    justify-content: center;
}

/* ── Auth ── */
#authOverlay,
#loadingOverlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    backdrop-filter: blur(12px);
    transition: opacity 0.3s ease;
}

#loadingOverlay {
    z-index: 2000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(56, 189, 248, 0.1);
    border-left-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.auth-card {
    background: var(--card);
    padding: 2.5rem;
    border-radius: 1.5rem;
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--border);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.auth-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.auth-tab {
    cursor: pointer;
    color: var(--dim);
    font-weight: 600;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid transparent;
}

.auth-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

#userProfile {
    position: fixed;
    top: 1rem;
    right: 1rem;
    display: none;
    align-items: center;
    gap: 0.75rem;
    background: var(--card);
    padding: 0.35rem 0.8rem;
    border-radius: 2rem;
    border: 1px solid var(--border);
    font-size: 0.8rem;
    z-index: 1001;
}

.tier-badge {
    padding: 0.1rem 0.6rem;
    border-radius: 1rem;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
}

.tier-free {
    background: #64748b;
    color: #fff;
}

.tier-pro {
    background: var(--primary);
    color: #0f172a;
}

/* ── Badges & Status ── */
.badge {
    display: inline-block;
    padding: .25rem .75rem;
    border-radius: 9999px;
    font-size: .8rem;
    font-weight: 700;
    margin-bottom: .6rem;
    letter-spacing: .04em;
}

.badge-pending {
    background: #ca8a04;
    color: #fff;
}

.badge-running {
    background: #2563eb;
    color: #fff;
}

.badge-completed {
    background: #16a34a;
    color: #fff;
}

.badge-failed {
    background: #dc2626;
    color: #fff;
}

.job-id {
    font-size: .78rem;
    color: var(--dim);
    margin-bottom: 1rem;
}

/* ── Progress ── */
#progressWrap {
    margin-top: .5rem;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: .82rem;
    color: var(--dim);
    margin-bottom: .4rem;
}

.progress-header span {
    color: var(--text);
    font-weight: 600;
}

.progress-track {
    width: 100%;
    height: 10px;
    border-radius: 9999px;
    background: #0f172a;
    overflow: hidden;
    border: 1px solid var(--border);
}

.progress-fill {
    height: 100%;
    border-radius: 9999px;
    background: linear-gradient(90deg, var(--primary), #a855f7);
    transition: width .6s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, .25) 50%, transparent 100%);
    animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(200%);
    }
}

.progress-msg {
    font-size: .84rem;
    color: var(--dim);
    margin-top: .5rem;
}

/* ── Stats chips ── */
.stats-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    margin: 1rem 0 1.25rem;
}

.stat-chip {
    background: #0f172a;
    border: 1px solid var(--border);
    border-radius: .5rem;
    padding: .35rem .8rem;
    font-size: .78rem;
    color: var(--dim);
}

.stat-chip strong {
    color: var(--text);
}

/* ── Table & preview ── */
#previewSection {
    margin-top: 1.5rem;
    display: none;
}

.preview-label {
    font-size: .9rem;
    color: var(--dim);
    margin-bottom: .6rem;
}

.table-wrap {
    overflow-x: auto;
    border-radius: .5rem;
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
}

thead th {
    background: #0f172a;
    color: #fbbf24;
    font-weight: 700;
    text-align: center;
    padding: .5rem .9rem;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, .02);
}

tbody td {
    padding: .4rem .9rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: top;
    max-width: 240px;
    word-break: break-word;
}

#errorBox {
    background: #1e1e2e;
    border: 1px solid #dc2626;
    border-radius: .5rem;
    padding: 1rem;
    color: #f87171;
    font-size: .83rem;
    white-space: pre-wrap;
    margin-top: .75rem;
    display: none;
}

/* ── Copy button ── */
.copy-btn {
    display: block;
    margin: .3rem auto 0;
    padding: .15rem .5rem;
    font-size: .68rem;
    border-radius: .3rem;
    border: 1px solid #334155;
    background: #1e293b;
    color: #94a3b8;
    cursor: pointer;
    transition: all .15s;
    font-weight: 600;
}

.copy-btn:hover {
    background: #38bdf8;
    color: #000;
    border-color: #38bdf8;
}

.copy-btn.copied {
    background: #22c55e;
    color: #fff;
    border-color: #22c55e;
}

/* ── Toast ── */
#toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(60px);
    background: #22c55e;
    color: #fff;
    padding: .5rem 1.4rem;
    border-radius: 9999px;
    font-size: .85rem;
    font-weight: 600;
    opacity: 0;
    transition: all .3s;
    pointer-events: none;
    z-index: 999;
}

#toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Tabs ── */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0px;
}

.tab {
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-weight: 600;
    color: var(--dim);
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab:hover {
    color: var(--text);
}

/* ── Link results & checkboxes ── */
#linkResults {
    display: none;
    flex-direction: column;
    gap: 1rem;
}

.link-item {
    background: #0f172a;
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    word-break: break-all;
    font-size: 0.9rem;
}

.checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--dim);
    cursor: pointer;
}

.checkbox-item input {
    width: auto;
    margin: 0;
    accent-color: var(--primary);
}

/* ── Platform selector ── */
.platform-selector {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.platform-btn {
    padding: 0.6rem 1.5rem;
    border-radius: 9999px;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--dim);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.platform-btn.active {
    background: var(--bg);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.2);
}

.platform-btn:hover:not(.active) {
    border-color: var(--dim);
    color: var(--text);
}

.platform-icon {
    font-size: 1.2rem;
}