/* Code Share (live editor) layout, on the shared design tokens. Loaded after
   site.css, so buttons, nav and toast come from there; this file only lays
   out the editor chrome. Class names are the ones public/app.js builds. */
.editor-page-body { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.editor-page-body .container { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---------- Single top bar: brand (way home) + room + editor controls ---------- */
.editor-bar {
  display: flex; align-items: center; gap: 12px; flex-shrink: 0; height: 56px; padding: 0 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  position: relative; z-index: 50;
}
.editor-bar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.editor-bar .brand { font-size: 16px; }
.editor-bar-divider { width: 1px; height: 22px; background: var(--border-strong); flex-shrink: 0; }
.room-id {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 8px;
  background: var(--bg-elevated); border: 1px solid var(--border-subtle);
  font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); white-space: nowrap;
}
#roomName { color: var(--accent-blue); font-weight: 600; }
.editor-bar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
.user-count {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border-radius: 8px;
  background: var(--bg-elevated); border: 1px solid var(--border-subtle); font-size: 13px; color: var(--text-secondary);
}
.user-count #userCount { color: var(--text-primary); font-weight: 600; font-family: var(--font-mono); }
.language-select {
  height: 34px; padding: 0 30px 0 10px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--bg-elevated) var(--select-chevron) no-repeat right 9px center; color: var(--text-primary);
  appearance: none; -webkit-appearance: none; font-size: 13px; cursor: pointer;
}
.language-select:hover { border-color: var(--text-muted); }
.editor-bar .theme-toggle { width: 34px; height: 34px; }
.share-icon, .upload-icon { font-size: 13px; line-height: 1; }

/* ---------- Editor ---------- */
.main-content { flex: 1; min-height: 0; display: flex; overflow: hidden; }
.editor-container { flex: 1; min-width: 0; position: relative; background: var(--bg-base); }
#editor { width: 100%; height: 100%; }
.editor-container .CodeMirror {
  height: 100% !important; font-family: var(--font-mono); font-size: 14px; line-height: 1.65; background: transparent !important;
}
.editor-container .CodeMirror-gutters { background: transparent !important; border-right: 1px solid var(--border-subtle) !important; }
:root[data-theme="light"] .editor-container .cm-s-default .CodeMirror-linenumber { color: var(--text-muted); }

.download-btn:hover { background: rgba(59, 130, 246, 0.14); }
.delete-btn:hover { background: rgba(239, 68, 68, 0.14); }

/* ---------- Status bar ---------- */
.footer {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-shrink: 0;
  padding: 8px 20px; border-top: 1px solid var(--border-subtle); background: var(--bg-surface);
  font-size: 12px; color: var(--text-muted);
}
.status { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-mono); }
.status-indicator { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.status-indicator.connected { background: var(--ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18); animation: status-pulse 2.4s ease-in-out infinite; }
.status-indicator.disconnected { background: var(--accent-danger); box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18); }
@keyframes status-pulse { 0%, 100% { box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18); } 50% { box-shadow: 0 0 0 5px rgba(52, 211, 153, 0.08); } }
.info { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Scrollbars ---------- */
.editor-container .CodeMirror-vscrollbar::-webkit-scrollbar { width: 8px; }
.editor-container .CodeMirror-vscrollbar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

/* ---------- Mobile: stack the editor over a shorter, always-reachable file panel ---------- */
@media (max-width: 860px) {
  .editor-bar { flex-wrap: wrap; height: auto; padding: 8px 12px; row-gap: 8px; }
  .editor-bar-left { width: 100%; }
  .editor-bar-divider { display: none; }
  .room-id { margin-left: auto; }
  .editor-bar-right { width: 100%; margin-left: 0; justify-content: flex-start; flex-wrap: wrap; }
  .editor-bar-right .theme-toggle { margin-left: auto; }
  .main-content { flex-direction: column; }
  .editor-container { flex: 1 1 55%; min-height: 240px; }
  .footer { padding: 8px 14px; }
  .footer .info { display: none; }
}

/* Phones: drop the presence counter so select, Clear, Copy link and the theme
   toggle share one row instead of the toggle wrapping onto a third. */
@media (max-width: 480px) {
  .editor-bar-right .user-count { display: none; }
  .language-select { min-width: 0; max-width: 130px; }
}

/* ---------- Private rooms: lock badge + PIN gate ---------- */
.room-lock { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; padding: 2px 7px; border-radius: 999px; background: rgba(59, 130, 246, 0.16); background: color-mix(in srgb, var(--accent-blue) 16%, transparent); color: var(--accent-blue); font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.room-lock .icon { width: 12px; height: 12px; }
.main-content { position: relative; }
.room-gate { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px; background: rgba(0, 0, 0, 0.72); background: color-mix(in srgb, var(--bg-base) 72%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.room-gate-card { width: min(440px, 100%); padding: 28px; border-radius: 16px; background: var(--bg-surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg, 0 20px 60px rgba(0,0,0,.35)); text-align: left; }
.room-gate-card .gate-icon { margin: 0 0 14px; width: 40px; height: 40px; }
.room-gate-card h2 { font-size: 20px; letter-spacing: -0.02em; margin-bottom: 8px; }
.room-gate-card p { color: var(--text-secondary); font-size: 14px; line-height: 1.55; }
.room-gate-card form { margin-top: 16px; }
.gate-row { display: flex; gap: 8px; }
.gate-row input { flex: 1; min-width: 0; height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--bg-base); color: var(--text-primary); font-family: var(--font-mono); font-size: 15px; letter-spacing: .12em; }
.gate-row input:focus { outline: none; border-color: var(--accent-blue); }
.room-gate-card .tool-error { margin-top: 10px; }
.room-gate-card .tool-error:empty { display: none; }
.gate-foot { margin-top: 16px; font-size: 12.5px; color: var(--text-muted); }
.gate-foot a { color: var(--text-secondary); text-decoration: underline; text-underline-offset: 3px; }
.room-gate[data-state="expired"] form, .room-gate[data-state="expired"] .tool-error { display: none; }
@media (max-width: 480px) { .gate-row { flex-direction: column; } .room-gate-card { padding: 22px; } }

/* ---------- Tools menu in the editor bar ---------- */
.bar-menu { position: relative; }
.bar-menu-btn .icon { width: 15px; height: 15px; }
.bar-menu-btn .label { margin-left: 6px; }
.bar-menu-panel { position: absolute; right: 0; top: calc(100% + 8px); width: 330px; max-width: calc(100vw - 24px); padding: 8px; border-radius: 14px; background: var(--bg-surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg, 0 16px 48px rgba(0,0,0,.4)); z-index: 40; display: flex; flex-direction: column; gap: 2px; }
.bar-menu-panel[hidden] { display: none; }
.bar-menu-section { padding: 8px 10px 4px; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.bar-menu-item { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--text-primary); text-align: left; font: inherit; cursor: pointer; text-decoration: none; }
.bar-menu-item:hover, .bar-menu-item:focus-visible { background: var(--bg-hover); outline: none; }
.bar-menu-item[hidden] { display: none; }
.bar-menu-item .icon, .bar-menu-glyph { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; color: var(--accent-blue); }
.bar-menu-glyph { font-family: var(--font-mono); font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.bar-menu-item strong { display: block; font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.bar-menu-item small { display: block; font-size: 12px; color: var(--text-muted); margin-top: 1px; line-height: 1.35; }
.bar-menu-more { justify-content: center; color: var(--accent-blue); font-size: 13px; font-weight: 500; margin-top: 2px; }
.lock-expiry { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 13px; color: var(--text-secondary); }
.lock-expiry select { height: 34px; padding: 0 28px 0 10px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--bg-elevated) var(--select-chevron) no-repeat right 9px center; color: var(--text-primary); appearance: none; -webkit-appearance: none; font-size: 13px; }
@media (max-width: 720px) {
  .bar-menu-btn .label { display: none; }
  .bar-menu-panel { position: fixed; left: 12px; right: 12px; top: auto; bottom: 12px; width: auto; max-width: none; max-height: 72vh; overflow: auto; }
}

/* Phones: keep the whole control row on one line (select, tools, Clear,
   Copy link, theme) instead of pushing the theme toggle to a third row. */
@media (max-width: 720px) {
  .editor-bar-right { gap: 6px; }
  .editor-bar-right #copyBtn .icon { display: none; }
  .editor-bar-right .language-select { max-width: 118px; }
}
@media (max-width: 400px) {
  .editor-bar-right #clearBtn { display: none; }
}
