@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

body {
    font-family: 'Press Start 2P', monospace;
    background: #1a1a1a;
    background-image: 
        radial-gradient(circle at 25% 25%, #2a2a2a 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, #333333 0%, transparent 50%),
        linear-gradient(45deg, #1a1a1a 0%, #2a2a2a 50%, #333333 100%);
    color: #cccccc;
    overflow: hidden;
    height: 100vh;
    margin: 0;
    padding: 0;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.header {
    background: #1a1a1a;
    border: 2px solid #666666;
    border-bottom: 4px solid #666666;
    padding: 1rem 1.5rem;
    z-index: 1000;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 100px; /* Fixed height for proper header */
    min-height: 100px;
    transition: transform 0.3s ease;
    box-shadow: 
        0 0 10px #666666,
        inset 0 0 10px rgba(102, 102, 102, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header h1 {
    font-size: 1.5rem;
    color: #cccccc;
    text-shadow: 
        2px 2px 0px #666666,
        4px 4px 0px #333333;
    margin: 0;
    letter-spacing: 2px;
    flex-shrink: 0;
}

.header p {
    color: #88ff88;
    font-size: 0.6rem;
    margin-bottom: 0.75rem;
    text-shadow: 1px 1px 0px #004400;
    line-height: 1.4;
}

.controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.btn {
    background: #1a1a1a;
    border: 2px solid #666666;
    color: #cccccc;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.6rem;
    transition: all 0.1s ease;
    text-shadow: 1px 1px 0px #666666;
    box-shadow: 
        2px 2px 0px #666666,
        4px 4px 0px #333333;
    position: relative;
}

.btn:hover {
    background: #666666;
    color: #ffffff;
    text-shadow: none;
    transform: translate(1px, 1px);
    box-shadow: 
        1px 1px 0px #666666,
        3px 3px 0px #333333;
}

.btn:active {
    transform: translate(2px, 2px);
    box-shadow: 
        0px 0px 0px #666666,
        2px 2px 0px #333333;
}

.zoom-info {
    background: #1a1a1a;
    border: 2px solid #666666;
    padding: 0.5rem 1rem;
    font-size: 0.6rem;
    color: #cccccc;
    text-shadow: 1px 1px 0px #666666;
    box-shadow: 
        2px 2px 0px #666666,
        4px 4px 0px #333333;
}

.grid-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.grid-controls label {
    color: #cccccc;
    font-size: 0.6rem;
    text-shadow: 1px 1px 0px #666666;
    margin: 0;
}

.grid-input {
    background: #1a1a1a;
    border: 2px solid #666666;
    color: #cccccc;
    padding: 0.25rem 0.5rem;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.5rem;
    text-shadow: 1px 1px 0px #666666;
    width: 60px;
    text-align: center;
}

.grid-input:focus {
    border-color: #999999;
    outline: none;
    box-shadow: 0 0 5px #666666;
}

.canvas-container {
    position: fixed;
    top: 100px; /* Start below the proper header */
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    cursor: grab;
    z-index: 1;
}

.canvas-container:active {
    cursor: grabbing;
}

#pixelCanvas {
    display: block;
    background: #1a1a1a;
    cursor: grab;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

#pixelCanvas:active {
    cursor: grabbing;
}

.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 100;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #004400;
    border-left: 4px solid #00ff00;
    border-radius: 0;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
    image-rendering: pixelated;
}

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

.loading p {
    color: #88ff88;
    font-size: 0.8rem;
    text-shadow: 1px 1px 0px #004400;
}


.pixel-detail {
    margin-bottom: 0.5rem;
    padding: 0.25rem 0;
    font-size: 0.6rem;
    border-bottom: 1px solid #004400;
}

.pixel-detail strong {
    color: #00ff00;
    text-shadow: 1px 1px 0px #008800;
}

.heatmap-overlay {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    opacity: 0.7;
    mix-blend-mode: screen;
}

/* Responsive design */
@media (max-width: 768px) {
    .header {
        padding: 0.5rem 1rem;
    }
    
    .header h1 {
        font-size: 1.25rem;
    }
    
    .header p {
        font-size: 0.8rem;
        margin-bottom: 0.5rem;
    }
    
    .controls {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
    }
    
    
    .zoom-info {
        font-size: 0.8rem;
        padding: 0.3rem 0.6rem;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 0.4rem 0.8rem;
    }
    
    .header h1 {
        font-size: 1.1rem;
    }
    
    .header p {
        font-size: 0.75rem;
    }
    
    .controls {
        gap: 0.4rem;
    }
    
    .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: #000000;
    border: 1px solid #004400;
}

::-webkit-scrollbar-thumb {
    background: #00ff00;
    border: 1px solid #008800;
    box-shadow: 2px 2px 0px #004400;
}

::-webkit-scrollbar-thumb:hover {
    background: #88ff88;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
}

.modal-content {
    background: #1a1a1a;
    margin: 5% auto;
    padding: 2rem;
    border: 4px solid #666666;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 
        8px 8px 0px #666666,
        16px 16px 0px #333333;
    font-family: 'Press Start 2P', monospace;
}

.close {
    color: #cccccc;
    float: right;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.1s ease;
    text-shadow: 1px 1px 0px #666666;
    font-family: 'Press Start 2P', monospace;
}

.close:hover {
    color: #ffffff;
    text-shadow: 2px 2px 0px #666666;
}

/* Upload Form Styles */
.upload-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.upload-mode-selector {
    display: flex;
    gap: 2rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.upload-mode-selector label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: #cccccc;
}

.upload-mode-selector input[type="radio"] {
    accent-color: #4ecdc4;
}

.upload-mode {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.file-count {
    color: #4ecdc4;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.bulk-preview {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

.bulk-preview h4 {
    color: #00ff00;
    margin-bottom: 1rem;
    font-size: 0.8rem;
    text-shadow: 1px 1px 0px #008800;
}

.preview-list {
    max-height: 200px;
    overflow-y: auto;
}

.preview-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.preview-item img {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.preview-item-info {
    flex: 1;
}

.preview-item-info .filename {
    color: #fff;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.preview-item-info .position {
    color: #cccccc;
    font-size: 0.8rem;
}

.upload-progress {
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin: 1rem 0;
}

.upload-progress-bar {
    height: 20px;
    background: linear-gradient(45deg, #4ecdc4, #45b7d1);
    width: 0%;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
}

.upload-status {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(78, 205, 196, 0.1);
    border: 1px solid rgba(78, 205, 196, 0.3);
    border-radius: 8px;
    color: #4ecdc4;
}

.upload-status.error {
    background: rgba(255, 107, 107, 0.1);
    border-color: rgba(255, 107, 107, 0.3);
    color: #ff6b6b;
}

/* Image Enlargement Modal Styles */
.image-enlarge-content {
    max-width: 90vw;
    max-height: 90vh;
    width: auto;
    height: auto;
    padding: 1rem;
}

.enlarged-image-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1rem;
}

#enlargedImage {
    max-width: 80vw;
    max-height: 60vh;
    width: auto;
    height: auto;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    transition: transform 0.3s ease;
    cursor: grab;
}

#enlargedImage:active {
    cursor: grabbing;
}

.image-zoom-controls {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.enlarged-image-info {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

.enlarged-image-info h3 {
    color: #4ecdc4;
    margin-bottom: 0.5rem;
}

.enlarged-image-info .info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
}

.enlarged-image-info .info-item {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.enlarged-image-info .info-label {
    color: #88ff88;
    font-weight: normal;
    font-size: 0.6rem;
}

.enlarged-image-info .info-value {
    color: #00ff00;
    font-size: 0.6rem;
    text-shadow: 1px 1px 0px #008800;
}

/* Zoom states */
.image-zoomed {
    transform: scale(2);
    cursor: grab;
}

.image-zoomed:active {
    cursor: grabbing;
}

/* Mobile responsiveness for enlarged image */
@media (max-width: 768px) {
    .image-enlarge-content {
        max-width: 95vw;
        max-height: 95vh;
        padding: 0.5rem;
    }
    
    #enlargedImage {
        max-width: 90vw;
        max-height: 50vh;
    }
    
    .image-zoom-controls {
        gap: 0.25rem;
    }
    
    .btn-small {
        padding: 0.2rem 0.4rem;
        font-size: 0.7rem;
    }
    
    .enlarged-image-info .info-grid {
        grid-template-columns: 1fr;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    color: #cccccc;
    font-weight: normal;
    font-size: 0.6rem;
    text-shadow: 1px 1px 0px #666666;
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group textarea {
    background: #1a1a1a;
    border: 2px solid #666666;
    padding: 0.75rem;
    color: #cccccc;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.6rem;
    transition: all 0.1s ease;
    text-shadow: 1px 1px 0px #666666;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #999999;
    box-shadow: 
        0 0 0 2px #666666,
        2px 2px 0px #666666;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* Image Management Styles */
.image-stats {
    display: flex;
    gap: 2rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    color: #cccccc;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.stat-value {
    color: #4ecdc4;
    font-size: 1.5rem;
    font-weight: bold;
}

.image-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.image-list {
    max-height: 400px;
    overflow-y: auto;
}

.image-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    transition: background 0.3s ease;
}

.image-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.image-preview {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.image-info {
    flex: 1;
}

.image-info h4 {
    color: #fff;
    margin-bottom: 0.25rem;
}

.image-info p {
    color: #cccccc;
    font-size: 0.9rem;
    margin: 0;
}

.image-actions-item {
    display: flex;
    gap: 0.5rem;
}

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    border-radius: 4px;
}

.btn-danger {
    background: linear-gradient(45deg, #ff6b6b, #ee5a52);
}

.btn-danger:hover {
    background: linear-gradient(45deg, #ee5a52, #ff6b6b);
}

/* Loading states */
.uploading {
    opacity: 0.6;
    pointer-events: none;
}

.upload-progress {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.upload-progress-bar {
    height: 100%;
    background: linear-gradient(45deg, #4ecdc4, #45b7d1);
    width: 0%;
    transition: width 0.3s ease;
}

/* Image placeholder styles */
.image-placeholder {
    width: 48px;
    height: 48px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 0.8rem;
}

/* Responsive modal */
@media (max-width: 768px) {
    .modal-content {
        margin: 2% auto;
        padding: 1rem;
        width: 95%;
    }
    
    .image-stats {
        flex-direction: column;
        gap: 1rem;
    }
    
    .image-actions {
        flex-direction: column;
    }
    
    .image-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .image-actions-item {
        width: 100%;
        justify-content: space-between;
    }
}
