/* ============================================================
   BlenderHub — Dark Blender-inspired theme
   ============================================================ */

:root {
  --bg-base:    #1a1a1a;
  --bg-panel:   #232323;
  --bg-input:   #2a2a2a;
  --bg-hover:   #2f2f2f;
  --border:     #3a3a3a;
  --accent:     #e87d0d;   /* Blender orange */
  --accent-dim: #9e5608;
  --text:       #d0d0d0;
  --text-muted: #808080;
  --text-bright:#f0f0f0;
  --success:    #5aaa3f;
  --error:      #c0392b;
  --warning:    #f39c12;
  --info:       #3498db;
  --running:    #27ae60;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text);
  font-size: 13px;
  overflow: hidden;
}

/* ===== Layout ===== */

#app {
  display: grid;
  grid-template-rows: 40px 1fr 200px;
  grid-template-columns: 220px 1fr;
  grid-template-areas:
    "header  header"
    "sidebar content"
    "tabs    tabs";
  height: 100vh;
  gap: 0;
}

/* ===== Header ===== */

#header {
  grid-area: header;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: #111;
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

#header h1 {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 1px;
  white-space: nowrap;
}

#header .sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }

#project-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  min-width: 160px;
}

#header-actions { margin-left: auto; display: flex; gap: 6px; }

/* ===== Buttons ===== */

button {
  cursor: pointer;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  padding: 4px 10px;
  transition: opacity .15s, background .15s;
}
button:disabled { opacity: .4; cursor: not-allowed; }

.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #f08d23; }

.btn-secondary { background: var(--bg-input); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); }

.btn-danger  { background: var(--error); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #e74c3c; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #6bbf4e; }

.btn-ai { background: #5b3dca; color: #fff; }
.btn-ai:hover:not(:disabled) { background: #7a5de0; }

.btn-3d { background: #0e7490; color: #fff; }
.btn-3d:hover:not(:disabled) { background: #0891b2; }
.btn-3d:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-sm { padding: 3px 7px; font-size: 11px; }

/* ===== Sidebar ===== */

#sidebar {
  grid-area: sidebar;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#sidebar-header {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}

#file-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  cursor: pointer;
  user-select: none;
  border-radius: 3px;
  margin: 1px 4px;
}
.file-item:hover   { background: var(--bg-hover); }
.file-item.active  { background: #2c3a50; color: var(--text-bright); }
.file-item .icon   { font-size: 14px; flex-shrink: 0; }
.file-item .fname  { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .fsize  { font-size: 10px; color: var(--text-muted); flex-shrink: 0; }
.file-item .del-file { opacity: 0; font-size: 11px; color: var(--error); flex-shrink: 0; padding: 0 2px; background: none; }
.file-item:hover .del-file { opacity: 1; }

#sidebar-footer {
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
}
#sidebar-footer button { flex: 1; }

/* ===== Content area ===== */

#content {
  grid-area: content;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Editor toolbar */
#editor-toolbar {
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  padding: 4px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#current-file-label {
  color: var(--text-muted);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#current-file-label span { color: var(--text-bright); font-weight: 600; }

#editor-actions { display: flex; gap: 5px; }

/* Monaco editor wrapper */
#editor-wrapper {
  flex: 1;
  overflow: hidden;
  position: relative;
}
#monaco-editor {
  width: 100%;
  height: 100%;
}

/* ===== Console pane ===== */

#console-pane {
  height: 160px;
  flex-shrink: 0;
  background: #0d0d0d;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
#console-header {
  padding: 3px 10px;
  background: #161616;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}
#console-header .label { text-transform: uppercase; letter-spacing: .5px; }
#job-status-badge {
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
}
.status-queued    { background: #444; color: #aaa; }
.status-running   { background: #1a4a2a; color: #5aaa3f; }
.status-done      { background: #1a3a1a; color: #6aff5a; }
.status-error     { background: #4a1a1a; color: #ff5a5a; }
.status-cancelled { background: #3a3a1a; color: #aaaa5a; }

#console-output {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px;
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  font-size: 11px;
  line-height: 1.5;
  color: #c0c0c0;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ===== Bottom tabs ===== */

#bottom-area {
  grid-area: tabs;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-top: 2px solid var(--border);
}

#tab-bar {
  display: flex;
  gap: 0;
  background: #161616;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tab-btn {
  padding: 6px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  border-radius: 0;
  font-size: 12px;
}
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-btn:hover:not(.active) { color: var(--text); }

#tab-content { flex: 1; overflow: hidden; position: relative; }
.tab-pane { display: none; height: 100%; overflow: auto; padding: 10px; }
.tab-pane.active { display: block; }

/* Gallery */
#gallery-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-content: flex-start;
}
.gallery-item {
  position: relative;
  cursor: pointer;
  border: 2px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  transition: border-color .15s;
}
.gallery-item:hover { border-color: var(--accent); }
.gallery-item img {
  display: block;
  width: 120px;
  height: 90px;
  object-fit: cover;
}
.gallery-item .gname {
  font-size: 10px;
  text-align: center;
  padding: 2px 4px;
  background: #0008;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#gallery-empty {
  color: var(--text-muted);
  font-style: italic;
  padding: 20px;
}

/* 3D Viewer */
#viewer-container {
  width: 100%;
  height: 100%;
  min-height: 120px;
  background: #111;
  border-radius: 4px;
}
#viewer-hint {
  color: var(--text-muted);
  font-style: italic;
  padding: 20px;
}

/* ===== Modal ===== */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  width: 500px;
  max-width: 95vw;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-box h2 { font-size: 16px; color: var(--text-bright); }

.modal-box textarea, .modal-box input[type=text] {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 4px;
  resize: vertical;
  font-family: inherit;
  font-size: 13px;
}
.modal-box textarea { height: 100px; }

.modal-footer { display: flex; gap: 8px; justify-content: flex-end; }

/* ===== Scrollbars ===== */

::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #666; }

/* ===== Helpers ===== */

.hidden { display: none !important; }
