/* 店家入口：側欄、建立比賽、比賽列表、改名按鈕及手機布局。
   保留原本樣式優先順序；媒體查詢限定在其所屬元件。 */

.portal-game-suffix {
  width: 220px;
}

.portal-section-divider {
  border: 0;
  border-top: 1px solid var(--ui-border);
  margin: 20px 0;
}

#eventTitle {
  margin-top: 0;
}

.portal-layout {
  min-height: 100vh;
  display: flex;
}

.portal-sidebar {
  width: 260px;
  min-height: 100vh;
  flex: 0 0 260px;
  background: #111;
  border-right: 1px solid #333;
  display: flex;
  flex-direction: column;
  transition:
    width 0.2s,
    flex-basis 0.2s;
}

.portal-sidebar.collapsed {
  width: 64px;
  flex-basis: 64px;
}

.portal-sidebar-header {
  height: 52px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.portal-sidebar-title {
  font-size: 24px;
  font-weight: 800;
  color: #fff;
}

.portal-sidebar.collapsed .portal-sidebar-title {
  display: none;
}

.portal-sidebar.collapsed .portal-sidebar-header {
  justify-content: center;
  padding: 0;
}

.sidebar-toggle {
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #ddd;
  border: 0;
  font-size: 18px;
}

.portal-main {
  --ui-page: #171b22; /* 右側整頁背景 */
  --ui-card: #222831;
  --ui-table: #1c222a;
  --ui-input: #181e26;
  --ui-border: #36414f; /* 表格線、卡片邊框、分隔線 */
  --ui-text: #edf2f7; /* 主要文字 */
  --ui-button: #20364d; /* 一般操作按鈕背景 */
  --ui-button-text: #69b8ff; /* 一般操作按鈕文字 */

  flex: 1;
  min-width: 0;
  padding: 0px 20px 20px;
  background: var(--ui-page);
  color: var(--ui-text);
}

.portal-main .container {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0;
}

.portal-main .container > h1 {
  margin-top: 0;
}

.portal-main #gameSelect {
  margin-left: 0;
}

.sidebar-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 8px;
}

.sidebar-menu-item {
  width: 100%;
  height: 42px;
  margin: 0;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #f2f2f2;
  text-align: left;
  font-size: 15px;
  font-weight: 700;
}

.sidebar-menu-item:hover {
  background: #2f2f2f;
}

.sidebar-icon {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-text {
  white-space: nowrap;
}

.sidebar-logout-btn {
  color: #ffb4b4;
}

.portal-sidebar.collapsed .sidebar-text {
  display: none;
}

.portal-sidebar.collapsed .sidebar-menu-item {
  justify-content: center;
  padding: 0;
}

@media (max-width: 768px) {
  .portal-layout {
    display: block;
    overflow-x: clip;
  }

  /* 側邊欄在下層、固定不動；上層頁面往右滑開時才露出來（同 player-dashboard） */
  .portal-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1;
    width: 70vw;
    min-height: 0;
    overflow-y: auto;
    visibility: hidden;
  }

  body.drawer-open .portal-sidebar,
  body.drawer-dragging .portal-sidebar {
    visibility: visible;
  }

  /* 頁面在上層，往右滑動；遮罩跟著滑開的幅度變暗 */
  .portal-main {
    position: relative;
    z-index: 2;
    min-height: 100vh; /* 背景撐滿手機畫面，蓋住下層選單 */
    touch-action: pan-y;
    padding: 16px;
  }

  .portal-main .container {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
  }
}

.event-name-button {
  display: inline;
  width: auto;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  text-align: left;
  cursor: pointer;
}

.event-name-button:hover {
  background: transparent;
  text-decoration: underline;
}

/* 首頁右側：卡片與表單 */
.portal-main .card {
  padding: 16px;
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  box-shadow: 0 4px 14px #0002;
}

.portal-main input,
.portal-main select {
  height: 44px;
  padding: 0 14px;
  border: 1px solid #455364;
  border-radius: 8px;
  background: var(--ui-input);
  color: var(--ui-text);
  font-size: 16px;
}

.portal-main input::placeholder {
  color: #8996a6;
}

.portal-main .form-row {
  align-items: center;
  gap: 12px;
}

.portal-main .form-row input,
.portal-main .form-row select,
.portal-main .form-row button {
  height: 44px;
  margin: 0;
  max-width: 100%;
}

.portal-main .form-row .field {
  min-width: 0;
  max-width: 100%;
}

/* 操作按鈕；排除可點擊的比賽名稱 */
.portal-main button:not(.event-name-button) {
  height: 44px;
  padding: 0 16px;
  border: 1px solid #395c7d;
  border-radius: 8px;
  background: var(--ui-button);
  color: var(--ui-button-text);
  font-size: 16px;
  font-weight: 600;
}

.portal-main button:not(.event-name-button):enabled:hover {
  background: #294760;
  border-color: #69b8ff;
}

.portal-main button.danger {
  background: #32252c;
  border-color: #82434d;
  color: #f08087;
}

.portal-main button.danger:enabled:hover {
  background: #462b34;
  border-color: #f08087;
}

.portal-main input:focus-visible,
.portal-main select:focus-visible,
.portal-main button:focus-visible {
  outline: 2px solid #69b8ff;
  outline-offset: 2px;
}

/* 比賽列表 */
.portal-main #eventList table {
  border: 1px solid var(--ui-border);
}

.portal-main #eventList th {
  padding: 12px 14px;
  background: var(--ui-input);
  color: #a5b1c0;
  font-size: 14px;
  font-weight: 600;
}

.portal-main #eventList td {
  padding: 12px 14px;
  color: var(--ui-text);
  font-size: 15px;
  vertical-align: middle;
}

.portal-main #eventList tr:hover td {
  background: #222c37;
}

.portal-main .event-name-button:hover {
  color: #69b8ff;
}

/* 手機比賽卡片沿用同一組配色 */
.portal-main .mobile-card {
  border-color: var(--ui-border);
  border-radius: 10px;
}

.portal-main .mobile-card p {
  color: #a5b1c0;
}

/* Portal 卡片：半透明毛玻璃，無陰影 */
.portal-main .card {
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  box-shadow: none;
}

/* 建立比賽、Enter：半透明藍底 */
.portal-main button:not(.event-name-button):not(.danger) {
  background: rgba(32, 54, 77, 0.25);
  box-shadow: none;
}

/* Delete：半透明紅底 */
.portal-main button.danger {
  background: rgba(50, 37, 44, 0.25);
  box-shadow: none;
}

/* 滑鼠移入 */
@media (hover: hover) {
  .portal-main button:not(.event-name-button):not(.danger):hover {
    background: rgba(41, 71, 96, 0.6);
  }

  .portal-main button.danger:hover {
    background: rgba(70, 43, 52, 0.6);
  }
}

/* 側邊欄：目前所在項目 */
.sidebar-menu-item.active {
  background: #2f2f2f;
}

/* 右側面板：Pairings History、Administrator */
.portal-main [hidden] {
  display: none !important; /* .form-row 的 display:flex 會蓋掉 hidden 屬性 */
}

.portal-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.portal-panel-head h2 {
  margin: 0;
}

.portal-panel .form-row {
  margin-top: 16px;
}

.portal-panel .form-row input {
  width: 260px;
}

.admin-msg {
  min-height: 1.4em;
  margin-top: 12px;
}

.admin-clerk-id {
  font-family: Consolas, "Courier New", monospace;
  letter-spacing: 0.04em;
}

.portal-panel table {
  margin-top: 12px;
  border: 1px solid var(--ui-border);
}

.portal-panel th {
  padding: 12px 14px;
  background: var(--ui-input);
  color: #a5b1c0;
  font-size: 14px;
  font-weight: 600;
}

.portal-panel td {
  padding: 12px 14px;
  font-size: 15px;
  vertical-align: middle;
}

.portal-panel tr:hover td {
  background: #222c37;
}

.portal-panel .mobile-card .admin-clerk-id {
  margin-left: 8px;
  font-size: 16px;
  color: #a5b1c0;
}

.panel-notice p {
  color: #a5b1c0;
}

/* 共用樣式 components.css 給所有按鈕 margin: 6px，這裡歸零才會和標題、文字對齊 */
.panel-notice .panel-back-btn {
  margin: 0;
}

/* Pairings History：整列可點擊下載，滑過或鍵盤選取時檔名變藍並加底線 */
.portal-panel .history-table td {
  padding: 0;
}

.portal-panel .history-table a.history-file {
  display: block;
  padding: 14px;
  color: var(--ui-text);
  font-size: 15px;
  text-decoration: none;
}

.portal-panel .history-table tr:hover a.history-file,
.portal-panel .history-table a.history-file:focus-visible {
  color: #69b8ff;
  text-decoration: underline;
}

.portal-panel .history-table a.history-file:focus-visible {
  outline: 2px solid #69b8ff;
  outline-offset: -2px;
}

@media (max-width: 768px) {
  .portal-panel .form-row input{
    width: 100%;
  }
}

/* 手機版頂端列；桌機不顯示 */
.mobile-topbar {
  display: none;
}

@media (max-width:768px) {
  .mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    height: 52px;
    margin: -16px -16px 16px; /* 抵銷 .portal-main 的 16px padding，貼齊畫面邊緣 */
    padding: 0 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #111;
    border-bottom: 1px solid #333;
  }

  /* 選擇器要夠具體，才不會被 .portal-main 一般按鈕的樣式蓋過 */
  .portal-main .mobile-topbar button.mobile-menu-btn,
  .portal-main .mobile-topbar button.mobile-menu-btn:hover {
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    box-shadow: none;
    color: #ddd;
    font-size: 22px;
  }

  .mobile-topbar-title {
    color: #fff;
    font-size: 18px;
    font-weight: 800;
  }

  /* 頁面遮罩：跟著選單打開的幅度變暗 */
  .portal-main::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 10;
    background: #000;
    opacity: var(--drawer-dim, 0);
    pointer-events: none;
  }
}

/* 賽事列表：整列可點擊進入 */
.portal-main .event-row {
  cursor: pointer;
}

.portal-main .event-row:focus-visible {
  outline: 2px solid #69b8ff;
  outline-offset: -2px;
}

.portal-main .mobile-card.event-row:hover {
  background: #222c37;
}

/* 右下角裝飾圖：內容短時貼在右下角，內容長時被推到內容下方，永遠不重疊 */
.portal-main {
  display: flex;
  flex-direction: column;
}

.portal-corner-art {
  --art-width: 360px; /* 大小：只設寬度，高度自動等比例 */
  --art-gap: 16px; /* 與上方內容的最小距離 */
  --art-right: 4px; /* 右側再往內縮多少（另外還有 .portal-main 的 20px padding） */
  --art-bottom: 4px; /* 下方再往上多少（另外還有 .portal-main 的 20px padding） */

  display: block;
  align-self: flex-end; /* 靠右 */
  width: var(--art-width);
  max-width: 40vw; /* 視窗變窄時跟著縮小 */
  height: auto; /* 等比例的關鍵 */
  margin: auto var(--art-right) var(--art-bottom) 0; /* margin-top: auto 把圖推到最下面 */
  padding-top: var(--art-gap);
  box-sizing: content-box;
  pointer-events: none;
  user-select: none;
}

@media (max-width: 768px) {
  .portal-corner-art {
    --art-width: 180px;
  }
}
