/* Images Section Styles */

#images-section {
    background: #F1F1F1;
}

#images-section main {
    width: 100vw;
    height: 100vh;
    padding: 0;
    margin: 0;
    position: fixed;
    top: 0;
    left: 0;
}

.images-container {
    width: 100%;
    height: 100%;
    display: flex;
    position: relative;
}

/* ==========================================
   FLOATING LEFT SIDEBAR
   ========================================== */

.image-creation-sidebar {
    position: fixed;
    top: 80px;
    left: 20px;
    width: 340px;
    max-height: calc(100vh - 100px);
    background: white;
    border: 0.5px solid #c1c1c1;
    border-radius: 6px;
    padding: 24px;
    overflow-y: auto;
    z-index: 10000;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.image-creation-sidebar.minimized {
    width: 60px;
    height: 60px;
    max-height: 60px;
    padding: 0;
    overflow: hidden;
    cursor: pointer;
}

.image-creation-sidebar.minimized .sidebar-content {
    display: none;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.minimize-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: transparent;
    border: 0.5px solid #c1c1c1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #6c757d;
}

.minimize-btn:hover {
    background: #f8f9ff;
    border-color: #667eea;
    color: #667eea;
}

.minimize-btn i {
    font-size: 18px;
}

.sidebar-minimized-icon {
    display: none;
    width: 60px;
    height: 60px;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #667eea;
}

.image-creation-sidebar.minimized .sidebar-minimized-icon {
    display: flex;
}

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

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

.image-creation-sidebar::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.image-creation-sidebar::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Form already styled by global.css, just need minor adjustments */
.image-generation-form {
    width: 100%;
}

/* ==========================================
   MODEL SELECTOR
   ========================================== */

.model-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.model-option-btn {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 0.5px solid #c1c1c1;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    position: relative;
}

.model-option-btn:hover {
    border-color: #667eea;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.model-option-btn.active {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

.model-option-btn i {
    font-size: 20px;
    color: #667eea;
}

.model-option-btn span {
    font-size: 14px;
    color: #333;
    flex: 1;
}

.model-badge {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 3px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    letter-spacing: 0.3px;
}

/* ==========================================
   IMAGE UPLOAD AREA
   ========================================== */

.image-upload-area {
    width: 100%;
    min-height: 140px;
    border: 2px dashed #c1c1c1;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.image-upload-area:hover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.02);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 140px;
    color: #999;
}

.upload-placeholder i {
    font-size: 32px;
    color: #667eea;
    margin-bottom: 8px;
}

.upload-placeholder p {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 2px;
}

.upload-placeholder span {
    font-size: 11px;
    color: #999;
}

.uploaded-image-preview {
    position: relative;
    width: 100%;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
}

.uploaded-image-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

.remove-image-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.remove-image-btn:hover {
    background: #dc3545;
    transform: scale(1.1);
}

.remove-image-btn i {
    font-size: 16px;
}

/* ==========================================
   IMAGE DISPLAY AREA - INFINITE CANVAS
   ========================================== */

.generated-image-display {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    box-sizing: border-box;
    overflow: hidden;
    background-image: 
        linear-gradient(rgba(0, 0, 0, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    background-position: center center;
    background-attachment: fixed;
}

.image-canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform-origin: center center;
    pointer-events: none;
    will-change: transform;
}

.image-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #999;
    text-align: center;
    pointer-events: none;
}

.image-placeholder i {
    font-size: 120px;
    margin-bottom: 20px;
    opacity: 0.3;
}

.image-placeholder p {
    font-size: 18px;
    font-family: 'Inter', sans-serif;
    margin: 0;
}

.generated-image-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    animation: fadeIn 0.5s ease-in-out;
    cursor: grab;
    user-select: none;
    pointer-events: auto;
}

.generated-image-wrapper:active {
    cursor: grabbing;
}

.generated-image {
    max-width: 800px;
    max-height: 600px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    object-fit: contain;
    pointer-events: auto;
    user-select: none;
    -webkit-user-drag: none;
    -moz-user-select: none;
    -webkit-user-select: none;
}

.image-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.image-action-btn {
    padding: 10px 20px;
    background: white;
    border: 0.5px solid #c1c1c1;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    pointer-events: auto;
}

.image-action-btn:hover {
    border-color: #667eea;
    color: #667eea;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.image-action-btn i {
    font-size: 18px;
}

/* ==========================================
   LOADING STATE
   ========================================== */

.image-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    pointer-events: none;
}

.image-loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.image-loading-text {
    font-size: 16px;
    color: #666;
    font-family: 'Inter', sans-serif;
}

.image-loading-subtext {
    font-size: 14px;
    color: #999;
    font-family: 'Inter', sans-serif;
    font-style: italic;
}

/* ==========================================
   ERROR STATE
   ========================================== */

.image-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    color: #dc3545;
    text-align: center;
    padding: 40px;
}

.image-error i {
    font-size: 80px;
    opacity: 0.5;
}

.image-error-text {
    font-size: 18px;
    font-family: 'Inter', sans-serif;
    max-width: 500px;
}

.retry-btn {
    padding: 0 16px;
    height: 44px;
    background: transparent;
    color: #dc3545;
    border: 0.5px solid #dc3545;
    border-radius: 6px;
    font-size: 10px;
    text-transform: uppercase;
    font-weight: lighter;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.retry-btn i {
    font-size: 14px;
}

.retry-btn:hover {
    background: #dc3545;
    color: white;
    transform: translateY(-1px);
}

/* ==========================================
   CANVAS IMAGE WRAPPERS (for multiple images)
   ========================================== */

.canvas-image-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    touch-action: none; /* Required for interact.js */
    user-select: none;
    cursor: grab;
}

.canvas-image-wrapper.dragging {
    opacity: 0.8;
    cursor: grabbing !important;
}

.canvas-image-wrapper.resizing {
    opacity: 0.9;
}

.canvas-image-wrapper.generating {
    cursor: grab;
}

.canvas-image-wrapper.generating .canvas-image-content {
    background: #f8f9ff;
    border: 2px dashed #667eea;
}

.canvas-image-wrapper.error .canvas-image-content {
    background: #fff5f5;
    border: 2px solid #dc3545;
}

.canvas-image-wrapper:hover {
    z-index: 9999 !important;
}

/* Ensure images are always below the sidebar */
.canvas-image-wrapper {
    max-z-index: 9999;
}

.canvas-image-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: white;
    padding: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    box-sizing: border-box;
}

.canvas-image-content:hover .canvas-image-actions {
    opacity: 1;
}

.canvas-image-content.loading-content,
.canvas-image-content.error-content {
    display: flex;
    align-items: center;
    justify-content: center;
}

.canvas-image-content.loading-content .image-loading {
    padding: 0;
}

.canvas-image-content.error-content .image-error {
    padding: 20px;
}

.canvas-image {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    border-radius: 6px;
    object-fit: contain;
    pointer-events: none;
}

.canvas-image-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.canvas-image-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    border: 0.5px solid #c1c1c1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    pointer-events: auto;
}

.canvas-image-action-btn:hover {
    background: white;
    border-color: #667eea;
    color: #667eea;
    transform: scale(1.1);
}

.canvas-image-action-btn i {
    font-size: 16px;
}

.canvas-image-action-btn[data-action="delete"]:hover {
    border-color: #dc3545;
    color: #dc3545;
}

/* ==========================================
   RESIZE HANDLES (DEPRECATED - interact.js handles this)
   ========================================== */
/* Old custom resize handles removed - interact.js provides native resize handles */

/* ==========================================
   FLOATING INDICATORS (LOADING & ERROR)
   ========================================== */

.floating-loading-indicator,
.floating-error-indicator {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    background: white;
    border: 0.5px solid #c1c1c1;
    border-radius: 12px;
    padding: 24px 32px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    animation: slideUp 0.3s ease;
    pointer-events: auto;
}

.floating-error-indicator {
    background: #fff5f5;
    border-color: #dc3545;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.floating-loading-indicator .image-loading,
.floating-error-indicator .image-error {
    padding: 0;
    position: relative;
}

/* ==========================================
   ANIMATIONS
   ========================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==========================================
   RESPONSIVE DESIGN
   ========================================== */

@media (max-width: 1024px) {
    .image-creation-sidebar {
        width: 300px;
    }
}

@media (max-width: 768px) {
    .image-creation-sidebar {
        position: relative;
        top: 0;
        left: 0;
        width: 100%;
        max-height: none;
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-top: none;
        z-index: 100;
    }
    
    .images-container {
        flex-direction: column;
    }
    
    .generated-image-display {
        padding: 20px;
        min-height: 60vh;
    }

    .image-placeholder i {
        font-size: 80px;
    }

    .image-placeholder p {
        font-size: 16px;
    }

    .generated-image {
        max-height: 50vh;
    }

    .image-actions {
        width: 100%;
    }

    .image-action-btn {
        flex: 1;
        justify-content: center;
        min-width: 100px;
    }
    
    /* Canvas images on mobile */
    .canvas-image {
        max-width: 300px;
        max-height: 300px;
    }
    
    .canvas-image-actions {
        opacity: 1; /* Always show on mobile */
    }
}
