/* ===========================
   layout.css - 框架結構（套版部分包含響應式，不常修改）
   =========================== */

/* 通用樣式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, "Microsoft JhengHei", BlinkMacSystemFont,
    "Segoe UI", Roboto, sans-serif;
  user-select: none;
}

body {
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: #f5f5f5;
  display: flex;
  flex-direction: column;
  margin: 0;
  position: relative;
}

/* ========== Header ========== */
#header {
  width: 100%;
  height: 100px;
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 50px;
  position: relative;
  z-index: 20;
  flex-shrink: 0;
}

a:link,
a:visited {
  text-decoration: none;
  color: black;
}
.logo {
  height: 80px;
}

.menu-content {
  display: flex;
  align-items: center;
  gap: 0;
  position: static;
  background: none;
  box-shadow: none;
  padding: 0;
  height: auto;
  width: auto;
  flex-direction: row;
}

.Alltitle {
  display: flex;
  padding: 0;
  justify-content: center;
  margin: 0 40px;
}

.title {
  padding: 0 40px;
  cursor: pointer;
  transition: color 0.2s ease;
}

.iconimg {
  height: 30px;
  padding: 0 8px;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

/* 漢堡選單按鈕 (桌面版隱藏) */
.hamburger-menu {
  display: none;
  flex-direction: column;
  cursor: pointer;
  padding: 10px;
  z-index: 30;
}

.hamburger-menu span {
  width: 25px;
  height: 3px;
  background-color: #333;
  margin: 3px 0;
  transition: 0.3s;
  border-radius: 2px;
}

/* 漢堡選單動畫 */
.hamburger-menu.active span:nth-child(1) {
  transform: rotate(-45deg) translate(-6px, 6px);
}

.hamburger-menu.active span:nth-child(2) {
  opacity: 0;
}

.hamburger-menu.active span:nth-child(3) {
  transform: rotate(45deg) translate(-6px, -6px);
}

/* ========== 主要內容區域 ========== */
#main-content {
  flex: 1;
  display: flex;
  height: calc(100vh - 110px);
  overflow: hidden;
}

/* 3D 畫面容器 */
#three-container {
  flex: 1;
  height: 100%;
  background: rgb(0, 0, 0);
  position: relative;
  overflow: hidden;
}

/* 右側控制面板 - 固定寬度和位置 */
#control-panel {
  width: auto;
  min-width: 26.2%;
  height: 100%;
  flex-shrink: 0;
  background: #ffffff;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
  padding: 25px;
  overflow-y: auto;
  position: relative;
  z-index: 10;
}

/* 碰撞文字警告(無啟用) */
/* #collision-warning {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: rgb(255, 0, 0);
  font-size: 16px;
  font-weight: bold;
  z-index: 99;
  padding: 12px 20px;
  border-radius: 8px;
  text-align: center;
} */

/* ========== UI Panel 框架 ========== */
#ui-panel {
  width: auto;
  min-width: 350px;
  height: 100%;
  flex-shrink: 0;
  background: #ffffff;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
  padding: 25px;
  overflow-y: auto;
  position: relative;
  z-index: 10;
}

/* ========== Footer ========== */
#footer {
  width: 100%;
  height: 55px;
  background: #787878;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  z-index: 20;
}

/* ========== 網頁開始 Loading 畫面 ========== */
#loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  font-family: sans-serif;
}
.spinner {
  width: 60px;
  height: 60px;
  border: 6px solid #ccc;
  border-top-color: #333;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}
.loading-text {
  font-size: 1.5em;
  color: #333;
  animation: blink 1.5s ease-in-out infinite;
}
/* ========== 點擊 AR按鈕後的 Loading 畫面 ========== */
#ar-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #ffffffe6;
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  font-family: sans-serif;
}
.ar-loading-box {
  text-align: center;
}
.ar-spinner {
  width: 60px;
  height: 60px;
  border: 6px solid #bbb;
  border-top-color: #444;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}
.ar-loading-message {
  font-size: 1.4em;
  color: #444;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes blink {
  0%,
  to {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}
.disabled-label {
  opacity: 0.6;
  pointer-events: none;
}
/* AR 模式容器 */
#ar-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  background: black;
}

/* ========== 響應式設計 - 手機版 ========== */
@media (max-width: 768px) {
  #header {
    height: 70px;
    padding: 0 20px;
    justify-content: center;
  }

  #three-container {
    height: 40%;
  }

  #main-content {
    flex-direction: column;
  }

  #control-panel {
    height: 60%;
  }

  #collision-warning {
    font-weight: 500;
    font-size: 14px;
    padding: 10px 8px;
    white-space: normal;
    width: 60%;
    border: 1px solid #ff0000;
  }

  #footer {
    font-size: 10px;
    height: 40px;
  }

  /* 按鈕欄位功能(無啟用) */
  /* .accessory-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  } */

  .accessory-btn {
    height: auto; /* 自動高度 */
    min-height: 140px;
    padding: 20px 10px;
  }

  /* 手機版配件圖片調整 */
  .accessory-image {
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .accessory-image img {
    width: 150px;
    height: 150px;
    padding: 5px 0 5px 0;
  }

  /* 手機版配件標籤調整 */
  .accessory-label {
    font-size: 16px;
    line-height: 1.2;
    text-align: center;
  }

  /* 手機版下拉選單調整 */
  .accessory-select {
    width: 100%;
    padding: 6px 8px; /* 增加padding讓觸控更容易 */
    font-size: 14px; /* 防止iOS自動縮放 */
    margin-top: 8px;
    min-height: 36px; /* iOS建議的最小觸控區域 */
  }

  .board-shape-select {
    padding: 12px 16px;
    font-size: 16px; /* 防止iOS自動縮放 */
    min-height: 48px; /* iOS建議的最小觸控區域 */
  }

  .logo {
    height: 60px; /* 縮小 Logo */
  }

  /* 顯示漢堡選單按鈕 */
  .hamburger-menu {
    display: flex;
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
  }

  /* 隱藏桌面版選單 */
  .menu-content {
    display: none;
    position: fixed;
    top: 70px;
    left: 0;
    width: 100%;
    height: calc(100vh - 70px);
    background: #ffffff;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding-top: 40px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 25;
  }

  /* 顯示手機版選單 */
  .menu-content.active {
    display: flex;
  }

  .Alltitle {
    flex-direction: column;
    padding: 0;
    margin-bottom: 40px;
  }

  .title {
    padding: 20px 40px;
    text-align: center;
    border-bottom: 1px solid #f0f0f0;
    width: 100%;
    font-size: 18px;
  }

  .title:last-child {
    border-bottom: none;
  }

  .icon {
    display: flex;
    justify-content: center;
    gap: 20px;
  }

  .iconimg {
    height: 40px;
    padding: 0;
  }

  .socket-position-group {
    gap: 6px;
    margin: 10px 0 6px 0;
  }

  .socket-checkbox-label {
    padding: 8px 6px;
    font-size: 11px;
  }

  .socket-checkbox {
    width: 16px;
    height: 16px;
  }

  .socket-checkbox:checked::after {
    top: -1px;
    left: 2px;
    font-size: 11px;
  }
}

/* ========== 響應式設計 - 平板版 ========== */
@media (min-width: 769px) and (max-width: 1024px) {
  #main-content {
    max-width: 100vw;
    max-height: calc(100vh - 110px);
  }

  #three-container {
    max-width: calc(100vw - 320px);
    max-height: 100%;
  }
  .iconimg {
    padding: 0 5px;
  }
  #-panelui {
    max-height: 100%;
  }
  #header {
    padding: 0 30px;
  }
  .title {
    padding: 0 15px;
  }
  .logo {
    height: 70px; /* 縮小 Logo */
  }
  #control-panel {
    max-height: 100%;
  }

  .accessory-image img {
    width: 100px;
    height: 100px;
    padding: 10px 0 10px 0;
  }
}
