/* Modern Minimalist Light Theme in iloveimg aesthetic */
:root {
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    
    --success: #16a34a;
    --success-hover: #15803d;
    --success-light: #f0fdf4;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
}

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

html, body {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.app-header {
    height: 56px;
    min-height: 56px;
    max-height: 56px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    z-index: 50;
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
}

.logo-icon {
    width: 26px;
    height: 26px;
    color: var(--primary);
}

.logo-text {
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    border-radius: var(--radius-md);
    transition: all 0.18s ease;
    font-size: 0.95rem;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-success {
    background: var(--success);
    color: #ffffff;
}

.btn-success:hover:not(:disabled) {
    background: var(--success-hover);
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.25);
}

.btn-secondary {
    background: #ffffff;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: #f1f5f9;
    border-color: var(--border-hover);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
}

.btn-md {
    padding: 10px 22px;
    font-size: 0.95rem;
}

.btn-lg {
    padding: 14px 32px;
    font-size: 1.05rem;
    border-radius: var(--radius-lg);
}

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

/* Main Content */
.main-content {
    flex: 1;
    width: 100%;
    height: calc(100vh - 56px);
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.view-section {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    flex: 1;
    overflow: hidden;
}

#uploadView {
    max-width: 800px;
    margin: auto;
    width: 100%;
    padding: 24px;
}

#workspaceView {
    height: 100%;
    width: 100%;
    flex: 1;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* Upload View */
.upload-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 480px;
    margin: auto 0;
}

.drop-zone {
    width: 100%;
    max-width: 720px;
    border: 2.5px dashed #cbd5e1;
    border-radius: var(--radius-lg);
    padding: 50px 24px;
    text-align: center;
    position: relative;
    background: #fafafa;
    transition: all 0.2s ease;
    cursor: pointer;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-icon-wrapper {
    width: 72px;
    height: 72px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 18px;
    transition: transform 0.2s ease, background 0.2s ease;
}

.drop-zone:hover .upload-icon-wrapper {
    transform: translateY(-2px);
    background: #dbeafe;
}

.upload-arrow-icon {
    width: 32px;
    height: 32px;
}

.upload-title {
    font-size: 1.45rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.upload-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.dropzone-pills {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 4px;
    pointer-events: none;
}

.pill-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 6px 14px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.pill-chip-accent {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: var(--primary);
    font-weight: 600;
}

.key-badge {
    display: inline-block;
    padding: 2px 6px;
    font-family: inherit;
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--text-primary);
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    box-shadow: 0 1.5px 0 #cbd5e1;
    line-height: 1.2;
}

.key-plus {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

.upload-hint {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 18px;
}

/* 2-Column Fullscreen Workspace Layout (iLoveIMG Exact Replica) */
.workspace-layout {
    display: flex;
    width: 100%;
    height: 100%;
    background: #f0f2f5;
    position: relative;
    overflow: hidden;
}

.viewer-pane {
    flex: 1;
    height: 100%;
    background: #f0f2f5;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    cursor: grab;
}

.viewer-pane.grabbing {
    cursor: grabbing;
}

/* Scalable / Pannable Stage */
.canvas-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    transform-origin: center center;
    will-change: transform;
}

.canvas-podium {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.canvas-top-badges {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 8px;
    pointer-events: none;
    gap: 12px;
}

.canvas-top-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.canvas-top-badge.gray {
    background: #64748b;
    color: #ffffff;
}

.canvas-top-badge.blue {
    background: #0ea5e9;
    color: #ffffff;
}

.preview-box {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.preview-box img {
    display: block;
    max-width: none;
}

.comparison-box {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    position: relative;
    display: inline-block;
    border: 1px solid rgba(0, 0, 0, 0.06);
    user-select: none;
}

.img-layer {
    position: relative;
    overflow: hidden;
}

.img-layer img {
    display: block;
    user-select: none;
    pointer-events: none;
    max-width: none;
}

.after-layer {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.before-layer {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 50%;
    overflow: hidden;
    z-index: 10;
}

.before-layer img {
    position: absolute;
    top: 0;
    left: 0;
    max-width: none;
    pointer-events: none;
}

/* Slider Handle with wide hitbox */
.slider-handle {
    position: absolute;
    top: 0;
    left: 50%;
    width: 44px;
    height: 100%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: ew-resize;
    z-index: 25;
    pointer-events: auto;
}

.slider-handle::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: ew-resize;
}

.handle-line {
    width: 2px;
    height: 100%;
    background: #ffffff;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

.handle-button {
    width: 36px;
    height: 36px;
    background: #ffffff;
    color: var(--primary);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    border: 2px solid var(--primary);
    transition: transform 0.15s ease;
    pointer-events: none;
    flex-shrink: 0;
}

.slider-handle:hover .handle-button {
    transform: scale(1.1);
}



/* Pixelated mode for Minecraft textures & pixel art */
.pixelated, .pixelated img {
    image-rendering: pixelated !important;
    image-rendering: crisp-edges !important;
}

/* Floating Zoom Toolbar */
.zoom-toolbar {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-full);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
    padding: 4px 8px;
    z-index: 30;
    gap: 4px;
}

.zoom-btn {
    border: none;
    background: transparent;
    color: var(--text-primary);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    font-size: 1.15rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.zoom-btn:hover {
    background: #f1f5f9;
    color: var(--primary);
}

.zoom-btn-text {
    width: auto;
    padding: 0 10px;
    font-size: 0.78rem;
    font-weight: 600;
}

.zoom-level {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 44px;
    text-align: center;
}

.zoom-divider {
    width: 1px;
    height: 16px;
    background: #e2e8f0;
    margin: 0 2px;
}

/* Right Sidebar (Solid iLoveIMG style) */
.sidebar-pane {
    width: 380px;
    flex-shrink: 0;
    background: #ffffff;
    border-left: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 20;
}

.sidebar-block {
    display: flex;
    flex-direction: column;
    height: 100%;
    justify-content: space-between;
}

.sidebar-scroll-content {
    flex: 1;
    overflow-y: auto;
    padding: 28px 24px 16px 24px;
}

.sidebar-bottom-action {
    padding: 16px 24px 24px 24px;
    background: #ffffff;
    border-top: 1px solid #f1f5f9;
}

.sidebar-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: #1e293b;
    margin-bottom: 18px;
    letter-spacing: -0.01em;
}

.sidebar-callout {
    background: #e0f2fe;
    color: #0369a1;
    border-radius: 10px;
    padding: 14px 16px;
    font-size: 0.86rem;
    line-height: 1.45;
    margin-bottom: 22px;
    font-weight: 500;
    border: 1px solid #bae6fd;
}

.setting-group {
    margin-bottom: 22px;
}

.setting-label {
    font-size: 0.88rem;
    font-weight: 700;
    color: #334155;
    margin-bottom: 10px;
    display: block;
}

.setting-hint {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 6px;
    line-height: 1.35;
}

/* Tile Grid Buttons */
.tile-grid {
    display: grid;
    gap: 8px;
}

.tile-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.tile-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.tile-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.tile-btn {
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    padding: 12px 6px;
    font-size: 0.92rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}

.tile-btn:hover {
    border-color: #94a3b8;
    color: #1e293b;
}

.tile-btn.active {
    border: 2px solid #3b82f6;
    color: #2563eb;
    background: #f0f7ff;
    font-weight: 700;
    box-shadow: 0 0 0 1px #3b82f6;
}

/* File Meta Card like iLoveIMG */
.file-meta-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 14px;
    margin-top: 14px;
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-meta-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: #475569;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.size-pill-gray {
    background: #94a3b8;
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
}

.size-pill-blue {
    background: #0ea5e9;
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
}

.size-arrow {
    color: #94a3b8;
    font-weight: 700;
}

/* iLoveIMG Large Action Button */
.btn-iloveimg {
    width: 100%;
    padding: 15px 20px;
    border-radius: 12px;
    font-size: 1.15rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.18s ease;
    letter-spacing: -0.01em;
    border: none;
    font-family: inherit;
}

.btn-primary.btn-iloveimg {
    background: #3b82f6;
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}

.btn-primary.btn-iloveimg:hover:not(:disabled) {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

.btn-success.btn-iloveimg {
    background: #16a34a;
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(22, 163, 74, 0.35);
}

.btn-success.btn-iloveimg:hover:not(:disabled) {
    background: #15803d;
    transform: translateY(-1px);
}

.result-success-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #16a34a;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.92rem;
    margin-bottom: 18px;
}

.full-width {
    width: 100%;
}

.setting-summary {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 22px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.86rem;
    margin-bottom: 8px;
}

.summary-row:last-child {
    margin-bottom: 0;
}

.summary-label {
    color: var(--text-secondary);
}

.summary-val {
    font-weight: 600;
    color: var(--text-primary);
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 40;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3.5px solid #e2e8f0;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

.loading-text {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 14px;
}

.progress-bar-container {
    width: 260px;
    height: 6px;
    background: #e2e8f0;
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 45%;
    background: var(--primary);
    border-radius: var(--radius-full);
    animation: indeterminate 1.5s infinite ease-in-out;
}

@keyframes indeterminate {
    0% { transform: translateX(-100%); width: 30%; }
    50% { transform: translateX(100%); width: 60%; }
    100% { transform: translateX(250%); width: 30%; }
}

/* Responsive */
@media (max-width: 960px) {
    .workspace-layout {
        flex-direction: column;
        overflow-y: auto;
    }
    .sidebar-pane {
        width: 100%;
        height: auto;
    }
}
