/* ============================================================
   Gaxity Code — style.css
   Dark developer-tool theme. Mobile-first. No frameworks.
   ============================================================ */

/* ---------- RESET & TOKENS ---------- */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg:            #0a0e14;
  --bg-1:          #0f141c;
  --bg-2:          #141b26;
  --bg-3:          #1a2332;
  --border:        #1e2a3a;
  --border-2:      #283548;
  --text:          #d6e0f0;
  --text-dim:      #7a8ba8;
  --text-faint:    #4a5a72;
  --accent:        #4c8dff;
  --accent-hover:  #6ba3ff;
  --accent-dim:    #1a2d52;
  --green:         #3dd68c;
  --yellow:        #f0b429;
  --red:           #f05e5e;
  --purple:        #a78bfa;
  --radius:        8px;
  --radius-sm:     5px;
  --radius-lg:     12px;
  --font:          -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  --mono:          "SF Mono", "Cascadia Code", "Fira Code", Consolas, "Liberation Mono", Menlo, monospace;
  --shadow:        0 4px 24px rgba(0,0,0,.4);
  --topbar-h:      52px;
}

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#app, .app { height: 100%; display: flex; flex-direction: column; }

/* ---------- UTILITIES ---------- */
.hidden { display: none !important; }
.muted  { color: var(--text-dim); }
.only-mobile  { display: none; }
.only-desktop { display: inline-flex; }

@media (max-width: 767px) {
  .only-mobile  { display: inline-flex; }
  .only-desktop { display: none !important; }
}

/* ---------- SCROLLBAR ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:hover  { background: var(--bg-3); border-color: var(--text-faint); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; pointer-events: none; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn .ico { font-size: 15px; line-height: 1; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-dim);
  font-size: 18px; cursor: pointer;
  transition: background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: var(--bg-3); color: var(--text); }

/* ---------- TOP BAR ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: var(--topbar-h);
  padding: 0 14px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), #7c5cff);
  color: #fff; font-size: 13px; font-weight: 700;
  font-family: var(--mono);
  letter-spacing: -1px;
}
.brand-text { font-size: 16px; font-weight: 600; letter-spacing: -.2px; }
.brand-text em { font-style: normal; color: var(--accent); font-weight: 700; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- SCREENS ---------- */
.screen {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; padding: 32px 24px; text-align: center;
}
.screen-title { font-size: 20px; font-weight: 600; margin: 0; }
.screen-sub   { font-size: 14px; color: var(--text-dim); margin: 0; max-width: 420px; }
.screen-icon  { font-size: 40px; line-height: 1; margin-bottom: 4px; }
.screen-actions { margin-top: 10px; }

.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- PROJECT ---------- */
.project { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.project-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  padding: 14px 18px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.project-head-main { min-width: 0; flex: 1; }
.project-name {
  font-size: 18px; font-weight: 650; margin: 0 0 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.project-desc {
  font-size: 13px; color: var(--text-dim); margin: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.project-meta { display: flex; gap: 6px; flex-wrap: wrap; flex-shrink: 0; }

.chip {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  font-size: 11.5px; font-weight: 500;
  color: var(--text-dim);
  white-space: nowrap;
}
.chip-ok { color: var(--green); border-color: rgba(61,214,140,.3); background: rgba(61,214,140,.08); }

/* ---------- WORKSPACE ---------- */
.workspace {
  flex: 1; display: flex; overflow: hidden; position: relative;
}

/* ---------- SIDEBAR ---------- */
.sidebar {
  width: 240px; flex-shrink: 0;
  display: flex; flex-direction: column;
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px 6px;
}
.sidebar-title {
  font-size: 11px; font-weight: 700; letter-spacing: .8px;
  text-transform: uppercase; color: var(--text-faint);
}
.sidebar-search { padding: 0 10px 8px; }
.sidebar-search input {
  width: 100%; padding: 6px 10px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text); font-size: 12.5px; font-family: var(--font);
  outline: none;
}
.sidebar-search input:focus { border-color: var(--accent); }
.sidebar-search input::placeholder { color: var(--text-faint); }

.file-tree { flex: 1; overflow-y: auto; padding: 4px 6px 16px; }

/* file tree items */
.tree-item {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
  transition: background .12s, color .12s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.tree-item:hover { background: var(--bg-2); color: var(--text); }
.tree-item.is-active { background: var(--accent-dim); color: var(--accent); font-weight: 550; }
.tree-item .tree-icon { font-size: 14px; flex-shrink: 0; width: 18px; text-align: center; }
.tree-item .tree-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tree-dir {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px; font-weight: 600;
  color: var(--text-dim);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.tree-dir:hover { background: var(--bg-2); }
.tree-dir .tree-arrow { font-size: 10px; width: 14px; text-align: center; transition: transform .15s; }
.tree-dir.is-open .tree-arrow { transform: rotate(90deg); }
.tree-children { padding-left: 12px; }

.tree-empty {
  padding: 20px 12px; text-align: center;
  font-size: 12.5px; color: var(--text-faint);
}

.sidebar-scrim {
  position: fixed; inset: 0; z-index: 29;
  background: rgba(0,0,0,.55);
  display: none;
}

/* ---------- PANEL ---------- */
.panel {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; min-width: 0;
}

.panel-tabs {
  display: flex; align-items: center; gap: 8px;
  padding: 0 10px;
  height: 42px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tabs { display: flex; gap: 2px; }
.tab {
  padding: 6px 14px;
  border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-dim);
  font-family: var(--font); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.tab:hover { background: var(--bg-2); color: var(--text); }
.tab.is-active { background: var(--bg-3); color: var(--text); font-weight: 600; }

.panel-tabs-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.device-group {
  display: flex; gap: 1px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.device {
  border: none !important; border-radius: 0 !important;
  padding: 4px 9px !important;
  background: transparent !important;
}
.device.is-active { background: var(--accent-dim) !important; color: var(--accent) !important; }

/* ---------- PANES ---------- */
.panes { flex: 1; display: flex; overflow: hidden; }
.pane { display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.pane-code { flex: 1; }
.pane-preview { flex: 1; }

/* view switching */
.panes[data-view="code"] .pane-preview { display: none; }
.panes[data-view="preview"] .pane-code { display: none; }
.panes[data-view="split"] .pane-code { flex: 1 1 50%; }
.panes[data-view="split"] .pane-preview { flex: 1 1 50%; border-left: 1px solid var(--border); }

/* ---------- CODE VIEWER ---------- */
.code-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.file-path {
  font-family: var(--mono); font-size: 12.5px;
  color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.code-toolbar-actions { display: flex; gap: 6px; flex-shrink: 0; }

.code-scroll {
  flex: 1; overflow: auto;
  background: var(--bg);
  position: relative;
}
.code-inner {
  display: flex; min-height: 100%;
  min-width: max-content;
}

.code-gutter {
  flex-shrink: 0; width: 52px;
  padding: 14px 10px 14px 0;
  text-align: right;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
  color: var(--text-faint);
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  user-select: none;
  white-space: pre;
  position: sticky; left: 0; z-index: 2;
}

.code-pre {
  margin: 0; padding: 14px 18px;
  flex: 1;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
  tab-size: 2;
}
.code-content {
  display: block;
  font-family: inherit; font-size: inherit; line-height: inherit;
  white-space: pre;
  color: var(--text);
  background: transparent;
}
.code-content code { font-family: inherit; }

/* Prism overrides for consistent theming */
.code-content .token.comment,
.code-content .token.prolog,
.code-content .token.doctype,
.code-content .token.cdata { color: #5c6e8a; }
.code-content .token.punctuation { color: #8a9bb5; }
.code-content .token.property,
.code-content .token.tag,
.code-content .token.boolean,
.code-content .token.number,
.code-content .token.constant,
.code-content .token.symbol { color: #f08c6e; }
.code-content .token.selector,
.code-content .token.attr-name,
.code-content .token.string,
.code-content .token.char,
.code-content .token.builtin { color: #7ec699; }
.code-content .token.operator,
.code-content .token.entity,
.code-content .token.url,
.code-content .language-css .token.string { color: #a5d6ff; }
.code-content .token.atrule,
.code-content .token.attr-value,
.code-content .token.keyword { color: #c792ea; }
.code-content .token.function,
.code-content .token.class-name { color: #82aaff; }
.code-content .token.regex,
.code-content .token.important,
.code-content .token.variable { color: #f0b429; }
.code-content .token.important,
.code-content .token.bold { font-weight: 700; }
.code-content .token.italic { font-style: italic; }

/* ---------- PREVIEW ---------- */
.preview-stage {
  flex: 1; display: flex; flex-direction: column;
  align-items: center;
  background: var(--bg);
  padding: 0;
  overflow: auto;
  position: relative;
}

.preview-frame-wrap {
  width: 100%; height: 100%;
  border: none;
  background: #fff;
  transition: width .2s, max-width .2s;
  flex-shrink: 0;
}
.preview-stage[data-device="desktop"] .preview-frame-wrap { max-width: 100%; }
.preview-stage[data-device="tablet"] .preview-frame-wrap {
  max-width: 768px;
  border-left: 1px solid var(--border-2);
  border-right: 1px solid var(--border-2);
}
.preview-stage[data-device="mobile"] .preview-frame-wrap {
  max-width: 390px;
  border-left: 1px solid var(--border-2);
  border-right: 1px solid var(--border-2);
}

#previewFrame {
  width: 100%; height: 100%;
  border: none;
  display: block;
}

.preview-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 24px; text-align: center;
  background: var(--bg-1);
}
.preview-empty-title { font-size: 15px; font-weight: 600; margin: 0; }

/* ---------- CONSOLE ---------- */
.console-panel {
  flex-shrink: 0;
  max-height: 140px;
  display: flex; flex-direction: column;
  border-top: 1px solid var(--border);
  background: var(--bg-1);
}
.console-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px;
  cursor: pointer;
  user-select: none;
}
.console-title {
  font-size: 11.5px; font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase; color: var(--text-faint);
  display: flex; align-items: center; gap: 6px;
}
.console-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px;
  background: var(--bg-3); color: var(--text-dim);
  font-size: 10px; font-weight: 700;
}
.console-badge.has-errors { background: rgba(240,94,94,.2); color: var(--red); }
.console-body {
  flex: 1; overflow-y: auto;
  padding: 0 12px 8px;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.5;
}
.console-line {
  display: flex; gap: 8px;
  padding: 2px 0;
  border-bottom: 1px solid rgba(255,255,255,.03);
}
.console-line .cl-type { flex-shrink: 0; font-weight: 700; width: 42px; }
.console-line.log   .cl-type { color: var(--text-faint); }
.console-line.warn  .cl-type { color: var(--yellow); }
.console-line.error .cl-type { color: var(--red); }
.console-line.error .cl-msg  { color: #f0a0a0; }
.console-line .cl-msg { color: var(--text-dim); word-break: break-word; white-space: pre-wrap; }

/* ---------- TOAST ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(80px);
  padding: 10px 20px;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  color: var(--text); font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 100;
  max-width: 90vw; text-align: center;
}
.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   RESPONSIVE — MOBILE
   ============================================================ */
@media (max-width: 767px) {
  :root { --topbar-h: 48px; }

  .brand-text { font-size: 14px; }
  .brand-mark { width: 26px; height: 26px; font-size: 11px; }

  .topbar { padding: 0 8px; }
  .topbar-actions { gap: 5px; }
  .topbar-actions .btn { padding: 6px 10px; font-size: 12px; }
  .topbar-actions .btn .lbl { display: none; }
  .topbar-actions .btn .ico { font-size: 16px; }
  .topbar-actions .btn-primary .lbl { display: inline; }

  .project-head { padding: 10px 12px; gap: 8px; }
  .project-name { font-size: 15px; }
  .project-desc { font-size: 12px; }
  .project-meta { gap: 4px; }
  .chip { font-size: 10.5px; padding: 2px 8px; }

  /* sidebar slides over */
  .sidebar {
    position: fixed; top: var(--topbar-h); bottom: 0; left: 0;
    z-index: 30;
    width: 78vw; max-width: 300px;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.5);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-scrim.is-visible { display: block; }

  .panel-tabs { height: 40px; padding: 0 6px; gap: 4px; }
  .tab { padding: 5px 10px; font-size: 12.5px; }

  .panel-tabs-right { gap: 3px; }
  .device-group { display: none; }

  .code-gutter { width: 40px; font-size: 11px; padding-right: 6px; }
  .code-pre { padding: 12px 10px; font-size: 11.5px; }

  .code-toolbar { padding: 6px 10px; }
  .file-path { font-size: 11.5px; max-width: 50vw; }

  .console-panel { max-height: 110px; }

  /* hide split tab on mobile via only-desktop */
}

/* Extra small phones */
@media (max-width: 360px) {
  .topbar-actions .btn-primary .lbl { display: none; }
  .panel-tabs-right .btn { padding: 4px 6px; }
}

/* ---------- PRINT / REDUCED MOTION ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}