/* ========================================
   MASTER TEMPLATE - MOBILE RESPONSIVE CSS
   主模板手機版響應式樣式
   ======================================== */

/* ========================================
   目標：為所有頁面提供統一的手機版基礎樣式
   
   負責範圍：
   1. Header 頁頭導航
   2. Footer 頁腳
   3. Main Content Container 主要內容容器
   4. Global Layout 全局佈局
   
   不負責：
   - 頁面特定內容樣式（由子模板CSS處理）
   - 組件內部樣式（由組件CSS處理）
   ======================================== */

/* ===== BREAKPOINTS ===== */
/* 
  手機版: ≤768px
  平板版: 769px - 1023px
  桌面版: ≥1024px
*/

/* ========================================
   MOBILE: ≤768px
   ======================================== */
@media (max-width: 768px) {
  
  /* ===== 1. GLOBAL LAYOUT ===== */
  body {
    font-size: 14px !important;
    line-height: 1.5 !important;
  }

  /* 主要內容區域 */
  .main-content,
  main {
    padding: 12px !important;
    min-height: calc(100vh - 140px) !important;
  }

  /* 容器 */
  .container,
  .container-fluid {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  /* ===== 2. HEADER (頁頭) ===== */
  .header {
    position: sticky !important;
    top: 0 !important;
    z-index: 1000 !important;
    background: white !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
    padding: 10px 12px !important;
  }

  .header-container {
    flex-wrap: wrap !important;
    gap: 10px !important;
  }

  /* Logo區域 */
  .header-left {
    flex: 1 !important;
    min-width: auto !important;
  }

  .logo-group {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
  }

  .platform-logo {
    width: 32px !important;
    height: 32px !important;
  }

  .platform-name {
    font-size: 16px !important;
    display: inline !important;
  }

  /* 桌面版導航隱藏 */
  .header-center.desktop-only {
    display: none !important;
  }

  /* 手機版導航顯示 */
  .header-right {
    display: flex !important;
    gap: 8px !important;
    align-items: center !important;
  }

  /* Hamburger Menu Button */
  .mobile-menu-btn {
    display: flex !important;
    width: 40px !important;
    height: 40px !important;
    padding: 8px !important;
    background: transparent !important;
    border: none !important;
    cursor: pointer !important;
  }

  /* Mobile Navigation Drawer */
  .mobile-nav-drawer {
    position: fixed !important;
    top: 0 !important;
    right: -100% !important;
    width: 280px !important;
    height: 100vh !important;
    background: white !important;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.2) !important;
    transition: right 0.3s ease !important;
    z-index: 2000 !important;
    overflow-y: auto !important;
  }

  .mobile-nav-drawer.open {
    right: 0 !important;
  }

  /* Mobile Nav Overlay */
  .mobile-nav-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.5) !important;
    display: none !important;
    z-index: 1999 !important;
  }

  .mobile-nav-overlay.show {
    display: block !important;
  }

  /* ===== 3. FOOTER (頁腳) ===== */
  .footer {
    padding: 20px 12px !important;
    text-align: center !important;
  }

  .footer-container {
    flex-direction: column !important;
    gap: 16px !important;
  }

  .footer-links {
    flex-direction: column !important;
    gap: 12px !important;
    align-items: center !important;
  }

  .footer-link {
    font-size: 13px !important;
  }

  .footer-text {
    font-size: 12px !important;
  }

  /* ===== 4. BOTTOM NAVIGATION (底部導航) ===== */
  .mobile-bottom-nav {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    background: white !important;
    border-top: 1px solid rgba(0, 0, 0, 0.1) !important;
    padding: 8px 0 !important;
    z-index: 999 !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05) !important;
  }

  .mobile-bottom-nav-item {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    padding: 8px 4px !important;
    text-decoration: none !important;
    color: #6b7280 !important;
    transition: all 0.2s ease !important;
  }

  .mobile-bottom-nav-item.active {
    color: #8b5cf6 !important;
  }

  .mobile-bottom-nav-icon {
    width: 24px !important;
    height: 24px !important;
  }

  .mobile-bottom-nav-text {
    font-size: 11px !important;
    font-weight: 500 !important;
  }

  /* ===== 5. CARDS & CONTAINERS ===== */
  .card,
  .panel,
  .box {
    border-radius: 12px !important;
    margin-bottom: 12px !important;
  }

  .card-header,
  .panel-heading {
    padding: 14px 16px !important;
    font-size: 16px !important;
  }

  .card-body,
  .panel-body {
    padding: 16px !important;
  }

  /* ===== 6. BUTTONS ===== */
  .btn,
  button:not(.consolidation-tab-btn):not(.mobile-menu-btn) {
    padding: 12px 20px !important;
    font-size: 15px !important;
    border-radius: 10px !important;
    min-height: 44px !important;
  }

  .btn-sm {
    padding: 8px 16px !important;
    font-size: 13px !important;
    min-height: 36px !important;
  }

  .btn-lg {
    padding: 14px 24px !important;
    font-size: 17px !important;
    min-height: 52px !important;
  }

  /* ===== 7. FORMS ===== */
  .form-group {
    margin-bottom: 16px !important;
  }

  .form-label,
  label {
    font-size: 14px !important;
    margin-bottom: 8px !important;
    font-weight: 600 !important;
  }

  .form-control,
  input[type=text],
  input[type=email],
  input[type=password],
  input[type=number],
  input[type=tel],
  textarea,
  select {
    width: 100% !important;
    padding: 12px 14px !important;
    font-size: 15px !important;
    border-radius: 10px !important;
    min-height: 44px !important;
  }

  textarea {
    min-height: 100px !important;
  }

  /* ===== 8. TABLES ===== */
  .table-responsive {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  table {
    font-size: 13px !important;
  }

  th, td {
    padding: 10px 8px !important;
  }

  /* ===== 9. MODALS (模態框) ===== */
  .modal-dialog {
    margin: 10px !important;
    max-width: calc(100vw - 20px) !important;
  }

  .modal-content {
    border-radius: 16px !important;
  }

  .modal-header {
    padding: 16px !important;
  }

  .modal-title {
    font-size: 18px !important;
  }

  .modal-body {
    padding: 16px !important;
    max-height: 60vh !important;
    overflow-y: auto !important;
  }

  .modal-footer {
    padding: 16px !important;
    flex-direction: column !important;
    gap: 10px !important;
  }

  .modal-footer .btn {
    width: 100% !important;
  }

  /* ===== 10. ALERTS & NOTIFICATIONS ===== */
  .alert {
    padding: 14px 16px !important;
    font-size: 14px !important;
    border-radius: 10px !important;
  }

  .notification {
    margin: 10px !important;
    max-width: calc(100vw - 20px) !important;
  }

  /* ===== 11. SPACING UTILITIES ===== */
  .mt-mobile-sm { margin-top: 8px !important; }
  .mt-mobile-md { margin-top: 16px !important; }
  .mt-mobile-lg { margin-top: 24px !important; }

  .mb-mobile-sm { margin-bottom: 8px !important; }
  .mb-mobile-md { margin-bottom: 16px !important; }
  .mb-mobile-lg { margin-bottom: 24px !important; }

  .p-mobile-sm { padding: 8px !important; }
  .p-mobile-md { padding: 16px !important; }
  .p-mobile-lg { padding: 24px !important; }

  /* ===== 12. VISIBILITY UTILITIES ===== */
  .desktop-only {
    display: none !important;
  }

  .mobile-only {
    display: block !important;
  }

  .mobile-flex {
    display: flex !important;
  }

  .mobile-grid {
    display: grid !important;
  }
}

/* ========================================
   TABLET: 769px - 1023px
   ======================================== */
@media (min-width: 769px) and (max-width: 1023px) {
  body {
    font-size: 15px !important;
  }

  .main-content,
  main {
    padding: 20px !important;
  }

  .header {
    padding: 12px 20px !important;
  }

  .container {
    max-width: 100% !important;
    padding-left: 20px !important;
    padding-right: 20px !important;
  }
}

/* ========================================
   DESKTOP: ≥1024px
   ======================================== */
@media (min-width: 1024px) {
  .mobile-only {
    display: none !important;
  }

  .mobile-bottom-nav {
    display: none !important;
  }

  .mobile-menu-btn {
    display: none !important;
  }
}
