/* 自訂微調樣式與滾動條控制 */
.text-mist-blue,
.nav-btn-active,
.nav-btn-active .nav-icon {
  color: #2c4c64 !important;
}

.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* 支援 iPhone 瀏海與下方橫條的安全邊距與點擊優化 */
body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

/* 時間軸節點小圓點動效 */
.timeline-dot {
  position: absolute;
  left: -29px;
  top: 4px;
}

/* 避免全螢幕彈窗 (Modal) 被 iOS 瀏海或狀態列遮擋關閉鍵 */
.fixed.inset-0 {
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

/* 頂部 Header 純圖片背景設定（加入深藍底色防止載入時白閃隱形） */
#app-header {
  background-color: #0b1021 !important;
  background-image: url('./header-map-bg.png') !important;
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
}

/* 票券頁底部資訊卡可由短橫槓拖曳展開，或收合至只顯示名稱。 */
.ticket-details-sheet {
  position: relative;
  flex: 0 0 auto;
  width: min(calc(100% - 1rem), 42rem);
  margin: 0 auto 0.75rem;
  padding: 4px 12px 12px;
}

#ticket-zoom-viewport {
  min-width: 0;
  min-height: 0;
}

#modal-ticket-img {
  display: block;
  flex: 0 1 auto;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

#modal-dynamic-warning-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 40;
  transform: translate(-50%, -50%);
}

#modal-dynamic-warning-link {
  background-color: transparent !important;
  color: #fff !important;
  text-align: center;
  box-shadow: none !important;
}

#modal-dynamic-warning-link:hover {
  background-color: rgb(255 255 255 / 0.1) !important;
}

.ticket-info-overlay {
  position: absolute;
  inset: 0;
  z-index: 60;
}

/* 豬豬園地摘要列：預設收合，展開時以抽屜方式向下顯示詳細內容 */
.yard-accordion-content {
  display: grid;
  grid-template-rows: 1fr;
  opacity: 1;
  transition: grid-template-rows 280ms ease, opacity 180ms ease;
}

.yard-accordion-content.yard-collapsed {
  grid-template-rows: 0fr;
  opacity: 0;
  pointer-events: none;
  border-top-color: transparent !important;
}

.yard-accordion-inner {
  min-height: 0;
  overflow: hidden;
}

.yard-accordion-content:not(.yard-collapsed) .yard-accordion-inner {
  padding: 12px 0 0;
}

/* ==================== 電腦版桌面視圖縮放與橫向切換樣式 ==================== */
#app-device-frame {
  transform-origin: top center;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 桌面縮放時，彈窗內容同步縮放；橫向模式下表單視窗使用較寬版面。 */
@media (min-width: 768px) {
  body .fixed.inset-0:not(#view-ticket-modal) > div:first-child {
    transform: scale(var(--desktop-dialog-scale, 1));
    transform-origin: center center;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: calc(90vh / var(--desktop-dialog-scale, 1));
  }

  body.desktop-landscape .fixed.inset-0:not(#view-ticket-modal) > div:first-child {
    width: min(680px, calc(100vw - 48px)) !important;
    max-width: 680px !important;
  }
}

/* ==================== 類 Word 行程表格格線與泡泡編輯樣式 ==================== */
.pdf-cabinet {
  background: #fff;
  border-color: #e2e8f0;
}

.pdf-cabinet-shelves {
  overflow: hidden;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  background: #f3f4f6;
}

.pdf-cabinet-drawer {
  background: #fff;
  border: 0;
  border-bottom: 1px solid #eef2f6;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
  transition: background-color 150ms ease;
}

.pdf-cabinet-drawer:hover {
  background: #fff;
}

.pdf-cabinet-drawer:last-child {
  border-bottom: 0;
}

.word-table {
  border: 1px solid #e2e8f0 !important;
  border-collapse: collapse !important;
}
.word-table th, .word-table td {
  border: 1px solid #e2e8f0 !important;
}
.word-table td {
  line-height: 1.35 !important;
  font-size: 12px !important;
  vertical-align: top;
}
.word-table .time-cell,
.word-table .event-cell,
.word-table .note-cell,
.word-table .bubble-title-editable {
  font-family: inherit !important;
  font-size: inherit !important;
}
.word-table td[rowspan] {
  vertical-align: middle !important;
}
.word-table td.single-line-cell {
  vertical-align: middle !important;
}
.word-table .event-cell,
.word-table .time-cell,
.word-table .note-cell {
  padding: 6px 8px !important;
}
.word-table .bubble-dropzone {
  min-height: 0 !important;
  gap: 0 !important;
  padding: 0 !important;
}
.word-table .direct-input-placeholder {
  min-height: 1.35em;
  line-height: 1.35 !important;
}

/* 行程泡泡項目：採用標準 Flex 橫向排版，拖曳把手與文字依序排列不重疊 */
.word-table .bubble-item {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  display: flex !important;
  width: 100%;
  align-items: flex-start !important;
  gap: 4px !important;
  line-height: 1.35 !important;
  position: static !important;
}

/* 拖曳把手：解除浮動定位，固定在文字左邊 */
.bubble-item .drag-handle {
  position: static !important;
  transform: none !important;
  flex-shrink: 0 !important;
  margin-top: 1px;
}
.word-table .bubble-title-editable {
  min-width: 0;
  max-width: none !important;
  font-weight: 400 !important;
  line-height: 1.35 !important;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* 手機版保留行程欄可讀寬度，必要時由外層橫向捲動表格 */
@media screen and (max-width: 640px) {
  .word-table {
    min-width: 520px !important;
    table-layout: fixed;
  }
}

/* 泡泡點擊打字時的聚焦外框 */
.bubble-title-editable:focus {
  background-color: #ffffff;
  border-radius: 4px;
  padding: 0 4px;
  outline: 1px dashed #3b82f6;
}

/* ==================== 電腦版橫式模式：全 App（票券、工具、行程）全面等比顯著放大 ==================== */
/* 覆寫 Tailwind 限制，全面提升各字級尺寸 */
#app-device-frame.is-landscape .text-\[10px\],
#app-device-frame.max-w-4xl .text-\[10px\],
nav.max-w-4xl .text-\[10px\] {
  font-size: 13px !important;
  line-height: 1.4 !important;
}

#app-device-frame.is-landscape .text-\[11px\],
#app-device-frame.max-w-4xl .text-\[11px\],
nav.max-w-4xl .text-\[11px\] {
  font-size: 14px !important;
  line-height: 1.4 !important;
}

#app-device-frame.is-landscape .text-xs,
#app-device-frame.max-w-4xl .text-xs,
nav.max-w-4xl .text-xs {
  font-size: 15px !important;
  line-height: 1.5 !important;
}

#app-device-frame.is-landscape .text-sm,
#app-device-frame.max-w-4xl .text-sm,
nav.max-w-4xl .text-sm {
  font-size: 17px !important;
  line-height: 1.5 !important;
}

#app-device-frame.is-landscape .text-base,
#app-device-frame.max-w-4xl .text-base,
nav.max-w-4xl .text-base {
  font-size: 19px !important;
  line-height: 1.5 !important;
}

#app-device-frame.is-landscape .text-lg,
#app-device-frame.max-w-4xl .text-lg,
nav.max-w-4xl .text-lg {
  font-size: 22px !important;
  line-height: 1.4 !important;
}

#app-device-frame.is-landscape .text-xl,
#app-device-frame.max-w-4xl .text-xl {
  font-size: 25px !important;
}

#app-device-frame.is-landscape .text-2xl,
#app-device-frame.max-w-4xl .text-2xl {
  font-size: 28px !important;
}

/* 園地角色按鈕在桌面橫向版面同步放大留白 */
#app-device-frame.is-landscape .yard-member-role-button,
#app-device-frame.max-w-4xl .yard-member-role-button,
body.desktop-landscape #app-device-frame .yard-member-role-button {
  padding: clamp(6px, 0.5vw, 9px) clamp(8px, 0.9vw, 14px) !important;
  font-size: clamp(11px, 1vw, 14px) !important;
  line-height: 1.3 !important;
}

/* 彈窗位於主畫面容器外，橫式時同步使用主畫面的字級比例 */
body.desktop-landscape .fixed.inset-0 .text-\[10px\] {
  font-size: 13px !important;
  line-height: 1.4 !important;
}

body.desktop-landscape .fixed.inset-0 .text-\[11px\] {
  font-size: 14px !important;
  line-height: 1.4 !important;
}

body.desktop-landscape .fixed.inset-0 .text-xs {
  font-size: 15px !important;
  line-height: 1.5 !important;
}

body.desktop-landscape .fixed.inset-0 .text-sm {
  font-size: 17px !important;
  line-height: 1.5 !important;
}

body.desktop-landscape .fixed.inset-0 .text-base {
  font-size: 19px !important;
  line-height: 1.5 !important;
}

body.desktop-landscape .fixed.inset-0 .text-lg {
  font-size: 22px !important;
  line-height: 1.4 !important;
}

body.desktop-landscape .fixed.inset-0 .text-xl {
  font-size: 25px !important;
}

body.desktop-landscape .fixed.inset-0 .text-2xl {
  font-size: 28px !important;
}

/* 橫式下輸入框、選單與按鈕文字適配 */
#app-device-frame.is-landscape input,
#app-device-frame.is-landscape select,
#app-device-frame.is-landscape textarea,
#app-device-frame.max-w-4xl input,
#app-device-frame.max-w-4xl select,
#app-device-frame.max-w-4xl textarea {
  font-size: 15px !important;
}

body.desktop-landscape .fixed.inset-0 input,
body.desktop-landscape .fixed.inset-0 select,
body.desktop-landscape .fixed.inset-0 textarea {
  font-size: 15px !important;
}

/* 每日行程表專用微調保持 */
#app-device-frame.is-landscape #schedule-title,
#app-device-frame.max-w-4xl #schedule-title {
  font-size: 1.5rem !important; /* 24px */
  margin-top: 1rem !important;
  margin-bottom: 1rem !important;
}

#app-device-frame.is-landscape .word-table th,
#app-device-frame.max-w-4xl .word-table th,
#app-device-frame.is-landscape .word-table td,
#app-device-frame.max-w-4xl .word-table td {
  padding: 8px 8px !important;
}

#app-device-frame.is-landscape .word-table td,
#app-device-frame.max-w-4xl .word-table td {
  font-size: 15px !important;
}

#app-device-frame.is-landscape .word-table .bubble-title-editable,
#app-device-frame.max-w-4xl .word-table .bubble-title-editable {
  font-size: inherit !important;
}

#app-device-frame.is-landscape .word-table .note-cell,
#app-device-frame.max-w-4xl .word-table .note-cell {
  line-height: 1.35 !important;
}

#app-device-frame.is-landscape .word-table .bubble-item,
#app-device-frame.max-w-4xl .word-table .bubble-item {
  padding: 0 !important;
  gap: 4px !important;
}

#app-device-frame.is-landscape .bubble-title-editable,
#app-device-frame.max-w-4xl .bubble-title-editable {
  max-width: 650px !important;
}

/* 列印與 PDF 匯出專用適配 */
@media print {
  @page {
    margin: 10mm;
  }

  body,
  #app-device-frame,
  .schedule-wrapper {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  #app-device-frame {
    transform: none !important;
    transform-origin: top left !important;
    transition: none !important;
  }

  #desktop-view-controller,
  .no-print,
  nav,
  header {
    display: none !important;
  }

  .overflow-x-auto {
    overflow: visible !important;
  }

  /* 1. 最外圍維持黑框 */
  .word-table {
    width: 100% !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
    border: 2px solid #000000 !important;
  }

  /* 2. 內部水平線改灰階 (#94a3b8) ； 3. 內部垂直線改更淡的灰階 (#e2e8f0) */
  .word-table th,
  .word-table td {
    border-top: none !important;
    border-left: none !important;
    border-right: 1px solid #e2e8f0 !important;
    border-bottom: 1px solid #94a3b8 !important;
    word-break: break-word !important;
  }

  /* 每日的多列資料盡量保留在同一頁，避免日期 rowspan 被切開 */
  .word-table tbody.schedule-day-group {
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  .word-table tbody td {
    vertical-align: middle !important;
  }

  /* 備註欄位是資料表最右側外框，明確沿用黑色外框線 */
  .word-table th:last-of-type:not(.no-print),
  .word-table td.note-cell {
    border-right: 2px solid #000000 !important;
  }

  /* 最底端一列不重複畫水平線，交由外圍黑框呈現 */
  .word-table > tbody.schedule-day-group:last-of-type > tr:last-child td {
    border-bottom: none !important;
  }

  /* ==================== 任務 3：列印專用字體大小設定 ==================== */
  /* 1. 旅程標題：16px 粗體 */
  #schedule-title {
    font-size: 16px !important;
    font-weight: bold !important;
  }

  /* 2. 表格表頭：14px 粗體 */
  .word-table th {
    font-size: 14px !important;
    font-weight: bold !important;
  }

  /* 3~6. 日期欄、時間欄、行程欄、備註欄：一律 12px */
  .word-table td,
  .word-table td span,
  .word-table .time-cell,
  .word-table .note-cell,
  .word-table .bubble-item,
  .word-table .bubble-title-editable {
    font-size: 12px !important;
  }

  .bubble-item {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    box-shadow: none !important;
    color: #000 !important;
  }

  .placeholder-text,
  .direct-input-placeholder,
  .pool-direct-input,
  .btn-add-day-row,
  .btn-remove-row,
  .btn-delete-bubble {
    display: none !important;
  }
}
