/* CSS Custom Properties - matching gridbuilder theme */
:root {
    --bg-primary: #1e1e1e;
    --bg-secondary: #252526;
    --bg-tertiary: #2d2d30;
    --bg-hover: #3e3e42;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --text-muted: #6e6e6e;
    --accent: #007acc;
    --accent-hover: #1a8ad4;
    --border: #3e3e42;
    --success: #4caf50;
    --warning: #ff9800;
    --error: #f44336;
    --code-bg: #1a1a1a;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: var(--bg-secondary);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.app-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-controls label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.header-controls select {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
}

.header-controls select:hover {
    border-color: var(--accent);
}

/* Main Layout - Side by Side */
.app-main {
    display: flex;
    flex: 1;
    min-height: 0;
}

/* Editor Panel (Left) */
.editor-panel {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    border-right: 1px solid var(--border);
    min-width: 320px;
    max-width: 400px;
    overflow-y: auto;
}

/* Properties Section */
.properties-section {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 16px;
}

.properties-section h2 {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 14px;
}

.properties-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.control-group label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.control-group select,
.control-group input[type="text"] {
    padding: 6px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.control-group select:focus,
.control-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.control-group select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Items Section */
.items-section {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.items-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.items-header h2 {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.items-actions {
    display: flex;
    gap: 6px;
}

.items-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    flex: 1;
}

/* Item Config */
.item-config {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.item-config summary {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}

.item-config summary:hover {
    background: var(--bg-hover);
}

.item-config[open] summary {
    border-bottom: 1px solid var(--border);
}

.item-config .item-name {
    font-weight: 500;
    color: var(--text-primary);
}

.item-config .item-preview {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
}

.item-controls {
    padding: 12px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.item-controls .control-group {
    gap: 3px;
}

.item-controls .control-group label {
    font-size: 0.75rem;
}

.item-controls .control-group input,
.item-controls .control-group select {
    padding: 5px 8px;
    font-size: 0.8rem;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-small {
    padding: 5px 10px;
    font-size: 0.8rem;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-copy {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 4px 10px;
    font-size: 0.8rem;
}

.btn-copy:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.editor-instructions {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
}

/* Preview Panel (Right) */
.preview-panel {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-width: 300px;
}

.preview-panel h2 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.preview-container {
    flex: 1;
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 20px;
    display: flex;
    align-items: stretch;
    min-height: 250px;
}

.flex-preview {
    flex: 1;
    border: 2px dashed var(--border);
    border-radius: 4px;
    padding: 10px;
    min-height: 200px;
}

.flex-item {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-weight: 500;
    font-size: 0.9rem;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    min-width: 50px;
    min-height: 50px;
    padding: 10px;
}

/* Code Panel (Bottom) */
.code-panel {
    display: flex;
    gap: 20px;
    padding: 20px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    max-height: 300px;
}

.code-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.code-header h3 {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.code-output {
    flex: 1;
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 12px;
    overflow: auto;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    white-space: pre;
    color: var(--text-primary);
}

.code-output code {
    display: block;
}

/* Item colors */
.flex-item:nth-child(1) { background-color: #4a90d9; }
.flex-item:nth-child(2) { background-color: #50c878; }
.flex-item:nth-child(3) { background-color: #f5a623; }
.flex-item:nth-child(4) { background-color: #9b59b6; }
.flex-item:nth-child(5) { background-color: #e74c3c; }
.flex-item:nth-child(6) { background-color: #1abc9c; }
.flex-item:nth-child(7) { background-color: #f39c12; }
.flex-item:nth-child(8) { background-color: #3498db; }
.flex-item:nth-child(9) { background-color: #e91e63; }
.flex-item:nth-child(10) { background-color: #00bcd4; }

/* Responsive adjustments */
@media (max-width: 900px) {
    .app-main {
        flex-direction: column;
    }

    .editor-panel {
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-width: none;
    }

    .code-panel {
        flex-direction: column;
        max-height: none;
    }

    .code-output {
        max-height: 200px;
    }
}

@media (max-width: 500px) {
    .app-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .properties-grid {
        grid-template-columns: 1fr;
    }

    .item-controls {
        grid-template-columns: 1fr;
    }
}
