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

:root {
    --primary-color: #6c5ce7;
    --secondary-color: #a8a4e6;
    --success-color: #00b894;
    --danger-color: #d63031;
    --warning-color: #fdcb6e;
    --dark-bg: #2d3436;
    --light-bg: #f5f6fa;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    color: white;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    margin-bottom: 10px;
}

.subtitle {
    color: rgba(255,255,255,0.9);
    font-size: 1.1em;
}

.main-panel {
    display: flex;
    gap: 20px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.blocks-palette {
    width: 250px;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 15px;
    border: 2px solid #dee2e6;
}

.palette-category {
    margin-bottom: 20px;
}

.palette-category h4 {
    color: #666;
    font-size: 14px;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 2px solid #6c5ce7;
}

.block-item {
    background: white;
    border: 2px solid #6c5ce7;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    cursor: move;
    color: #6c5ce7;
    font-weight: 500;
    text-align: center;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.block-item:hover {
    background: #6c5ce7;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(108, 92, 231, 0.4);
}

.block-icon {
    font-size: 18px;
}

.block-text {
    font-size: 14px;
}

.workspace {
    flex: 1;
    min-height: 600px;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 15px;
    border: 2px solid #dee2e6;
}

.workspace-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.program-area {
    min-height: 500px;
    background: white;
    border-radius: 8px;
    padding: 15px;
    border: 1px dashed #adb5bd;
}

.program-area.drag-over {
    border: 3px dashed #6c5ce7;
    background: rgba(108, 92, 231, 0.1);
}

.program-block {
    background: #e3f2fd;
    border: 2px solid #2196f3;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 10px;
    transition: all 0.2s;
}

.program-block:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.program-block[draggable="true"] {
    cursor: grab;
}

.program-block.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.program-block.variable-decl {
    background: #fff3e0;
    border-color: #ff9800;
}

.program-block.assignment {
    background: #e8f5e8;
    border-color: #4caf50;
}

.program-block.if-block {
    background: #f3e5f5;
    border-color: #9c27b0;
}

.program-block.arithmetic {
    background: #fff3e0;
    border-color: #ff9800;
}

.block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-weight: bold;
}

.block-actions button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 2px 6px;
    border-radius: 4px;
}

.block-content {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    width: 100%;
}

.block-content input, .block-content select {
    padding: 5px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

/* Стили для IF блока */
.if-block input {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    border: 2px solid #ba68c8;
    border-radius: 6px;
    box-sizing: border-box;
}

.if-block input:focus {
    border-color: #9c27b0;
    outline: none;
    box-shadow: 0 0 0 3px rgba(156, 39, 176, 0.2);
}

/* Стили для арифметического блока */
.arithmetic-block input {
    width: 100%;
    padding: 8px;
    border: 2px solid #ffb74d;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    box-sizing: border-box;
}

.arithmetic-block input:focus {
    border-color: #ff9800;
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.2);
}

/* Стили для вложенных блоков */
.nested-slot {
    margin-left: 20px;
    padding: 10px;
    border-left: 3px solid #4caf50;
    background: #f0f9f0;
    border-radius: 0 8px 8px 0;
    min-height: 50px;
    margin-top: 10px;
    transition: all 0.2s;
}

.nested-slot.drag-over {
    background: #c8e6c9 !important;
    border: 2px dashed #2e7d32 !important;
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.2);
}

.nested-slot .program-block {
    margin-bottom: 8px;
}

.nested-slot:empty::before {
    content: "⬇️ Перетащите блоки сюда";
    color: #2e7d32;
    font-size: 12px;
    opacity: 0.5;
    display: block;
    text-align: center;
    padding: 10px;
}

/* Стили для ошибок */
.block-error {
    border: 2px solid #f44336 !important;
    background-color: #ffebee !important;
}

.block-error-message {
    background-color: #f44336;
    color: white;
    font-size: 12px;
    padding: 4px 8px;
    margin-top: 8px;
    border-radius: 4px;
}

.error-highlight {
    border: 2px solid #f44336 !important;
    background-color: #ffebee !important;
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Панель вывода */
.output-panel {
    margin-top: 20px;
    background: white;
    border-radius: 10px;
    padding: 20px;
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.console-output {
    background: #1e1e1e;
    color: #00ff00;
    padding: 15px;
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    min-height: 100px;
    max-height: 200px;
    overflow-y: auto;
}

/* Панель переменных */
.variables-panel {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.variables-list {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.variable-item {
    background: #6c5ce7;
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 14px;
}

.empty-state {
    color: #999;
    font-style: italic;
}

.info-panel {
    width: 250px;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 15px;
    border: 2px solid #dee2e6;
}

/* Кнопки управления */
.execution-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.execution-controls button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}

.btn-execute {
    background: #28a745;
    color: white;
}

.btn-execute:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.3);
}

.btn-clear {
    background: #dc3545;
    color: white;
}

.btn-clear:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(220, 53, 69, 0.3);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

/* Зона удаления */
.delete-zone {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100px;
    background: #d63031;
    color: white;
    display: none;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    font-weight: bold;
    z-index: 9999;
}

.delete-zone.show {
    display: flex;
}

/* Адаптивность */
@media (max-width: 800px) {
    .main-panel {
        flex-direction: column;
    }
    
    .blocks-palette {
        width: 100%;
    }
    
    .info-panel {
        width: 100%;
    }
}

.else-slot {
    border-left: 3px solid #f44336 !important;
    background: #ffebee !important;
    margin-top: 10px;
}

.else-slot.drag-over {
    background: #ffcdd2 !important;
    border: 2px dashed #c62828 !important;
    box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.2);
}

.else-slot:empty::before {
    content: "⬇️ Блоки ELSE сюда";
    color: #c62828;
}

/* Стили для THEN слота */
.then-slot {
    border-left: 3px solid #4caf50 !important;
    background: #f0f9f0 !important;
}

.then-slot.drag-over {
    background: #c8e6c9 !important;
    border: 2px dashed #2e7d32 !important;
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.2);
}

.then-slot:empty::before {
    content: "⬇️ Блоки THEN сюда";
    color: #2e7d32;
}

/* Стили для IF-ELSE блока */
.ifelse-block {
    background: #f3e5f5;
    border-color: #9c27b0;
}
