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

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

body {
    font-family: 'Courier New', monospace;
    background: #1a1a1a;
    color: #ffffff;
    overflow-x: auto;
}

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

/* Header */
.header {
    background: #2d2d2d;
    padding: 1rem;
    border-bottom: 3px solid #00ff41;
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.app-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 1.2rem;
    color: #00ff41;
    text-shadow: 2px 2px 0px #000000;
}

.sign-toggle {
    display: flex;
    gap: 0.5rem;
}

.toggle-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.7rem;
    padding: 0.8rem 1.2rem;
    border: 2px solid #555;
    background: #333;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-btn:hover {
    background: #444;
    transform: translateY(-1px);
}

.toggle-btn.active {
    background: #cc0000;
    border-color: #ff0000;
    box-shadow: 0 0 10px rgba(204, 0, 0, 0.5);
}

.export-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.7rem;
    padding: 0.8rem 1.2rem;
    border: 2px solid #00ff41;
    background: #004400;
    color: #00ff41;
    cursor: pointer;
    margin-left: auto;
    transition: all 0.2s;
}

.export-btn:hover {
    background: #006600;
    box-shadow: 0 0 10px rgba(0, 255, 65, 0.3);
    transform: translateY(-1px);
}

/* Main Content */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 250px 1fr 200px;
    gap: 1rem;
    padding: 1rem;
}

/* Sidebars */
.left-sidebar, .right-sidebar {
    background: #2d2d2d;
    border: 2px solid #555;
    border-radius: 4px;
    padding: 1rem;
    height: fit-content;
}

.tools-panel h3, .elements-panel h3 {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.7rem;
    color: #ffb000;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

#canvasSize {
    width: 100%;
    padding: 0.5rem;
    background: #333;
    border: 1px solid #555;
    color: #fff;
    font-family: monospace;
    margin-bottom: 1rem;
}

/* Color Palette */
.color-palette {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.3rem;
    margin-bottom: 1rem;
}

.color-swatch {
    width: 30px;
    height: 30px;
    border: 2px solid #555;
    cursor: pointer;
    transition: all 0.2s;
}

.color-swatch:hover, .color-swatch.active {
    border-color: #00ff41;
    box-shadow: 0 0 8px rgba(0, 255, 65, 0.4);
}

#customColor {
    width: 100%;
    height: 30px;
    border: 2px solid #555;
    background: transparent;
    cursor: pointer;
    margin-top: 0.5rem;
}

/* Brush Tools */
.brush-tools {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem;
    margin-bottom: 1rem;
}

.tool-btn, .template-btn, .action-btn {
    font-family: monospace;
    font-size: 0.75rem;
    padding: 0.6rem;
    border: 2px solid #555;
    background: #333;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
}

.tool-btn:hover, .template-btn:hover, .action-btn:hover {
    background: #444;
    transform: translateY(-1px);
}

.tool-btn.active {
    background: #cc0000;
    border-color: #ff0000;
    box-shadow: 0 0 8px rgba(204, 0, 0, 0.4);
}

.template-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.template-btn.danger {
    background: #440000;
    border-color: #cc0000;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

/* Canvas Area */
.canvas-container {
    background: #2d2d2d;
    border: 2px solid #555;
    border-radius: 4px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.canvas-controls {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 1rem;
    align-items: center;
}

.canvas-controls label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.zoom-controls button {
    width: 30px;
    height: 30px;
    border: 2px solid #555;
    background: #333;
    color: #fff;
    cursor: pointer;
    font-weight: bold;
}

.zoom-controls button:hover {
    background: #444;
}

#zoomLevel {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.7rem;
    color: #00ff41;
    min-width: 40px;
    text-align: center;
}

.canvas-wrapper {
    position: relative;
    border: 3px solid #00ff41;
    box-shadow: 
        0 0 20px rgba(0, 255, 65, 0.2),
        inset 0 0 20px rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    overflow: hidden;
}

.canvas-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(0, 255, 65, 0.03) 2px,
            rgba(0, 255, 65, 0.03) 4px
        );
    pointer-events: none;
}

#canvas, #gridCanvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

#gridCanvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

/* Icon Library */
.icon-library {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.icon-item {
    background: #333;
    border: 2px solid #555;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.icon-item:hover {
    border-color: #00ff41;
    background: #444;
}

.icon-item img {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
}

/* Text Tool */
.text-tool {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#textInput {
    padding: 0.5rem;
    background: #333;
    border: 1px solid #555;
    color: #fff;
    font-family: monospace;
}

#addTextBtn {
    font-family: monospace;
    font-size: 0.75rem;
    padding: 0.6rem;
    border: 2px solid #555;
    background: #333;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
}

#addTextBtn:hover {
    background: #444;
}

/* Bottom Panel */
.bottom-panel {
    background: #2d2d2d;
    border-top: 2px solid #555;
    padding: 1rem;
}

.gallery-section h3 {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.7rem;
    color: #ffb000;
    margin-bottom: 0.5rem;
}

.gallery {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.gallery-item {
    min-width: 80px;
    background: #333;
    border: 2px solid #555;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.gallery-item:hover {
    border-color: #00ff41;
    transform: scale(1.05);
}

.gallery-item img {
    width: 60px;
    height: 60px;
    image-rendering: pixelated;
    margin-bottom: 0.3rem;
}

.item-info {
    font-size: 0.6rem;
    color: #aaa;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #2d2d2d;
    border: 3px solid #00ff41;
    border-radius: 8px;
    padding: 2rem;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
}

.close:hover {
    color: #ff0000;
}

.modal-content h2 {
    font-family: 'Press Start 2P', monospace;
    color: #00ff41;
    margin-bottom: 1rem;
}

.inspiration-actions {
    margin-top: 1rem;
}

.inspiration-actions button {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.7rem;
    padding: 0.8rem 1.2rem;
    border: 2px solid #00ff41;
    background: #004400;
    color: #00ff41;
    cursor: pointer;
}

/* Responsive */
@media (max-width: 1000px) {
    .main-content {
        grid-template-columns: 200px 1fr;
        grid-template-rows: auto auto;
    }
    
    .right-sidebar {
        grid-column: 1 / -1;
        grid-row: 2;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }
    
    .left-sidebar, .canvas-container, .right-sidebar {
        grid-column: 1;
    }
    
    .app-title {
        font-size: 1rem;
    }
    
    .toggle-btn, .export-btn {
        font-size: 0.6rem;
        padding: 0.6rem 1rem;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #333;
}

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

::-webkit-scrollbar-thumb:hover {
    background: #777;
}