/* ==========================================================================
   共用外殼（頂欄 + 左側圖示導覽 + 主內容/側欄骨架）
   基準：02_G02_角色首頁（經確認為全站 shell 基準）
   由 assets/js/shell.js 注入 DOM，各頁只需撰寫主內容。
   ========================================================================== */

/* ==========================================================================
   頂欄
   ========================================================================== */

.topbar {
  height: var(--topbar-h);
  background: var(--c-navy-topbar);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px 0 22px;
  color: #E8EEF0;
}

.topbar__brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex: none;
}

.topbar__mark { display: block; flex: none; }

.topbar__name {
  font-size: 19px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .01em;
  white-space: nowrap;
}

/* --- 環境／密級標籤 --- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  flex: none;
}

.chip--env {
  margin-left: 18px;
  color: #5FD3C4;
  border: 1px solid rgba(95, 211, 196, .45);
  background: rgba(95, 211, 196, .07);
}

.chip--secret {
  color: #E7B45A;
  border: 1px solid rgba(231, 180, 90, .5);
  background: rgba(231, 180, 90, .07);
}

/* --- 資料截至 --- */
.topbar__meta {
  margin-left: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: none;
}

.topbar__meta-line {
  font-size: 13px;
  color: #C4D2D7;
  line-height: 1.5;
  white-space: nowrap;
}

.topbar__meta-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #8EA5AD;
}

/* --- 搜尋 --- */
.search {
  margin-left: auto;
  position: relative;
  display: flex;
  align-items: center;
  width: 350px;
  height: 40px;
  border-radius: var(--r-sm);
  border: 1px solid rgba(160, 186, 195, .28);
  background: rgba(255, 255, 255, .04);
  padding: 0 12px;
  gap: 10px;
  flex: none;
}

.search__icon { color: #93A9B1; flex: none; }

.search__input {
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  outline: none;
  font-size: 14px;
  color: #E8EEF0;
}

.search__input::placeholder { color: #81959C; }

.search__kbd {
  font: inherit;
  font-size: 12px;
  color: #94A8AF;
  border: 1px solid rgba(160, 186, 195, .3);
  border-radius: 5px;
  padding: 2px 7px;
  flex: none;
}

/* --- 通知 --- */
.topbar__bell {
  position: relative;
  color: #D3DEE2;
  padding: 4px;
  flex: none;
  margin-left: 6px;
}

.topbar__badge {
  position: absolute;
  top: -3px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #E8963C;
  color: #1A1206;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  padding: 0 4px;
}

.topbar__sep {
  width: 1px;
  height: 30px;
  background: rgba(160, 186, 195, .26);
  flex: none;
}

/* --- 帳號 --- */
.account {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: #D3DEE2;
  flex: none;
}

.account__avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #0B6E6B;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex: none;
}

.account__name {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  line-height: 1.35;
  white-space: nowrap;
}

.account__role {
  display: block;
  font-size: 12px;
  color: #8EA5AD;
  line-height: 1.4;
  white-space: nowrap;
}

/* ==========================================================================
   殼層骨架
   ========================================================================== */

.shell {
  display: flex;
  align-items: flex-start;
  min-height: calc(100vh - var(--topbar-h));
}

/* --- 左側圖示導覽 --- */
.rail {
  flex: none;
  width: var(--rail-w);
  align-self: stretch;
  background: var(--c-rail);
  display: flex;
  flex-direction: column;
  padding: 14px 0 18px;
  position: sticky;
  top: 0;
}

.rail__list { display: flex; flex-direction: column; gap: 2px; }

.rail__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 12px 4px;
  color: #90A8B0;
  font-size: 12px;
  line-height: 1.3;
  text-align: center;
  position: relative;
}

.rail__item:hover { color: #CFE0E4; }

.rail__item.is-active { color: #E9F3F4; background: var(--c-rail-active); }

.rail__item.is-active::before {
  content: "";
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: #3FB3AC;
}

/* 尚未切版的導覽項（待補頁面） */
.rail__item[data-pending="1"] { opacity: .72; }

.rail__collapse {
  margin-top: auto;
  align-self: center;
  color: #8AA2AA;
  padding: 10px;
}

/* --- 主內容 --- */
.main {
  flex: 1;
  min-width: 0;
  padding: 26px 20px 30px 36px;
}

/* --- 右側欄 --- */
.side {
  flex: none;
  width: var(--sidebar-w);
  padding: 120px 18px 30px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ==========================================================================
   響應式
   ========================================================================== */

@media (max-width: 1280px) {
  .shell { flex-wrap: wrap; align-items: stretch; }

  .main { flex: 1 1 100%; order: 2; }

  .side {
    flex: 1 1 100%;
    order: 3;
    width: auto;
    padding: 0 26px 30px;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .topbar__meta { display: none; }
  .search { width: 260px; }
}

@media (max-width: 640px) {
  .topbar {
    height: auto;
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 10px;
  }

  .topbar__name { font-size: 16px; }
  .chip { height: 30px; font-size: 12.5px; padding: 0 10px; }
  .chip--env { margin-left: 0; }

  .search {
    order: 9;
    margin-left: 0;
    width: 100%;
    height: 38px;
  }

  .search__kbd { display: none; }
  .topbar__bell { margin-left: auto; }
  .topbar__sep { display: none; }
  .account__text { display: none; }

  /* 導覽改為底部橫向捲動 */
  .shell { flex-direction: column; align-items: stretch; }

  .shell > .rail,
  .shell > .main,
  .shell > .side {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex: 0 0 auto;
  }

  .rail {
    order: 3;
    position: static;
    align-self: auto;
    padding: 6px 0;
  }

  .rail__list {
    flex-direction: row;
    overflow-x: auto;
    gap: 0;
    width: 100%;
    min-width: 0;
    -webkit-overflow-scrolling: touch;
  }

  .rail__item {
    flex: none;
    min-width: 84px;
    padding: 10px 6px;
    font-size: 11.5px;
  }

  .rail__item.is-active::before {
    left: 6px; right: 6px; top: auto; bottom: 0;
    width: auto; height: 3px;
    border-radius: 3px 3px 0 0;
  }

  .rail__collapse { display: none; }

  .main { order: 1; padding: 18px 14px 8px; }

  .side {
    order: 2;
    padding: 0 14px 8px;
    flex-direction: column;
    gap: 12px;
  }
}
