:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --success: #10b981;
    --warning: #ef4444;
    --border-color: rgba(255, 255, 255, 0.1);
    --ring: rgba(99, 102, 241, 0.5);
    --overlay: rgba(15, 23, 42, 0.8);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: clamp(1rem, 5vw, 3rem) clamp(1rem, 3vw, 2rem);
    overflow-x: hidden;
}

.app-container {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    gap: clamp(2rem, 5vw, 3rem);
}

header {
    text-align: center;
    animation: fadeInDown 0.8s ease-out;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: clamp(0.5rem, 2vw, 1rem);
    flex-wrap: wrap; /* in case of tiny screens */
}

h1 {
    font-size: clamp(2rem, 5vw, 2.75rem);
    font-weight: 800;
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -1px;
}

header p {
    color: var(--text-secondary);
    font-size: clamp(0.95rem, 2vw, 1.15rem);
    font-weight: 300;
    padding: 0 1rem; /* prevent edge-touching on mobile */
    line-height: 1.5;
}

/* Upload Zone */
.upload-zone {
    background: rgba(30, 41, 59, 0.6);
    border: 2px dashed rgba(99, 102, 241, 0.4);
    border-radius: 1.5rem;
    padding: clamp(3rem, 10vw, 6rem) clamp(1.5rem, 5vw, 2rem);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3), 0 0 0 4px var(--ring);
}

.hidden-input {
    display: none;
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    pointer-events: none;
}

.upload-icon {
    width: clamp(60px, 15vw, 80px);
    height: clamp(60px, 15vw, 80px);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #818cf8;
    margin-bottom: 0.5rem;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1) inset;
}

.upload-icon svg {
    width: clamp(24px, 6vw, 40px);
    height: clamp(24px, 6vw, 40px);
}

.upload-content h2 {
    font-size: clamp(1.25rem, 4vw, 1.75rem);
    font-weight: 600;
}

.upload-content p {
    color: var(--text-secondary);
    font-size: clamp(0.9rem, 2vw, 1rem);
}

/* Dashboard */
.jobs-dashboard {
    background: var(--bg-secondary);
    border-radius: 1.5rem;
    padding: clamp(1.5rem, 5vw, 2.5rem);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    animation: fadeIn 0.5s ease-out;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap; /* allows button stacking on small screens */
    gap: 1.5rem;
}

.dashboard-header h2 {
    font-size: clamp(1.2rem, 3.5vw, 1.5rem);
    font-weight: 600;
}

/* Nav/Control Group */
.nav-group {
    display: flex; 
    gap: clamp(0.5rem, 2vw, 1rem); 
    align-items: center;
}

/* Buttons */
.btn-primary, .download-btn {
    background: var(--primary);
    color: white;
    font-family: inherit;
    font-weight: 600;
    border: none;
    padding: clamp(0.6rem, 2vw, 0.8rem) clamp(1.2rem, 3vw, 1.5rem);
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    font-size: clamp(0.9rem, 2vw, 1rem);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
    min-height: 44px; /* Accessible touch target */
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.5);
}

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

.btn-primary:disabled {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: not-allowed;
    box-shadow: none;
}

.download-btn {
    background: transparent;
    border: 1px solid var(--bg-tertiary);
    color: var(--text-secondary);
    padding: clamp(0.5rem, 1.5vw, 0.6rem) clamp(0.75rem, 2vw, 1rem);
    box-shadow: none;
}

.download-btn.ready {
    border-color: var(--success);
    color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

.download-btn.ready:hover {
    background: var(--success);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    transform: translateY(-2px);
}

/* Jobs List */
.jobs-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.job-card {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: clamp(1.25rem, 4vw, 1.75rem);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    animation: slideUp 0.4s ease-out backwards;
}

.job-card:hover {
    background: rgba(15, 23, 42, 0.7);
    border-color: rgba(99, 102, 241, 0.3);
}

.job-info {
    flex: 1;
    min-width: 0; /* allows text truncation if needed */
}

.job-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap; 
}

.job-name {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    font-size: clamp(0.95rem, 2.5vw, 1.05rem);
    color: #e2e8f0;
    word-break: break-all;
    flex: 1;
}

.job-name svg {
    color: #818cf8;
    flex-shrink: 0; /* prevents icon from shrinking */
}

.status-badge {
    font-size: clamp(0.7rem, 1.5vw, 0.8rem);
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.status-queued { background: rgba(148, 163, 184, 0.15); color: #94a3b8; }
.status-processing { background: rgba(99, 102, 241, 0.15); color: #818cf8; animation: pulse 2s infinite; }
.status-completed { background: rgba(16, 185, 129, 0.15); color: #10b981; }

/* Progress Bar */
.progress-bar-bg {
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
    width: 100%;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #818cf8, #c084fc);
    border-radius: 4px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0; left: 0; bottom: 0; right: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shine 1.5s infinite;
}

.progress-bar-fill.completed {
    background: var(--success);
}
.progress-bar-fill.completed::after {
    display: none;
}

.job-actions {
    margin-left: 2rem; 
    display: flex; 
    align-items: center;
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Animations */
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}

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

/* Highly Responsive Mobile Utilities */
@media (max-width: 768px) {
    .job-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
    }
    .job-info {
        width: 100%;
    }
    .job-actions {
        margin-left: 0;
        width: 100%;
    }
    .job-actions .download-btn {
        width: 100%;
        padding: 0.8rem;
    }
    .dashboard-header {
        flex-direction: column;
        align-items: stretch;
    }
    .nav-group {
        justify-content: space-between;
        margin-bottom: 0.5rem;
    }
    #download-all {
        width: 100%;
    }
}
