/* Import czcionki i zmienne globalne */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap');

:root {
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --background-light: #fafafa;
    --border-color: #ddd;
    --text-color: #333;
    --shadow-light: 0 2px 5px rgba(0, 0, 0, 0.1);
    --success-color: #28a745;
    --error-color: #dc3545;
    --canvas-bg: #ffffff;
    --grid-color: #e0e0e0;
}

/* Reset i styl bazowy */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    color: var(--text-color);
    background: #f5f5f5;
    margin: 0;
    padding: 0;
}

#app {
    max-width: 1400px;
    margin: 20px auto;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-light);
    display: grid;
    grid-template-columns: 250px 1fr 300px;
    grid-template-rows: auto auto 1fr auto;
    gap: 15px;
    height: calc(100vh - 40px);
    overflow: hidden;
}

/* Górny pasek narzędzi */
.toolbar {
    grid-column: 1 / 4;
    grid-row: 1 / 2;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    padding: 10px;
    background: var(--background-light);
    border-radius: 10px;
    box-shadow: var(--shadow-light);
}

.toolbar button {
    padding: 8px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.3s;
}

.toolbar button:hover {
    background: var(--primary-hover);
}

.toolbar button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.sync-status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.sync-success {
    color: var(--success-color);
}

.sync-error {
    color: var(--error-color);
}

/* Lewy panel: Picker elementów i szczegóły gry */
.game-editor,
.element-picker {
    grid-column: 1 / 2;
    grid-row: 2 / 4;
    background: var(--background-light);
    padding: 15px;
    border-radius: 10px;
    box-shadow: var(--shadow-light);
    overflow-y: auto;
}

.game-editor h3,
.element-picker h3 {
    font-weight: 500;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.game-editor label,
.element-picker label {
    display: block;
    margin-bottom: 10px;
}

.element-types {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.element-type {
    padding: 6px 10px;
    cursor: pointer;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    text-align: center;
    transition: all 0.3s;
}

.element-type:hover {
    background: #f0f0f0;
}

.element-type.selected {
    background: #e0f1ff;
    border-color: var(--primary-color);
}

.element-icon {
    width: 40px;
    height: 40px;
    object-fit: contain;
    display: block;
    margin: 0 auto 5px;
}

/* Centralny canvas */
.canvas-container {
    grid-column: 2 / 3;
    grid-row: 3 / 4;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

#gameCanvas {
    border: 1px solid var(--border-color);
    background: var(--canvas-bg);
    border-radius: 6px;
    box-shadow: var(--shadow-light);
    max-width: 100%;
    max-height: 100%;
}

.canvas-tools {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(255, 255, 255, 0.9);
    padding: 6px 12px;
    border-radius: 8px;
    display: flex;
    gap: 10px;
    box-shadow: var(--shadow-light);
    z-index: 10;
}

.canvas-tools label,
.canvas-tools select {
    margin: 0;
}

.mini-preview {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.9);
    padding: 5px;
    border-radius: 6px;
    box-shadow: var(--shadow-light);
}

#miniCanvas {
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

/* Prawy panel: Inspektor */
.inspector {
    grid-column: 3 / 4;
    grid-row: 2 / 4;
    background: var(--background-light);
    padding: 15px;
    border-radius: 10px;
    box-shadow: var(--shadow-light);
    overflow-y: auto;
}

.inspector h3,
.inspector h4 {
    font-weight: 500;
    color: var(--primary-color);
    margin: 10px 0;
}

.inspector ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.inspector li {
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
}

.inspector li:hover {
    background: #f1f1f1;
}

.inspector li.selected {
    background: #cde8ff;
}

.element-icon-small,
.asset-icon {
    width: 18px;
    height: 18px;
    vertical-align: middle;
    margin-right: 5px;
}

.asset-list li {
    cursor: move;
}

/* Dolny pasek: Kontrolki poziomu */
.controls {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    padding: 10px;
    background: var(--background-light);
    border-radius: 10px;
    box-shadow: var(--shadow-light);
}

.controls select,
.controls input {
    width: auto;
    min-width: 150px;
}

.game-image-preview,
.background-preview {
    max-width: 90px;
    height: auto;
    margin-top: 6px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

/* Pływający panel właściwości */
.properties {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 250px;
    background: var(--background-light);
    padding: 15px;
    border-radius: 10px;
    box-shadow: var(--shadow-light);
    z-index: 20;
}

.properties h3 {
    margin-top: 0;
}

.properties label {
    display: block;
    margin-bottom: 10px;
}

/* Ogólne style dla inputów, selectów i buttonów */
input,
textarea,
select {
    width: 100%;
    padding: 8px;
    margin-top: 4px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    outline: none;
    transition: border 0.2s;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary-color);
}

button {
    padding: 7px 14px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.3s;
}

button:hover {
    background: var(--primary-hover);
}

button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

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

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: var(--shadow-light);
    width: 300px;
}

.modal-content label {
    display: block;
    margin-bottom: 10px;
}

.modal-content button {
    margin-right: 10px;
}

/* Responsywność */
@media (max-width: 1200px) {
    #app {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto auto auto;
        padding: 10px;
    }

    .toolbar,
    .game-editor,
    .element-picker,
    .canvas-container,
    .controls,
    .inspector {
        grid-column: 1 / 2;
    }

    .toolbar {
        grid-row: 1 / 2;
    }

    .controls {
        grid-row: 2 / 3;
    }

    .canvas-container {
        grid-row: 3 / 4;
    }

    .game-editor {
        grid-row: 4 / 5;
    }

    .element-picker {
        grid-row: 5 / 6;
    }

    .inspector {
        grid-row: 6 / 7;
    }

    .properties {
        position: static;
        width: 100%;
        margin-top: 15px;
    }
}