/* ============================================
   DRAGGABLE IMAGE EDITOR - STYLES
   GitHub Pages Compatible
   ============================================ */

:root {
    --sidebar-height: 0px;
    --workspace-scale: 0.5;
}

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

html, body {
    width: 100%;
    min-height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
        sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 0;
    overflow-x: hidden;
}

.container {
    width: 100%;
    min-height: 100vh;
    background: white;
    overflow: visible;
}

/* ============================================
   SIDEBAR STYLES
   ============================================ */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1500;
    width: 100%;
    background: linear-gradient(180deg, #2c3e50 0%, #34495e 100%);
    color: white;
    border-bottom: 2px solid #667eea;
    overflow-y: hidden;
}

.image-library {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(90px, 130px) 1fr;
    gap: 8px;
    align-items: start;
    padding: 6px 8px;
    overflow: visible;
}

.library-section {
    min-width: 0;
    margin-bottom: 0;
    overflow: visible;
}

.library-section h3 {
    font-size: 16px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    color: #ecf0f1;
    border-bottom: 1px solid #667eea;
    padding-bottom: 3px;
}

.image-list {
    display: flex;
    gap: 5px;
    overflow: visible;
}

.image-item {
    position: relative;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    overflow: hidden;
    cursor: grab;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    padding: 0;
    appearance: none;
    flex: 0 0 auto;
}

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

.image-item:active {
    cursor: grabbing;
    border-color: #2ecc71;
    box-shadow: 0 0 0 1px rgba(46, 204, 113, 0.45);
}

.image-item img,
.image-item svg {
    flex: 0 0 auto;
    max-width: none;
    max-height: none;
    pointer-events: none;
}

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

.skill-item {
    overflow: visible;
}

.skill-item img {
    width: auto;
    height: auto;
    transform-origin: center;
    image-rendering: auto;
}

/* Upload Section */
#fileInput {
    display: none;
}

/* Scrollbar */
.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

/* ============================================
   MAIN CONTENT STYLES
   ============================================ */

.main-content {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: calc(var(--sidebar-height) + 15px) 15px 15px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.canvas-wrapper {
    position: relative;
    flex: 0 0 auto;
    width: fit-content;
    height: fit-content;
    max-width: 100%;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.1);
    margin-bottom: 10px;
}

#canvas {
    display: block;
    user-select: none;
    -webkit-user-select: none;
}

.canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    user-select: none;
    -webkit-user-select: none;
}

/* ============================================
   DRAGGABLE IMAGE STYLES
   ============================================ */

.draggable-image {
    position: absolute;
    cursor: grab;
    transition: box-shadow 0.2s ease;
    border: 1px solid transparent;
    border-radius: 4px;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(1px);
}

.draggable-image:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.draggable-image.selected {
    border-color: #3498db;
    box-shadow: 0 0 8px rgba(52, 152, 219, 0.5), inset 0 0 0 2px #3498db;
}

.draggable-image.dragging {
    opacity: 0.8;
    cursor: grabbing;
    z-index: 20;
}

.draggable-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
}

.image-controls {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 3px;
    background: white;
    padding: 3px 4px;
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1000;
}

.draggable-image.selected .image-controls {
    opacity: 1;
    pointer-events: auto;
}

.control-btn {
    width: 15px;
    height: 15px;
    border: none;
    border-radius: 2px;
    cursor: pointer;
    font-size: 8px;
    font-weight: bold;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
}

.control-btn.delete {
    background: #e74c3c;
    color: white;
}

.control-btn.delete:hover {
    background: #c0392b;
    transform: scale(1.1);
}

.control-btn:active {
    transform: scale(0.95);
}

/* ============================================
   CONTROLS STYLES
   ============================================ */

.controls {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.btn {
    padding: 6px 15px;
    border: none;
    border-radius: 4px;
    font-size: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.25px;
    user-select: none;
    -webkit-user-select: none;
}

.btn:focus {
    outline: 1px solid rgba(0, 0, 0, 0.2);
    outline-offset: 1px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-danger {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(245, 87, 108, 0.4);
}

.btn-danger:active {
    transform: translateY(0);
}

.btn-info {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.btn-info:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(79, 172, 254, 0.4);
}

.btn-info:active {
    transform: translateY(0);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    z-index: 2000;
    transition: bottom 0.3s ease;
    max-width: 90%;
    text-align: center;
}

.toast.show {
    bottom: 20px;
}

.toast.success {
    background: rgba(46, 204, 113, 0.9);
}

.toast.error {
    background: rgba(231, 76, 60, 0.9);
}

.toast.info {
    background: rgba(52, 152, 219, 0.9);
}

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

@media (max-width: 1200px) {
    .image-library {
        grid-template-columns: minmax(80px, 110px) 1fr;
        gap: 7px;
        padding: 5px 7px;
    }

    .main-content {
        padding: calc(var(--sidebar-height) + 10px) 10px 10px;
    }
}

@media (max-width: 768px) {
    .image-library {
        grid-template-columns: 1fr;
        gap: 5px;
        padding: 4px 5px;
    }

    .library-section h3 {
        font-size: 6px;
        margin-bottom: 3px;
        padding-bottom: 2px;
    }

    .image-list {
        gap: 4px;
    }

    .main-content {
        padding: calc(var(--sidebar-height) + 8px) 5px 5px;
    }

    .controls {
        gap: 5px;
    }

    .btn {
        padding: 4px 8px;
        font-size: 7px;
    }
}

@media (max-width: 480px) {
    .image-library {
        gap: 4px;
        padding: 4px;
    }

    .image-list {
        gap: 3px;
    }

    .main-content {
        padding: calc(var(--sidebar-height) + 6px) 4px 4px;
    }

    .controls {
        flex-direction: column;
        width: 100%;
    }

    .btn {
        padding: 4px 6px;
        font-size: 6px;
        width: 100%;
    }

    .toast {
        font-size: 6px;
        padding: 6px 8px;
        max-width: 95%;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    body {
        background: white;
    }

    .container {
        box-shadow: none;
        height: auto;
    }

    .sidebar,
    .controls {
        display: none;
    }

    .canvas-wrapper {
        margin: 0;
        padding: 0;
    }
}
