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

:root {
    --primary-color: #6366f1;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #0f172a;
    --surface-color: #1e293b;
    --surface-light: #334155;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #475569;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, var(--bg-color) 0%, #1a1f3a 100%);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--surface-color);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
}

.header h1 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Toolbar */
.toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    padding: 20px;
    background: var(--surface-color);
    border-radius: 12px;
    box-shadow: var(--shadow);
    flex-wrap: wrap;
    align-items: center;
}

.model-info {
    display: flex;
    align-items: center;
    margin-left: auto;
}

.model-badge {
    padding: 10px 20px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
    border: 2px solid rgba(99, 102, 241, 0.5);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.btn-secondary {
    background: var(--success-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-small {
    padding: 10px 16px;
    font-size: 0.9rem;
    background: var(--primary-color);
    color: white;
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    min-height: 600px;
}

/* Block Palette */
.block-palette {
    background: var(--surface-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
    overflow-y: auto;
    max-height: calc(100vh - 280px);
}

.block-palette h3 {
    margin-bottom: 20px;
    color: var(--text-color);
    font-size: 1.3rem;
}

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

.palette-section h4 {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.block-item {
    margin-bottom: 12px;
    cursor: grab;
}

.block-item:active {
    cursor: grabbing;
}

/* Blocks */
.block {
    padding: 16px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    border-left: 4px solid;
    position: relative;
}

.block:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-lg);
}

.block-label {
    font-weight: 600;
    display: block;
    margin-bottom: 8px;
}

.action-block {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border-left-color: #1d4ed8;
}

.condition-block {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border-left-color: #b45309;
}

.loop-block {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    border-left-color: #6d28d9;
}

.function-block {
    background: linear-gradient(135deg, #ec4899, #db2777);
    border-left-color: #be185d;
}

.event-block {
    background: linear-gradient(135deg, #10b981, #059669);
    border-left-color: #047857;
}

.ui-block {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
    border-left-color: #0e7490;
}

.data-block {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    border-left-color: #4338ca;
}

/* Workspace */
.workspace-container {
    background: var(--surface-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.workspace-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.workspace-header h3 {
    font-size: 1.3rem;
}

.hint {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.workspace {
    min-height: 500px;
    background: var(--bg-color);
    border-radius: 8px;
    padding: 20px;
    border: 2px dashed var(--border-color);
    transition: all 0.3s ease;
}

.workspace.drag-over {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

/* Workspace Block */
.workspace-block {
    margin-bottom: 16px;
    cursor: move;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.workspace-block .block {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.block-input {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: var(--text-color);
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.block-input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.15);
}

.block-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.block-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.block-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.block-btn:hover {
    transform: translateY(-1px);
}

.btn-generate {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.btn-delete {
    background: rgba(239, 68, 68, 0.8);
    color: white;
    margin-left: auto;
}

.block-code {
    margin-top: 8px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: #a5f3fc;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
}

.block-status {
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: 6px;
    display: inline-block;
}

.status-generated {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

.status-error {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface-color);
    padding: 40px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    text-align: center;
    max-width: 500px;
}

.modal-content h3 {
    margin-bottom: 20px;
    color: var(--text-color);
}

/* Loader */
.loader {
    width: 50px;
    height: 50px;
    border: 4px solid var(--surface-light);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

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

::-webkit-scrollbar-track {
    background: var(--surface-color);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Responsive */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .block-palette {
        max-height: 300px;
    }
}

