/* ========================================================
   🖨️ 今彩539 實體開獎拷貝單（標準 A4 列印手寫版）專屬樣式庫
   檔案路徑: static/css/lottery_539_copy_sheet.css
   說明:
     1. 入口卡片：置於 539 工作台最底端，深色典雅、點擊彈出預覽。
     2. 預覽彈窗：全螢幕浮層，自適應紙張檢視，頂部帶有【確認列印 (A4)】與【關閉】。
     3. A4 紙張與 3 欄表格：嚴格 108 格（3 欄 × 36 列），精準容納於 A4 直式單頁。
     4. @media print：呼叫列印時隱藏其餘所有網頁組件，純淨輸出黑白單頁。
   ======================================================== */

/* 1. 539 頁面最下方入口卡片 */
.copy-sheet-539-entry-card {
  margin-top: 6px;
  border-radius: 14px;
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.96), rgba(6, 78, 59, 0.35), rgba(15, 23, 42, 0.98)) !important;
  border: 1.5px solid rgba(16, 185, 129, 0.45) !important;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45), 0 0 16px rgba(16, 185, 129, 0.15);
  transition: all 0.3s ease;
}

.copy-sheet-entry-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.copy-sheet-entry-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 260px;
}

.copy-sheet-entry-icon {
  font-size: 1.8rem;
  line-height: 1;
  filter: drop-shadow(0 2px 8px rgba(16, 185, 129, 0.5));
}

.copy-sheet-entry-texts {
  display: flex;
  flex-direction: column;
}

.copy-sheet-entry-title {
  margin: 0;
  font-size: clamp(0.98rem, 3.6vw, 1.15rem);
  font-weight: 900;
  color: #6ee7b7;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.copy-sheet-entry-sub {
  font-size: 0.74rem;
  color: #94a3b8;
  margin-top: 2px;
}

.btn-copy-sheet-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: linear-gradient(135deg, #10b981, #047857);
  border: 1px solid #34d399;
  border-radius: 10px;
  color: #ffffff;
  font-size: 0.92rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.btn-copy-sheet-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.5);
  background: linear-gradient(135deg, #34d399, #059669);
}

.btn-copy-sheet-action:active {
  transform: translateY(1px);
}

/* 2. 彈窗預覽組件 (Modal) */
.copy-sheet-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(2, 6, 23, 0.88);
  backdrop-filter: blur(6px);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  box-sizing: border-box;
}

.copy-sheet-modal-card {
  width: 100%;
  max-width: 960px;
  height: 94vh;
  background: #0b1120;
  border: 1.5px solid rgba(16, 185, 129, 0.5);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.copy-sheet-modal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: #0f172a;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.copy-sheet-toolbar-title {
  font-size: 1.05rem;
  font-weight: 900;
  color: #fef08a;
  letter-spacing: 0.5px;
}

.copy-sheet-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-copy-sheet-print {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border: 1px solid #fbbf24;
  border-radius: 8px;
  color: #0b0f19;
  font-size: 0.9rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
  transition: all 0.15s ease;
}

.btn-copy-sheet-print:hover {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  transform: translateY(-1px);
}

.btn-copy-sheet-ibon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  background: linear-gradient(135deg, #ea580c, #c2410c);
  border: 1px solid #fb923c;
  border-radius: 8px;
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.35);
  transition: all 0.15s ease;
}

.btn-copy-sheet-ibon:hover {
  background: linear-gradient(135deg, #f97316, #ea580c);
  transform: translateY(-1px);
}

.btn-copy-sheet-close {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #e2e8f0;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 1.3rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-copy-sheet-close:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  border-color: #ef4444;
}

/* 3. 預覽紙張視口 (可滾動) */
.copy-sheet-preview-viewport {
  flex: 1;
  overflow: auto;
  padding: 20px;
  background: #1e293b;
  display: flex;
  justify-content: center;
}

/* 4. 實體 A4 紙張本體 */
.copy-sheet-paper {
  width: 210mm;
  min-height: 297mm;
  background: #ffffff;
  color: #000000;
  padding: 8mm;
  box-sizing: border-box;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

/* 紙張頂部標題 */
.paper-header {
  text-align: center;
  margin-bottom: 2mm;
  border-bottom: 1.5px solid #000000;
  padding-bottom: 1.5mm;
}

.paper-title-main {
  font-size: 16pt;
  font-weight: 900;
  letter-spacing: 2px;
  color: #000000;
  margin: 0;
  line-height: 1.2;
}

.paper-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 8pt;
  color: #333333;
  margin-top: 1mm;
  font-weight: 600;
}

/* 3 欄式表格佈局 */
.paper-columns-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2.5mm;
  flex: 1;
}

.sheet-col-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 8pt;
}

.sheet-col-table thead th {
  background: #e5e7eb;
  color: #000000;
  font-weight: 900;
  text-align: center;
  border: 1px solid #000000;
  padding: 1.2mm 0;
  line-height: 1;
}

.sheet-col-table thead th.th-m { width: 11%; }
.sheet-col-table thead th.th-d { width: 11%; }
.sheet-col-table thead th.th-w { width: 10%; }
.sheet-col-table thead th.th-p { width: 23%; }
.sheet-col-table thead th.th-b { width: 9%; }

.sheet-col-table tbody td {
  border: 1px solid #1f2937;
  text-align: center;
  height: 6.8mm;
  padding: 0;
  line-height: 6.8mm;
  font-size: 7.8pt;
  color: #000000;
  box-sizing: border-box;
}

.sheet-col-table tbody td.td-m,
.sheet-col-table tbody td.td-d {
  font-family: monospace;
  font-weight: 600;
}

.sheet-col-table tbody td.td-w {
  font-weight: 700;
}

.sheet-col-table tbody td.td-p {
  font-family: monospace;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.sheet-col-table tbody td.td-b {
  font-family: monospace;
  font-weight: 800;
  font-size: 8pt;
}

/* 最新一期醒目標示 (灰色微底) */
.row-latest td {
  background: #f3f4f6;
  font-weight: 900;
}

/* 未來 6 期手寫空白格 (帶線、留空) */
.row-blank {
  background: #ffffff;
}

.row-blank td.td-m,
.row-blank td.td-d,
.row-blank td.td-w,
.row-blank td.td-p {
  font-weight: 700;
  color: #1f2937;
}

.row-blank td.td-b {
  background: #ffffff;
}

/* 紙張底部資訊 */
.paper-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 7pt;
  color: #4b5563;
  border-top: 1px solid #6b7280;
  padding-top: 1mm;
  margin-top: 1.5mm;
}

/* 5. A4 列印樣式適配 (@media print) */
@media print {
  @page {
    size: A4 portrait;
    margin: 8mm;
  }

  html, body {
    background: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* 隱藏整個頁面其他所有元素 */
  body * {
    visibility: hidden;
  }

  /* 僅顯示拷貝單紙張本體及其所有子代 */
  #copy-sheet-paper,
  #copy-sheet-paper * {
    visibility: visible !important;
  }

  #modal-539-copy-sheet {
    display: block !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    backdrop-filter: none !important;
    z-index: 9999999 !important;
  }

  .copy-sheet-modal-card {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    height: auto !important;
  }

  .copy-sheet-modal-toolbar {
    display: none !important;
  }

  .copy-sheet-preview-viewport {
    background: transparent !important;
    padding: 0 !important;
    overflow: visible !important;
    display: block !important;
  }

  #copy-sheet-paper {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    min-height: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    border: none !important;
  }

  .sheet-col-table {
    border-collapse: collapse !important;
    width: 100% !important;
  }

  .sheet-col-table th,
  .sheet-col-table td {
    border: 1px solid #000000 !important;
    color: #000000 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .sheet-col-table thead th {
    background: #e5e7eb !important;
  }

  .row-latest td {
    background: #f3f4f6 !important;
  }

  .row-blank td.td-b {
    background: #ffffff !important;
  }

  #modal-ibon-guide {
    display: none !important;
  }
}

/* ========================================================
   🏪 7-11 ibon 雲端列印指引浮層樣式
   ======================================================== */
.ibon-flow-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(2, 6, 23, 0.88);
  backdrop-filter: blur(8px);
  z-index: 10000000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.ibon-flow-card {
  width: 100%;
  max-width: 480px;
  background: #0f172a;
  border: 1.5px solid #f97316;
  border-radius: 18px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.85), 0 0 30px rgba(249, 115, 22, 0.3);
  overflow: hidden;
  animation: ibonFadeIn 0.25s ease-out;
  display: flex;
  flex-direction: column;
}

@keyframes ibonFadeIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.ibon-flow-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ibon-flow-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
  font-weight: 900;
  color: #fed7aa;
}

.ibon-logo-badge {
  background: #ea580c;
  color: #ffffff;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.5px;
}

.ibon-flow-close {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 1.25rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ibon-flow-close:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  border-color: #ef4444;
}

.ibon-flow-body {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* 步驟 1: 說明與選擇卡片 */
.ibon-intro-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(249, 115, 22, 0.1);
  border: 1px solid rgba(249, 115, 22, 0.25);
  border-radius: 10px;
}

.ibon-intro-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.ibon-intro-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.85rem;
  color: #e2e8f0;
}

.ibon-intro-text strong {
  color: #fb923c;
  font-size: 0.92rem;
}

.ibon-mode-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ibon-mode-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(30, 41, 59, 0.7);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ibon-mode-card:hover {
  border-color: rgba(249, 115, 22, 0.5);
  background: rgba(30, 41, 59, 0.9);
}

.ibon-mode-card.active {
  border-color: #f97316;
  background: rgba(249, 115, 22, 0.12);
  box-shadow: 0 0 16px rgba(249, 115, 22, 0.25);
}

.ibon-mode-card input[type="radio"] {
  margin-top: 3px;
  accent-color: #f97316;
  cursor: pointer;
  transform: scale(1.15);
}

.ibon-mode-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.ibon-mode-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ibon-mode-name {
  font-size: 0.95rem;
  font-weight: 800;
  color: #f8fafc;
}

.ibon-mode-price {
  font-size: 0.92rem;
  font-weight: 900;
  color: #fde047;
  background: rgba(234, 179, 8, 0.15);
  padding: 1px 8px;
  border-radius: 6px;
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.ibon-mode-desc {
  font-size: 0.8rem;
  color: #94a3b8;
}

.ibon-flow-footer {
  padding: 12px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-ibon-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 18px;
  background: linear-gradient(135deg, #f97316, #ea580c);
  border: 1px solid #fb923c;
  border-radius: 12px;
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(234, 88, 12, 0.45);
  transition: all 0.2s ease;
}

.btn-ibon-submit:hover {
  background: linear-gradient(135deg, #fb923c, #f97316);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(234, 88, 12, 0.6);
}

.btn-ibon-cancel {
  width: 100%;
  padding: 8px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: #94a3b8;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-ibon-cancel:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
}

/* 步驟 2: 上傳中載入動畫 */
.ibon-loading-body {
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
}

.ibon-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(249, 115, 22, 0.2);
  border-top-color: #f97316;
  border-radius: 50%;
  animation: ibonSpin 0.8s linear infinite;
}

@keyframes ibonSpin {
  to { transform: rotate(360deg); }
}

.ibon-loading-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #fed7aa;
}

.ibon-loading-desc {
  margin: 0;
  font-size: 0.85rem;
  color: #94a3b8;
  max-width: 320px;
  line-height: 1.5;
}

/* 步驟 3: 結果出碼視圖 */
.ibon-result-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ibon-result-badge {
  font-size: 1.12rem;
  font-weight: 900;
  color: #4ade80;
  letter-spacing: 0.5px;
}

.ibon-result-sub {
  font-size: 0.82rem;
  color: #94a3b8;
}

.ibon-qrcode-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
}

.ibon-qrcode-frame {
  background: #ffffff;
  padding: 10px;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 16px rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ibon-qrcode-img {
  width: 200px;
  height: 200px;
  display: block;
  border-radius: 6px;
}

.ibon-qrcode-hint {
  font-size: 0.82rem;
  color: #fdba74;
  font-weight: 700;
}

.ibon-code-card {
  background: rgba(15, 23, 42, 0.9);
  border: 1.5px solid #eab308;
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(234, 179, 8, 0.15);
}

.ibon-code-label {
  font-size: 0.78rem;
  color: #cbd5e1;
}

.ibon-code-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ibon-code-val {
  font-size: 1.55rem;
  font-weight: 900;
  color: #fde047;
  letter-spacing: 2px;
  font-family: "Consolas", monospace, sans-serif;
}

.btn-copy-code {
  background: rgba(234, 179, 8, 0.15);
  border: 1px solid #eab308;
  color: #fde047;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-copy-code:hover {
  background: #eab308;
  color: #000000;
}

.ibon-details-list {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ibon-detail-item {
  display: flex;
  align-items: center;
  font-size: 0.82rem;
  color: #94a3b8;
}

.detail-label {
  width: 70px;
  color: #cbd5e1;
}

.detail-val {
  color: #ffffff;
  font-weight: 700;
}

.detail-tag {
  margin-left: 8px;
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.4);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
}

.ibon-store-guide {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.store-guide-title {
  font-size: 0.82rem;
  font-weight: 800;
  color: #fed7aa;
}

.store-guide-steps {
  margin: 0;
  padding-left: 18px;
  font-size: 0.78rem;
  line-height: 1.5;
  color: #cbd5e1;
}

.store-guide-steps li {
  margin-bottom: 2px;
}

.btn-ibon-finish {
  width: 100%;
  padding: 11px;
  background: linear-gradient(135deg, #10b981, #059669);
  border: 1px solid #34d399;
  border-radius: 10px;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
  transition: all 0.15s ease;
}

.btn-ibon-finish:hover {
  background: linear-gradient(135deg, #34d399, #047857);
  transform: translateY(-1px);
}
