/* ========================================
   Base Styles
   ======================================== */

body {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    overflow: hidden;
    background-color: #050505;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
}

/* ========================================
   Custom Scrollbar
   ======================================== */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #18181b;
}

::-webkit-scrollbar-thumb {
    background: #3f3f46;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #52525b;
}

/* ========================================
   Canvas
   ======================================== */

canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
    background: #0a0a0a;
}

/* ========================================
   Utility Components
   ======================================== */

.glass-panel {
    background: rgba(24, 24, 27, 0.7);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.glow-btn {
    box-shadow: 0 0 15px var(--tw-colors-primary-glow);
}

/* ========================================
   Drop Zones (Image Upload)
   ======================================== */

.drop-zone-container {
    position: relative;
}

.drop-zone {
    position: relative;
    aspect-ratio: 1;
    background: #000;
    border: 2px dashed #27272a;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
    overflow: hidden;
}

.drop-zone:hover {
    border-color: #10b981;
    background: #0a0a0a;
}

.drop-zone.has-image {
    border-style: solid;
    border-color: #10b981;
}

.drop-zone.drag-over {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.05);
}

.drop-zone-label {
    font-size: 0.65rem;
    font-weight: 800;
    color: #a1a1aa;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.drop-zone-icon {
    font-size: 1.5rem;
    color: #27272a;
    margin-bottom: 8px;
}

.drop-zone.has-image .drop-zone-icon {
    display: none;
}

.drop-zone-text {
    font-size: 0.6rem;
    color: #a1a1aa;
    text-align: center;
}

.drop-zone.has-image .drop-zone-text {
    display: none;
}

.drop-zone.has-image .drop-zone-label {
    display: none;
}

.drop-zone-preview {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.drop-zone input[type="file"] {
    display: none;
}

/* Wide Drop Zone (single image input) */
.drop-zone-wide {
    position: relative;
    width: 100%;
    padding: 24px 16px;
    background: #000;
    border: 2px dashed #27272a;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: 0.2s;
    overflow: hidden;
}

.drop-zone-wide:hover {
    border-color: #10b981;
    background: #0a0a0a;
}

.drop-zone-wide.has-image {
    border-style: solid;
    border-color: #10b981;
    padding: 0;
}

.drop-zone-wide.drag-over {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.05);
}

.drop-zone-wide .drop-zone-label {
    margin-bottom: 0;
}

.drop-zone-wide.has-image .drop-zone-label,
.drop-zone-wide.has-image .material-symbols-outlined {
    display: none;
}

.drop-zone-wide .drop-zone-preview {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ========================================
   Toggle Switch
   ======================================== */

.toggle-switch {
    position: relative;
    width: 34px;
    height: 18px;
    -webkit-appearance: none;
    appearance: none;
    background: #3f3f46;
    border-radius: 20px;
    cursor: pointer;
    transition: .3s;
}

.toggle-switch:checked {
    background: #10b981;
}

.toggle-switch::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    background: #fff;
    transition: .3s;
}

.toggle-switch:checked::before {
    left: 18px;
}

/* ========================================
   Zoom Badge
   ======================================== */

.zoom-badge {
    position: absolute;
    bottom: 15px;
    right: 20px;
    font-size: 0.65rem;
    color: #10b981;
    background: #000;
    padding: 4px 10px;
    border-radius: 15px;
    border: 1px solid #27272a;
    font-weight: bold;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ========================================
   Collapsible Sections
   ======================================== */

.collapsible-section {
    background: #000;
    border: 1px solid #27272a;
    border-radius: 0.375rem;
    overflow: hidden;
}

.collapsible-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.collapsible-header:hover {
    background: #0a0a0a;
}

.collapsible-title {
    font-size: 0.7rem;
    color: #a1a1aa;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    flex: 1;
}

.collapse-icon {
    font-size: 0.8rem;
    color: #a1a1aa;
    transition: transform 0.3s, color 0.2s;
    order: -1;
}

.collapsible-header:hover .collapse-icon {
    color: #10b981;
}

.collapse-icon.collapsed {
    transform: rotate(-90deg);
}

.collapsible-content {
    max-height: 2000px;
    transition: max-height 0.3s ease-out;
    overflow: hidden;
}

.collapsible-content.collapsed {
    max-height: 0;
}

.collapsible-inner {
    padding: 0 1rem 1rem 1rem;
}

/* ========================================
   Canvas and Viewport
   ======================================== */

.canvas-wrapper {
    position: relative;
    background: #0a0a0a;
    border: 1px solid #27272a;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 0.5rem;
}

.view-tag {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(0,0,0,0.8);
    padding: 4px 10px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 800;
    color: #10b981;
    border: 1px solid rgba(255,255,255,0.1);
    z-index: 5;
    pointer-events: none;
    text-transform: uppercase;
}

/* ========================================
   Standard Viewport (2-column grid)
   ======================================== */

#std-viewport {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    padding: 20px;
    height: 100%;
    box-sizing: border-box;
}

#std-viewport .canvas-wrapper {
    height: 100%;
    min-height: 0;
}

/* ========================================
   Comparison View
   ======================================== */

#comp-viewport {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    background-image: radial-gradient(#111 1px, transparent 1px);
    background-size: 20px 20px;
    overflow: hidden;
}

#comp-viewport:active {
    cursor: grabbing;
}

.comp-canvas-container {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transform-origin: center center;
}

#comp-overlay-layer {
    clip-path: inset(0 0 0 50%);
    z-index: 2;
}

#comp-bar {
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 100%;
    background: #10b981;
    z-index: 10;
    cursor: col-resize;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
}

#comp-bar::after {
    content: '↔';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #10b981;
    color: #000;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

/* ========================================
   Layer Switcher
   ======================================== */

.layer-switcher {
    position: absolute;
    bottom: 15px;
    right: 15px;
    display: flex;
    gap: 8px;
    background: rgba(0,0,0,0.8);
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #27272a;
}

.layer-btn {
    background: #18181b;
    border: 1px solid #27272a;
    color: #a1a1aa;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 700;
    transition: 0.2s;
}

.layer-btn.active {
    background: #10b981;
    color: #000;
    border-color: #10b981;
}

.layer-btn:hover:not(.active) {
    background: #27272a;
    color: #fff;
}

/* ========================================
   Sliders
   ======================================== */

.slider-container {
    background: #000;
    border: 1px solid #27272a;
    border-radius: 0.375rem;
    padding: 0.75rem;
    margin-bottom: 0.625rem;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    font-weight: 800;
    color: #a1a1aa;
    margin-bottom: 0.5rem;
    letter-spacing: 1px;
}

.slider-header .val-indicator {
    color: #10b981;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: #27272a;
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: #10b981;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

input[type="range"]::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: #10b981;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
    border: none;
}

/* ========================================
   Progress Bar Animations
   ======================================== */

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

@keyframes progress-indeterminate {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(200%);
    }
}

.progress-indeterminate {
    position: relative;
    overflow: hidden;
}

.progress-indeterminate::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: progress-indeterminate 1.5s infinite;
}

.progress-pulse {
    animation: progress-pulse 1s ease-in-out infinite;
}

/* ========================================
   Queue System
   ======================================== */

.queue-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #0a0a0a;
    border: 1px solid #27272a;
    border-radius: 6px;
    padding: 8px;
    transition: all 0.2s;
}

.queue-item:hover {
    border-color: #3f3f46;
}

.queue-item-active {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.05);
}

.queue-item-done {
    border-color: #22c55e;
}

.queue-item-thumb {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
    background: #000;
}

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

.queue-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.queue-item-name {
    font-size: 11px;
    font-weight: 600;
    color: #e4e4e7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.queue-item-status {
    font-size: 10px;
}

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

.queue-action-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid #3f3f46;
    border-radius: 4px;
    color: #a1a1aa;
    cursor: pointer;
    transition: all 0.2s;
}

.queue-action-btn:hover {
    background: #27272a;
    border-color: #10b981;
    color: #10b981;
}

.queue-action-btn .material-symbols-outlined {
    font-size: 14px;
}

.queue-action-remove:hover {
    border-color: #ef4444;
    color: #ef4444;
}

/* Queue Item Progress Bar */
.queue-item-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #27272a;
    border-radius: 0 0 5px 5px;
    overflow: hidden;
}

.queue-item-progress-inner {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #059669);
    width: 0%;
    transition: width 0.15s ease-out;
}

/* Make queue-item relative for progress bar positioning */
.queue-item {
    position: relative;
}

/* ========================================
   Edit Toolbox Sidebar
   ======================================== */

#edit-sidebar {
    background: linear-gradient(180deg, rgba(24, 24, 27, 0.95) 0%, rgba(9, 9, 11, 0.98) 100%);
}

.edit-section {
    background: #0a0a0a;
    border: 1px solid #27272a;
    border-radius: 8px;
    padding: 12px;
}

.edit-section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 700;
    color: #71717a;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #1f1f23;
}

.edit-section-header .material-symbols-outlined {
    color: #10b981;
    font-size: 14px;
}

.edit-control {
    margin-bottom: 12px;
}

.edit-control:last-child {
    margin-bottom: 0;
}

.edit-control-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.edit-control-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 500;
    color: #a1a1aa;
    cursor: pointer;
    user-select: none;
}

.edit-control-label:hover {
    color: #e4e4e7;
}

.edit-checkbox {
    width: 12px;
    height: 12px;
    accent-color: #10b981;
    cursor: pointer;
}

.edit-value {
    font-size: 11px;
    font-weight: 600;
    color: #10b981;
    font-family: 'Fira Code', 'Consolas', monospace;
    min-width: 36px;
    width: 36px;
    text-align: right;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 3px;
    padding: 2px 4px;
    outline: none;
    transition: all 0.15s;
    -moz-appearance: textfield;
}

.edit-value::-webkit-outer-spin-button,
.edit-value::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.edit-value:hover {
    border-color: #3f3f46;
}

.edit-value:focus {
    border-color: #10b981;
    background: #18181b;
}

.edit-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: #27272a;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    margin: 0;
}

.edit-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: #10b981;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
    transition: transform 0.15s, box-shadow 0.15s;
    margin-top: -5px;
}

.edit-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.6);
}

.edit-slider::-webkit-slider-thumb:active {
    transform: scale(1.1);
    background: #059669;
}

.edit-slider::-webkit-slider-runnable-track {
    height: 4px;
    background: #27272a;
    border-radius: 2px;
}

.edit-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #10b981;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
    border: none;
    transition: transform 0.15s, box-shadow 0.15s;
}

.edit-slider::-moz-range-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.6);
}

.edit-slider::-moz-range-track {
    height: 4px;
    background: #27272a;
    border-radius: 2px;
}

/* Disabled state */
.edit-control-label input:not(:checked) + span {
    color: #52525b;
    text-decoration: line-through;
}

.edit-control:has(.edit-checkbox:not(:checked)) .edit-slider {
    opacity: 0.3;
    pointer-events: none;
}

.edit-control:has(.edit-checkbox:not(:checked)) .edit-value {
    color: #52525b;
}

/* Reset All button */
#edit-reset-all {
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

#edit-reset-all:hover {
    background: rgba(16, 185, 129, 0.1);
}

/* Apply button */
#edit-apply {
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

#edit-apply:hover {
    border-color: #10b981;
    color: #10b981;
}
