/* ============================================================
   Benzo Code — editor.css
   Fully responsive. Mobile-first drawer layout.
   ============================================================ */
html,body{height:100%;overflow:hidden;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}

.ed-shell{
  display:grid;
  grid-template-rows:52px 1fr;
  height:100vh;
  height:100dvh;
  background:var(--bg);
}

/* ============================================================
   TOP BAR — desktop
   ============================================================ */
.ed-top{
  display:flex;align-items:center;gap:8px;
  padding:0 12px;
  background:var(--bg-2);
  border-bottom:1px solid var(--border);
  position:relative;z-index:10;
}
.ed-top .brand{font-size:15px;gap:8px}
.ed-top .brand-mark{width:26px;height:26px}
.ed-top .brand .wordmark span{
  background:linear-gradient(120deg,#06b6d4,#10b981,#84cc16);
  -webkit-background-clip:text;background-clip:text;color:transparent;font-weight:800;
}

.ed-title{
  padding:6px 10px;background:transparent;
  border:1px solid transparent;border-radius:8px;
  font-size:13px;font-weight:700;color:var(--text);
  width:200px;font-family:inherit;
  min-width:0;
}
.ed-title:hover{background:var(--bg-3)}
.ed-title:focus{outline:0;background:var(--bg-3);border-color:var(--accent)}

.ed-spacer{flex:1}

.ed-btn{
  display:inline-flex;align-items:center;gap:6px;
  padding:8px 14px;border-radius:9px;
  background:var(--bg-3);color:var(--text);
  font-size:12.5px;font-weight:700;
  border:1px solid var(--border);
  cursor:pointer;font-family:inherit;
  transition:all .15s;white-space:nowrap;
  min-height:36px;
}
.ed-btn:hover{background:var(--bg-4)}
.ed-btn.primary{
  background:linear-gradient(120deg,#06b6d4,#10b981);
  color:#fff;border-color:transparent;
  box-shadow:0 4px 12px var(--accent-glow);
}
.ed-btn.primary:hover{filter:brightness(1.06)}
.ed-btn.run{
  background:linear-gradient(120deg,#10b981,#84cc16);
  color:#fff;border-color:transparent;
  box-shadow:0 4px 12px rgba(16,185,129,.3);
}
.ed-btn.run:hover{filter:brightness(1.06)}
.ed-btn:disabled{opacity:.5;cursor:not-allowed}

.ed-icon-btn{
  width:36px;height:36px;border-radius:9px;
  display:flex;align-items:center;justify-content:center;
  background:var(--bg-3);border:1px solid var(--border);
  color:var(--text);font-size:15px;
  cursor:pointer;flex-shrink:0;
}
.ed-icon-btn:hover{background:var(--bg-4)}

/* ============================================================
   BODY — 3 columns on desktop
   ============================================================ */
.ed-body{
  display:grid;
  grid-template-columns:220px 1fr 1fr;
  overflow:hidden;
  min-height:0;
}

/* SIDEBAR */
.ed-side{
  background:var(--bg-2);
  border-right:1px solid var(--border);
  overflow-y:auto;
  display:flex;flex-direction:column;
  min-height:0;
  position:relative;
}
.ed-side-head{
  padding:12px 14px 8px;
  font-size:10px;font-weight:800;
  letter-spacing:1.4px;text-transform:uppercase;
  color:var(--text-3);
}
.ed-files{padding:0 8px 12px;flex:1;overflow-y:auto}
.ed-file{
  display:flex;align-items:center;gap:8px;
  padding:8px 10px;border-radius:8px;
  font-size:13px;font-weight:600;
  color:var(--text-2);
  cursor:pointer;transition:all .12s;
  user-select:none;margin-bottom:2px;
}
.ed-file:hover{background:var(--bg-3);color:var(--text)}
.ed-file.active{background:var(--accent-soft);color:var(--accent-2)}
html[data-theme="dark"] .ed-file.active{color:var(--accent)}
.ed-file .ficon{
  width:18px;height:18px;border-radius:4px;
  display:flex;align-items:center;justify-content:center;
  font-size:9px;font-weight:900;color:#fff;flex-shrink:0;
}
.ed-file .ficon.html{background:#e34c26}
.ed-file .ficon.css{background:#264de4}
.ed-file .ficon.js{background:#f7df1e;color:#000}
.ed-file .ficon.py{background:#3776ab}
.ed-file .ficon.ts{background:#3178c6}
.ed-file .ficon.json{background:#8b8b8b}
.ed-file .ficon.md{background:#444}
.ed-file .ficon.other{background:#7c3aed}
.ed-file .fname{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ed-file .fdel{
  width:18px;height:18px;border-radius:4px;
  display:flex;align-items:center;justify-content:center;
  background:transparent;color:var(--text-3);
  border:0;cursor:pointer;opacity:0;font-size:12px;
}
.ed-file:hover .fdel{opacity:1}
.ed-file .fdel:hover{background:rgba(220,38,38,.15);color:var(--danger)}

.ed-addfile{
  margin:0 8px 12px;padding:8px;
  border:1px dashed var(--border);border-radius:8px;
  font-size:12px;font-weight:700;color:var(--text-3);
  cursor:pointer;text-align:center;background:transparent;
  font-family:inherit;transition:all .15s;
}
.ed-addfile:hover{border-color:var(--accent);color:var(--accent)}

/* MAIN EDITOR */
.ed-main{
  overflow:hidden;display:flex;flex-direction:column;
  min-height:0;background:var(--bg-2);
  border-right:1px solid var(--border);
}
.ed-tabs{
  display:flex;align-items:center;gap:2px;
  padding:6px 8px;background:var(--bg-3);
  border-bottom:1px solid var(--border);
  overflow-x:auto;scrollbar-width:none;flex-shrink:0;
}
.ed-tabs::-webkit-scrollbar{display:none}
.ed-tab{
  display:flex;align-items:center;gap:6px;
  padding:6px 12px;border-radius:7px;
  font-size:12px;font-weight:600;
  color:var(--text-2);cursor:pointer;
  white-space:nowrap;font-family:inherit;
  background:transparent;border:0;
  transition:all .12s;
}
.ed-tab:hover{background:var(--bg-4)}
.ed-tab.active{background:var(--bg-2);color:var(--text);box-shadow:var(--shadow-sm)}
.ed-tab .dot{width:6px;height:6px;border-radius:50%;background:var(--text-3)}
.ed-tab.dirty .dot{background:var(--amber)}
.ed-container{flex:1;min-height:0;position:relative}
#monaco{position:absolute;inset:0}

/* RIGHT PANEL */
.ed-right{display:flex;flex-direction:column;min-height:0;background:var(--bg-2)}
.ed-right-tabs{
  display:flex;align-items:center;gap:2px;
  padding:6px 8px;background:var(--bg-3);
  border-bottom:1px solid var(--border);flex-shrink:0;
}
.ed-right-tabs button{
  padding:6px 14px;border-radius:7px;
  font-size:12px;font-weight:700;
  color:var(--text-2);cursor:pointer;font-family:inherit;
  background:transparent;border:0;
}
.ed-right-tabs button.active{background:var(--bg-2);color:var(--text);box-shadow:var(--shadow-sm)}
.ed-right-tabs .spacer{flex:1}
.ed-right-tabs .refresh{
  width:28px;height:28px;border-radius:7px;
  display:flex;align-items:center;justify-content:center;
  background:transparent;border:0;color:var(--text-2);
  cursor:pointer;font-size:14px;
}
.ed-right-tabs .refresh:hover{background:var(--bg-4)}
.ed-pane{flex:1;min-height:0;position:relative;display:none}
.ed-pane.active{display:flex;flex-direction:column}

#preview{flex:1;width:100%;border:0;background:#fff}

.console-box{
  flex:1;overflow-y:auto;
  background:#0f172a;color:#e2e8f0;
  font-family:ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  font-size:12.5px;line-height:1.6;padding:12px 14px;
}
.console-box .c-line{
  padding:2px 0;border-bottom:1px solid rgba(255,255,255,.04);
  display:flex;gap:10px;
}
.console-box .c-line .c-type{
  color:#64748b;flex-shrink:0;font-size:10px;
  text-transform:uppercase;padding-top:2px;min-width:52px;
}
.console-box .c-line.log .c-msg{color:#e2e8f0}
.console-box .c-line.warn .c-msg{color:#fbbf24}
.console-box .c-line.error .c-msg{color:#f87171}
.console-box .c-line.info .c-msg{color:#22d3ee}
.console-box .c-empty{color:#64748b;font-style:italic;padding:20px 0;text-align:center}

.lang-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;max-height:60vh;overflow-y:auto}
.lang-grid button{
  padding:12px;background:var(--bg-3);border:1px solid var(--border);
  border-radius:10px;cursor:pointer;font-family:inherit;
  font-size:13px;font-weight:700;color:var(--text);
  text-align:left;display:flex;flex-direction:column;gap:4px;
}
.lang-grid button:hover{border-color:var(--accent);background:var(--accent-soft)}
.lang-grid button .desc{font-size:10px;color:var(--text-3);font-weight:500}

.ed-status{
  position:absolute;bottom:0;left:0;right:0;height:22px;
  display:flex;align-items:center;padding:0 12px;
  background:var(--bg-3);border-top:1px solid var(--border);
  font-size:10.5px;color:var(--text-3);font-weight:600;z-index:5;
}

/* Backdrop (mobile overlays) */
.ed-backdrop{
  position:fixed;inset:0;
  background:rgba(0,0,0,.4);
  backdrop-filter:blur(2px);
  z-index:80;
  opacity:0;visibility:hidden;
  transition:opacity .25s,visibility .25s;
}
.ed-backdrop.show{opacity:1;visibility:visible}

/* Mobile close buttons — hidden on desktop */
.ed-mobile-close{display:none}
.ed-mobile-toggle{display:none}

/* ============================================================
   TABLET & MOBILE  (≤ 900px)
   ============================================================ */
@media(max-width:900px){

  /* Top bar becomes 56px tall, more room for buttons */
  .ed-shell{grid-template-rows:56px 1fr}

  .ed-top{
    height:56px;
    padding:0 8px;
    gap:6px;
    padding-left:max(8px,env(safe-area-inset-left));
    padding-right:max(8px,env(safe-area-inset-right));
    overflow:hidden;
  }

  .ed-top .brand{gap:6px;font-size:0}   /* hide wordmark text */
  .ed-top .brand .wordmark{display:none} /* keep only mark */
  .ed-top .brand-mark{width:30px;height:30px}

  /* Title shrinks */
  .ed-title{
    width:auto;
    flex:1;
    min-width:0;
    font-size:13px;
    padding:8px 6px;
    font-weight:600;
  }

  .ed-spacer{display:none}   /* no gap */

  /* Buttons get bigger tap targets */
  .ed-btn{
    padding:9px 12px;
    min-height:40px;
    font-size:12px;
  }
  .ed-btn .lbl{display:none}   /* hide text, keep icon */
  .ed-btn.icon-only{padding:9px 11px}

  .ed-icon-btn{
    width:40px;height:40px;
    font-size:17px;
  }

  /* Show mobile-only elements */
  .ed-mobile-toggle{display:flex !important}
  .ed-mobile-close{display:flex !important}
  .ed-hide-mobile{display:none !important}

  /* ============ BODY LAYOUT ============ */
  .ed-body{
    grid-template-columns:1fr;
    position:relative;
  }
  .ed-main,.ed-right{grid-column:1}

  /* ---- Sidebar → full-height drawer from left ---- */
  .ed-side{
    position:fixed;
    top:56px;left:0;bottom:0;
    width:280px;
    max-width:82vw;
    z-index:100;
    transform:translateX(-100%);
    transition:transform .28s cubic-bezier(.32,.72,0,1);
    box-shadow:20px 0 60px rgba(0,0,0,.25);
    padding-top:8px;
  }
  .ed-side.open{transform:translateX(0)}

  /* Close button on sidebar */
  .ed-side .ed-mobile-close{
    position:absolute;
    top:12px;right:12px;
    width:36px;height:36px;
    border-radius:10px;
    background:var(--bg-3);
    border:1px solid var(--border);
    color:var(--text);
    align-items:center;justify-content:center;
    cursor:pointer;font-size:16px;
    z-index:5;
  }

  /* Sidebar file rows get bigger */
  .ed-file{
    padding:12px 12px;
    font-size:14px;
    min-height:44px;
  }
  .ed-file .ficon{width:22px;height:22px;font-size:10px;border-radius:5px}
  .ed-file .fdel{opacity:1;width:28px;height:28px;font-size:14px}

  .ed-addfile{
    padding:14px;
    font-size:13px;
    min-height:48px;
  }

  /* ---- Right panel (preview/console) → full-screen from right ---- */
  .ed-right{
    position:fixed;
    top:56px;left:0;right:0;bottom:0;
    z-index:100;
    transform:translateX(100%);
    transition:transform .28s cubic-bezier(.32,.72,0,1);
    box-shadow:-20px 0 60px rgba(0,0,0,.25);
  }
  .ed-right.show{transform:translateX(0)}

  /* Close button on right panel */
  .ed-right .ed-mobile-close{
    position:absolute;
    top:12px;right:12px;
    width:36px;height:36px;
    border-radius:10px;
    background:var(--bg-3);
    border:1px solid var(--border);
    color:var(--text);
    align-items:center;justify-content:center;
    cursor:pointer;font-size:16px;
    z-index:5;
  }

  /* Right panel tabs are bigger */
  .ed-right-tabs{
    padding:10px 12px;
    min-height:52px;
  }
  .ed-right-tabs button{
    padding:10px 18px;
    font-size:14px;
    min-height:40px;
  }
  .ed-right-tabs .refresh{
    width:40px;height:40px;font-size:18px;
  }

  /* Console bigger text on mobile */
  .console-box{font-size:13.5px;padding:14px 16px}
  .console-box .c-line{padding:4px 0}
  .console-box .c-line .c-type{font-size:11px;min-width:58px}

  /* Status bar taller to be tappable */
  .ed-status{height:26px;font-size:11.5px}

  /* Editor container gets padding so lines aren't cut off */
  .ed-tabs{padding:8px 10px;min-height:44px}
  .ed-tab{padding:8px 14px;font-size:13px;min-height:36px}
}

/* ============================================================
   VERY SMALL PHONES  (≤ 400px)
   ============================================================ */
@media(max-width:400px){
  .ed-title{font-size:12px;padding:6px 4px}
  .ed-btn{padding:8px 10px;min-height:38px}
  .ed-icon-btn{width:38px;height:38px;font-size:16px}
  .ed-side{width:88vw}
}

/* ============================================================
   LANDSCAPE PHONES  (short height)
   ============================================================ */
@media(max-height:500px) and (orientation:landscape){
  .ed-shell{grid-template-rows:48px 1fr}
  .ed-top{height:48px}
  .ed-icon-btn{width:36px;height:36px}
  .ed-btn{min-height:34px;padding:6px 10px}
  .ed-side,.ed-right{top:48px}
}

/* ============================================================
   DESKTOP-ONLY RESETS  (≥ 901px)
   ============================================================ */
@media(min-width:901px){
  .ed-mobile-toggle{display:none !important}
  .ed-mobile-close{display:none !important}
  .ed-backdrop{display:none !important}
}