/* Concoct Styles */
:root {
    --primary-color: #1674c1;
    --primary-border-color: #1674c1;
    --primary-hover-color: #0f5b9a;
    --secondary-color: #FFC107;
    --bg-color: #111111;
    --dark-hover-color: #1B1B1B;
    --med-hover-color: #242424;
    --panel-bg: #181818;
    --border-color: #2A2A2A;
    --text-color: #aaaaaa;
    --text-muted: #838383;
    --success-color: #4CAF50;
    --warning-color: #88550a;
    --warning-hover-color: #ae6e0d;
    --danger-color: #a4180d;
    --danger-hover-color: #811008;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
    user-select: none; /* Prevent text selection globally */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #202020;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-color);
}

.logo h1 {
    font-size: 18px;
    color: var(--primary-color);
    margin-bottom: 2px;
}

.logo span {
    font-size: 12px;
    color: var(--text-muted);
}

.toolbar {
    display: flex;
    gap: 8px;
}

/* Buttons */
.btn, .btn-small {
    padding: 8px 16px;
    background: var(--panel-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);
}

.btn-small {
    padding: 4px 8px;
    font-size: 11px;
}

.btn:hover, .btn-small:hover {
    background: var(--med-hover-color);
    transform: translateY(1px);
}

.btn-primary {
    background: var(--primary-hover-color);
    border-color: var(--primary-color);
    color: white;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: var(--primary-color);
    transform: translateY(1px);
}

.btn-success {
    background: var(--success-color);
    border-color: #27ae60;
    color: white;
    transition: all 0.2s;
}

.btn-success:hover {
    background: #27ae60;
    transform: translateY(1px);
}

.btn-warning {
    background: var(--warning-color);
    border-color: var(--warning-hover-color);
    color: white;
}

.btn-warning:hover {
    background: var(--warning-hover-color);
}

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

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

/* Input Styles */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea,
select,
.form-control {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 13px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: all 0.2s;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);
    user-select: text; /* Allow text selection in inputs */
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

select option {
    background: var(--bg-color);
    color: var(--text-color);
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
textarea:focus,
select:focus,
.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--panel-bg);
}

input[type="text"]:hover,
input[type="number"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
input[type="search"]:hover,
textarea:hover,
select:hover,
.form-control:hover {
    border-color: #555;
}

input[type="text"]::placeholder,
input[type="number"]::placeholder,
input[type="email"]::placeholder,
input[type="password"]::placeholder,
input[type="search"]::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

input[readonly],
input[disabled],
textarea[readonly],
textarea[disabled],
select[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* Allow text selection in code blocks */
pre,
code {
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

/* Number Input Spinner Styles */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    opacity: 1;
    background: var(--panel-bg);
    border-left: 1px solid var(--border-color);
    cursor: pointer;
}

input[type="number"]::-webkit-inner-spin-button:hover,
input[type="number"]::-webkit-outer-spin-button:hover {
    background: var(--border-color);
}

/* Firefox number input */
input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* Checkbox and Radio Styles */
input[type="checkbox"],
input[type="radio"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
    flex-shrink: 0;
}

input[type="checkbox"]:hover,
input[type="radio"]:hover {
    border-color: var(--primary-color);
}

input[type="checkbox"]:checked,
input[type="radio"]:checked {
    background: var(--bg-color);
    border-color: var(--primary-color);
}

input[type="checkbox"]:checked::after,
input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    background: var(--primary-color);
    border-radius: 2px;
}

input[type="radio"] {
    border-radius: 50%;
}

input[type="radio"]:checked::after {
    border-radius: 50%;
}

/* Form Groups */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-color);
    font-size: 13px;
    font-weight: 500;
}

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

.sidebar-left, .sidebar-right {
    width: 280px;
    background: var(--panel-bg);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
}

.sidebar-right {
    border-right: none;
    border-left: 1px solid var(--border-color);
}

.center-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-color);
    min-width: 0;
    overflow: hidden;
    position: relative; /* Ensure proper positioning */
}

/* Panels */
.panel {
    border-bottom: 1px solid var(--border-color);
    padding: 12px;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.3);
}

.panel h3 {
    font-size: 14px;
    margin-bottom: 12px;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-actions {
    display: flex;
    gap: 4px;
}

.btn-icon {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--text-color);
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.1);
}

.btn-icon:hover {
    background: var(--border-color);
    transform: translateY(1px);
}

.btn-icon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-icon:disabled:hover {
    background: var(--bg-color);
    border-color: var(--border-color);
    transform: none;
}

.btn-icon span {
    display: block;
    line-height: 1;
}

.panel h4 {
    font-size: 12px;
    margin: 8px 0 6px 0;
    color: var(--text-muted);
}

/* Object Properties Panel in Sidebar */
.object-properties-panel {
    padding: 12px;
    background: var(--panel-bg);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 12px;
}

.object-properties-panel h3 {
    font-size: 13px;
    margin: 0 0 12px 0;
    color: var(--text-color);
}

.object-properties-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Tabs */
.tab-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.tabs {
    display: flex;
    background: var(--panel-bg);
    border-bottom: 1px solid var(--border-color);
}

.tab {
    padding: 8px 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab:hover
{
    transform: translateY(1px);
    color: white;
}

.tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab.hidden {
    display: none;
}

.tab-content {
    flex: 1;
    display: none !important; /* Force hide inactive tabs */
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.tab-content.active {
    display: flex !important; /* Force show active tab */
}

/* Scene Editor */
.scene-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--panel-bg);
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
    margin: 0;
    box-sizing: border-box;
    flex-shrink: 0;
    width: 100%;
    position: relative;
    z-index: 10; /* Keep toolbar above canvas */
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.3);
}

.scene-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.scene-selector label {
    margin: 0;
    font-weight: 500;
}

.scene-selector select {
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    min-width: 120px;
}

/* Scene Editor Container */
.tab-content#sceneEditor.active {
    background: #1a1a1a;
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

/* Scene canvas container (the scrollable wrapper) - only in scene editor */
.tab-content#sceneEditor .scene-canvas-container {
    flex: 1;
    overflow: auto;
    padding: 50px; /* Increased padding for better zoom scrolling */
    min-height: 0; /* Allow proper flexbox behavior */
    position: relative;
    display: block;
}

/* The actual scene canvas (1280x720 game area) - only in scene editor */
.tab-content#sceneEditor .scene-canvas {
    position: relative;
    background: #2d2d2d;
    width: 1280px;
    height: 720px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    transform-origin: center center;
    flex-shrink: 0;
    z-index: 1; /* Keep canvas below toolbar */
    display: block;
    margin: 0 auto; /* Will be overridden by JavaScript for zoom */
}

.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(255,255,255,.3) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.3) 1px, transparent 1px);
    background-size: 32px 32px;
    pointer-events: none;
    z-index: 0;
}

.scene-canvas.drag-over {
    border-color: var(--primary-color);
    background-color: rgba(33, 150, 243, 0.1);
}

/* Object instances in scene */
.object-instance {
    position: absolute;
    cursor: move;
    border: 1px solid transparent;
    border-radius: 3px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.object-instance:hover {
    border-color: var(--primary-color);
}

.object-instance.selected {
    border-color: var(--success-color);
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.3);
}

.instance-image {
    pointer-events: none;
    display: block;
}

.instance-label {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    font-size: 10px;
    border-radius: 2px;
    margin-top: 2px;
    pointer-events: none;
}

/* Event Editor */
.event-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.event-object-info {
    padding: 8px 12px;
    background: var(--panel-bg);
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-muted);
}

.event-canvas {
    flex: 1;
    padding: 20px;
    min-height: 400px;
    position: relative;
}

.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Asset Lists */
.asset-list, .object-list {
    min-height: 60px;
    margin-bottom: 8px;
}

.object-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    margin-bottom: 4px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 11px;
    cursor: grab;
    transition: all 0.2s;
    position: relative;
}

.asset-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    margin-bottom: 4px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 11px;
    transition: all 0.2s;
    position: relative;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);
}

.asset-item > span:nth-child(2),
.object-item > span:nth-child(2) {
    flex: 1; /* Take up remaining space */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0; /* Important for flex children to allow shrinking */
}

.delete-btn, .edit-btn {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 16px;
    padding: 2px 6px;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s;
    line-height: 1;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.1);
}

.edit-btn {
    font-size: 12px;
}

.edit-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

.delete-btn:hover {
    background: var(--danger-color);
    border-color: var(--danger-color);
    color: white;
    transform: scale(1.1);
}

.asset-item:hover, .object-item:hover {
    background: var(--dark-hover-color);
    transform: translateY(1px);
}

.object-item.selected-for-placement {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    box-shadow: 0 0 10px rgba(22, 116, 193, 0.5);
}

.object-item.selected-for-placement:hover {
    background: var(--primary-hover-color);
    border-color: var(--primary-hover-color);
}

/* Event and Action Blocks */
.block-category {
    margin-bottom: 12px;
}

.event-block, .action-block {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    margin-bottom: 4px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 11px;
    cursor: grab;
    transition: all 0.2s;
    user-select: none;
}

.event-block:hover, .action-block:hover {
    background: var(--border-color);
    transform: translateY(-1px);
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.3);
}

.event-block:active, .action-block:active {
    cursor: grabbing;
}

.event-block span, .action-block span {
    font-size: 14px;
}

/* Event Blocks - different colors */
.event-block[data-event^="keypressed"], 
.event-block[data-event^="buttonpressed"] {
    border-left: 3px solid var(--secondary-color);
}

.event-block[data-event="create"],
.event-block[data-event="step"],
.event-block[data-event="draw"] {
    border-left: 3px solid var(--success-color);
}

/* Action Blocks - different colors by category */
/* Audio actions - Purple */
.action-block[data-action="play_sound"],
.action-block[data-action="play_music"],
.action-block[data-action="stop_sound"],
.action-block[data-action="stop_music"] {
    border-left: 3px solid #9C27B0;
}

/* Movement actions - Orange */
.action-block[data-action="move_x"],
.action-block[data-action="move_y"],
.action-block[data-action="set_position"] {
    border-left: 3px solid var(--warning-color);
}

/* Variable actions - Cyan */
.action-block[data-action="set_variable"],
.action-block[data-action="random_number"],
.action-block[data-action="random_string"] {
    border-left: 3px solid #00BCD4;
}

/* List actions - Turquoise */
.action-block[data-action="list_create"],
.action-block[data-action="list_add"],
.action-block[data-action="list_remove"],
.action-block[data-action="list_contains"] {
    border-left: 3px solid #00d494;
}

/* Drawing actions - Green */
.action-block[data-action="draw_self"],
.action-block[data-action="draw_text"],
.action-block[data-action="draw_rectangle"],
.action-block[data-action="draw_circle"],
.action-block[data-action="draw_line"],
.action-block[data-action="draw_image"] {
    border-left: 3px solid var(--success-color);
}

/* Object management - Pink */
.action-block[data-action="create_instance"],
.action-block[data-action="destroy_self"] {
    border-left: 3px solid #E91E63;
}

/* Visual properties - Teal */
.action-block[data-action="set_alpha"],
.action-block[data-action="set_rotation"],
.action-block[data-action="set_scale"] {
    border-left: 3px solid #009688;
}

/* Game control - Deep Orange */
.action-block[data-action="quit_game"],
.action-block[data-action="wait"],
.action-block[data-action="change_scene"],
.action-block[data-action="import_scene"],
.action-block[data-action="restart_scene"] {
    border-left: 3px solid #FF5722;
}

/* Conditional actions - Blue */
/* Conditional actions - Blue */
.action-block[data-action="if_statement"],
.action-block[data-action="elseif_statement"],
.action-block[data-action="else_statement"],
.action-block[data-action="end_statement"],
.action-block[data-action="check_collision"],
.action-block[data-action="check_will_collide"] {
    border-left: 3px solid var(--primary-color);
}

/* Loop actions - Red */
.action-block[data-action="repeat"],
.action-block[data-action="while_loop"],
.action-block[data-action="for_loop"] {
    border-left: 3px solid #ff0000;
}

/* Code/Lua - Yellow */
.action-block[data-action="execute_lua"] {
    border-left: 3px solid var(--secondary-color);
}

/* Dragging states */


.drag-over {
    background: rgba(33, 150, 243, 0.1);
    border-color: var(--primary-color);
}

/* Object Tabs */
.object-tabs {
    display: inline-flex;
    align-items: center;
    gap: 0;
}

.object-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 12px;
    color: var(--text-muted);
    user-select: none;
}

.object-tab:hover {
    color: var(--text-color);
    background: var(--hover-color);
    transform: translateY(1px);
}

.object-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.object-tab-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
}

.object-tab-icon img {
    width: 14px;
    height: 14px;
    object-fit: contain;
}

.object-tab-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 2px;
    opacity: 0.5;
    transition: all 0.15s ease;
    font-size: 10px;
}

.object-tab-close:hover {
    opacity: 1;
    background: var(--danger-color);
    color: white;
}

.no-tabs-message {
    padding: 8px 12px;
    color: var(--text-muted);
    font-size: 12px;
    font-style: italic;
}

.concoct-event-editor {
    display: flex;
    flex: 1; /* Take remaining space after header */
    min-height: 0; /* Allow flexbox to shrink properly */
    overflow: hidden; /* Prevent overflow beyond viewport */
    background-color: var(--panel-bg);
}

.event-list-panel, .action-list-panel {
    flex: 1;
    background: var(--panel-bg);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    border-top: 0;
    min-height: 0; /* Allow flexbox to shrink properly */
    overflow: hidden; /* Ensure content doesn't overflow */
    border-left: 0;
}

.action-list-panel
{
    border-right: 0;
}

.event-list-panel {
    max-width: 30%;
}

.event-list-panel h4, .action-list-panel h4 {
    padding: 8px 12px;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
}

.action-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    gap: 8px;
}

.action-list-header h4 {
    padding: 0;
    margin: 0;
    border: none;
    background: none;
    flex: 1;
}

.action-list-header .btn-small {
    flex-shrink: 0;
    font-size: 11px;
    padding: 4px 8px;
}

.event-list, .action-list {
    flex: 1;
    padding: 8px;
    overflow-y: auto;
    min-height: 0; /* Allow flexbox to shrink below min-content */
}

.event-item, .action-item {
    padding: 8px 10px;
    margin-bottom: 4px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 1;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
}

.event-item:hover, .action-item:hover {
    background: var(--border-color);
    box-shadow: 0 5px 7px rgba(0, 0, 0, 0.1);
    transform: translateY(1px);
}

.event-item.selected {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.3);
}

.action-item.selected {
    border: 1px solid var(--primary-color);
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.3);
}

.event-item.selected span {
    color: rgba(255, 255, 255, 0.9) !important;
}

/* Event group styles */
.event-group-header {
    padding: 8px 12px;
    margin: 4px 0;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    font-size: 11px;
    transition: all 0.2s;
    user-select: none;
}

.event-group-header:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary-color);
}

.event-group-header.expanded {
    background: rgba(255, 255, 255, 0.05);
}

.event-group-container {
    margin-left: 8px;
    border-left: 2px solid rgba(255, 255, 255, 0.1);
    padding-left: 8px;
    margin-bottom: 4px;
}

.event-group-item {
    margin: 2px 0;
    font-size: 10px;
}

.action-list {
    position: relative;
}

.indent-guide-line {
    position: absolute;
    width: 2px;
    background: rgba(128, 128, 128, 0.3);
    pointer-events: none;
    z-index: 0;
}

.action-item .remove-action {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 2px;
    width: 16px;
    height: 16px;
    font-size: 10px;
    cursor: pointer;
    display: none;
}

.action-item:hover .remove-action {
    display: block;
}

.action-item .param-summary {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}

.action-item .action-name {
    flex: 1;
}

/* Category color coding */
.action-item.category-code {
    border-left: 3px solid #9b59b6;
}

.action-item.category-conditional {
    border-left: 3px solid #e74c3c;
}

.action-item.category-variables {
    border-left: 3px solid #3498db;
}

.action-item.category-loops {
    border-left: 3px solid #f39c12;
}

.action-item.category-lists {
    border-left: 3px solid #1abc9c;
}

.action-item.category-movement {
    border-left: 3px solid #2ecc71;
}

.action-item.category-drawing {
    border-left: 3px solid #e91e63;
}

.action-item.category-visual {
    border-left: 3px solid #673ab7;
}

.action-item.category-objects {
    border-left: 3px solid #9c27b0;
}

.action-item.category-camera {
    border-left: 3px solid #00bcd4;
}

.action-item.category-audio {
    border-left: 3px solid #4caf50;
}

.action-item.category-files {
    border-left: 3px solid #795548;
}

.action-item.category-timers {
    border-left: 3px solid #ff5722;
}

.action-item.category-game {
    border-left: 3px solid #607d8b;
}

/* Category colors for action library blocks */
.action-block.category-code {
    border-left: 3px solid #9b59b6;
}

.action-block.category-conditional {
    border-left: 3px solid #e74c3c;
}

.action-block.category-variables {
    border-left: 3px solid #3498db;
}

.action-block.category-loops {
    border-left: 3px solid #f39c12;
}

.action-block.category-lists {
    border-left: 3px solid #1abc9c;
}

.action-block.category-movement {
    border-left: 3px solid #2ecc71;
}

.action-block.category-drawing {
    border-left: 3px solid #e91e63;
}

.action-block.category-visual {
    border-left: 3px solid #673ab7;
}

.action-block.category-objects {
    border-left: 3px solid #9c27b0;
}

.action-block.category-camera {
    border-left: 3px solid #00bcd4;
}

.action-block.category-audio {
    border-left: 3px solid #4caf50;
}

.action-block.category-files {
    border-left: 3px solid #795548;
}

.action-block.category-timers {
    border-left: 3px solid #ff5722;
}

.action-block.category-game {
    border-left: 3px solid #607d8b;
}

.no-events, .no-actions {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    font-size: 11px;
}

/* Object Editor Header */
.object-editor-header {
    padding: 16px;
    background: var(--panel-bg);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0; /* Remove margin to work better with flex layout */
    flex-shrink: 0; /* Don't shrink this section */
}

.object-properties h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: var(--text-color);
}

/* Object Properties Panel */
.property-item {
    margin-bottom: 12px;
}

.property-item label {
    display: block;
    margin-bottom: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

.property-item select, .property-item input {
    width: 100%;
    padding: 6px 8px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-color);
    font-size: 12px;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.3);
}

.property-item input[readonly] {
    background: var(--border-color);
    color: var(--text-muted);
}

/* Scene Controls */
.scene-controls {
    display: flex;
    gap: 6px;
    align-items: center;
    font-size: 12px;
    flex-wrap: nowrap;
    min-width: 0;
    flex-shrink: 1;
    max-width: 100%;
}

.scene-controls label {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 2px;
    white-space: nowrap;
}

.zoom-controls span {
    min-width: 40px;
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
}

/* Drop zones in action list */
.action-list.drag-over {
    background: #0f5b9a11;
    border-color: var(--primary-color);
}

/* Actions Library Blocks */
.action-blocks {
    padding: 8px;
}

.block-category {
    margin-bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: flex-start;
    padding: 8px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.3);
}

.block-category h4 {
    font-size: 11px;
    color: var(--text-muted);
    margin: 0 0 8px 0;
    padding: 0;
    text-transform: uppercase;
    flex-basis: 100%;
    width: 100%;
}

.action-block {
    padding: 8px 10px;
    margin-bottom: 0;
    flex: 0 0 auto;
    font-size: 11px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: grab;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);
}

.action-block:hover {
    background: var(--border-color);
    transform: translateY(1px);
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);
}

.action-block:active {
    cursor: grabbing;
    transform: translateY(0);
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.3);
}

.action-block span {
    font-size: 12px;
}

/* Hide actions library by default (scene tab is default active) */
.actions-library-sidebar {
    display: none;
}

/* Responsive */
@media (max-width: 1200px) {
    .sidebar-left, .sidebar-right {
        width: 240px;
    }
}

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

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

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

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

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

.modal-content {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 24px;
    max-height: 90%;
    width: 80%;
    overflow-y: auto;
    box-shadow: 0 5px 5px rgba(0, 0, 0, 0.3);
}

.modal-content h3 {
    margin: 0 0 20px 0;
    color: var(--text-color);
    font-size: 18px;
}

#modalBody {
    margin-bottom: 20px;
}

#modalBody label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-color);
    font-size: 13px;
    font-weight: 500;
}

#modalBody input[type="text"],
#modalBody input[type="number"],
#modalBody textarea,
#modalBody select {
    width: 100%;
    padding: 8px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-color);
    font-size: 13px;
    font-family: 'Courier New', monospace;
    margin-bottom: 16px;
    box-sizing: border-box;
}

#modalBody textarea {
    min-height: 150px;
    resize: vertical;
}

#modalBody input[type="color"] {
    width: 60px;
    height: 32px;
    padding: 2px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 16px;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-buttons .btn {
    min-width: 80px;
}
/* Image Selection Grid */
.image-selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    padding: 12px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin: 15px 0;
}

.image-selection-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
    background: var(--panel-bg);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.image-selection-item:hover {
    border-color: var(--primary-color);
    transform: translateY(2px);
}

.image-selection-item.selected {
    border-color: var(--primary-color);
    background: var(--primary-hover-color);
}

.image-selection-item img {
    width: 100%;
    height: 48px;
    object-fit: contain;
    margin-bottom: 6px;
}

.image-selection-item span {
    font-size: 11px;
    color: var(--text-color);
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.image-selection-grid:empty::before {
    content: 'No images imported yet';
    display: block;
    text-align: center;
    color: var(--text-muted);
    padding: 40px;
    font-size: 14px;
}

.image-selection-content {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 24px;
    min-width: 50%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.3);
}

.image-selection-content h3 {
    margin: 0 0 20px 0;
    color: var(--text-color);
    font-size: 18px;
}

/* Toast Notification Animations */
@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* Expression Builder Segments */
.expr-segment {
    transition: all 0.2s ease;
}

.expr-segment:hover {
    border-color: var(--primary-color) !important;
}

.expr-segment.drag-over {
    border-color: var(--success-color) !important;
    background: rgba(76, 175, 80, 0.1) !important;
    transform: scale(1.05);
}

/* Drop position indicators */
.expr-segment.drop-before {
    border-left: 3px solid var(--success-color) !important;
    margin-left: 2px;
}

.expr-segment.drop-after {
    border-right: 3px solid var(--success-color) !important;
    margin-right: 2px;
}

.action-item.drop-before {
    border-top: 3px solid var(--success-color) !important;
    margin-top: 2px;
    transition: none !important;
}

.action-item.drop-after {
    border-bottom: 3px solid var(--success-color) !important;
    margin-bottom: 2px;
    transition: none !important;
}

/* Export Success Modal Animations */
@keyframes successPulse {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes confettiFall {
    to {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    animation: confettiFall 3s linear forwards;
}

@keyframes slideInUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

#exportSuccessModal .modal-content {
    animation: slideInUp 0.4s ease-out;
}

/* Expression Builder Palette Styles */
.expr-palette {
    flex-shrink: 0;
}

.expr-palette-btn {
    transition: all 0.15s ease;
}

.expr-palette-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.expr-palette-btn:active {
    transform: translateY(0);
}

/* When modal has expression builder, increase width */
#actionModal .modal-content:has(.expr-palette) {
    max-width: 900px;
    width: 90%;
}
