/* Footer Styles - RWD Redesign */
/* Updated for new footer structure with Bootstrap 5.3.3 integration */

/* ===== Footer Container ===== */
.footer {
  background-color: var(--ezp-bg-light, #f8f9fa);
  border-top: 1px solid var(--ezp-border-light, #dee2e6);
  padding: 40px 0 0;
}

/* ===== Footer Section Titles ===== */
.footer-section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ezp-dark-blue, #003A5D);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--ezp-brand-blue, #5997C7);
}

/* ===== Footer Links ===== */
.footer-links {
  list-style: none;
  padding-left: 0;
  margin-bottom: 1.5rem;
}

.footer-links li {
  margin-bottom: 0.5rem;
}

.footer-links a {
  color: var(--ezp-text-dark, #495057);
  text-decoration: none;
  transition: color 0.3s ease, padding-left 0.2s ease;
  display: inline-block;
}

.footer-links a:hover {
  color: var(--ezp-brand-blue, #5997C7);
  padding-left: 3px;
}

/* ===== Footer Search ===== */
.footer-search {
  margin-bottom: 1rem;
}

.footer-search .form-control,
.footer-search .form-select {
  border-radius: 4px;
  border-color: var(--ezp-border-light, #dee2e6);
  font-size: 0.875rem;
}

.footer-search .btn {
  background-color: var(--ezp-brand-blue, #5997C7);
  color: white;
  border: none;
  border-radius: 4px;
  transition: background-color 0.3s ease;
}

.footer-search .btn:hover {
  background-color: var(--ezp-dark-blue, #003A5D);
}

/* ===== Footer Contact ===== */
.footer-contact p {
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

.footer-contact i {
  color: var(--ezp-brand-blue, #5997C7);
  margin-right: 0.5rem;
  width: 20px;
  text-align: center;
}

/* ===== Social Links ===== */
.social-links {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.social-links a {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.social-links a:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* ===== Footer Accordion (Mobile) ===== */
.footer-accordion .accordion-button {
  background-color: transparent;
  color: var(--ezp-dark-blue, #003A5D);
  font-weight: 600;
  padding: 0.75rem 0;
  box-shadow: none;
  border: none;
  font-size: 1rem;
}

.footer-accordion .accordion-button:not(.collapsed) {
  color: var(--ezp-brand-blue, #5997C7);
  background-color: transparent;
  box-shadow: none;
}

.footer-accordion .accordion-button:focus {
  border-color: transparent;
  box-shadow: none;
}

.footer-accordion .accordion-button::after {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%235997C7'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
}

.footer-accordion .accordion-body {
  padding: 0.5rem 0 1rem 1rem;
}

.footer-accordion .accordion-item {
  border-bottom: 1px solid var(--ezp-border-light, #dee2e6);
}

.footer-accordion .accordion-item:last-child {
  border-bottom: none;
}

/* ===== Payment Methods ===== */
.payment-methods {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  align-items: center;
  margin-top: 1rem;
}

.payment-method {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  transition: transform 0.2s ease;
}

.payment-method:hover {
  transform: translateY(-3px);
}

.payment-icon {
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--ezp-light-blue, #89CEE9) 0%, var(--ezp-brand-blue, #5997C7) 100%);
  color: white;
  font-size: 1.5rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.payment-method:hover .payment-icon {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.payment-method span {
  font-size: 0.75rem;
  color: var(--ezp-text-dark, #495057);
  text-align: center;
}

/* Payment icon specific colors */
.payment-icon.atm {
  background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
}

.payment-icon.credit-card {
  background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
}

.payment-icon.convenience-7 {
  background: linear-gradient(135deg, #198754 0%, #146c43 100%);
}

.payment-icon.convenience-family {
  background: linear-gradient(135deg, #20c997 0%, #0d9488 100%);
}

.payment-icon.gov-pay {
  background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
}

.payment-icon.e-invoice {
  background: linear-gradient(135deg, #dc3545 0%, #b02a37 100%);
}

.payment-icon.logistics {
  background: linear-gradient(135deg, var(--ezp-pink, #F47A94) 0%, #e85d79 100%);
}

/* ===== Footer Bottom (Copyright) ===== */
.footer-bottom {
  background-color: var(--ezp-dark-blue, #003A5D);
  color: white;
  padding: 1rem 0;
  text-align: center;
  margin-top: 0;
}

.footer-bottom a {
  color: var(--ezp-light-blue, #89CEE9);
  text-decoration: none;
  transition: color 0.3s ease;
}

.footer-bottom a:hover {
  color: white;
  text-decoration: underline;
}

/* ===== Mobile Bottom Menu ===== */
.mobile-bottom-menu {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  background-color: white;
  border-top: 1px solid var(--ezp-border-light, #dee2e6);
  z-index: 1030;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  /* iOS Safari 修復：僅用 backface-visibility 做 compositing hint */
  /* 注意：不要用 transform 或 will-change:transform，會建立新 containing block */
  /* 導致 iOS 地址欄出現/消失時 fixed 元素跳動 + icon 字型重繪消失 */
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  /* iOS safe area padding */
  padding-bottom: constant(safe-area-inset-bottom); /* iOS 11.0-11.2 */
  padding-bottom: env(safe-area-inset-bottom, 0px); /* iOS 11.2+ */
  /* 防止 iOS 雙擊縮放但允許滑動 */
  touch-action: manipulation;
}

/* iOS Safari 底部安全區域背景延伸 — 防止滾動時出現間隙 */
.mobile-bottom-menu::after {
  content: '';
  display: block;
  position: absolute;
  bottom: calc(-1 * env(safe-area-inset-bottom, 34px));
  left: 0;
  right: 0;
  height: env(safe-area-inset-bottom, 34px);
  background-color: white;
  z-index: -1;
}

@supports (padding-bottom: constant(safe-area-inset-bottom)) {
  .mobile-bottom-menu::after {
    bottom: calc(-1 * constant(safe-area-inset-bottom));
    height: constant(safe-area-inset-bottom);
  }
}

/* ===== Zone Submenu (限時活動二級選單) ===== */
.zone-submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  background: #f8f9fa;
  border-bottom: 1px solid #eee;
}

.zone-submenu.open {
  max-height: 60px;
}

/* 子選單開啟時，提升 z-index 蓋過商品頁固定底部操作列 (z-index: 1031) */
.mobile-bottom-menu.zone-open {
  z-index: 1035;
}

.zone-submenu-inner {
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  gap: 8px;
  padding: 8px 12px;
  scrollbar-width: none;
}

.zone-submenu-inner::-webkit-scrollbar {
  display: none;
}

.zone-submenu-item {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  padding: 4px 12px;
  border-radius: 20px;
  background: white;
  border: 1px solid #dee2e6;
  color: #333;
  text-decoration: none;
  font-size: 0.8rem;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.zone-submenu-item:hover,
.zone-submenu-item:active {
  background: var(--ezp-pink, #F47A94);
  color: white;
  border-color: var(--ezp-pink, #F47A94);
  text-decoration: none;
}

.zone-submenu-badge {
  font-size: 0.75rem;
  color: #dc3545;
  font-weight: 600;
}

.zone-submenu-item:hover .zone-submenu-badge,
.zone-submenu-item:active .zone-submenu-badge {
  color: white;
}

.zone-submenu-all {
  background: var(--ezp-brand-blue, #5997C7);
  color: white;
  border-color: var(--ezp-brand-blue, #5997C7);
}

.zone-submenu-all .zone-submenu-name {
  font-weight: 600;
}

.mobile-bottom-menu .nav {
  display: flex;
  justify-content: space-around;
  align-items: center;
  /* 上下 padding 固定 */
  padding: 0.5rem 0;
}

.mobile-bottom-menu .nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 0;
  color: var(--ezp-text-dark, #495057);
  text-decoration: none;
  font-size: 0.75rem;
  width: 16.666%;
  transition: color 0.3s ease;
}

.mobile-bottom-menu .nav-link i {
  font-size: 1.3rem;
  margin-bottom: 0.25rem;
  color: var(--ezp-brand-blue, #5997C7);
  transition: transform 0.2s ease;
}

.mobile-bottom-menu .nav-link:hover i,
.mobile-bottom-menu .nav-link.active i {
  transform: scale(1.1);
  color: var(--ezp-dark-blue, #003A5D);
}

.mobile-bottom-menu .nav-link:hover,
.mobile-bottom-menu .nav-link.active {
  color: var(--ezp-brand-blue, #5997C7);
  font-weight: 600;
}

/* 限時活動按鈕 active 狀態加火焰色 */
#zoneMenuBtn.active i {
  color: #dc3545 !important;
}

#zoneMenuBtn.active {
  color: #dc3545;
}

/* ===== Mobile Search Overlay ===== */
#mobile-search-overlay {
  background-color: rgba(0, 0, 0, 0.75);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  pointer-events: none; /* 默认不拦截点击事件 */
}

/* 显示时才允许点击事件 */
#mobile-search-overlay[style*="display: block"],
#mobile-search-overlay.show {
  pointer-events: auto;
}

#mobile-search-overlay .card {
  max-width: 90%;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  border: none;
}

#mobile-search-overlay .card-header {
  background-color: var(--ezp-brand-blue, #5997C7);
  color: white;
  padding: 1rem;
  border-bottom: none;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}

#mobile-search-overlay .card-body {
  padding: 1.5rem;
}

#mobile-search-overlay .btn-close {
  filter: brightness(0) invert(1);
  opacity: 1;
}

#mobile-search-overlay .form-control,
#mobile-search-overlay .form-select {
  border: 1px solid var(--ezp-border-light, #dee2e6);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
}

#mobile-search-overlay .form-control:focus,
#mobile-search-overlay .form-select:focus {
  border-color: var(--ezp-brand-blue, #5997C7);
  box-shadow: 0 0 0 0.25rem rgba(89, 151, 199, 0.25);
}

#mobile-search-overlay .btn-primary {
  background-color: var(--ezp-brand-blue, #5997C7);
  border-color: var(--ezp-brand-blue, #5997C7);
}

#mobile-search-overlay .btn-primary:hover {
  background-color: var(--ezp-dark-blue, #003A5D);
  border-color: var(--ezp-dark-blue, #003A5D);
}

/* ===== Floating Action Menu ===== */
#floating-action-menu {
  transition: all 0.3s ease;
}

#floating-action-menu .btn {
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  border-width: 2px;
}

#floating-action-menu .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* ===== LINE Service Modal ===== */
.line-service-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.line-service-modal-overlay.show {
  opacity: 1;
}

.line-service-modal-content {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  overflow: hidden;
  transform: translateY(-20px);
  transition: transform 0.3s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.line-service-modal-overlay.show .line-service-modal-content {
  transform: translateY(0);
}

.line-service-modal-header {
  padding: 1rem;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #f8f9fa;
}

.line-service-modal-body {
  padding: 1.5rem;
}

.qr-code-container .bg-light {
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed #dee2e6;
}

/* ===== Responsive Design ===== */

/* Tablet (768px - 991px) */
@media (min-width: 768px) and (max-width: 991.98px) {
  .footer-section-title {
    font-size: 1rem;
  }

  .payment-methods {
    gap: 0.75rem;
  }

  .payment-icon {
    width: 45px;
    height: 45px;
    font-size: 1.3rem;
  }
}

/* Mobile (< 768px) */
@media (max-width: 767.98px) {
  .footer {
    padding: 30px 0 0;
  }

  .footer-section-title {
    font-size: 1rem;
    margin-top: 1rem;
  }

  .social-links {
    justify-content: center;
  }

  .footer-contact {
    text-align: left;
  }

  .payment-methods {
    gap: 0.75rem;
  }

  .payment-icon {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }

  .payment-method span {
    font-size: 0.75rem;
  }

  /* Show mobile bottom menu */
  .mobile-bottom-menu {
    display: block;
  }

  /* Add padding to body to prevent content being hidden behind bottom menu */
  /* 包含 iOS safe area 支援 */
  body {
    padding-bottom: 60px;
    padding-bottom: calc(60px + constant(safe-area-inset-bottom)); /* iOS 11.0-11.2 */
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); /* iOS 11.2+ */
  }

  /* Adjust floating action menu position */
  /* 加上 safe area 避免被 iPhone Home Indicator 遮擋 */
  #floating-action-menu {
    bottom: 80px !important;
    bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Adjust back-to-top button */
  #back-to-top {
    bottom: 80px !important;
    bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* Small Mobile (< 576px) */
@media (max-width: 575.98px) {
  .footer-section-title {
    font-size: 0.95rem;
  }

  .payment-methods {
    gap: 0.5rem;
  }

  .payment-icon {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  .payment-method span {
    font-size: 0.75rem;
  }

  .mobile-bottom-menu .nav-link {
    font-size: 0.75rem;
    padding: 0.4rem 0;
  }

  .mobile-bottom-menu .nav-link i {
    font-size: 1.2rem;
  }

  .line-service-modal-content {
    width: 95%;
    margin: 1rem;
  }

  .line-service-modal-header,
  .line-service-modal-body {
    padding: 1rem;
  }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print styles */
@media print {
  .footer {
    border-top: 1px solid #000;
  }

  .mobile-bottom-menu,
  #floating-action-menu,
  #mobile-search-overlay,
  .social-links {
    display: none !important;
  }

  .footer-accordion .accordion-button::after {
    display: none;
  }

  .footer-accordion .accordion-collapse {
    display: block !important;
  }
}
