/* Apps Script editor (static/js/script_editor.js): files, code with line numbers and highlighting, the run log. */

.se { display: flex; flex-direction: column; height: 100%; min-height: 0; background: var(--bg); color: var(--text); }
.se-shade { position: fixed; inset: 0; z-index: 900; background: var(--bg); }
.se-shade-box { position: absolute; inset: 0; display: flex; flex-direction: column; }
.se-missing { margin: 12vh auto; max-width: 420px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }

/* ---------------------------------------------------------------- the header */
.se-head {
  display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: var(--surface);
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.se-logo {
  width: 32px; height: 32px; border-radius: 8px; background: var(--code); color: #fff; display: grid; place-items: center;
  flex: none;
}
.se-title-wrap { min-width: 0; flex: 1 1 240px; }
.se-title-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.se-title {
  font-size: 17px; font-weight: 600; border: 1px solid transparent; border-radius: var(--radius-sm); padding: 2px 6px;
  background: transparent; min-width: 0; width: min(100%, 420px); text-overflow: ellipsis;
}
.se-title:hover:not([readonly]), .se-title:focus { border-color: var(--border-strong); outline: none; background: var(--surface); }
.se-state { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.se-state.unsaved { color: var(--warn-text); }
.se-state.error { color: var(--danger); }
.se-sub { display: flex; align-items: center; gap: 10px; font-size: 12px; padding: 1px 0 0 7px; min-width: 0; }
.se-back {
  display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); max-width: 280px; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis;
}
.se-back:hover { color: var(--accent); }
.se-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.se-fn { width: auto; max-width: 210px; }   /* (not .select's 100%: the actions' width would leave out part of it, and the last button wrapped alone) */
.se-banner {
  display: flex; gap: 8px; align-items: center; padding: 8px 14px; background: var(--warn-weak); color: var(--warn-text);
  font-size: 13px; border-bottom: 1px solid var(--border);
}
.se-banner[hidden], .se-log[hidden] { display: none; }

/* ---------------------------------------------------------------- files */
.se-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.se-files { border-right: 1px solid var(--border); background: var(--surface); overflow: auto; padding: 8px 0; }
.se-files-head {
  display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 4px 14px; min-height: 30px;
  font-size: 11.5px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em;
}
.se-macros { margin-top: 10px; }
.se-file-list { list-style: none; margin: 0; padding: 0 6px; }
.se-file, .se-macro {
  display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 8px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 13px; color: var(--text); min-height: 30px;
}
.se-file .grow, .se-macro span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.se-file:hover, .se-macro:hover { background: var(--surface-2); }
.se-file:focus-visible, .se-macro:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.se-file.active { background: var(--accent-weak); color: var(--accent); font-weight: 600; }
.se-file .icon-btn { visibility: hidden; width: 24px; height: 24px; flex: none; }
.se-file:hover .icon-btn, .se-file.active .icon-btn, .se-file:focus-within .icon-btn { visibility: visible; }
.se-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn-text); flex: none; }

/* ---------------------------------------------------------------- the code */
.se-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.se-code { flex: 1; min-height: 0; display: flex; background: var(--page); font: 13px/20px var(--mono); }
.se-gutter {
  flex: none; width: 54px; padding: 10px 10px 40px 0; text-align: right; color: var(--text-3); background: var(--surface-2);
  border-right: 1px solid var(--border); overflow: hidden; white-space: pre; user-select: none; font: inherit;
}
.se-scroll { flex: 1; min-width: 0; position: relative; overflow: hidden; }
.se-hl, .se-text {
  margin: 0; padding: 10px 14px 40px; font: inherit; white-space: pre; tab-size: 2; letter-spacing: 0; word-wrap: normal;
  overflow-wrap: normal; box-sizing: border-box; font-variant-ligatures: none; font-kerning: none;
}
.se-hl { position: absolute; top: 0; left: 0; min-width: 100%; pointer-events: none; color: var(--page-text); will-change: transform; }
.se-text {
  position: absolute; inset: 0; width: 100%; height: 100%; resize: none; border: 0; outline: none; background: transparent;
  color: transparent; caret-color: var(--text); overflow: auto; -webkit-text-fill-color: transparent;
}
.se-text::selection { background: var(--sel-strong); }
.se-text[readonly] { caret-color: transparent; }
.se-readonly { position: static; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--page);
  font: 12.5px/19px var(--mono); max-height: 50vh; overflow: auto; padding: 8px 10px; }

/* tokens (also in dark mode: they come from the theme's colours where they can) */
.tk-com { color: #6a7685; font-style: italic; }
.tk-str { color: #0b7a3e; }
.tk-num { color: #b35c00; }
.tk-re { color: #a3157a; }
.tk-kw { color: #7a3ec8; font-weight: 600; }
.tk-svc { color: #1d63c9; }
.tk-fn { color: #0d6e86; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tk-com { color: #8a94a3; }
  :root:not([data-theme="light"]) .tk-str { color: #7fd49b; }
  :root:not([data-theme="light"]) .tk-num { color: #f2a65a; }
  :root:not([data-theme="light"]) .tk-re { color: #f08ad2; }
  :root:not([data-theme="light"]) .tk-kw { color: #c49bff; }
  :root:not([data-theme="light"]) .tk-svc { color: #7fb0ff; }
  :root:not([data-theme="light"]) .tk-fn { color: #67d1e6; }
}
:root[data-theme="dark"] .tk-com { color: #8a94a3; }
:root[data-theme="dark"] .tk-str { color: #7fd49b; }
:root[data-theme="dark"] .tk-num { color: #f2a65a; }
:root[data-theme="dark"] .tk-re { color: #f08ad2; }
:root[data-theme="dark"] .tk-kw { color: #c49bff; }
:root[data-theme="dark"] .tk-svc { color: #7fb0ff; }
:root[data-theme="dark"] .tk-fn { color: #67d1e6; }

/* ---------------------------------------------------------------- the execution log */
.se-log { flex: none; height: 34%; min-height: 120px; display: flex; flex-direction: column; border-top: 1px solid var(--border);
  background: var(--surface); }
.se-log-head { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 14px; border-bottom: 1px solid var(--border);
  font-size: 13px; }
.se-log-body { flex: 1; overflow: auto; padding: 4px 0; font: 12.5px/18px var(--mono); }
.se-log-row { display: grid; grid-template-columns: 84px 70px minmax(0, 1fr); gap: 8px; padding: 2px 14px; }
.se-log-row.link { cursor: pointer; }
.se-log-row.link:hover .se-log-msg { text-decoration: underline; }
.se-log-time { color: var(--text-3); }
.se-log-level { color: var(--text-2); }
.se-log-msg { white-space: pre-wrap; overflow-wrap: anywhere; }
.se-log-row.error .se-log-level, .se-log-row.error .se-log-msg { color: var(--danger); }
.se-log-row.warn .se-log-level { color: var(--warn-text); }
.se-log-row.notice .se-log-msg { color: var(--text-2); }
.se-alert { white-space: pre-wrap; margin: 0; }

/* ---------------------------------------------------------------- dialogs */
.se-dialog { display: flex; flex-direction: column; gap: 10px; }
.se-h3 { font-size: 13px; font-weight: 600; margin: 8px 0 0; color: var(--text-2); }
.se-trigger-list, .se-version-list { display: flex; flex-direction: column; gap: 6px; max-height: 40vh; overflow: auto; }
.se-trigger, .se-version {
  display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface);
}
.se-trigger-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.se-trigger-actions { display: flex; gap: 4px; align-items: center; }
.se-trigger-add { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: var(--radius-sm);
  background: var(--surface-2); }
.se-trigger-row, .se-trigger-extra { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.se-trigger-row .field { flex: 1 1 180px; }
.se-preview { min-height: 18px; }
.warn-text { color: var(--warn-text); }
.se-exec-list { display: flex; flex-direction: column; max-height: 40vh; overflow: auto; border: 1px solid var(--border);
  border-radius: var(--radius-sm); }
.se-exec {
  display: grid; grid-template-columns: minmax(0, 1.4fr) 1fr 0.8fr 0.9fr 0.5fr 1fr; gap: 8px; padding: 7px 10px; border: 0;
  border-bottom: 1px solid var(--border); background: transparent; text-align: left; cursor: pointer; font-size: 13px;
}
.se-exec:last-child { border-bottom: 0; }
.se-exec:hover { background: var(--surface-2); }
.se-exec-fn { font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.se-exec-status.completed { color: var(--ok); }
.se-exec-status.failed, .se-exec-status.timed_out { color: var(--danger); }
.se-exec-detail { max-height: 30vh; overflow: auto; font: 12.5px/18px var(--mono); }
.se-exec-detail .se-log-row { grid-template-columns: 70px minmax(0, 1fr); padding: 2px 0; }
.se-props { display: flex; flex-direction: column; gap: 6px; }
.se-prop { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) auto; gap: 6px; align-items: center; }
.se-consent { max-width: 460px; }
.se-consent p { margin: 0 0 8px; }
.se-consent-uses { margin: 0 0 10px; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }

/* ---------------------------------------------------------------- small screens */
@media (max-width: 760px) {
  .se-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .se-files { border-right: 0; border-bottom: 1px solid var(--border); max-height: 132px; padding: 4px 0; }
  .se-actions .btn.ghost span { display: none; }
  .se-gutter { width: 40px; padding-right: 6px; }
  .se-log-row { grid-template-columns: 64px minmax(0, 1fr); }
  .se-log-level { display: none; }
  .se-exec { grid-template-columns: minmax(0, 1fr) 1fr 1fr; }
  .se-exec > :nth-child(n + 4) { display: none; }
}
