/* assets/css/builder.css */
/* ETUI Builder v31 */

* { box-sizing: border-box; }

body { 
    background: #050608; 
    color: #ccc; 
    font-family: 'Segoe UI', Tahoma, sans-serif; 
    margin: 0; 
    min-height: 100vh;
}

/* === THEME SUPPORT === */
body.theme-light {
    background: #f0f2f5;
    color: #333;
}

body.theme-light header {
    background: linear-gradient(to right, #e0e0e0, #f5f5f5);
    border-bottom-color: #ccc;
}

body.theme-light header h1 { color: #333; }
body.theme-light header h1 small { color: #666; }

body.theme-light .mod-tabs {
    background: #e8e8e8;
    border-bottom-color: #ccc;
}

body.theme-light .mod-tab { color: #666; }
body.theme-light .mod-tab:hover { color: #333; background: rgba(0,0,0,0.05); }

body.theme-light .sidebar {
    background: #f5f5f5;
    border-right-color: #ccc;
}

body.theme-light .sidebar strong { color: #333; }
body.theme-light .file-list a { color: #666; border-bottom-color: #ddd; }
body.theme-light .file-list a:hover { background: #e0e0e0; color: #333; }

body.theme-light input[type="text"],
body.theme-light input[type="number"],
body.theme-light input[type="password"],
body.theme-light select,
body.theme-light textarea {
    background: #fff;
    border-color: #ccc;
    color: #333;
}

body.theme-light .settings-panel,
body.theme-light .tutorial-panel,
body.theme-light .shortcuts-panel {
    background: #fff;
    border-color: #ccc;
}

body.theme-light .builder-box {
    background: #f8f8f8;
    border-color: #ccc;
}

body.theme-light .console-container {
    background: #f5f5f5;
    border-color: #ccc;
}

body.theme-light .console-header { background: #e8e8e8; }
body.theme-light .console-line { color: #666; }
body.theme-light .console-line.log { color: #333; }

body.theme-light .editor-container textarea {
    background: #fff;
    color: #333;
    border-color: #ccc;
}

body.theme-light .editor-toolbar,
body.theme-light .save-controls,
body.theme-light .zoom-controls {
    background: #e8e8e8;
    border-color: #ccc;
}

/* === FULLSCREEN EDITOR MODE === */
body.fullscreen-editor .sidebar,
body.fullscreen-editor .preview-container,
body.fullscreen-editor .builder-container,
body.fullscreen-editor .console-container,
body.fullscreen-editor .mod-tabs {
    display: none !important;
}

body.fullscreen-editor .workspace {
    padding: 0;
}

body.fullscreen-editor .tools-area {
    flex: 1;
    min-height: calc(100vh - 60px);
}

body.fullscreen-editor .editor-container {
    flex: 1;
    min-height: calc(100vh - 120px);
    max-height: none;
}

body.fullscreen-editor .editor-container textarea {
    min-height: calc(100vh - 180px);
}

/* === HEADER === */
header { 
    background: linear-gradient(to right, #111, #1a1a2e);
    padding: 10px 20px; 
    border-bottom: 1px solid #333; 
    height: 50px; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    position: sticky;
    top: 0;
    z-index: 1000;
}

header h1 { 
    margin: 0; 
    font-size: 18px; 
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

header h1 small { color: #888; font-weight: normal; font-size: 12px; }
header h1 .author { color: #ff5722; font-size: 11px; font-weight: normal; margin-left: 10px; }

.header-buttons { display: flex; gap: 8px; }
.header-buttons button.active { background: #ff5722; }

/* === MOD TABS === */
.mod-tabs { 
    display: flex; 
    background: #0a0a0a; 
    border-bottom: 1px solid #333; 
    padding: 0 10px; 
    overflow-x: auto; 
    flex-shrink: 0;
    align-items: center;
}

.mod-tabs-toggle {
    background: transparent;
    border: none;
    color: #888;
    font-size: 16px;
    padding: 8px;
    cursor: pointer;
    flex-shrink: 0;
}

.mod-tabs-toggle:hover { color: #fff; }

.mod-tabs-inner {
    display: flex;
    flex: 1;
    overflow-x: auto;
}

.mod-tabs.collapsed .mod-tabs-inner { display: none; }
.mod-tabs.collapsed { padding: 0 5px; }

.mod-tab { 
    padding: 10px 16px; 
    color: #888; 
    text-decoration: none; 
    font-size: 13px; 
    border-bottom: 3px solid transparent; 
    white-space: nowrap;
    transition: all 0.2s;
}

.mod-tab:hover { color: #fff; background: rgba(255,255,255,0.05); }
.mod-tab.active { color: #fff; border-bottom-color: var(--mod-color, #2563eb); }

/* === MAIN LAYOUT === */
main { display: flex; min-height: calc(100vh - 90px); }

/* === SIDEBAR === */
.sidebar { 
    width: 200px; 
    background: #0b0c10; 
    border-right: 1px solid #333; 
    display: flex; 
    flex-direction: column; 
    padding: 10px; 
    position: sticky;
    top: 90px;
    height: calc(100vh - 90px);
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar strong { color: #fff; margin-bottom: 8px; display: block; font-size: 12px; }
.sidebar-search { margin-bottom: 8px; }
.sidebar-search input { width: 100%; padding: 5px 8px; font-size: 11px; }

.file-list { flex: 1; overflow-y: auto; }
.file-list a { 
    display: block; 
    padding: 5px 8px; 
    color: #888; 
    text-decoration: none; 
    font-size: 11px; 
    border-bottom: 1px solid #1a1a1a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-list a:hover { background: #222; color: #fff; }
.file-list a.active { background: #2563eb; color: #fff; }
.file-category {
    padding: 6px 8px 4px;
    color: #aaa;
    font-size: 10px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    background: #111;
    border-bottom: 1px solid #1a1a1a;
}
.no-files.small { font-size: 10px; padding-left: 12px; }

.no-files { color: #555; padding: 10px; font-size: 11px; }
.current-file { 
    padding: 8px; 
    background: #1a1a1a; 
    border-radius: 4px; 
    font-size: 11px; 
    color: #4ade80;
    margin-top: 10px;
}

/* === FORM ELEMENTS === */
input[type="text"], input[type="number"], input[type="password"], select, textarea { 
    width: 100%; 
    padding: 6px 8px; 
    background: #111; 
    border: 1px solid #444; 
    color: #ddd; 
    font-size: 12px; 
    border-radius: 3px;
}

input:focus, select:focus, textarea:focus { border-color: #2563eb; outline: none; }

button { 
    cursor: pointer; 
    background: #2563eb; 
    border: none; 
    color: white; 
    padding: 6px 12px; 
    border-radius: 4px; 
    font-size: 11px; 
    transition: background 0.2s;
}

button:hover { background: #1d4ed8; }
button.secondary { background: #444; }
button.secondary:hover { background: #555; }
button.small { padding: 3px 6px; font-size: 10px; }
button.full-width { width: 100%; margin-top: 5px; }
button.active { background: #ff5722; }

.close-btn { 
    float: right; 
    background: transparent; 
    color: #888; 
    font-size: 18px; 
    padding: 0 5px;
}

/* === WORKSPACE === */
.workspace { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    padding: 10px;
    gap: 10px;
    min-width: 0;
}

/* === SETTINGS PANEL === */
.settings-panel, .tutorial-panel, .shortcuts-panel { 
    background: #111; 
    border: 1px solid #333; 
    border-radius: 4px; 
    padding: 15px; 
    display: none;
    max-height: 400px;
    overflow-y: auto;
}

.settings-panel.visible, .tutorial-panel.visible, .shortcuts-panel.visible { display: block; }

.settings-panel h4, .tutorial-panel h4, .shortcuts-panel h4 { 
    margin: 0 0 10px 0; 
    color: #60a5fa; 
    font-size: 13px; 
    border-bottom: 1px solid #333; 
    padding-bottom: 8px; 
}

.settings-info { font-size: 11px; color: #666; margin-bottom: 15px; }
.settings-section { margin-bottom: 15px; }
.settings-section h5 { margin: 0 0 8px 0; color: #888; font-size: 11px; text-transform: uppercase; }
.settings-row { display: flex; gap: 10px; margin-bottom: 8px; align-items: center; }
.settings-row label { font-size: 11px; color: #888; min-width: 120px; }
.settings-row input { flex: 1; max-width: 100px; }

/* === KEYBOARD SHORTCUTS PANEL === */
.shortcuts-content { font-size: 12px; }
.shortcut-section { margin-bottom: 15px; }
.shortcut-section h5 { color: #60a5fa; margin: 0 0 8px 0; font-size: 13px; }
.shortcut-row { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 4px 0; 
    border-bottom: 1px solid #222; 
}
.shortcut-row kbd {
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 3px;
    padding: 2px 8px;
    font-family: monospace;
    font-size: 11px;
    color: #4ade80;
}
.shortcut-row span { color: #888; }

/* === TUTORIAL PANEL === */
.tutorial-content { font-size: 12px; line-height: 1.6; }
.tutorial-content h5 { color: #60a5fa; margin: 15px 0 8px 0; font-size: 13px; }
.tutorial-content p { margin: 0 0 10px 0; }
.tutorial-content ul { margin: 5px 0 10px 20px; padding: 0; }
.tutorial-content li { margin: 3px 0; }
.tutorial-content code { background: #1a1a1a; padding: 2px 5px; border-radius: 3px; color: #4ade80; }
.tutorial-content pre { 
    background: #1a1a1a; 
    padding: 10px; 
    border-radius: 4px; 
    overflow-x: auto; 
    color: #4ade80;
    font-size: 11px;
}

/* === PREVIEW === */
.preview-container { 
    background: #000; 
    border: 1px solid #444; 
    border-radius: 4px;
    display: flex; 
    flex-direction: column;
    position: relative;
    resize: vertical;
    overflow: auto;
    min-height: 250px;
    max-height: 80vh;
}

.preview-scroller {
    overflow: auto;
    background: repeating-conic-gradient(#151515 0% 25%, #0a0a0a 0% 50%) 50% / 20px 20px;
    flex: 1;
    min-height: 200px;
}

#preview-zoom-wrapper {
    position: relative; 
    width: 640px; 
    height: 480px; 
    box-shadow: 0 0 30px rgba(0,0,0,0.8); 
    margin: 20px;
    transform-origin: 0 0;
}

.preview-bg-image {
    width: 100%; 
    height: 100%; 
    position: absolute; 
    top: 0; left: 0; 
    z-index: 0;
    background-size: cover;
    pointer-events: none;
}

#preview-stage {
    position: absolute; 
    top: 0; left: 0; 
    width: 640px; 
    height: 480px; 
    z-index: 1;
}

.live-edit-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 10;
    pointer-events: none;
    display: none;
}

.live-edit-overlay.active {
    display: block;
    pointer-events: none;
}

.live-edit-box {
    position: absolute;
    border: 1px dashed #ff9800;
    box-shadow: 0 0 0 1px rgba(255, 152, 0, 0.35);
    background: rgba(255, 152, 0, 0.04);
    pointer-events: auto;
}

.live-edit-handle {
    width: 8px;
    height: 8px;
    background: #ff9800;
    border: 1px solid #111;
    position: absolute;
    border-radius: 2px;
}

.live-edit-handle.nw { top: -5px; left: -5px; cursor: nwse-resize; }
.live-edit-handle.ne { top: -5px; right: -5px; cursor: nesw-resize; }
.live-edit-handle.sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.live-edit-handle.se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.live-edit-handle.n { top: -5px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.live-edit-handle.s { bottom: -5px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.live-edit-handle.w { left: -5px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.live-edit-handle.e { right: -5px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }

.live-edit-toolbar {
    position: absolute;
    top: -26px;
    left: 0;
    display: flex;
    gap: 6px;
    align-items: center;
    background: #111;
    color: #ff9800;
    font-size: 10px;
    padding: 2px 6px;
    border: 1px solid #ff9800;
    border-radius: 3px;
    pointer-events: auto;
}

.live-edit-toolbar button {
    background: #ff9800;
    color: #111;
    padding: 2px 6px;
    font-size: 10px;
    border-radius: 2px;
}

.zoom-controls { 
    padding: 8px 15px; 
    background: #111; 
    border-top: 1px solid #333; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    font-size: 11px;
    flex-wrap: wrap;
    gap: 10px;
}

.zoom-controls > div { display: flex; align-items: center; gap: 8px; }
.zoom-controls input[type="range"] { width: 100px; }
.zoom-controls select { width: auto; min-width: 80px; }

.pixel-display { 
    background: #1a1a1a; 
    padding: 4px 10px; 
    border-radius: 3px; 
    font-family: monospace;
    color: #4ade80;
}

.pixel-display span:first-child, .pixel-display span:nth-child(3) { color: #888; }

/* === TOOLS AREA === */
.tools-area { display: flex; gap: 10px; min-height: 250px; }

.editor-container { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    min-width: 0;
    resize: vertical;
    overflow: auto;
    min-height: 200px;
    max-height: 80vh;
}

.save-controls { 
    display: flex; 
    gap: 8px; 
    align-items: center; 
    padding: 8px; 
    background: #111; 
    border: 1px solid #333; 
    border-radius: 4px; 
    margin-bottom: 8px; 
    flex-wrap: wrap;
}

.save-controls input[type="password"] { width: 100px; }
.save-controls select { width: 100px; }
.checkbox-label { font-size: 11px; color: #888; display: flex; align-items: center; gap: 4px; }
.id-display { color: #888; font-size: 10px; font-family: monospace; }

.status-message { 
    padding: 8px; 
    border-radius: 4px; 
    font-size: 11px; 
    display: none; 
    margin-bottom: 8px;
}
.status-message.success { display: block; background: rgba(74,222,128,0.2); color: #4ade80; }
.status-message.error { display: block; background: rgba(248,113,113,0.2); color: #f87171; }

.permalink { 
    background: #1a1a1a; 
    padding: 8px; 
    border-radius: 4px; 
    font-family: monospace; 
    font-size: 10px; 
    color: #4ade80; 
    word-break: break-all; 
    display: none; 
    margin-bottom: 8px;
}
.permalink.visible { display: block; }

.editor-toolbar { 
    display: flex; 
    gap: 5px; 
    margin-bottom: 5px;
    padding: 5px;
    background: #111;
    border-radius: 4px;
}
.editor-toolbar button { padding: 4px 8px; }
.toolbar-separator { width: 1px; background: #333; margin: 0 5px; }

.editor-container textarea { 
    flex: 1; 
    background: #080808; 
    color: #0f0; 
    border: 1px solid #333; 
    font-family: 'Consolas', 'Monaco', monospace; 
    resize: none; 
    font-size: 11px; 
    padding: 10px;
    line-height: 1.4;
    min-height: 200px;
}

/* === BUILDER PANEL === */
.builder-container { 
    width: 300px; 
    display: flex; 
    flex-direction: column; 
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
    flex-shrink: 0;
}

.builder-box { 
    background: #161616; 
    border: 1px solid #333; 
    padding: 10px; 
    border-radius: 4px;
}

.builder-box h3 { 
    margin: 0 0 8px 0; 
    color: #60a5fa; 
    font-size: 12px; 
    border-bottom: 1px solid #333;
    padding-bottom: 5px;
    cursor: pointer;
    user-select: none;
}

.builder-box h3::before { content: '▼ '; font-size: 9px; }
.builder-box.collapsed h3::before { content: '▶ '; }
.builder-box.collapsed .builder-content { display: none; }

.builder-row { display: flex; gap: 6px; margin-bottom: 6px; }
.builder-row > div { flex: 1; min-width: 0; }
.builder-row label { font-size: 9px; color: #888; display: block; margin-bottom: 2px; text-transform: uppercase; }

/* === BUILDER CONTAINER COLLAPSIBLE === */
.builder-header {
    padding: 8px 10px;
    background: #111;
    border: 1px solid #333;
    border-radius: 4px;
    font-size: 12px;
    color: #60a5fa;
    cursor: pointer;
    margin-bottom: 8px;
}

.builder-header:hover { background: #1a1a1a; }

.builder-container.collapsed .builder-box { display: none; }
.builder-container.collapsed .builder-header { margin-bottom: 0; }

/* === CONSOLE === */
.console-container {
    background: #0a0a0a;
    border: 1px solid #333;
    border-radius: 4px;
    height: 180px;
    display: flex;
    flex-direction: column;
    resize: vertical;
    overflow: auto;
    min-height: 80px;
    max-height: 80vh;
}

.console-container.collapsed {
    height: auto !important;
    min-height: auto;
    resize: none;
}

.console-container.collapsed .console-output { display: none; }

.console-header {
    padding: 5px 10px;
    background: #111;
    border-bottom: 1px solid #333;
    font-size: 11px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.console-actions {
    display: flex;
    gap: 5px;
}

.console-output {
    flex: 1;
    overflow-y: auto;
    padding: 5px 10px;
    font-family: 'Consolas', monospace;
    font-size: 10px;
}

.console-line { margin: 2px 0; color: #888; }
.console-line.log { color: #aaa; }
.console-line.error { color: #f87171; }
.console-line.warn { color: #fbbf24; }
.console-line .time { color: #555; }

/* === PREVIEW ITEMS === */
.preview-item { 
    position: absolute; 
    box-sizing: border-box; 
    pointer-events: none;
    overflow: visible; /* Allow slider thumb to extend beyond bounds like in ET */
}

.preview-item.selected {
    outline: 2px solid #ff5722;
    outline-offset: 2px;
}

.preview-text-inner { 
    position: absolute; 
    white-space: pre-wrap; 
    text-shadow: 1px 1px 0px rgba(0,0,0,1); 
    line-height: 1.0; 
    width: max-content; 
}

.preview-item.window-black { 
    background-color: rgba(0,0,0,0.85); 
    border: 1px solid rgba(128,128,128,0.5); 
}

.border-kcgradient {
    border: 6px solid transparent;
    position: relative;
}

.border-kcgradient::before {
    content: '';
    position: absolute;
    top: -6px; left: -6px; right: -6px; bottom: -6px;
    background: linear-gradient(135deg, 
        rgba(80,80,80,1) 0%, 
        rgba(60,60,60,0.8) 25%, 
        rgba(40,40,40,0.5) 50%, 
        rgba(20,20,20,0.2) 75%, 
        rgba(0,0,0,0) 100%);
    z-index: -1;
}

/* === ITEM-SPECIFIC STYLES === */
.checkbox-img {
    width: 8px;
    height: 8px;
}

.slider-track {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    /* Size and background set via JS with actual slider image */
}

.slider-thumb {
    position: absolute;
    left: 30%;
    top: 50%;
    transform: translate(-50%, -50%);
    cursor: pointer;
    /* Size and background set via JS with actual slider image */
}

/* === LISTBOX SCROLLBAR === */
.listbox-scrollbar {
    z-index: 10;
}

.scrollbar-arrow-up,
.scrollbar-arrow-down {
    cursor: pointer;
}

.scrollbar-arrow-up:hover,
.scrollbar-arrow-down:hover {
    filter: brightness(1.3);
}

.scrollbar-track {
    cursor: default;
}

.scrollbar-thumb {
    cursor: pointer;
}

.scrollbar-thumb:hover {
    filter: brightness(1.2);
}

.clickable {
    cursor: pointer;
}

.clickable:hover {
    filter: brightness(1.2);
}

/* === FONTS === */
.font-ariblk { font-family: "Arial Black", sans-serif; font-weight: 900; }
.font-courbd { font-family: "Courier New", monospace; font-weight: bold; }
.font-default { font-family: "Courier New", monospace; }

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #111; }
::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #555; }
