/* ===========================================
   PIXELIUS - Glassmorphism Theme
   Premium AI Image Upscaler
   =========================================== */

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

:root {
    /* Background */
    --bg-primary: #0f1922;
    --bg-secondary: #1a2a3a;
    --bg-tertiary: #2d3a4a;
    --bg-gradient: linear-gradient(135deg, #0f1922 0%, #1a2a3a 40%, #1e3a5f 100%);
    
    /* Glass Effect */
    --glass-bg: rgba(255, 255, 255, 0.06);
    --glass-bg-hover: rgba(255, 255, 255, 0.1);
    --glass-bg-active: rgba(255, 255, 255, 0.14);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-border-hover: rgba(255, 255, 255, 0.2);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    
    /* Text */
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.4);
    
    /* Accent Colors */
    --accent: #60a5fa;
    --accent-hover: #3b82f6;
    --accent-gradient: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
    
    /* Status Colors */
    --success: #34d399;
    --warning: #fbbf24;
    --error: #f87171;
    
    /* Sizes */
    --sidebar-width: 360px;
    --sidebar-right-width: 420px;
    --header-height: 64px;
    --border-radius: 16px;
    --border-radius-sm: 12px;
    --border-radius-xs: 8px;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;
}

/* ===========================================
   BASE STYLES
   =========================================== */
html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* Background Effects */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 15% 85%, rgba(96, 165, 250, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 85% 15%, rgba(52, 211, 153, 0.06) 0%, transparent 40%);
    pointer-events: none;
    z-index: 0;
}

/* ===========================================
   APP LAYOUT
   =========================================== */
.app-container {
    display: flex;
    height: 100vh;
    padding: 16px;
    gap: 16px;
    position: relative;
    z-index: 1;
}

/* ===========================================
   SIDEBAR BASE
   =========================================== */
.sidebar {
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-left {
    width: var(--sidebar-width);
    flex-shrink: 0;
}

.sidebar-right {
    width: var(--sidebar-right-width);
    flex-shrink: 0;
}

/* ===========================================
   SIDEBAR HEADER
   =========================================== */
.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--glass-border);
}

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

.logo-icon {
    font-size: 28px;
    filter: drop-shadow(0 2px 8px rgba(96, 165, 250, 0.4));
}

.logo-text {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff 0%, rgba(255,255,255,0.85) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-badge {
    font-size: 10px;
    font-weight: 600;
    background: var(--primary);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 8px;
}

.logo-badge.advanced {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

/* ===========================================
   SIDEBAR CONTENT
   =========================================== */
.sidebar-content {
    flex: 1;
    overflow: hidden;
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.sidebar-content::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ===========================================
   IMPORT SECTION
   =========================================== */
.import-section {
    margin-bottom: 16px;
    flex-shrink: 0;
}

.import-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.import-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.import-btn:hover {
    background: var(--glass-bg-hover);
    border-color: var(--glass-border-hover);
    transform: translateY(-1px);
}

.import-btn .icon {
    font-size: 14px;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 8px;
}

.btn-run {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--border-radius-sm);
    color: #fff;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: 0 3px 10px rgba(96, 165, 250, 0.25);
}

.btn-run:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(96, 165, 250, 0.35);
}

.btn-run:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-clear {
    padding: 10px 14px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.btn-clear:hover:not(:disabled) {
    background: rgba(248, 113, 113, 0.15);
    border-color: rgba(248, 113, 113, 0.3);
    color: var(--error);
}

.btn-clear:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-save-all {
    padding: 10px 12px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-save-all:hover {
    background: rgba(52, 211, 153, 0.15);
    border-color: rgba(52, 211, 153, 0.3);
    color: var(--success);
}

.btn-save-all.has-pending {
    background: rgba(52, 211, 153, 0.2);
    border-color: var(--success);
    color: var(--success);
    animation: pulse-save 2s infinite;
}

@keyframes pulse-save {
    0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(52, 211, 153, 0); }
}

/* ===========================================
   DIVIDER
   =========================================== */
.nav-divider {
    height: 1px;
    background: var(--glass-border);
    margin: 14px 0;
    flex-shrink: 0;
}

/* ===========================================
   SETTINGS SECTION
   =========================================== */
.settings-section {
    margin-bottom: 4px;
    flex-shrink: 0;
}

.settings-group {
    margin-bottom: 14px;
}

.settings-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

/* Resolution Buttons */
.resolution-buttons {
    display: flex;
    gap: 6px;
}

.res-btn {
    flex: 1;
    padding: 8px 10px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-xs);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.res-btn:hover:not(.active) {
    background: var(--glass-bg-hover);
    color: var(--text-primary);
}

.res-btn.active {
    background: var(--accent-gradient);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 2px 8px rgba(96, 165, 250, 0.3);
}

.res-btn.restricted {
    opacity: 0.4;
    cursor: not-allowed;
    position: relative;
}

.res-btn.restricted::after {
    content: '🔒';
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 8px;
}

.res-btn.restricted:hover {
    background: var(--glass-bg);
    color: var(--text-secondary);
}

/* Auto Save Toggle */
.auto-save-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    transition: all var(--transition-normal);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: all var(--transition-normal);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.status-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
    text-transform: uppercase;
}

.status-badge.on {
    background: rgba(52, 211, 153, 0.2);
    color: var(--success);
}

.status-badge.off {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

/* ===========================================
   QUEUE SECTION
   =========================================== */
.queue-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.nav-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.queue-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.queue-empty {
    text-align: center;
    padding: 20px 12px;
    color: var(--text-muted);
}

.queue-empty .empty-icon {
    font-size: 24px;
    display: block;
    margin-bottom: 8px;
    opacity: 0.5;
}

.queue-empty p {
    font-size: 12px;
}

/* Queue Item */
.queue-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-normal);
}

.queue-item:hover {
    background: var(--glass-bg-hover);
}

.queue-item.processing {
    border-color: var(--warning);
    background: rgba(251, 191, 36, 0.1);
}

.queue-item.done {
    border-color: var(--success);
    background: rgba(52, 211, 153, 0.1);
    cursor: pointer;
}

.queue-item.error {
    border-color: var(--error);
    background: rgba(248, 113, 113, 0.1);
}

.queue-item.oversized {
    border-color: #f97316;
    background: rgba(249, 115, 22, 0.1);
}

.queue-thumb {
    width: 44px;
    height: 44px;
    border-radius: var(--border-radius-xs);
    object-fit: cover;
    flex-shrink: 0;
}

.queue-info {
    flex: 1;
    min-width: 0;
}

.queue-name {
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.queue-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.queue-resolution {
    font-size: 11px;
    padding: 3px 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: inherit;
    cursor: pointer;
    outline: none;
    min-width: 50px;
}

.queue-resolution:focus {
    border-color: var(--accent);
}

.queue-resolution option {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 8px;
}

.queue-resolution option:disabled {
    color: var(--text-muted);
    background: var(--bg-tertiary);
}

.queue-res-tag {
    font-size: 10px;
    font-weight: 600;
    padding: 3px 7px;
    background: var(--accent);
    border-radius: 4px;
    color: #fff;
}

.queue-res-tag.error {
    background: #f97316;
    color: #fff;
}

.queue-status {
    font-size: 10px;
    color: var(--text-secondary);
}

.queue-status.processing { color: var(--warning); }
.queue-status.done { color: var(--success); }
.queue-status.error { color: var(--error); }
.queue-status.oversized { color: #f97316; }

.queue-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-xs);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.queue-btn:hover {
    background: var(--glass-bg-hover);
    color: var(--text-primary);
}

.queue-btn.remove:hover {
    background: rgba(248, 113, 113, 0.2);
    color: var(--error);
}

.queue-btn.info {
    background: rgba(249, 115, 22, 0.2);
    border-color: rgba(249, 115, 22, 0.4);
    color: #f97316;
    cursor: help;
}

.queue-btn.info:hover {
    background: rgba(249, 115, 22, 0.3);
}

.queue-btn.run {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.queue-btn.run:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.queue-btn.stop {
    background: rgba(251, 191, 36, 0.2);
    border-color: rgba(251, 191, 36, 0.4);
    color: var(--warning);
}

.queue-btn.stop:hover {
    background: rgba(251, 191, 36, 0.3);
}

.queue-btn.rerun {
    background: rgba(52, 211, 153, 0.15);
    border-color: rgba(52, 211, 153, 0.3);
    color: var(--success);
}

.queue-btn.delete {
    background: var(--glass-bg);
    border-color: var(--glass-border);
    color: var(--text-secondary);
}

.queue-btn.delete:hover {
    background: rgba(248, 113, 113, 0.2);
    border-color: var(--error);
    color: var(--error);
}

.queue-btn.download {
    background: var(--glass-bg);
    border-color: var(--glass-border);
    color: var(--text-secondary);
}

.queue-btn.download:hover {
    background: rgba(96, 165, 250, 0.2);
    border-color: var(--accent);
    color: var(--accent);
}

.queue-btn.rerun:hover {
    background: rgba(52, 211, 153, 0.25);
}

.queue-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* ===========================================
   QUEUE STATS
   =========================================== */
.queue-stats {
    display: flex;
    gap: 8px;
    padding: 10px 20px;
    margin: 0;
    background: var(--surface-darker);
    border-top: 1px solid var(--glass-border);
    flex-shrink: 0;
}

.stat-item {
    flex: 1;
    text-align: center;
}

.stat-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 1px;
}

.stat-label {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* ===========================================
   RE-FIX LINK SECTION
   =========================================== */
.refix-link-section {
    padding: 8px 20px;
}

.refix-link-section:first-of-type {
    padding-top: 10px;
}

.refix-link-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border: none;
    border-radius: var(--border-radius-xs);
    color: white;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
}

.refix-link-btn:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.refix-link-btn .icon {
    font-size: 16px;
}

/* Basic Mode Link - màu xanh */
.refix-link-btn.basic-link {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
}

.refix-link-btn.basic-link:hover {
    background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

/* ===========================================
   SIDEBAR FOOTER
   =========================================== */
.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--glass-border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
}

.logout-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-xs);
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.logout-btn:hover {
    background: rgba(248, 113, 113, 0.15);
    border-color: rgba(248, 113, 113, 0.3);
    color: var(--error);
}

.login-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition-normal);
}

.login-link:hover {
    background: var(--glass-bg-hover);
    color: var(--text-primary);
}

/* ===========================================
   MAIN CONTENT
   =========================================== */
.main-content {
    flex: 1;
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Main Header */
.main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--glass-border);
}

.main-header h1 {
    font-size: 20px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.header-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-xs);
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.header-btn:hover {
    background: var(--glass-bg-hover);
    color: var(--text-primary);
}

/* Server Queue Indicator */
.server-queue-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(251, 191, 36, 0.15);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: var(--border-radius-xs);
    font-size: 12px;
    color: var(--warning);
    margin-right: 12px;
}

.server-queue-indicator .queue-icon {
    animation: spin 2s linear infinite;
}

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

/* ===========================================
   WORKSPACE SECTIONS
   =========================================== */
.workspace {
    flex: 1;
    display: none;
    overflow: hidden;
}

.workspace.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Welcome Section */
.welcome-container {
    text-align: center;
    padding: 40px;
    max-width: 400px;
}

.welcome-icon {
    font-size: 64px;
    margin-bottom: 24px;
    filter: drop-shadow(0 4px 12px rgba(96, 165, 250, 0.3));
}

.welcome-container h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 12px;
}

.welcome-container p {
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.welcome-container .hint {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 32px;
}

.welcome-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.welcome-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 24px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.welcome-btn:hover {
    background: var(--glass-bg-hover);
    border-color: var(--glass-border-hover);
    transform: translateY(-2px);
}

/* Processing Section */
.processing-container {
    text-align: center;
    padding: 40px;
    max-width: 500px;
    width: 100%;
}

.processing-preview {
    width: 200px;
    height: 200px;
    margin: 0 auto 24px;
    border-radius: var(--border-radius);
    overflow: hidden;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
}

.processing-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.processing-filename {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 20px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.progress-bar-container {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ===========================================
   VIEWER SECTION
   =========================================== */
.viewer-section.active {
    display: flex;
    flex-direction: column;
}

.viewer-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px 24px;
    overflow: hidden;
}

.viewer-header {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.viewer-controls-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-close {
    padding: 8px 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-xs);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-close:hover {
    background: var(--glass-bg-hover);
    color: var(--text-primary);
}

/* Zoom Controls */
.zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.zoom-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-xs);
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.zoom-btn:hover {
    background: var(--glass-bg-hover);
}

#zoom-level {
    font-size: 13px;
    font-weight: 500;
    min-width: 45px;
    text-align: center;
}

.zoom-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin: 0;
}

/* Viewer Main - ảnh + nút bên phải */
.viewer-main {
    flex: 1;
    display: flex;
    gap: 16px;
    min-height: 0;
    align-items: center;
    justify-content: center;
}

/* Comparison Container - Fixed size 700x700 */
.comparison-container {
    width: 700px;
    height: 700px;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    overflow: hidden;
    flex-shrink: 0;
}

.comparison-slider {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    cursor: default;
    user-select: none;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--border-radius);
}

.comparison-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform-origin: center center;
    transform: translate(-50%, -50%) scale(1);
    transition: none;
    display: flex;
    align-items: center;
    justify-content: center;
    /* GPU acceleration */
    will-change: transform;
    backface-visibility: hidden;
}

.comparison-after,
.comparison-before {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    /* GPU acceleration */
    backface-visibility: hidden;
}

/* Ảnh fill hết khung - chiều lớn nhất >= chiều khung tương ứng */
.comparison-after img,
.comparison-before img {
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    object-fit: cover;
    /* Prevent image rendering issues */
    image-rendering: auto;
}

.comparison-before {
    clip-path: inset(0 50% 0 0);
    /* GPU acceleration for clip-path */
    will-change: clip-path;
}

.comparison-label {
    position: absolute;
    bottom: 12px;
    padding: 5px 12px;
    background: rgba(0, 0, 0, 0.75);
    border-radius: 16px;
    font-size: 11px;
    font-weight: 600;
    pointer-events: none;
    z-index: 10;
}

.label-before { left: 12px; }
.label-after { right: 12px; }

.comparison-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 3px;
    background: #fff;
    transform: translateX(-50%);
    cursor: ew-resize;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    z-index: 20;
    /* GPU acceleration */
    will-change: left;
    backface-visibility: hidden;
}

.handle-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--bg-primary);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    cursor: ew-resize;
}

/* Viewer Side Buttons - Download + Delete */
.viewer-side-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
    justify-content: center;
}

.btn-viewer-action {
    padding: 14px 20px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    white-space: nowrap;
}

.btn-viewer-action.download {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: 0 4px 12px rgba(96, 165, 250, 0.25);
}

.btn-viewer-action.download:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(96, 165, 250, 0.35);
}

.btn-viewer-action.delete {
    background: #b91c1c;
    border: none;
    color: #fff;
    box-shadow: 0 4px 12px rgba(185, 28, 28, 0.3);
}

.btn-viewer-action.delete:hover {
    background: #991b1b;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(185, 28, 28, 0.4);
}

/* Viewer Footer - tên file dưới ảnh */
.viewer-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    flex-shrink: 0;
}

.viewer-footer-info {
    text-align: center;
    flex: 1;
}

.viewer-footer h2 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--text-primary);
}

.viewer-footer p {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
}

.viewer-footer .btn-close {
    flex-shrink: 0;
}

/* Hidden old classes */
.viewer-info,
.viewer-actions,
.btn-download,
.btn-download-side {
    display: none;
}

/* ===========================================
   RIGHT SIDEBAR - RECENT FILES
   =========================================== */
.recent-header {
    padding: 20px;
    border-bottom: 1px solid var(--glass-border);
}

.recent-header h3 {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.recent-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    background: var(--accent);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.recent-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.recent-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
    font-size: 13px;
}

.recent-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.recent-item:hover {
    background: var(--glass-bg-hover);
    border-color: var(--accent);
}

.recent-thumb {
    width: 72px;
    height: 72px;
    border-radius: var(--border-radius-xs);
    object-fit: cover;
    flex-shrink: 0;
}

.recent-info {
    flex: 1;
    min-width: 0;
}

.recent-name {
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.recent-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.recent-meta.refix {
    color: #f59e0b;
    font-weight: 600;
}

.recent-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.recent-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.recent-btn:hover {
    background: var(--glass-bg-hover);
    color: var(--text-primary);
}

.recent-btn.download:hover {
    background: rgba(96, 165, 250, 0.2);
    border-color: var(--accent);
    color: var(--accent);
}

.recent-btn.upscale:hover {
    background: rgba(52, 211, 153, 0.2);
    border-color: var(--success);
    color: var(--success);
}

.recent-btn.delete:hover {
    background: rgba(248, 113, 113, 0.2);
    border-color: var(--error);
    color: var(--error);
}

/* ===========================================
   TOASTS
   =========================================== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 16px 24px;
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    max-width: 400px;
}

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

.toast.error {
    background: rgba(248, 113, 113, 0.95);
    color: #fff;
}

.toast.success {
    background: rgba(52, 211, 153, 0.95);
    color: #fff;
}

/* ===========================================
   HIDDEN INPUTS
   =========================================== */
input[type="file"][hidden] {
    display: none;
}

/* ===========================================
   RESPONSIVE
   =========================================== */
@media (max-width: 1200px) {
    .sidebar-right {
        display: none;
    }
}

@media (max-width: 900px) {
    .app-container {
        padding: 8px;
        gap: 8px;
    }
    
    .sidebar-left {
        width: 240px;
    }
}

@media (max-width: 768px) {
    .sidebar-left {
        display: none;
    }
}

/* ===========================================
   RE-FIX MODAL
   =========================================== */
.refix-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.refix-modal.show {
    display: flex;
}

.refix-content {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.refix-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--glass-border);
    position: relative;
}

.refix-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.refix-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

.btn-close-refix {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--glass-bg);
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-close-refix:hover {
    background: var(--glass-bg-hover);
    color: var(--text-primary);
}

.refix-jobs {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.refix-job-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.refix-job-card.processing {
    border-color: var(--accent);
    background: rgba(96, 165, 250, 0.1);
}

.refix-job-card.done {
    border-color: var(--success);
    background: rgba(52, 211, 153, 0.1);
}

.refix-job-card.error {
    border-color: var(--error);
    background: rgba(248, 113, 113, 0.1);
}

.refix-job-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.refix-job-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.refix-job-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.refix-job-badge.wf-4k { background: #10b981; color: white; }
.refix-job-badge.wf-6k { background: #3b82f6; color: white; }
.refix-job-badge.wf-9k { background: #8b5cf6; color: white; }

.refix-job-info {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.refix-job-progress {
    height: 6px;
    background: var(--glass-bg);
    border-radius: 3px;
    overflow: hidden;
}

.refix-job-progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    width: 0%;
    transition: width 0.3s ease;
}

.refix-job-card.done .refix-job-progress-fill {
    background: var(--success);
    width: 100%;
}

.refix-job-status {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

.refix-job-card.processing .refix-job-status {
    color: var(--accent);
}

.refix-job-card.done .refix-job-status {
    color: var(--success);
}

.refix-job-card.error .refix-job-status {
    color: var(--error);
}

.refix-job-actions {
    display: flex;
    gap: 8px;
}

.refix-job-btn {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-xs);
    background: var(--glass-bg);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.refix-job-btn:hover:not(:disabled) {
    background: var(--glass-bg-hover);
    border-color: var(--glass-border-hover);
}

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

.refix-job-btn.run {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.refix-job-btn.run:hover:not(:disabled) {
    background: var(--accent-hover);
}

.refix-job-btn.stop {
    background: var(--error);
    border-color: var(--error);
    color: white;
}

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

.refix-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-refix-all, .btn-refix-stop-all {
    padding: 10px 24px;
    border: none;
    border-radius: var(--border-radius-xs);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-refix-all {
    background: var(--accent);
    color: white;
}

.btn-refix-all:hover {
    background: var(--accent-hover);
}

.btn-refix-stop-all {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
}

.btn-refix-stop-all:hover {
    background: var(--error);
    border-color: var(--error);
}

/* Re-fix button in viewer */
.btn-viewer-action.refix {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border-color: #f59e0b;
}

.btn-viewer-action.refix:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
}

@media (max-width: 768px) {
    .refix-jobs {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 500px) {
    .refix-jobs {
        grid-template-columns: 1fr;
    }
}
