/* CipatWeb - Navy & Azure colors of StopStart web (light and dark modes) */

:root {
  --navy: #162049;
  --azure: #0097DD;
  --text: #282832;
  --text2: #444752;
  --bg: #F2F2F3;
  --success: #026060;
  --error: #82053F;
  --surface: #ffffff;
  --border: #c9cad0;
  --hover: #e4e6ee;
  --selected: #d6e9f6;
  --topbar: var(--navy);
  --topbar-text: #ffffff;
  --button: var(--navy);
  --button-text: #ffffff;
  --link: #006d9f;
  --focus: var(--azure);
  --code-bg: #fafafb;
  --m-get: #026060;
  --m-post: #0b5cad;
  --m-put: #8a5300;
  --m-delete: #9b1c1c;
  --m-other: #6b2d8f;
  --changed: var(--navy);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --text: #F2F2F3;
  --text2: #b9bbc6;
  --bg: #0c1129;
  --surface: #162049;
  --border: #444752;
  --hover: #1f2b5e;
  --selected: #24407a;
  --topbar: #282832;
  --topbar-text: #F2F2F3;
  --button: #0097DD;
  --button-text: #0c1129;
  --link: #4fc3f7;
  --focus: #BA91F2;
  --code-bg: #10183a;
  --success: #3fc1b0;
  --error: #f07fa6;
  --m-get: #3fc1b0;
  --m-post: #6db8ff;
  --m-put: #f0b35a;
  --m-delete: #f28b8b;
  --m-other: #c9a2f5;
  --changed: #8fb8ff;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  display: flex;
  flex-direction: column;
  font: 14px/1.4 Barlow, Selawik, "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}

pre, textarea.code, .code, code {
  font: 12.5px/1.45 Consolas, "Cascadia Mono", "DejaVu Sans Mono", monospace;
}

h1 { font-size: 18px; margin: 0; font-weight: 600; white-space: nowrap; }
h1 small { font-weight: 400; opacity: .75; font-size: 13px; margin-left: 6px; }
h2 { font-size: 16px; margin: 8px 0 4px; }
h3 { font-size: 13px; margin: 6px 0 4px; color: var(--text2); font-weight: 600; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

/* ------------------------------------------------------------------ top bar */

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 14px;
  background: var(--topbar);
  color: var(--topbar-text);
}
.logo {
  display: inline-flex;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: #ffffff;
  align-items: center; justify-content: center;
}
.logo img { width: 28px; height: 28px; }
.tabs { display: flex; gap: 2px; margin-left: 18px; flex: 1; }
.tabs button, .subtabs button {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 8px 14px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
}
.tabs button { color: var(--topbar-text); opacity: .8; }
.tabs button.right { margin-left: auto; }
.tabs button.active { opacity: 1; border-bottom-color: var(--azure); font-weight: 600; }
.tabs button:hover { opacity: 1; }
.icon-btn {
  border: 1px solid rgba(255,255,255,.4);
  background: transparent;
  color: var(--topbar-text);
  border-radius: 50%;
  width: 30px; height: 30px;
  cursor: pointer;
  font-size: 16px;
}

/* ------------------------------------------------------------------ layout */

main { flex: 1; min-height: 0; display: flex; }
.tab { display: none; flex: 1; min-width: 0; flex-direction: column; padding: 8px 12px; gap: 6px; }
.tab.active { display: flex; }

.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; }
.toolbar .grow { flex: 1; }
label { display: inline-flex; align-items: center; gap: 6px; }
label.check { gap: 4px; }

input[type=text], input[type=password], input[type=search], select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 6px;
}
select { max-width: 280px; }
#diffOld, #diffNew, #apiVersion { min-width: 160px; }
#diffFilter { width: 240px; }

button, label.button {
  font: inherit;
  padding: 5px 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
button:hover:not(:disabled), label.button:hover { background: var(--hover); }
button.primary, label.button.primary {
  background: var(--button);
  border-color: var(--button);
  color: var(--button-text);
}
button.primary:hover:not(:disabled), label.button.primary:hover { filter: brightness(1.15); background: var(--button); }
button:disabled { opacity: .5; cursor: default; }
button.link { border: 0; background: none; color: var(--link); padding: 2px 4px; }
button.danger { color: var(--error); }
a.button-link { color: var(--link); padding: 2px 4px; text-decoration: none; }
a.button-link:hover { text-decoration: underline; }

.hint, .desc { color: var(--text2); }
.desc { margin: 2px 0 6px; max-height: 6em; overflow: auto; }
.empty { color: var(--text2); padding: 12px; margin: 0; }

/* ------------------------------------------------------------------ tables */

.table-wrap { overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; min-height: 0; }
table.grid { border-collapse: collapse; width: 100%; }
.grid th, .grid td { padding: 3px 8px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.grid th { position: sticky; top: 0; background: var(--surface); color: var(--text2); font-weight: 600; z-index: 1; }
.grid td.num, .grid th.num { text-align: right; }
.grid.small { font-size: 13px; margin-bottom: 6px; }
.grid.small td input { width: 100%; }
#diffTable td { white-space: nowrap; max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
#diffTable tbody tr { cursor: pointer; }
#diffTable tbody tr:hover { background: var(--hover); }
#diffTable tbody tr.sel { background: var(--selected); }
tr.k-added td { color: var(--success); }
tr.k-removed td { color: var(--error); }
tr.k-changed td { color: var(--changed); }

.split-v { flex: 1; min-height: 0; display: grid; grid-template-rows: minmax(120px, 3fr) minmax(90px, 2fr); gap: 6px; }

.detail-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; min-height: 0; }
.detail-pair > div { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.detail-pair pre, .detail-pair textarea {
  flex: 1;
  margin: 0;
  min-height: 120px;
  overflow: auto;
  padding: 6px 8px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  white-space: pre;
  resize: none;
}
#diffDetail pre { white-space: pre-wrap; word-break: break-word; }

/* ------------------------------------------------------------------ API */

.api-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(340px, 38%) 1fr; gap: 10px; }
.tree-pane { display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.tree-pane input[type=search] { width: 100%; }
.tree {
  flex: 1;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 0;
  min-height: 0;
}
.tree .group > .gh {
  display: flex; align-items: center; gap: 4px;
  padding: 2px 6px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.tree .group > .gh::before { content: "▸"; width: 12px; color: var(--text2); }
.tree .group.open > .gh::before { content: "▾"; }
.tree .group > .items { display: none; }
.tree .group.open > .items { display: block; }
.tree .ep {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 4px;
  padding: 1px 6px 1px 22px;
  cursor: pointer;
  white-space: nowrap;
}
.tree .ep:hover, .tree .gh:hover { background: var(--hover); }
.tree .ep.sel { background: var(--selected); }
.tree .ep .m { font-weight: 600; font-size: 12px; }
.tree .ep .p { overflow: hidden; text-overflow: ellipsis; }
.tree .ep.deprecated .p { text-decoration: line-through; }
.tree .ep.unsupported { opacity: .6; }
.m-GET { color: var(--m-get); }
.m-POST { color: var(--m-post); }
.m-PUT { color: var(--m-put); }
.m-DELETE { color: var(--m-delete); }
.m-PATCH { color: var(--m-other); }

.api-right { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.subtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); }
.subtabs button.active { border-bottom-color: var(--azure); font-weight: 600; }
.tabs button:hover:not(:disabled), .subtabs button:hover:not(:disabled) { background: transparent; }
.subtabs button:hover { color: var(--link); }
.subtab { display: none; flex: 1; flex-direction: column; min-height: 0; overflow: auto; padding-top: 4px; }
.subtab.active { display: flex; }
.subtab .detail-pair { flex: 1; min-height: 220px; }

fieldset.conn {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
  border: 1px solid var(--border); border-radius: 4px; margin: 4px 0;
  background: var(--surface);
}
fieldset.conn legend { color: var(--text2); padding: 0 4px; }
fieldset.conn .url { color: var(--text2); font-size: 13px; }
#tRespStatus.err { color: var(--error); }
#tRespStatus.ok { color: var(--success); }

/* ------------------------------------------------------------------ specs */

.messages div { padding: 3px 8px; border-radius: 4px; margin: 2px 0; }
.messages .ok { color: var(--success); }
.messages .err { color: var(--error); }
body.dragging main { outline: 3px dashed var(--azure); outline-offset: -6px; }

/* ------------------------------------------------------------------ status */

.statusbar, .statusline {
  font-size: 12.5px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.statusbar { padding: 3px 12px; border-top: 1px solid var(--border); background: var(--surface); }
.statusbar.err { color: var(--error); }

.busy {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.08);
  cursor: progress;
  z-index: 10;
}
.busy span {
  position: absolute; top: 50%; left: 50%;
  width: 34px; height: 34px; margin: -17px;
  border: 4px solid var(--azure);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .api-layout { grid-template-columns: 1fr; }
  .detail-pair { grid-template-columns: 1fr; }
  h1 small { display: none; }
}

/* ------------------------------------------------------------------ Generation */

/* Endpoint checkbox under the text of its group (6 + 12 + 4 + 13 + 6 = 41px) */
.tree .ep { grid-template-columns: 13px 54px 1fr; gap: 6px; align-items: center; padding-left: 41px; }
.tree .ep .cb, .tree .gh .cb { margin: 0; width: 13px; height: 13px; cursor: pointer; flex: none; }
.tree .ep .nocb { width: 13px; }
.tree .gh .cb { margin-right: 2px; }
.gen-pair { flex: 1; min-height: 360px; display: grid; grid-template-rows: minmax(90px, 2fr) minmax(200px, 3fr); gap: 8px; }
.gen-pair > div { min-height: 0; min-width: 0; }
.gen-out { display: flex; flex-direction: column; gap: 4px; }
.gen-out pre {
  flex: 1; margin: 0; min-height: 200px; overflow: auto; padding: 6px 8px;
  background: var(--code-bg); border: 1px solid var(--border); border-radius: 4px; white-space: pre;
}
#gSel td { vertical-align: middle; }
#gSel td.k { white-space: nowrap; }
#gSel td.k .p { margin-left: 4px; }
#gSel td.n { width: 45%; }
#gSel td.n input { width: 100%; font: 12.5px Consolas, "Cascadia Mono", "DejaVu Sans Mono", monospace; }
#gSel tr.bad td.n input { border-color: var(--error); color: var(--error); }
#gSel tr.missing td { color: var(--error); }
#gSel td.x button { padding: 0 6px; }
#gSummary.err { color: var(--error); }
#gWarnings { margin: 0; padding-left: 18px; color: var(--changed); font-size: 13px; max-height: 120px; overflow: auto; }
#gWarnings:empty { display: none; }

/* ------------------------------------------------------------------ Specs: where to get the files */

.howto { margin: 6px 0; padding: 6px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; }
.howto summary { cursor: pointer; color: var(--text2); }
.howto summary a { color: var(--link); }
.howto p { margin: 6px 0; }
.howto img { display: block; max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 4px; }

/* ------------------------------------------------------------------ Icons (same as CIPAT, SVG 32x32) */

.ico { width: 16px; height: 16px; flex: none; vertical-align: -3px; margin-right: 6px; }
.tabs .ico { width: 18px; height: 18px; vertical-align: -4px; }
button:disabled .ico { opacity: .45; }
#themeBtn { padding: 0; display: inline-grid; place-items: center; }
#themeBtn .ico { margin: 0; width: 18px; height: 18px; vertical-align: middle; }
/* Theme button: light off = switch to dark mode, light on = switch to light mode */
#themeBtn .to-light { display: none; }
[data-theme="dark"] #themeBtn .to-dark { display: none; }
[data-theme="dark"] #themeBtn .to-light { display: inline; }
