/* style.css
 * ICU 儀器動向管理 App - 統一手機版 UI
 * 原則：Mobile First / 簡潔 / 專業 / 高辨識度 / 大按鈕 / 無多餘動畫
 */

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  background: #f2f4f7;
  color: #1a1f29;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.app-header {
  background: #0b5fa5;
  color: #fff;
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.app-main {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px 40px;
  width: 100%;
}

.state-block {
  width: 100%;
}

/* index.html / unit-inventory.html 互相跳轉的按鈕，跟卡片維持一致的垂直間距 */
.app-main > .btn {
  margin-bottom: 14px;
}

/* ---- 卡片 ---- */

.card {
  background: #fff;
  border-radius: 12px;
  padding: 18px 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  width: 100%;
}

.card-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 14px;
  text-align: center;
}

.hint-text {
  color: #55606e;
  font-size: 14px;
  margin: 0;
}

/* ---- 儀器資訊 ---- */

.equipment-info-card {
  border-left: 5px solid #0b5fa5;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid #eef0f3;
  gap: 12px;
}

.info-row:last-child {
  border-bottom: none;
}

.info-row-sub .info-label,
.info-row-sub .info-value {
  font-size: 13px;
  color: #7a8592;
}

.info-label {
  color: #55606e;
  font-size: 14px;
  white-space: nowrap;
}

.info-value {
  font-weight: 600;
  font-size: 15px;
  text-align: right;
  word-break: break-word;
}

.info-value-large {
  font-size: 20px;
  font-weight: 700;
}

.info-value-code {
  font-size: 22px;
  font-weight: 800;
  color: #0b5fa5;
  letter-spacing: 0.5px;
}

.info-value-location {
  font-size: 18px;
  font-weight: 700;
  color: #12805c;
}

/* ---- 表單元件 ---- */

.field-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #33404d;
  margin-bottom: 8px;
}

.field-group {
  margin-top: 14px;
}

.field-select,
.field-input {
  width: 100%;
  padding: 14px 12px;
  font-size: 17px;
  border: 2px solid #cdd5dd;
  border-radius: 10px;
  background: #fff;
  color: #1a1f29;
  appearance: none;
  -webkit-appearance: none;
}

.field-select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2355606e' stroke-width='3'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.field-select:focus,
.field-input:focus {
  outline: none;
  border-color: #0b5fa5;
}

.staff-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ---- 搜尋結果清單（人員搜尋 / 位置搜尋共用） ---- */

.search-result-list {
  margin-top: 10px;
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid #e3e7eb;
  border-radius: 10px;
}

.search-result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 14px;
  background: #fff;
  border: none;
  border-bottom: 1px solid #eef0f3;
  font-size: 16px;
  text-align: left;
  cursor: pointer;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item.selected {
  background: #0b5fa5;
  color: #fff;
}

.search-result-name {
  font-weight: 700;
}

.search-result-sub {
  font-size: 13px;
  opacity: 0.75;
}

/* ---- 按鈕 ---- */

.btn {
  display: block;
  width: 100%;
  text-align: center;
  padding: 15px 16px;
  font-size: 17px;
  font-weight: 700;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
  min-height: 50px;
}

.btn + .btn {
  margin-top: 10px;
}

.btn-primary {
  background: #0b5fa5;
  color: #fff;
}

.btn-secondary {
  background: #eef1f4;
  color: #1a1f29;
}

.btn-large {
  font-size: 18px;
  padding: 17px 16px;
}

.btn-text {
  width: auto;
  background: transparent;
  color: #0b5fa5;
  padding: 10px 14px;
  min-height: 44px;
  font-weight: 700;
  text-decoration: underline;
}

/* ---- 錯誤畫面 ---- */

.error-card {
  text-align: center;
}

.error-text {
  color: #b3261e;
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 18px;
}

/* ---- 成功畫面 ---- */

.success-card {
  text-align: center;
}

.success-icon {
  width: 64px;
  height: 64px;
  line-height: 64px;
  margin: 0 auto 10px;
  background: #12805c;
  color: #fff;
  border-radius: 50%;
  font-size: 32px;
  font-weight: 700;
}

.success-title {
  font-size: 20px;
  font-weight: 800;
  color: #12805c;
  margin-bottom: 12px;
}

.success-card .info-row {
  text-align: left;
}

.success-card .btn {
  margin-top: 12px;
}

/* ---- 確認彈窗 ---- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

/* author 樣式的 .overlay{display:flex} 若寫死，specificity 會蓋過瀏覽器內建的
   [hidden]{display:none}，導致彈窗即使有 hidden 屬性也會整片蓋住畫面、擋住點擊。
   因此改用 :not([hidden]) 才套用 flex，交由 JS 切換 hidden 屬性控制顯示。 */
.overlay:not([hidden]) {
  display: flex;
}

.overlay-card {
  background: #fff;
  border-radius: 14px;
  padding: 24px 20px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.confirm-eq-id {
  font-size: 20px;
  font-weight: 800;
  color: #0b5fa5;
  margin-bottom: 6px;
}

.confirm-text {
  margin: 6px 0 2px;
  color: #55606e;
  font-size: 14px;
}

.confirm-location {
  font-size: 22px;
  font-weight: 800;
  color: #12805c;
  margin-bottom: 12px;
}

.confirm-question {
  margin: 0 0 16px;
  font-size: 15px;
}

.overlay-actions {
  display: flex;
  gap: 10px;
}

.overlay-actions .btn {
  margin-top: 0;
}

/* ---- 儀器總數（index.html） ---- */

.total-count-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ---- 分頁籤（index.html） ---- */

.tab-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  flex: 0 0 auto;
  padding: 10px 16px;
  border-radius: 20px;
  border: 2px solid #cdd5dd;
  background: #fff;
  color: #33404d;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.tab-btn.active {
  background: #0b5fa5;
  border-color: #0b5fa5;
  color: #fff;
}

/* 次頁籤（例如管理後台裡「依單位」的第二層分類）：比主頁籤小一號，做出層級感 */
.sub-tab-bar {
  margin-bottom: 14px;
}

.sub-tab-bar .tab-btn {
  padding: 7px 12px;
  font-size: 13px;
}

/* ---- 卡片清單容器（index.html / unit-inventory.html 共用） ---- */

.equipment-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---- 床位卡片：目前單位現況（index.html） ---- */

.location-card {
  background: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.location-card-title {
  font-size: 16px;
  font-weight: 800;
  color: #0b5fa5;
  margin-bottom: 6px;
}

.location-card-empty {
  font-size: 14px;
  color: #9aa4af;
  padding: 4px 0;
}

.location-card-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid #eef0f3;
  text-decoration: none;
  color: inherit;
}

.location-card-item:first-of-type {
  border-top: none;
}

.location-card-item-name {
  font-size: 15px;
  font-weight: 700;
}

.location-card-item-id {
  font-size: 13px;
  color: #55606e;
  font-weight: 700;
  white-space: nowrap;
}

/* ---- 儀器類型卡片：單位儀器財產動向（unit-inventory.html） ---- */

.type-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.type-card-title {
  font-size: 17px;
  font-weight: 800;
  color: #1a1f29;
  margin-bottom: 8px;
}

.type-card-item {
  display: block;
  padding: 10px 0;
  border-top: 1px solid #eef0f3;
  text-decoration: none;
  color: inherit;
}

.type-card-item:first-of-type {
  border-top: none;
}

.type-card-item-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.type-card-item-id {
  font-size: 15px;
  font-weight: 800;
  color: #0b5fa5;
}

.type-card-item-location {
  font-size: 15px;
  font-weight: 700;
  color: #12805c;
  text-align: right;
  white-space: nowrap;
}

.type-card-item-sub {
  font-size: 12px;
  color: #7a8592;
  margin-top: 2px;
}

/* ---- 管理後台（admin.html） ---- */

.admin-table {
  margin-bottom: 16px;
}

.admin-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 0;
  border-top: 1px solid #eef0f3;
}

.admin-row:first-child {
  border-top: none;
}

.admin-row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.admin-row-id {
  font-size: 15px;
  font-weight: 800;
  color: #0b5fa5;
}

.admin-row-name {
  font-size: 14px;
  color: #1a1f29;
}

.admin-row-unit {
  font-size: 12px;
  color: #7a8592;
}

.admin-row-sub {
  font-size: 12px;
  color: #7a8592;
  margin-top: 2px;
}

.admin-row-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}

.admin-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #55606e;
  white-space: nowrap;
}

.admin-toggle input {
  width: 18px;
  height: 18px;
}

.btn-danger-sm {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #e0a3a0;
  background: #fdecea;
  color: #b3261e;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.admin-add-form {
  border-top: 1px dashed #dde2e7;
  padding-top: 14px;
  margin-top: 4px;
}

.admin-add-form .field-group:first-child {
  margin-top: 0;
}

.admin-import-block {
  border-top: 1px dashed #dde2e7;
  padding-top: 14px;
  margin-top: 18px;
}

.admin-import-block .field-label {
  line-height: 1.5;
}

/* ---- 新增儀器後的 QR Code 即時預覽 ---- */

.qr-preview-box {
  background: #f2f7fc;
  border: 1px dashed #a9c6e3;
  border-radius: 10px;
  padding: 14px;
  margin-top: 14px;
  text-align: center;
}

/* ---- QR Code 產生（admin.html） ---- */

.qr-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.qr-cell {
  width: 140px;
  text-align: center;
  border: 1px solid #e3e7eb;
  border-radius: 10px;
  padding: 10px;
}

.qr-holder {
  display: flex;
  justify-content: center;
  margin-bottom: 6px;
}

.qr-cell-id {
  font-weight: 800;
  font-size: 14px;
  color: #0b5fa5;
}

.qr-cell-name {
  font-size: 12px;
  color: #55606e;
  margin-bottom: 8px;
}

.btn-secondary-sm {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #cdd5dd;
  background: #eef1f4;
  color: #1a1f29;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

/* ---- 小螢幕微調 ---- */

@media (max-width: 360px) {
  .app-main {
    padding: 12px 12px 32px;
  }
  .card {
    padding: 14px 12px;
  }
}
