/* ===========================================================================
   Lazco Cloud — Smokeping 前端客製
   Lazco
   ---------------------------------------------------------------------------
   放在 /var/www/smokeping-custom/ 而非 /usr/share/smokeping/www/css/，
   因為後者是 dpkg 擁有的路徑，apt 升級會直接覆蓋。
   本檔案在官方 CSS 之後載入，以此覆寫。
   =========================================================================== */

:root {
  --lz-brand:        #00b9f8;
  --lz-brand-dim:    #0090c4;

  --lz-bg:           #eef1f4;
  --lz-surface:      #ffffff;
  --lz-surface-alt:  #f5f7f9;
  --lz-border:       #d7dde3;
  --lz-text:         #1c2733;
  --lz-text-dim:     #5b6b7c;

  --lz-sidebar-bg:   #16202b;
  --lz-sidebar-alt:  #0f1821;
  --lz-sidebar-text: #b6c4d2;
  --lz-navbar-bg:    #ffffff;

  --lz-radius:       8px;
  --lz-shadow:       0 1px 2px rgba(16,32,48,.06), 0 4px 12px rgba(16,32,48,.06);

  /* 圖表卡片永遠維持淺色：RRD 產生的 PNG 是深色文字與線條，
     放在深色底上會完全看不見，反轉濾鏡又會破壞紅/綠的語意色。 */
  --lz-plot-bg:      #ffffff;
}

:root[data-theme="dark"],
html[data-theme="dark"] {
  --lz-bg:           #0d141b;
  --lz-surface:      #16202b;
  --lz-surface-alt:  #1c2836;
  --lz-border:       #2a3846;
  --lz-text:         #e3ebf2;
  --lz-text-dim:     #8c9cad;
  --lz-navbar-bg:    #16202b;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --lz-bg:         #0d141b;
    --lz-surface:    #16202b;
    --lz-surface-alt:#1c2836;
    --lz-border:     #2a3846;
    --lz-text:       #e3ebf2;
    --lz-text-dim:   #8c9cad;
    --lz-navbar-bg:  #16202b;
  }
}

/* --------------------------------------------------------------- 基礎排版 */

body {
  background: var(--lz-bg);
  color: var(--lz-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC",
               "PingFang TC", "Microsoft JhengHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1 {
  font-size: 26px;
  line-height: 1.3;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 4px 0 6px;
  color: var(--lz-text);
}

h2 {
  font-size: 14px;
  line-height: 1.6;
  font-weight: 400;
  color: var(--lz-text-dim);
  margin: 0 0 4px;
}

a { color: var(--lz-brand-dim); }
:root[data-theme="dark"] a { color: var(--lz-brand); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) a { color: var(--lz-brand); }
}

/* ------------------------------------------------------------------- 側欄 */

.sidebar {
  background: var(--lz-sidebar-bg);
  color: var(--lz-sidebar-text);
  width: 260px;
  border-right: 1px solid rgba(255,255,255,.05);
}

.sidebar-header {
  border-bottom: 1px solid rgba(255,255,255,.07);
  height: 56px;
  display: flex;
  align-items: center;
}

.sidebar-menu {
  top: 51px;
  width: 259px;
  scrollbar-width: thin;
  scrollbar-color: #33414f transparent;
}
.sidebar-menu::-webkit-scrollbar { width: 8px; }
.sidebar-menu::-webkit-scrollbar-thumb {
  background: #33414f;
  border-radius: 4px;
}

.sidebar .filter-text input {
  background: var(--lz-sidebar-alt);
  color: var(--lz-sidebar-text);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
}
.sidebar .filter-text input:focus {
  outline: none;
  border-color: var(--lz-brand);
  box-shadow: 0 0 0 3px rgba(0,185,248,.15);
}

.sidebar ul.menu {
  padding: 6px 0 14px;
}

.sidebar ul.menu li {
  margin: 0 8px;
  border: 0;
  border-radius: 5px;
}

/* 官方把 hover / 展開 / 目前所在的底色與外框畫在 <li> 本身：
     .sidebar ul.menu li.menuopen, li:hover, li.menuactive   → (0,3,2)
   比上面那條 .sidebar ul.menu li (0,2,2) 多一個 class，所以展開的群組外面
   會多出一個深色方框、連同底下的子選單一起被框住。這裡照抄官方選擇器歸零
   （同分時後載入者勝），選取狀態一律交給裡面的 <a> 呈現。 */
.sidebar ul.menu li.menuopen,
.sidebar ul.menu li:hover,
.sidebar ul.menu li.menuactive {
  background: transparent;
  border: 0;
  color: inherit;
}

.sidebar ul.menu li a,
.sidebar ul.menu li .menulink {
  color: var(--lz-sidebar-text);
  border-radius: 5px;
  padding: 5px 9px;
  display: block;
  text-decoration: none;
  font-size: 12.5px;
  line-height: 1.45;
  transition: background .1s ease, color .1s ease;
}

.sidebar ul.menu li a:hover,
.sidebar ul.menu li .menulink:hover {
  background: rgba(255,255,255,.06);
  color: #fff;
}

.sidebar ul.menu li.menuactive > a,
.sidebar ul.menu li a.menuactive,
.sidebar ul.menu li .menulink.menuactive {
  background: var(--lz-brand);
  color: #04222e;
  font-weight: 600;
}

/* 目標樹有三層（例如 中國三網 > 中國電信 > 上海），靠縮排線與字級
   區分層級，否則 159 個項目全部同一個樣子會很難掃。 */
.sidebar ul.menu > li > a,
.sidebar ul.menu > li > .menulink {
  font-size: 13px;
  font-weight: 550;
  color: #cfdae6;
}

/* 選擇器帶上 li 是為了湊到 (0,2,3)，才追平官方的
   `.sidebar ul.menu li ul { background:#343434; padding:5px }`；
   少了那個 li 就只有 (0,2,2)，子選單會頂著一塊比側欄還淺的灰底。 */
.sidebar ul.menu li ul {
  list-style: none;
  background: transparent;
  padding: 0 0 0 8px;
  margin: 1px 0 4px 9px;
  border-left: 1px solid rgba(255,255,255,.09);
}

.sidebar ul.menu li ul ul {
  margin-left: 7px;
}

.sidebar ul.menu ul a,
.sidebar ul.menu ul .menulink {
  font-size: 12px;
  color: #9dadbd;
}

.sidebar .filter-text { margin: 9px 10px; }

/* ------------------------------------------------------------------- 頂列 */

/* 官方把 .navbar-user 設成 position:absolute; right:0，會脫離排版流並蓋住
   左邊的元素。改回 static 交給 flex 排列，並拿掉官方的分隔線與行高。 */
.navbar {
  background: var(--lz-navbar-bg);
  border-bottom: 1px solid var(--lz-border);
  height: 50px;
  left: 260px;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 0 0;
  box-sizing: border-box;
  box-shadow: none;
  text-shadow: none;
}

.navbar .navbar-menu {
  border-right: 1px solid var(--lz-border);
  height: 50px;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

/* 官方用 text-indent:100% + overflow:hidden 把文字推出可視範圍，只留漢堡
   背景圖。絕對不能加 padding，否則文字會被擠回畫面內露出半截。 */
a#menu-button {
  width: 50px;
  height: 50px;
  padding: 0;
  border-radius: 0;
  opacity: .45;
}
a#menu-button:hover { opacity: .8; background-color: var(--lz-surface-alt); }
:root[data-theme="dark"] a#menu-button { filter: invert(1); opacity: .5; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) a#menu-button { filter: invert(1); opacity: .5; }
}

.navbar .navbar-user {
  position: static;
  border-left: 0;
  height: auto;
  line-height: normal;
  padding: 0;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

/* SVG 商標沒有固定寬高比上限，只鎖 height 會被文字寬度撐爆並溢出畫面。 */
.navbar-user .logo { margin: 0; display: flex; align-items: center; }
.navbar-user .logo img {
  height: 26px !important;
  width: auto !important;
  max-width: 128px;
  display: block;
}

/* 右側群組：主題切換鈕 + 商標 */
.navbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  flex: 0 0 auto;
}

.lz-theme-toggle {
  appearance: none;
  border: 1px solid var(--lz-border);
  background: var(--lz-surface);
  color: var(--lz-text-dim);
  border-radius: 6px;
  padding: 5px 11px;
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color .12s ease, color .12s ease;
}
.lz-theme-toggle:hover { border-color: var(--lz-brand); color: var(--lz-brand); }

/* 側欄頁首：換成 Lazco 文字標題，不用官方那顆灰底 smokeping 圖 */
.sidebar-header {
  height: 50px;
  padding: 0 14px;
  display: flex;
  align-items: center;
}
.lz-sidebar-title {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: .02em;
  color: #fff;
  text-decoration: none;
  display: flex;
  align-items: baseline;
  gap: 7px;
}
.lz-sidebar-title small {
  font-size: 11px;
  font-weight: 400;
  color: var(--lz-brand);
  letter-spacing: .06em;
}

/* 側欄底部的 RRDtool 出處連結。
   官方給的是一張 100×30 的 PNG——深藍字壓白底，擺在深色側欄上就是一塊
   突兀的白方塊；壓透明度只會變成灰方塊，filter + mix-blend-mode 也消不
   乾淨。改成純文字連結，出處照樣留著，樣式跟側欄一致。 */
.sidebar-menu > .logo { padding: 16px 14px 22px; }
.sidebar-menu > .logo img { display: none; }
.sidebar-menu > .logo a {
  color: #5d6d7e;
  font-size: 11px;
  letter-spacing: .02em;
  text-decoration: none;
  transition: color .15s ease;
}
.sidebar-menu > .logo a::after { content: "Powered by RRDtool"; }
.sidebar-menu > .logo a:hover { color: var(--lz-brand); }

/* ----------------------------------------------------------------- 主內容 */

.main {
  padding-left: 260px;
  padding-top: 50px;
  margin: 0;
  display: block;
}

.main > h1,
.main > h2 {
  padding-left: 20px;
  padding-right: 20px;
}
.main > h1 { padding-top: 18px; }

.main .overview,
.main .details {
  padding: 0 12px 12px;
}

/* 節點圖例（由 basepage.html 提供） */
.lz-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  margin: 10px 20px 16px;
  padding: 10px 14px;
  background: var(--lz-surface);
  border: 1px solid var(--lz-border);
  border-radius: var(--lz-radius);
  font-size: 13px;
  color: var(--lz-text-dim);
  box-shadow: var(--lz-shadow);
}
.lz-legend span { display: inline-flex; align-items: center; gap: 7px; }
.lz-legend i {
  width: 22px;
  height: 3px;
  border-radius: 2px;
  display: inline-block;
}
.lz-legend .lz-tpe { background: #1c3f8f; }
.lz-legend .lz-txg { background: #e8590c; }

/* 圖表卡片 */
.main .panel {
  background: var(--lz-surface);
  border: 1px solid var(--lz-border);
  border-radius: var(--lz-radius);
  box-shadow: var(--lz-shadow);
  margin: 8px;
  overflow: hidden;
  transition: box-shadow .15s ease, transform .15s ease;
}
.main .panel:hover {
  box-shadow: 0 2px 4px rgba(16,32,48,.08), 0 10px 22px rgba(16,32,48,.10);
}

.main .panel-heading {
  background: var(--lz-surface-alt);
  border-bottom: 1px solid var(--lz-border);
  box-shadow: none;
}

.main .panel-heading h2 {
  line-height: 38px;
  font-size: 13px;
  font-weight: 600;
  color: var(--lz-text);
  padding-left: 14px;
}

.main .panel-body {
  padding: 10px;
  /* 圖表本身永遠淺底，確保深色模式下 RRD 圖的黑色文字仍清晰 */
  background: var(--lz-plot-bg);
}

.main .panel-body img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Smokeping 產生的表格（詳細數值） */
.main table {
  border-collapse: collapse;
  font-size: 13px;
  color: var(--lz-text);
}
.main table td,
.main table th {
  padding: 4px 8px;
}

/* ------------------------------------------------------------------- 頁尾 */

.footer {
  border-top: 1px solid var(--lz-border);
  padding-left: 260px;
  margin-top: 20px;
  background: var(--lz-surface);
}
.footer,
.footer a { color: var(--lz-text-dim); }
.footer p { margin: 12px 20px; font-size: 12px; }

/* --------------------------------------------------------- 側欄收合狀態 */

.sidebar-hidden .sidebar { left: -260px !important; }
.sidebar-hidden .main,
.sidebar-hidden .footer { padding-left: 0 !important; }
.sidebar-hidden .navbar { left: 0 !important; }

/* ------------------------------------------------------------ 行動裝置 */

@media (max-width: 900px) {
  .sidebar { left: -260px; width: 260px; }
  .navbar  { left: 0; }
  .main, .footer { padding-left: 0; }

  .sidebar-visible .sidebar { left: 0 !important; }
  .sidebar-visible .navbar  { left: 260px !important; }

  h1 { font-size: 21px; }
  .main > h1, .main > h2 { padding-left: 14px; padding-right: 14px; }
  .lz-legend { margin: 10px 14px 14px; gap: 12px; }
  .main .panel { margin: 8px 0; border-radius: 0; border-left: 0; border-right: 0; }
  .main .overview, .main .details { padding: 0 0 12px; }
  .navbar-user .logo img { height: 26px !important; }
  .lz-theme-toggle { padding: 5px 9px; margin-right: 8px; }
}

@media (max-width: 480px) {
  .lz-legend { font-size: 12px; }
  .footer p { margin: 10px 14px; }
}

/* 列印時不顯示裝飾 */
@media print {
  .sidebar, .navbar, .lz-theme-toggle, .lz-legend { display: none !important; }
  .main, .footer { padding-left: 0 !important; padding-top: 0 !important; }
}

/* ------------------------------------------------- 首頁空狀態引導 */

.lz-empty {
  margin: 8px;
  padding: 28px 24px;
  background: var(--lz-surface);
  border: 1px dashed var(--lz-border);
  border-radius: var(--lz-radius);
  color: var(--lz-text-dim);
  max-width: 720px;
}
.lz-empty strong {
  display: block;
  font-size: 16px;
  font-weight: 650;
  color: var(--lz-text);
  margin-bottom: 10px;
}
.lz-empty p { margin: 6px 0; font-size: 13px; }
.lz-empty em {
  font-style: normal;
  font-weight: 600;
  color: var(--lz-text);
}

/* ------------------------------------------- 側欄頁首 / 商標深淺色切換 */

/* 原本的 "Lazco Cloud NETWORK" 是硬湊的 lockup——右上已有正式商標，
   側欄再放一次只是重複。改成功能名 + 兩地節點標籤，資訊密度更高。 */
.lz-sidebar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #e7eef6;
  text-decoration: none;
  letter-spacing: .01em;
}
.lz-title-main { white-space: nowrap; }
.lz-title-nodes { display: flex; gap: 5px; }
.lz-title-nodes em {
  font-style: normal;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .05em;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0,185,248,.14);
  border: 1px solid rgba(0,185,248,.3);
  color: var(--lz-brand);
  line-height: 1.4;
}

/* 亮色主題用彩色 SVG、深色主題用反白 PNG。
   選擇器一定要帶 `.navbar-user .logo img`，否則會被上面那條
   `.navbar-user .logo img { display:block }`（0,2,1）壓過純 class 的
   `.lz-logo-dark`（0,1,0）→ 亮色模式兩張商標同時顯示、把頂列撐爆。
   深色模式當初沒中招，是因為 `:root[...]` 前綴剛好把特異性墊高。 */
.navbar-user .logo img.lz-logo-dark  { display: none; }
.navbar-user .logo img.lz-logo-light { display: block; }
:root[data-theme="dark"] .navbar-user .logo img.lz-logo-dark  { display: block; }
:root[data-theme="dark"] .navbar-user .logo img.lz-logo-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .navbar-user .logo img.lz-logo-dark  { display: block; }
  :root:not([data-theme="light"]) .navbar-user .logo img.lz-logo-light { display: none; }
}
