/* ============================================
   Apollo List Saver — Premium Dark UI
   ============================================ */

:root {
    /* Color Palette */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(18, 18, 28, 0.85);
    --bg-card-hover: rgba(24, 24, 38, 0.9);
    --bg-input: rgba(255, 255, 255, 0.04);
    --bg-input-focus: rgba(255, 255, 255, 0.07);

    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-focus: rgba(99, 102, 241, 0.5);

    --text-primary: #f0f0f5;
    --text-secondary: #8b8b9e;
    --text-muted: #5a5a6e;
    --text-placeholder: #4a4a5e;

    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-dark: #4f46e5;
    --accent-glow: rgba(99, 102, 241, 0.25);

    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --success-border: rgba(16, 185, 129, 0.2);

    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.1);
    --error-border: rgba(239, 68, 68, 0.2);

    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);

    /* Spacing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Shadows */
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-hover: 0 8px 40px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 30px var(--accent-glow);

    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---- Reset & Base ---- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* ---- Animated Background ---- */
.bg-blobs {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.35;
    animation: blobFloat 18s ease-in-out infinite;
}

.blob-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #6366f1 0%, transparent 70%);
    top: -10%;
    left: -5%;
    animation-delay: 0s;
}

.blob-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #8b5cf6 0%, transparent 70%);
    bottom: -10%;
    right: -5%;
    animation-delay: -6s;
}

.blob-3 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, #06b6d4 0%, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -12s;
    opacity: 0.2;
}

@keyframes blobFloat {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    25% {
        transform: translate(30px, -40px) scale(1.05);
    }

    50% {
        transform: translate(-20px, 20px) scale(0.95);
    }

    75% {
        transform: translate(15px, 30px) scale(1.02);
    }
}

/* ---- Container ---- */
.container {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px 40px;
}

/* ---- Header ---- */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    padding: 16px 24px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    border-radius: var(--radius-md);
    color: white;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.logo-icon svg {
    width: 22px;
    height: 22px;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 1px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ---- Stealth Badge ---- */
.stealth-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--success);
    background: var(--success-bg);
    border: 1px solid var(--success-border);
    border-radius: 20px;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s var(--ease-out);
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: white;
    box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    box-shadow: 0 4px 20px var(--accent-glow);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.12);
}

.btn-full {
    width: 100%;
    justify-content: center;
    padding: 14px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-md);
}

/* ---- Main Grid ---- */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 860px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
}

/* ---- Cards ---- */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    transition: box-shadow 0.3s var(--ease-out);
}

.card:hover {
    box-shadow: var(--shadow-hover);
}

.card-header {
    padding: 20px 24px 0;
}

.card-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-header h2 svg {
    color: var(--accent-light);
    flex-shrink: 0;
}

/* ---- Form ---- */
form {
    padding: 20px 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group label svg {
    color: var(--accent-light);
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 20px;
    padding: 0 6px;
    font-size: 0.72rem;
    font-weight: 600;
    background: var(--accent);
    color: white;
    border-radius: 20px;
    transition: all 0.3s var(--ease-spring);
}

.badge-small {
    font-size: 0.68rem;
    min-width: unset;
    height: 18px;
    padding: 0 7px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
}

.badge-success {
    background: var(--success-bg) !important;
    color: var(--success) !important;
    border: 1px solid var(--success-border);
}

.badge-error {
    background: var(--error-bg) !important;
    color: var(--error) !important;
    border: 1px solid var(--error-border);
}

textarea,
input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.88rem;
    line-height: 1.6;
    transition: all 0.25s var(--ease-out);
    resize: vertical;
}

textarea::placeholder,
input::placeholder {
    color: var(--text-placeholder);
}

textarea:focus,
input[type="text"]:focus {
    outline: none;
    background: var(--bg-input-focus);
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea {
    min-height: 80px;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.78rem;
    line-height: 1.7;
}

.cookies-textarea {
    min-height: 80px;
    max-height: 120px;
    font-size: 0.72rem;
    line-height: 1.5;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.form-hint a {
    color: var(--accent-light);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

.form-hint a:hover {
    border-color: var(--accent-light);
}

/* ---- Controls Row (Batch + Delay) ---- */
.controls-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 520px) {
    .controls-row {
        grid-template-columns: 1fr;
    }
}

/* ---- Range Slider ---- */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    outline: none;
    cursor: pointer;
    transition: background 0.2s;
}

input[type="range"]:hover {
    background: rgba(255, 255, 255, 0.12);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    cursor: pointer;
    box-shadow: 0 2px 8px var(--accent-glow);
    border: 2px solid rgba(255, 255, 255, 0.15);
    transition: transform 0.2s var(--ease-spring), box-shadow 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 3px 14px var(--accent-glow);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    cursor: pointer;
    box-shadow: 0 2px 8px var(--accent-glow);
    border: 2px solid rgba(255, 255, 255, 0.15);
}

.range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ---- Delay Inputs ---- */
.delay-inputs {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.delay-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.delay-sub-label {
    font-size: 0.68rem !important;
    color: var(--text-muted) !important;
    font-weight: 400 !important;
}

.delay-field input[type="number"] {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
    text-align: center;
    transition: all 0.25s var(--ease-out);
    -moz-appearance: textfield;
}

.delay-field input[type="number"]::-webkit-inner-spin-button,
.delay-field input[type="number"]::-webkit-outer-spin-button {
    opacity: 0.3;
}

.delay-field input[type="number"]:focus {
    outline: none;
    background: var(--bg-input-focus);
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.delay-separator {
    color: var(--text-muted);
    font-size: 0.9rem;
    padding-bottom: 8px;
}

/* ---- Summary Bar ---- */
.summary-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 14px 20px;
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.12);
    border-radius: var(--radius-md);
    animation: fadeSlideIn 0.4s var(--ease-out);
}

.summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.summary-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 500;
}

.summary-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-light);
}

.summary-divider {
    width: 1px;
    height: 28px;
    background: var(--border-subtle);
}

/* ---- Jobs Panel ---- */
.jobs-container {
    padding: 16px 24px 24px;
    max-height: 70vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.jobs-container::-webkit-scrollbar {
    width: 5px;
}

.jobs-container::-webkit-scrollbar-track {
    background: transparent;
}

.jobs-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
}

/* ---- Empty State ---- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px 20px;
    color: var(--text-muted);
    text-align: center;
    gap: 10px;
}

.empty-state svg {
    opacity: 0.3;
    margin-bottom: 4px;
}

.empty-state p {
    font-size: 0.95rem;
    font-weight: 500;
}

.empty-hint {
    font-size: 0.82rem !important;
    font-weight: 400 !important;
    color: var(--text-placeholder) !important;
}

/* ---- Job Card ---- */
.job-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
    animation: fadeSlideIn 0.4s var(--ease-out);
    transition: all 0.25s var(--ease-out);
}

.job-card:hover {
    background: rgba(255, 255, 255, 0.035);
}

.job-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.job-id {
    font-size: 0.78rem;
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
    padding: 3px 8px;
    border-radius: 4px;
}

.job-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 4px 10px;
    border-radius: 20px;
}

.job-status.running {
    color: var(--accent-light);
    background: rgba(99, 102, 241, 0.12);
}

.job-status.completed {
    color: var(--success);
    background: var(--success-bg);
}

.job-status.completed_with_errors {
    color: var(--warning);
    background: var(--warning-bg);
}

.job-status.failed {
    color: var(--error);
    background: var(--error-bg);
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.status-dot.running {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.4;
        transform: scale(0.8);
    }
}

.job-meta {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.job-meta-item {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.job-meta-item strong {
    color: var(--text-primary);
    font-weight: 600;
}

.engine-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem !important;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--success) !important;
    background: var(--success-bg);
    padding: 2px 8px;
    border-radius: 10px;
    border: 1px solid var(--success-border);
}

/* ---- Progress Bar ---- */
.progress-wrapper {
    margin-bottom: 10px;
}

.progress-bar-bg {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    border-radius: 10px;
    transition: width 0.5s var(--ease-out);
    position: relative;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(255, 255, 255, 0.2) 50%,
            transparent 100%);
    animation: shimmer 2s ease-in-out infinite;
}

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

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

.progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.progress-percent {
    color: var(--accent-light);
    font-weight: 600;
}

/* ---- Batch Details ---- */
.batch-details-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.78rem;
    cursor: pointer;
    padding: 4px 0;
    transition: color 0.2s;
}

.batch-details-toggle:hover {
    color: var(--text-secondary);
}

.batch-details-toggle svg {
    transition: transform 0.25s var(--ease-out);
}

.batch-details-toggle.open svg {
    transform: rotate(90deg);
}

.batch-details {
    display: none;
    margin-top: 8px;
    max-height: 200px;
    overflow-y: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.batch-details.open {
    display: block;
    animation: fadeSlideIn 0.3s var(--ease-out);
}

.batch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    font-size: 0.78rem;
    border-bottom: 1px solid var(--border-subtle);
}

.batch-row:last-child {
    border-bottom: none;
}

.batch-row.success {
    background: rgba(16, 185, 129, 0.04);
}

.batch-row.failed {
    background: rgba(239, 68, 68, 0.04);
}

.batch-row-left {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

.batch-row-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.batch-row-icon.success {
    color: var(--success);
}

.batch-row-icon.failed {
    color: var(--error);
}

.batch-row-ids {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.72rem;
    color: var(--text-muted);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.batch-row-message {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ---- Toast Notifications ---- */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
}

.toast {
    min-width: 280px;
    max-width: 400px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(20px);
    animation: toastIn 0.4s var(--ease-spring);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.toast.success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid var(--success-border);
    color: var(--success);
}

.toast.error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--error-border);
    color: var(--error);
}

.toast.info {
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: var(--accent-light);
}

.toast.removing {
    animation: toastOut 0.3s var(--ease-out) forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    to {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---- Responsive ---- */
@media (max-width: 860px) {
    .container {
        padding: 16px 12px 32px;
    }

    .header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
        padding: 14px 18px;
    }

    .header-actions {
        align-self: flex-end;
    }

    .card-header {
        padding: 16px 18px 0;
    }

    form {
        padding: 16px 18px 20px;
    }

    .jobs-container {
        padding: 12px 18px 20px;
    }

    .summary-bar {
        gap: 10px;
        padding: 12px 14px;
    }
}

/* ---- Loading spinner for submit button ---- */
.btn-loading {
    position: relative;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-left: 8px;
}

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