/* 8-Bit CSS Icon Builder - Fullscreen Layout */

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

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

body {
    font-family: 'Press Start 2P', cursive;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #e0e0e0;
    font-size: 10px;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

/* Header */
.header {
    padding: 6px 20px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 2px solid #4ecdc4;
    flex-shrink: 0;
}

.header h1 {
    font-size: 1.1rem;
    text-shadow: 2px 2px 0 #ff6b6b, 4px 4px 0 #4ecdc4;
    letter-spacing: 2px;
    text-align: center;
}

/* Main Layout - 3 Spalten */
.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

h2 {
    font-size: 1rem;
    margin-bottom: 10px;
    color: #4ecdc4;
    border-bottom: 1px dashed #4ecdc4;
    padding-bottom: 5px;
}

/* Sidebar Links - Farbpalette */
.sidebar-left {
    width: 140px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-right: 2px solid #4ecdc4;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}

.color-palette {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-bottom: 15px;
}

.color-swatch {
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid #333;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.1s;
}

.color-swatch:hover {
    transform: scale(1.1);
    z-index: 1;
}

.color-swatch.selected {
    border-color: #fff;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

.current-color {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.current-color span {
    font-size: 0.85rem;
}

.color-preview {
    width: 30px;
    height: 30px;
    border: 2px solid #fff;
    flex-shrink: 0;
}

/* Toolbar über dem Grid - 100% Breite */
.toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    padding: 10px 15px;
    background: #1d2b53; /* PICO-8 Dark Blue */
    border: 3px solid #7e2553; /* PICO-8 Dark Purple */
    border-radius: 0;
    width: 100%;
    justify-content: center;
}

.toolbar-btn {
    width: 48px;
    height: 48px;
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: transform 0.05s, box-shadow 0.05s, background 0.1s;
    /* Einheitliche Farbe - PICO-8 Dark Gray/Blue */
    background: #5f574f;
    box-shadow: 
        inset -3px -3px 0 0 #3b3530,
        inset 3px 3px 0 0 #8a8178,
        0 4px 0 0 #3b3530;
}

.toolbar-btn:hover {
    background: #7a7268;
    transform: translateY(-2px);
    box-shadow: 
        inset -3px -3px 0 0 #3b3530,
        inset 3px 3px 0 0 #8a8178,
        0 6px 0 0 #3b3530;
}

.toolbar-btn:active {
    transform: translateY(2px);
    box-shadow: 
        inset -3px -3px 0 0 #3b3530,
        inset 3px 3px 0 0 #8a8178,
        0 2px 0 0 #3b3530;
}

/* Aktiver/Selektierter Button - Dunkelgrün */
.toolbar-btn.active {
    background: #00A800; /* Dunkelgrün aus der Palette */
    box-shadow: 
        inset -3px -3px 0 0 #005400,
        inset 3px 3px 0 0 #40d040,
        0 4px 0 0 #005400;
}

.toolbar-btn.active:hover {
    background: #20c820;
    box-shadow: 
        inset -3px -3px 0 0 #005400,
        inset 3px 3px 0 0 #40d040,
        0 6px 0 0 #005400;
}

/* Tool Buttons - 8-Bit Retro Style */
.tool-btn {
    padding: 10px 14px;
    background: #3c44a4;
    color: #fff;
    border: none;
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    cursor: pointer;
    position: relative;
    image-rendering: pixelated;
    /* 8-Bit pixel border effect */
    box-shadow: 
        inset -4px -4px 0 0 #1a1a4a,
        inset 4px 4px 0 0 #6070d0,
        0 4px 0 0 #1a1a2e;
    transition: transform 0.05s, box-shadow 0.05s;
}

.tool-btn:hover {
    background: #4c54b4;
    transform: translateY(-2px);
    box-shadow: 
        inset -4px -4px 0 0 #1a1a4a,
        inset 4px 4px 0 0 #6070d0,
        0 6px 0 0 #1a1a2e;
}

.tool-btn:active {
    transform: translateY(2px);
    box-shadow: 
        inset -4px -4px 0 0 #1a1a4a,
        inset 4px 4px 0 0 #6070d0,
        0 2px 0 0 #1a1a2e;
}

/* Aktiver Size-Button - Dunkelgrün */
.tool-btn.size-btn.active {
    background: #00A800; /* Dunkelgrün aus der Palette */
    box-shadow: 
        inset -4px -4px 0 0 #005400,
        inset 4px 4px 0 0 #40d040,
        0 4px 0 0 #1a1a2e;
}

.tool-btn.size-btn.active:hover {
    background: #20c820;
    box-shadow: 
        inset -4px -4px 0 0 #005400,
        inset 4px 4px 0 0 #40d040,
        0 6px 0 0 #1a1a2e;
}

/* Editor Center */
.editor-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 20px;
    overflow: hidden;
}

/* Grid-Wrapper - zentriert horizontal und vertikal */
.grid-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.pixel-grid {
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    gap: 1px;
    background: #333;
    border: 3px solid #4ecdc4;
    padding: 1px;
    width: min(100%, 500px);
    max-height: calc(100vh - 180px);
    aspect-ratio: 1;
}

.pixel {
    background: #1a1a2e;
    aspect-ratio: 1;
    cursor: crosshair;
    transition: background 0.05s;
}

.pixel:hover {
    opacity: 0.8;
}

.editor-controls {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

/* Sidebar Rechts - Vorschau */
.sidebar-right {
    width: 180px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-left: 2px solid #4ecdc4;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.preview-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.preview-item {
    text-align: center;
}

.preview-item span {
    display: block;
    font-size: 0.8rem;
    color: #9d9d9d;
    margin-bottom: 5px;
}

.preview-box {
    background: #2a2a4a;
    border: 2px solid #4ecdc4;
    position: relative;
    overflow: hidden;
    margin: 0 auto;
    /* Default-Größe für leere Vorschau - wird per JS überschrieben */
    width: 16px;
    height: 16px;
    min-width: 16px;
    min-height: 16px;
}

.preview-box.medium {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
}

.preview-box.large {
    width: 64px;
    height: 64px;
    min-width: 64px;
    min-height: 64px;
}

.icon-preview {
    position: absolute;
    /* top/left/width/height werden per JS gesetzt */
}

/* Export Section */
.export-section {
    margin-top: auto;
}

.class-name-input {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 10px;
}

.class-name-input label {
    font-size: 0.85rem;
}

.class-name-input input {
    padding: 6px 10px;
    background: #1a1a2e;
    border: 2px solid #4ecdc4;
    color: #fff;
    font-family: inherit;
    font-size: 0.9rem;
    width: 100%;
}

.generate-btn {
    width: 100%;
    padding: 12px 10px;
    background: #e74c3c;
    color: #fff;
    border: none;
    font-family: 'Press Start 2P', cursive;
    font-size: 9px;
    cursor: pointer;
    position: relative;
    /* 8-Bit pixel border effect */
    box-shadow: 
        inset -4px -4px 0 0 #a33527,
        inset 4px 4px 0 0 #f7897d,
        0 4px 0 0 #1a1a2e;
    transition: transform 0.05s, box-shadow 0.05s;
}

.generate-btn:hover {
    background: #f05545;
    transform: translateY(-2px);
    box-shadow: 
        inset -4px -4px 0 0 #a33527,
        inset 4px 4px 0 0 #f7897d,
        0 6px 0 0 #1a1a2e;
}

.generate-btn:active {
    transform: translateY(2px);
    box-shadow: 
        inset -4px -4px 0 0 #a33527,
        inset 4px 4px 0 0 #f7897d,
        0 2px 0 0 #1a1a2e;
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: #1a1a2e;
    border: 3px solid #4ecdc4;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 2px solid #4ecdc4;
}

.modal-header h2 {
    margin: 0;
    border: none;
    padding: 0;
}

.close-btn {
    background: none;
    border: none;
    color: #ff6b6b;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.close-btn:hover {
    color: #fff;
}

.modal-body {
    flex: 1;
    overflow: auto;
    padding: 15px 20px;
}

.modal-body pre {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.4;
}

.modal-body code {
    color: #4ecdc4;
    white-space: pre-wrap;
    word-break: break-all;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 2px solid #4ecdc4;
    display: flex;
    justify-content: flex-end;
}

.copy-btn {
    padding: 10px 16px;
    background: #4ecdc4;
    color: #1a1a2e;
    border: none;
    font-family: 'Press Start 2P', cursive;
    font-size: 9px;
    cursor: pointer;
    /* 8-Bit pixel border effect */
    box-shadow: 
        inset -4px -4px 0 0 #2a9d96,
        inset 4px 4px 0 0 #7eeee6,
        0 4px 0 0 #1a1a2e;
    transition: transform 0.05s, box-shadow 0.05s;
}

.copy-btn:hover {
    background: #5eddd5;
    transform: translateY(-2px);
    box-shadow: 
        inset -4px -4px 0 0 #2a9d96,
        inset 4px 4px 0 0 #7eeee6,
        0 6px 0 0 #1a1a2e;
}

.copy-btn:active {
    transform: translateY(2px);
    box-shadow: 
        inset -4px -4px 0 0 #2a9d96,
        inset 4px 4px 0 0 #7eeee6,
        0 2px 0 0 #1a1a2e;
}

/* Preview Highlight Animation für Shape-Tools */
.preview-highlight {
    animation: pulse-preview 0.5s ease-in-out infinite alternate;
}

@keyframes pulse-preview {
    0% {
        opacity: 0.7;
    }
    100% {
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 700px) {
    .main-layout {
        flex-direction: column;
    }
    
    .sidebar-left {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 15px;
        border-right: none;
        border-bottom: 2px solid #4ecdc4;
    }
    
    .sidebar-left h2 {
        display: none;
    }
    
    .color-palette {
        grid-template-columns: repeat(8, 1fr);
        flex: 1;
        margin-bottom: 0;
    }
    
    .sidebar-right {
        width: 100%;
        border-left: none;
        border-top: 2px solid #4ecdc4;
    }
    
    .preview-container {
        flex-direction: row;
        justify-content: center;
    }
    
    .pixel-grid {
        width: min(100%, 350px);
    }
}