/* Onasis Tech theme for the GenieACS UI (acs.onasis.tech).
   nginx adds this after GenieACS's own stylesheet (sub_filter in ~/genieacs/nginx.conf),
   so GenieACS itself is untouched and an upgrade keeps the theme. */

:root {
  --base-font-size: 14px;
  --color1: #e5e7eb;   /* borders */
  --color2: #9ca3af;
  --color3: #f3f4f6;   /* soft fills, row hover */
  --color4: #15803d;   /* accent: links, active items */
  --color5: #1f2937;   /* text */
  --disabled: #9ca3af;
  --ot-green: #16a34a;
  --ot-green-dark: #15803d;
  --ot-green-soft: #ecfdf5;
  --ot-bg: #f6f7f9;
  --ot-muted: #6b7280;
  --ot-red: #b91c1c;
  --ot-radius: 10px;
  --ot-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html body, html body :is(input, button, select, option, textarea) {
  font-family: var(--ot-font);
  color: var(--color5);
  outline-color: var(--ot-green);
}
html body { background: var(--ot-bg); font-size: var(--base-font-size); }

/* Links: green, no filled hover block */
html body a, html body a:visited { color: var(--ot-green-dark); text-decoration: none; }
html body a:hover { background: none; color: var(--ot-green); text-decoration: underline; }

/* Header */
html body #header {
  background: #fff;
  border-bottom: 1px solid var(--color1);
  box-shadow: 0 1px 3px rgba(17, 24, 39, .06);
  min-height: 64px;
}
html body #header > .logo > img { height: 40px; margin: 12px 16px 12px 18px; }
html body #header > .logo > .version { bottom: 2px; right: 18px; font-size: 9px; color: #b0b5bd; }
html body #header > .user-menu {
  margin: 0; padding: 16px 20px; color: var(--ot-muted); font-size: 13px;
  display: flex; align-items: center; gap: 10px;
}
html body #header > .user-menu > button {
  border: 1px solid var(--color1); background: #fff; color: var(--color5);
  padding: 5px 12px; border-radius: 8px; font-size: 13px;
}
html body #header > .user-menu > button:hover:enabled { border-color: var(--ot-green); color: var(--ot-green-dark); background: var(--ot-green-soft); }

/* Main tabs: text with a green underline instead of beige folders */
html body #header > nav { bottom: 0; }
html body #header > nav > ul { margin: 0 12px; font-weight: 600; }
html body #header > nav > ul > li {
  background: none; border: 0; border-radius: 0; margin: 0 2px;
  border-bottom: 2px solid transparent;
}
html body #header > nav > ul > li:hover { background: none; border-bottom-color: var(--color1); }
html body #header > nav > ul > li.active { background: none; border-bottom-color: var(--ot-green); }
html body #header > nav > ul > li > :is(a, a:visited, a:hover) {
  min-width: 0; padding: 22px 16px 19px; color: var(--ot-muted); text-decoration: none; font-size: 14px;
}
html body #header > nav > ul > li.active > :is(a, a:visited, a:hover) { color: var(--color5); }
html body #header > nav > ul > li:hover > a { color: var(--color5); }

/* Content on a white card */
html body #content {
  min-width: 0; overflow-x: auto;
  margin: 20px; padding: 20px 24px; background: #fff;
  border: 1px solid var(--color1); border-radius: 14px;
  box-shadow: 0 1px 2px rgba(17, 24, 39, .04);
}
html body h1 { color: #111827; font-size: 20px; font-weight: 650; margin: 0 0 16px; }
html body h2 { color: #111827; font-size: 16px; font-weight: 650; }
html body h3 { color: #374151; font-size: 15px; font-weight: 600; }

/* Admin side menu */
html body #side-menu { width: 210px; min-width: 210px; padding: 20px 0 0 20px; }
html body #side-menu > ul > li > a {
  background: none; border: 0; border-radius: 8px; margin: 2px 0; padding: 9px 12px;
  color: #374151; font-weight: 500;
}
html body #side-menu > ul > li > a:hover { background: var(--color3); color: #111827; text-decoration: none; }
html body #side-menu > ul > li.active > a { background: var(--ot-green-soft); color: var(--ot-green-dark); font-weight: 650; }
html body #side-menu + #content { margin-left: 12px; }

/* Tables */
html body table.table { border-collapse: separate; border-spacing: 0; }
html body table.table th {
  color: var(--ot-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--color1); padding: 10px 12px;
}
html body table.table th a, html body table.table th button { color: var(--ot-muted); }
html body table.table td { padding: 8px 12px; }
html body table.table.highlight > tbody > tr > td { border-bottom: 1px solid #f1f2f4; }
html body table.table.highlight > tbody > tr:hover { background: #f0fdf4; }
html body table.table tfoot td { padding-top: 12px; color: var(--ot-muted); }
html body table.table td a { font-weight: 500; }

/* Inputs */
html body :is(textarea, select, input:not([type=checkbox]):not([type=radio]):not([type=button]):not([type=submit])) {
  background: #fff; border: 1px solid #d1d5db; border-radius: 8px; padding: 7px 10px;
}
html body .CodeMirror { background: #fff; border: 1px solid #d1d5db; border-radius: 8px; }
html body :is(.CodeMirror, textarea, select, input):is(:focus, :hover) { border-color: var(--ot-green); }
html body :is(textarea, select, input):focus { outline: none; box-shadow: 0 0 0 3px rgba(22, 163, 74, .18); }
html body .filter { margin-bottom: 14px; }
html body .filter > b { display: block; font-size: 12px; font-weight: 600; color: var(--ot-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
html body .filter > input { font-size: 14px; width: 36em; max-width: 100%; margin: 0; padding: 8px 12px; }
html body .all-parameters > input { font-size: 13px; padding: 8px 12px; }
html body input[type=checkbox] { accent-color: var(--ot-green); }

/* Buttons */
html body :is(input[type=button], button) { color: var(--ot-green-dark); border-radius: 8px; }
html body :is(input[type=button], button):hover:enabled { background: var(--ot-green-soft); color: var(--ot-green-dark); }
html body :is(input[type=button], button).primary {
  background: var(--ot-green); border: 1px solid var(--ot-green); color: #fff;
  padding: 7px 14px; font-weight: 600; font-size: 13px;
}
html body :is(input[type=button], button).primary:hover:enabled { background: var(--ot-green-dark); border-color: var(--ot-green-dark); color: #fff; }
html body :is(input[type=button], button).critical {
  background: #fff; border: 1px solid #fecaca; color: var(--ot-red);
  padding: 7px 14px; font-weight: 600; font-size: 13px;
}
html body :is(input[type=button], button).critical:hover:enabled { background: #fef2f2; border-color: var(--ot-red); color: var(--ot-red); }
html body :is(input[type=button], button):disabled { opacity: .45; cursor: not-allowed; }
html body .actions-bar { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; }
html body .actions-bar > button { margin-right: 0; }

/* Login */
html body .page-login, html body #content.page-login { max-width: 360px; }

/* Notifications, overlays, menus */
html body #header > .drawer-wrapper > .notifications-wrapper > .notification {
  border-radius: 10px; padding: 10px 14px; box-shadow: 0 10px 25px rgba(17, 24, 39, .12);
}
html body #header > .drawer-wrapper > .drawer {
  border-bottom-left-radius: 12px; border-bottom-right-radius: 12px; box-shadow: 0 10px 25px rgba(17, 24, 39, .12);
}
html body .overlay-wrapper { background: rgba(17, 24, 39, .35); }
html body .overlay-wrapper > .overlay { border-radius: 14px; padding: 20px; border: 1px solid var(--color1); box-shadow: 0 20px 50px rgba(17, 24, 39, .2); }
html body .autocomplete { border-radius: 10px; box-shadow: 0 10px 25px rgba(17, 24, 39, .12); }
html body .autocomplete > .suggestion:is(.selected, :hover) { background: var(--ot-green-soft); }
html body .wizard-dialog { border-radius: 14px; box-shadow: 0 10px 25px rgba(17, 24, 39, .08); }

/* Device page */
html body .all-parameters > .parameter-list { height: 320px; border: 1px solid var(--color1); border-radius: 10px; padding: 4px 8px; }
html body .all-parameters > .parameter-list > table > tbody > tr > td { border-bottom: 1px solid #f1f2f4; padding: 3px 0; }
html body .all-parameters > .parameter-list > table > tbody > tr:hover { background: #f0fdf4; }
html body table.parameter-list th { color: #374151; font-weight: 600; padding: 3px 18px 3px 0; }
html body table.parameter-list td { padding: 3px 0; }

/* Charts and progress */
html body .progress > .progress-bar { background: var(--ot-green); }
html body .page-overview > h1 { text-align: center; }
html body .pie-chart > svg > path { stroke: #fff; stroke-width: 2px; }

/* ---------- Added by enhance.js ---------- */

/* Devices: search bar and pager */
html body #ot-search { display: flex; gap: 8px; align-items: center; margin: 0 0 14px; max-width: 760px; }
html body #ot-search > input { flex: 1; font-size: 15px; padding: 10px 14px; border-radius: 10px; }
html body #ot-search > button.primary { padding: 10px 18px; border-radius: 10px; font-size: 14px; }
html body #ot-search > .ot-clear { padding: 10px 12px; color: var(--ot-muted); }
html body .filter > input { font-size: 13px; }
html body table.table.ot-paged > thead input[type=checkbox] { visibility: hidden; }
html body #ot-pager { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 14px; color: var(--ot-muted); font-size: 13px; }
html body #ot-pager .ot-sel { color: #b45309; font-weight: 600; }
html body #ot-pager .ot-pages { margin-left: auto; display: flex; gap: 4px; align-items: center; }
html body #ot-pager .ot-pages > button { min-width: 34px; padding: 6px 10px; border: 1px solid var(--color1); background: #fff; color: var(--color5); font-size: 13px; }
html body #ot-pager .ot-pages > button.ot-on { background: var(--ot-green); border-color: var(--ot-green); color: #fff; font-weight: 600; }
html body #ot-pager .ot-pages > button:hover:enabled:not(.ot-on) { border-color: var(--ot-green); background: var(--ot-green-soft); }
html body #ot-pager .ot-gap { padding: 0 4px; }

/* Overview: our panel replaces GenieACS's pie chart once it has loaded */
body.ot-ov-ready #content.page-overview > :not(#ot-overview) { display: none; }
html body #content.page-overview { background: transparent; border: 0; box-shadow: none; padding: 0; }
html body .ot-ov-head { display: flex; align-items: baseline; justify-content: space-between; margin: 4px 2px 14px; }
html body .ot-ov-head h1 { margin: 0; text-align: left; }
html body .ot-updated { color: var(--ot-muted); font-size: 12px; }
html body .ot-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
html body a.ot-card {
  display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; background: #fff;
  border: 1px solid var(--color1); border-radius: 14px; color: var(--color5); text-decoration: none;
  box-shadow: 0 1px 2px rgba(17, 24, 39, .04); border-top: 3px solid #cbd5e1;
  transition: box-shadow .15s, transform .15s;
}
html body a.ot-card:hover { text-decoration: none; color: var(--color5); box-shadow: 0 8px 20px rgba(17, 24, 39, .08); transform: translateY(-1px); }
html body a.ot-card.ot-good { border-top-color: #16a34a; }
html body a.ot-card.ot-warn { border-top-color: #f59e0b; }
html body a.ot-card.ot-bad { border-top-color: #dc2626; }
html body .ot-card-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ot-muted); }
html body .ot-card-n { font-size: 30px; font-weight: 700; line-height: 1.1; color: #111827; }
html body .ot-card-sub { font-size: 12px; color: var(--ot-muted); }
html body .ot-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
html body .ot-panel { background: #fff; border: 1px solid var(--color1); border-radius: 14px; padding: 16px 18px; box-shadow: 0 1px 2px rgba(17, 24, 39, .04); }
html body .ot-panel h3 { margin: 0 0 12px; font-size: 14px; color: #111827; }
html body .ot-donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
html body .ot-donut svg { display: block; }
html body .ot-donut-big { font-size: 28px; font-weight: 700; fill: #111827; font-family: var(--ot-font); }
html body .ot-donut-small { font-size: 12px; fill: #6b7280; font-family: var(--ot-font); }
html body .ot-legend { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 150px; }
html body a.ot-legend-row { display: flex; align-items: center; gap: 8px; color: var(--color5); font-size: 13px; padding: 4px 6px; border-radius: 8px; }
html body a.ot-legend-row:hover { background: var(--color3); text-decoration: none; color: var(--color5); }
html body a.ot-legend-row > b { margin-left: auto; font-weight: 600; }
html body .ot-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
html body a.ot-bar { display: grid; grid-template-columns: minmax(110px, 40%) 1fr 34px; align-items: center; gap: 10px; padding: 5px 6px; border-radius: 8px; color: var(--color5); font-size: 13px; }
html body a.ot-bar:hover { background: var(--color3); text-decoration: none; color: var(--color5); }
html body .ot-bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html body .ot-bar-label small { color: var(--ot-muted); font-size: 11px; }
html body .ot-bar-track { height: 8px; background: #eef0f3; border-radius: 99px; overflow: hidden; }
html body .ot-bar-fill { display: block; height: 100%; background: linear-gradient(90deg, #22c55e, #15803d); border-radius: 99px; }
html body .ot-bar-n { text-align: right; font-weight: 600; }
html body .ot-more { color: var(--ot-muted); font-size: 12px; margin: 8px 6px 0; }

/* ---------- Layout: header as a flex row (all sizes) ---------- */
html body #header { display: flex; align-items: center; flex-wrap: wrap; }
html body #header > .logo { flex: none; order: 1; }
html body #header > nav { position: static; bottom: auto; order: 2; align-self: stretch; display: flex; align-items: flex-end; }
html body #header > nav > ul { display: flex; }
html body #header > .user-menu { float: none; order: 3; margin-left: auto; }

/* ---------- Login: a centred card ---------- */
html body #header > .user-menu > a[href*="login"] { display: none; }
html body #content-wrapper > #content.page-login {
  flex: 0 1 400px; width: 100%; max-width: 400px; box-sizing: border-box;
  margin: 9vh auto 40px; padding: 32px 30px 24px;
  box-shadow: 0 12px 32px rgba(17, 24, 39, .08);
}
html body #content.page-login h1 { font-size: 0; text-align: center; margin: 0 0 22px; }
html body #content.page-login h1::before { content: "Sign in"; display: block; font-size: 22px; font-weight: 700; color: #111827; }
html body #content.page-login h1::after { content: "Onasis Tech ACS · device management"; display: block; font-size: 13px; font-weight: 400; color: var(--ot-muted); margin-top: 6px; }
html body #content.page-login form p { margin: 0 0 14px; }
html body #content.page-login label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 6px; }
html body #content.page-login input { width: 100%; box-sizing: border-box; padding: 11px 12px; font-size: 15px; }
html body #content.page-login button.primary { width: 100%; padding: 11px; font-size: 15px; margin-top: 4px; border-radius: 10px; }
html body #content.page-login > a { display: block; text-align: center; font-size: 13px; margin-top: 4px; }

/* ---------- Phones and small tablets ---------- */
@media (max-width: 760px) {
  html body #header > .logo > img { height: 32px; margin: 10px 12px; }
  html body #header > .logo > .version { display: none; }
  html body #header > .user-menu { padding: 10px 12px; font-size: 12px; gap: 8px; }
  html body #header > .user-menu > button { padding: 5px 10px; font-size: 12px; }
  html body #header > nav { order: 4; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-top: 1px solid #f1f2f4; }
  html body #header > nav > ul { margin: 0 4px; }
  html body #header > nav > ul > li > :is(a, a:visited, a:hover) { padding: 12px 12px 10px; white-space: nowrap; }
  html body #header > .drawer-wrapper { width: auto; left: 8px; right: 8px; margin-left: 0; }

  html body #content-wrapper { flex-direction: column; }
  html body #content { margin: 10px; padding: 16px 14px; border-radius: 12px; }
  html body h1 { font-size: 18px; margin-bottom: 12px; }
  html body #content-wrapper > #content.page-login { margin: 6vh auto 24px; padding: 26px 20px 20px; width: calc(100% - 20px); }

  /* Admin side menu: a scrolling row of pills */
  html body #side-menu { width: auto; min-width: 0; padding: 10px 10px 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  html body #side-menu > ul { display: flex; gap: 6px; margin: 0; }
  html body #side-menu > ul > li > a { white-space: nowrap; margin: 0; padding: 7px 12px; border: 1px solid var(--color1); background: #fff; border-radius: 99px; }
  html body #side-menu + #content { margin-left: 10px; }

  /* Devices list */
  html body #ot-search { flex-wrap: wrap; }
  html body #ot-search > input { flex: 1 1 100%; font-size: 16px; }
  html body #ot-search > button.primary { flex: 1; }
  html body .filter > input { width: 100%; box-sizing: border-box; font-size: 16px; }
  html body #content.page-devices table.table :is(th, td):is(:nth-child(3), :nth-child(4), :nth-child(5), :nth-child(8)) { display: none; }
  html body table.table td { max-width: 220px; }
  html body #ot-pager .ot-pages { margin-left: 0; width: 100%; justify-content: center; flex-wrap: wrap; }
  html body .actions-bar > button { flex: 1 1 auto; }

  /* Overview */
  html body .ot-ov-head { flex-wrap: wrap; gap: 4px; margin: 4px 4px 10px; }
  html body .ot-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  html body .ot-cards > :last-child:nth-child(odd) { grid-column: span 2; }
  html body a.ot-card { padding: 12px 14px; }
  html body .ot-card-n { font-size: 24px; }
  html body .ot-card-label { font-size: 11px; }
  html body .ot-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  html body .ot-donut-wrap { justify-content: center; }
  html body a.ot-bar { grid-template-columns: minmax(80px, 45%) 1fr 28px; }

  /* Device page, dialogs */
  html body .all-parameters > input { width: 100%; box-sizing: border-box; font-size: 16px; }
  html body .all-parameters > .parameter-list { height: 50vh; font-size: 12px; }
  html body table.parameter-list th { white-space: normal; padding-right: 10px; }
  html body .container-right { float: none; }
  html body .overlay-wrapper > .overlay { max-width: calc(100vw - 20px); box-sizing: border-box; }
  html body .overlay > .put-form { min-width: 0; }
  html body .wizard-dialog { margin: 10px; }
}

/* Fixes: the header must never shrink (body is a 100vh flex column), and the
   login card sizes to its content */
html body #header { flex-shrink: 0; }
html body #content-wrapper > #content.page-login { align-self: flex-start; min-height: 0; }
@media (max-width: 760px) {
  html body #content-wrapper > #content.page-login { align-self: center; }
}
@media (max-width: 760px) {
  html body #content.page-devices table.table { font-size: 13px; }
  html body #content.page-devices table.table :is(th, td) { padding: 7px 6px; }
  html body #content.page-devices table.table td:nth-child(7) { white-space: normal; min-width: 120px; }
  html body #content.page-devices table.table td:nth-child(7) span.inform { display: flex; flex-direction: column; gap: 2px; }
}
@media (max-width: 760px) {
  /* Phones: the list shows status only (date and SSID editing stay on the device page) */
  html body #content.page-devices table.table td:nth-child(7) span.inform > :first-child { display: none; }
  html body #content.page-devices table.table td:nth-child(7) { min-width: 0; white-space: nowrap; }
  html body #content.page-devices table.table td:nth-child(6) button { display: none; }
  html body #content.page-devices table.table td:nth-child(2) a { font-size: 12px; }
}
