/* Root Variables */
:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.1);
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;

    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #252538;

    --text-primary: #ffffff;
    --text-secondary: #a0a0b8;
    --text-tertiary: #6b6b84;

    --border: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(255, 255, 255, 0.2);

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.25);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #0a0a15 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.6s ease-out;
}

header h1 {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.125rem;
}

/* Upload Section */
.upload-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
    animation: fadeInUp 0.6s ease-out 0.2s both;
}

.upload-card h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.upload-zone {
    position: relative;
    background: var(--bg-secondary);
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    min-height: 400px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.upload-zone:hover {
    border-color: var(--primary);
    background: var(--bg-tertiary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.upload-zone.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: scale(1.02);
}

.upload-zone.has-image {
    padding: 0;
    border-style: solid;
}

.upload-placeholder {
    text-align: center;
    color: var(--text-secondary);
    transition: var(--transition);
}

.upload-zone:hover .upload-placeholder {
    color: var(--primary);
    transform: scale(1.05);
}

.upload-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    stroke: currentColor;
}

.upload-placeholder p {
    font-size: 1.125rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.upload-hint {
    font-size: 0.875rem;
    color: var(--text-tertiary);
}

.preview-image {
    display: none;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: var(--radius-lg);
}

.upload-zone.has-image .preview-image {
    display: block;
}

.upload-zone.has-image .upload-placeholder {
    display: none;
}

/* Video preview styling */
.preview-media {
    display: none;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: var(--radius-lg);
}

.remove-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.upload-zone.has-image:hover .remove-btn {
    opacity: 1;
}

.remove-btn:hover {
    background: var(--error);
    transform: scale(1.1);
}

.remove-btn svg {
    width: 20px;
    height: 20px;
    stroke: white;
}

/* Action Section */
.action-section {
    text-align: center;
    margin: 3rem 0;
    animation: fadeInUp 0.6s ease-out 0.4s both;
}

.swap-btn {
    position: relative;
    padding: 1.25rem 4rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.swap-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.swap-btn:hover::before {
    left: 100%;
}

.swap-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

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

.swap-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.swap-btn.processing {
    pointer-events: none;
}

.swap-btn.processing .btn-text {
    opacity: 0;
}

.swap-btn.processing .spinner {
    display: block;
}

/* Action buttons container */
.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Cancel Upload Button */
.cancel-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--error) 0%, #dc2626 100%);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
    animation: fadeIn 0.3s ease-out;
}

.cancel-upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

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

/* Enhance Only Button */
.enhance-only-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
}

.enhance-only-btn svg {
    width: 20px;
    height: 20px;
}

.enhance-only-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.enhance-only-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.enhance-only-btn.processing {
    pointer-events: none;
}

.enhance-only-btn.processing .btn-text {
    opacity: 0;
}

.enhance-only-btn.processing .spinner {
    display: block;
}

.enhance-only-btn .spinner {
    display: none;
    position: absolute;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

.status-text {
    margin-top: 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    min-height: 1.5rem;
}

/* Result Section */
.result-section {
    display: none;
    animation: fadeInUp 0.6s ease-out;
}

.result-section.visible {
    display: block;
}

.result-section h2 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.result-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
}

.result-image,
.result-media {
    width: 100%;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-md);
}

.result-media {
    max-height: 70vh;
}

.result-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.download-btn,
.new-swap-btn {
    flex: 1;
    min-width: 200px;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.download-btn {
    background: var(--success);
    color: white;
}

.download-btn:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.download-btn svg {
    width: 20px;
    height: 20px;
}

.new-swap-btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.new-swap-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

/* Enhance Section */
.enhance-section {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.enhance-header {
    margin-bottom: 1rem;
}

.enhance-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.enhance-hint {
    font-size: 0.875rem;
    color: var(--text-tertiary);
}

.enhance-options {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.enhance-option {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.enhance-option input[type="checkbox"] {
    display: none;
}

.enhance-option .option-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    transition: var(--transition);
}

.enhance-option .option-label svg {
    width: 18px;
    height: 18px;
}

.enhance-option input:checked + .option-label {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.enhance-option:hover .option-label {
    border-color: var(--primary);
}

.enhance-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.enhance-btn svg {
    width: 20px;
    height: 20px;
}

.enhance-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.enhance-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.enhance-btn.processing .btn-text,
.enhance-btn.processing svg:first-child {
    opacity: 0;
}

.enhance-btn.processing .spinner {
    display: block;
}

.enhance-btn .spinner {
    display: none;
    position: absolute;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.enhance-status {
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
    min-height: 1.25rem;
}

/* Error Message */
.error-message {
    position: fixed;
    top: 2rem;
    right: 2rem;
    max-width: 400px;
    background: var(--bg-secondary);
    border: 1px solid var(--error);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    box-shadow: var(--shadow-xl);
    display: none;
    align-items: flex-start;
    gap: 1rem;
    animation: slideInRight 0.4s ease-out;
    z-index: 1000;
}

.error-message.visible {
    display: flex;
}

.error-message > svg {
    width: 24px;
    height: 24px;
    stroke: var(--error);
    flex-shrink: 0;
}

.error-message span {
    flex: 1;
    color: var(--text-primary);
    font-size: 0.875rem;
    line-height: 1.5;
}

.close-error {
    width: 24px;
    height: 24px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
    flex-shrink: 0;
}

.close-error:hover {
    color: var(--text-primary);
    transform: scale(1.1);
}

.close-error svg {
    width: 20px;
    height: 20px;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 4rem;
    padding: 2rem 0;
    color: var(--text-tertiary);
    font-size: 0.875rem;
    animation: fadeIn 0.6s ease-out 0.6s both;
}

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

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

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

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ==================== SIDEBAR ==================== */

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 998;
}

.sidebar-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 320px;
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-xl);
    transform: translateX(-100%);
    transition: transform 0.3s ease-out;
    z-index: 999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.sidebar-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.ws-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-tertiary);
    transition: var(--transition);
}

.ws-status.connected {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.ws-status.disconnected {
    background: var(--error);
    animation: pulse 1.5s infinite;
}

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

.sidebar-section {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-section h4 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    margin-bottom: 0.75rem;
}

.jobs-list {
    max-height: 200px;
    overflow-y: auto;
}

.history-list {
    max-height: 300px;
    flex: 1;
}

.no-jobs {
    color: var(--text-tertiary);
    font-size: 0.875rem;
    text-align: center;
    padding: 1rem;
}

.job-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    transition: var(--transition);
}

.job-item:hover {
    background: var(--bg-primary);
}

.job-item.current {
    border: 1px solid var(--primary);
    background: var(--primary-light);
}

.job-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
    flex: 1;
}

.job-id {
    font-size: 0.875rem;
    font-family: monospace;
    color: var(--text-primary);
}

.job-status {
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 500;
}

.job-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.job-type-badge {
    font-size: 0.625rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--primary-light);
    color: var(--primary);
    text-transform: uppercase;
}

.job-progress-bar {
    width: 100%;
    height: 4px;
    background: var(--bg-primary);
    border-radius: 2px;
    margin-top: 0.5rem;
    overflow: hidden;
}

.job-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #8b5cf6);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.job-cancel-btn {
    width: 24px;
    height: 24px;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: 4px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.job-cancel-btn:hover {
    background: var(--error);
    color: white;
}

/* Job action buttons container */
.job-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

/* Download button for active jobs (for partial results) */
.job-download-btn {
    width: 24px;
    height: 24px;
    background: var(--success);
    border: none;
    color: white;
    cursor: pointer;
    border-radius: 4px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.job-download-btn svg {
    width: 14px;
    height: 14px;
}

.job-download-btn:hover {
    background: #059669;
    transform: scale(1.1);
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.history-item:hover {
    background: var(--bg-primary);
    transform: translateX(4px);
}

.history-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.history-type {
    font-size: 0.875rem;
    color: var(--text-primary);
    text-transform: capitalize;
}

.history-time {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.history-status {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 500;
}

.history-status.completed {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.history-status.failed {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

.history-download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: var(--transition);
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.history-download-btn svg {
    width: 16px;
    height: 16px;
}

.history-download-btn:hover {
    background: #7c3aed;
    transform: scale(1.1);
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.sidebar-toggle:hover {
    background: var(--bg-secondary);
    border-color: var(--primary);
    color: var(--primary);
}

.sidebar-toggle svg {
    width: 24px;
    height: 24px;
}

.job-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    background: var(--primary);
    color: white;
    font-size: 0.625rem;
    font-weight: 700;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* Header Layout Fix */
header {
    position: relative;
    padding-left: 60px;
}

.header-content {
    display: block;
}

/* ==================== END SIDEBAR ==================== */

/* ==================== BATCH MODE ==================== */

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

.upload-header h2 {
    margin-bottom: 0;
}

.batch-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.batch-toggle input {
    display: none;
}

.toggle-label {
    padding: 0.375rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: var(--transition);
}

.batch-toggle:hover .toggle-label {
    border-color: var(--primary);
}

.batch-toggle input:checked + .toggle-label {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.batch-preview {
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
    padding: 1rem;
    width: 100%;
    max-height: 350px;
    overflow-y: auto;
}

.upload-zone.has-batch .batch-preview {
    display: grid;
}

.upload-zone.has-batch .preview-image,
.upload-zone.has-batch .upload-placeholder {
    display: none;
}

.batch-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-tertiary);
}

.batch-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.batch-item .remove-batch {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.batch-item:hover .remove-batch {
    opacity: 1;
}

.batch-item .remove-batch:hover {
    background: var(--error);
}

.batch-count {
    position: absolute;
    bottom: 4px;
    left: 4px;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 4px;
    font-size: 0.625rem;
    color: white;
    font-weight: 600;
}

.batch-add {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 2rem;
}

.batch-add:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

/* ==================== END BATCH MODE ==================== */

/* ==================== FACE PRESETS ==================== */

.save-preset-btn {
    width: 36px;
    height: 36px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.save-preset-btn:hover {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.save-preset-btn svg {
    width: 18px;
    height: 18px;
}

.presets-section {
    margin-top: 1rem;
    display: none;
}

.presets-section.has-presets {
    display: block;
}

.presets-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.presets-header span {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
}

.presets-grid {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.preset-item {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--transition);
}

.preset-item:hover {
    border-color: var(--primary);
    transform: scale(1.05);
}

.preset-item.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.preset-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preset-item .preset-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 10px;
    cursor: pointer;
    opacity: 0;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.preset-item:hover .preset-remove {
    opacity: 1;
}

.preset-item .preset-remove:hover {
    background: var(--error);
}

.preset-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2px;
    background: rgba(0, 0, 0, 0.7);
    font-size: 0.5rem;
    color: white;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==================== END FACE PRESETS ==================== */

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header {
        padding-left: 50px;
    }

    header h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .upload-section {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .upload-zone {
        min-height: 300px;
        padding: 1.5rem;
    }

    .swap-btn {
        padding: 1rem 3rem;
        font-size: 1.125rem;
    }

    .result-actions {
        flex-direction: column;
    }

    .download-btn,
    .new-swap-btn {
        width: 100%;
    }

    .error-message {
        right: 1rem;
        left: 1rem;
        max-width: none;
    }

    /* Sidebar mobile */
    .sidebar {
        width: 100%;
        max-width: 320px;
    }

    .sidebar-toggle {
        width: 40px;
        height: 40px;
    }

    .sidebar-toggle svg {
        width: 20px;
        height: 20px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus Styles */
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
