/* ========================================
   響應式設計 CSS
   ======================================== */

/* 全域響應式設定 */
* {
    box-sizing: border-box;
}

img {
    max-width: 100%;
    height: auto;
}

/* ========================================
   桌面版 (≥1200px)
   ======================================== */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
}

/* ========================================
   平板版 (768px - 991px)
   ======================================== */
@media (max-width: 991px) {
    /* 導航列調整 */
    .navbar-brand {
        font-size: 1.25rem;
    }
    
    /* 標題調整 */
    .display-4 {
        font-size: 2.5rem;
    }
    
    .display-5 {
        font-size: 2rem;
    }
    
    /* 卡片排版：2欄 */
    .col-md-4 {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    /* 間距調整 */
    .py-5 {
        padding-top: 3rem !important;
        padding-bottom: 3rem !important;
    }
    
    /* 輪播高度調整 */
    .carousel-item {
        height: 400px;
    }
    
    .carousel-item img {
        height: 400px;
        object-fit: cover;
    }
}

/* ========================================
   手機版 (< 768px)
   ======================================== */
@media (max-width: 767px) {
    /* 導航列調整 */
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    .navbar-toggler {
        padding: 0.5rem;
        font-size: 1rem;
    }
    
    /* 標題調整 */
    .display-4 {
        font-size: 2rem;
        letter-spacing: 2px;
    }
    
    .display-5 {
        font-size: 1.5rem;
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    h3 {
        font-size: 1.25rem;
    }
    
    h4 {
        font-size: 1.1rem;
    }
    
    /* 卡片排版：1欄 */
    .col-md-4,
    .col-md-6,
    .col-lg-3,
    .col-lg-4 {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 1rem;
    }
    
    /* 間距調整 */
    .py-5 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
    
    .mb-5 {
        margin-bottom: 2rem !important;
    }
    
    .mt-5 {
        margin-top: 2rem !important;
    }
    
    /* 輪播調整 */
    .carousel-item {
        height: 300px;
    }
    
    .carousel-item img {
        height: 300px;
        object-fit: cover;
    }
    
    .carousel-caption {
        padding: 1rem;
    }
    
    .carousel-caption h2 {
        font-size: 1.25rem;
    }
    
    .carousel-caption p {
        font-size: 0.875rem;
        display: none; /* 隱藏副標題 */
    }
    
    /* 按鈕調整 */
    .btn-lg {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
    
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
    
    /* 表單調整 */
    .form-control,
    .form-select {
        font-size: 1rem; /* 防止 iOS 自動縮放 */
    }
    
    /* 卡片調整 */
    .card {
        margin-bottom: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    /* 統計數據調整 */
    .stat-number {
        font-size: 2rem;
    }
    
    /* 頁尾調整 */
    footer .col-md-4 {
        margin-bottom: 1.5rem;
    }
    
    /* 隱藏桌面版元素 */
    .d-none.d-lg-block {
        display: none !important;
    }
    
    /* 圖片調整 */
    .img-thumbnail {
        max-width: 100%;
    }
    
    /* 表格調整 */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* 導航選單調整 */
    .navbar-collapse {
        max-height: 400px;
        overflow-y: auto;
    }
    
    .navbar-nav {
        padding: 1rem 0;
    }
    
    .nav-link {
        padding: 0.75rem 1rem;
        border-bottom: 1px solid rgba(0,0,0,0.1);
    }
}

/* ========================================
   極小螢幕 (< 576px)
   ======================================== */
@media (max-width: 575px) {
    /* 容器調整 */
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    /* 標題調整 */
    .display-4 {
        font-size: 1.75rem;
        letter-spacing: 1px;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.25rem;
    }
    
    /* 輪播調整 */
    .carousel-item {
        height: 250px;
    }
    
    .carousel-item img {
        height: 250px;
    }
    
    .carousel-caption {
        padding: 0.5rem;
    }
    
    .carousel-caption h2 {
        font-size: 1rem;
    }
    
    /* 按鈕調整 */
    .btn-lg {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
    
    /* 卡片調整 */
    .card-body {
        padding: 0.75rem;
    }
    
    /* 統計數據調整 */
    .stat-number {
        font-size: 1.5rem;
    }
    
    .stat-label {
        font-size: 0.875rem;
    }
}

/* ========================================
   觸控裝置優化
   ======================================== */
@media (hover: none) and (pointer: coarse) {
    /* 增加觸控區域 */
    .btn,
    .nav-link,
    a {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* 移除 hover 效果 */
    .hover-lift:hover {
        transform: none;
    }
    
    /* 優化表單元件 */
    input,
    textarea,
    select {
        font-size: 16px; /* 防止 iOS 自動縮放 */
    }
}

/* ========================================
   列印樣式
   ======================================== */
@media print {
    /* 隱藏不需要列印的元素 */
    .navbar,
    .carousel-control-prev,
    .carousel-control-next,
    .btn,
    footer,
    .no-print {
        display: none !important;
    }
    
    /* 調整顏色 */
    * {
        color: #000 !important;
        background: #fff !important;
    }
    
    /* 調整連結 */
    a[href]:after {
        content: " (" attr(href) ")";
    }
}

/* ========================================
   橫向模式優化 (手機橫向)
   ======================================== */
@media (max-height: 500px) and (orientation: landscape) {
    .carousel-item {
        height: 100vh;
    }
    
    .carousel-item img {
        height: 100vh;
    }
    
    .py-5 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }
}

/* ========================================
   高解析度螢幕優化
   ======================================== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* 優化圖片顯示 */
    img {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* ========================================
   暗色模式支援 (可選)
   ======================================== */
@media (prefers-color-scheme: dark) {
    /* 如果需要支援暗色模式，可以在這裡添加樣式 */
}

/* ========================================
   減少動畫 (無障礙)
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   自訂響應式工具類別
   ======================================== */

/* 文字對齊 */
.text-center-mobile {
    text-align: center;
}

@media (min-width: 768px) {
    .text-center-mobile {
        text-align: left;
    }
}

/* 間距調整 */
.mb-mobile-3 {
    margin-bottom: 1rem;
}

@media (min-width: 768px) {
    .mb-mobile-3 {
        margin-bottom: 0;
    }
}

/* 圖片容器 */
.img-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 比例 */
    overflow: hidden;
}

.img-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 響應式嵌入 (影片、地圖等) */
.embed-responsive {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 */
    overflow: hidden;
}

.embed-responsive iframe,
.embed-responsive embed,
.embed-responsive object,
.embed-responsive video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* 響應式表格 */
@media (max-width: 767px) {
    .table-mobile-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table-mobile-responsive table {
        min-width: 600px;
    }
}
