/* ==========================================
   LOADING OVERLAY STYLES
   ========================================== */
#loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(3px);
}

#loading-overlay .loading-content {
    background: white;
    padding: 30px 50px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

#loading-overlay .spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3rem;
}

#loading-overlay .loading-text {
    margin-top: 15px;
    font-size: 16px;
    font-weight: 500;
    color: #333;
}

/* ==========================================
   OPTIMIZED STYLES - Critical CSS inlined
   ========================================== */
body {
    margin: 0;
    height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Sidebar - Optimized */
#ie-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 20px;
    color: white;
    height: 100%;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #555 #000;
    will-change: scroll-position;
}

#ie-nav::-webkit-scrollbar {
    width: 6px;
}

#ie-nav::-webkit-scrollbar-thumb {
    background-color: #555;
    border-radius: 10px;
}

.ie-nav-item {
    text-align: center;
    margin: 15px 0;
    cursor: pointer;
    transition: background-color 0.2s ease;
    padding: 8px;
    border-radius: 10px;
    width: 80%;
}

.ie-nav-item:hover,
.ie-nav-item.active {
    background-color: #333;
}

.ie-nav-item i {
    font-size: 24px;
    display: block;
}

.ie-nav-item .title {
    font-size: 12px;
    margin-top: 5px;
    white-space: nowrap;
}

/* Panel - Optimized */
#ie-panel {
    overflow-y: auto;
    height: 94vh;
    will-change: scroll-position;
}

.ie-panel-section {
    display: none;
}

.ie-panel-section.active {
    display: block;
}

/* Editor Zone - GPU acceleration */
#image-editor-zone {
    height: 84vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #6c757d;
    position: relative;
    color: white;
    overflow: hidden;
    will-change: transform;
}

#ie-work-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform-origin: center center;
    transition: transform 0.3s ease;
    will-change: transform;
}

#ie-shape {
    background: #f8f9fa;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    position: relative;
    clip-path: none;
    will-change: transform, clip-path;
}

/* Zoom controls */
.ie-controls {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.5);
    padding: 5px 10px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ie-controls button {
    padding: 2px 8px;
    font-size: 14px;
}

/* Draggable elements - GPU acceleration */
.logo-preview,
.preview-text,
#qr-preview {
    position: absolute;
    cursor: move;
    user-select: none;
    will-change: transform;
    transform: translate3d(0, 0, 0);
}

/* Resize handles - Optimized */
.resize-logo {
    position: absolute;
    width: 3px;
    height: 3px;
    background: #007bff;
    border: 2px solid white;
    border-radius: 50%;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.logo-preview:hover .resize-logo,
.logo-preview.active .resize-logo {
    opacity: 1;
}

/* Resize handle positions */
.resize-logo.nw {
    top: -2.5px;
    left: -2.5px;
    cursor: nw-resize;
}

.resize-logo.ne {
    top: -2.5px;
    right: -2.5px;
    cursor: ne-resize;
}

.resize-logo.sw {
    bottom: -2.5px;
    left: -2.5px;
    cursor: sw-resize;
}

.resize-logo.se {
    bottom: -2.5px;
    right: -2.5px;
    cursor: se-resize;
}

.resize-logo.n {
    top: -2.5px;
    left: 50%;
    transform: translateX(-50%);
    cursor: n-resize;
}

.resize-logo.s {
    bottom: -2.5px;
    left: 50%;
    transform: translateX(-50%);
    cursor: s-resize;
}

.resize-logo.e {
    top: 50%;
    right: -2.5px;
    transform: translateY(-50%);
    cursor: e-resize;
}

.resize-logo.w {
    top: 50%;
    left: -2.5px;
    transform: translateY(-50%);
    cursor: w-resize;
}

/* Text preview styles */
.preview-text {
    padding: 2px 4px;
    border: 1px dashed transparent;
    transition: border-color 0.2s ease;
}

.preview-text:hover,
.preview-text.active {
    border-color: #007bff;
    background: rgba(0, 123, 255, 0.1);
}

/* Shape grid - Optimized layout */
.ie-shape-grid,
.ie-fixation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.ie-shape-item,
.ie-fixation-item {
    padding: 15px;
    text-align: center;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ie-shape-item:hover,
.ie-fixation-item:hover {
    border-color: #007bff;
    background: rgba(0, 123, 255, 0.1);
    transform: translateY(-2px);
}

.ie-shape-item.active,
.ie-fixation-item.active {
    border-color: #007bff;
    background: rgba(0, 123, 255, 0.2);
}

.ie-shape-item i,
.ie-fixation-item i {
    font-size: 24px;
    display: block;
    margin-bottom: 5px;
}

.ie-shape-item span,
.ie-fixation-item span {
    font-size: 12px;
    display: block;
}

/* Mobile optimizations */
@media (max-width: 992px) {
    #image-editor-zone {
        height: 92vh;
    }

    #ie-panel {
        height: 92vh;
    }

    .ie-shape-grid,
    .ie-fixation-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 8px;
    }

    .ie-nav-item {
        padding: 6px;
        margin: 10px 0;
    }

    .resize-logo {
        width: 16px;
        height: 16px;
    }
}

/* Performance: Reduce animations on low-end devices */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
