/* SDLP 響應式設計 CSS */

/* 基本響應式設置 */
* {
    box-sizing: border-box;
}

/* 表格響應式 */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive table {
    min-width: 600px;
}

/* 圖片響應式基本設定 */
.menu-frame img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
}

/* 進度百分比樣式 */
.progress-menu {
    position: relative;
}

.progress-badge {
    position: absolute;
    right: 10px;
    bottom: 10px;
    background-color: #cfd0d0;
    border-radius: 4px;
    padding: 2px 6px;
    opacity: 0.9;
}

.progress-text {
    font-size: 14px;
    color: #d96652;
    font-family: fantasy;
    font-weight: bold;
}

/* 階段圖片響應式 */
.stage-container {
    text-align: center;
    margin-top: 20px;
}

.stage-image {
    max-width: 100%;
    height: auto;
    max-height: 200px;
}

/* 觸控設備改善 */
.touch-device .menu-frame {
    -webkit-tap-highlight-color: rgba(255, 0, 5, 0.3);
    cursor: pointer;
    transition: all 0.2s ease;
}

.touch-device .menu-frame a {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    transition: all 0.2s ease;
}

/* 觸控活躍狀態 */
.touch-active {
    background-color: rgba(255, 0, 5, 0.05) !important;
    transform: scale(0.98);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

/* 觸控回饋動畫 */
.touch-feedback {
    background-color: rgba(255, 0, 5, 0.1) !important;
    transform: scale(0.95);
    box-shadow: 0 0 10px rgba(255, 0, 5, 0.3);
}

/* 載入指示器 */
.loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 1000;
    pointer-events: none;
}

/* 改善觸控目標大小 */
.touch-device .menu-frame {
    min-width: 44px;
}

/* 平板尺寸 (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    /* 主要標題區域響應式 */
    #title-bar {
        width: 100% !important;
        max-width: 1200px;
        padding: 10px 15px;
        position: relative !important;
        height: auto !important;
        min-height: 80px;
    }

    #title-left {
        font-size: 3rem !important;
        text-align: center !important;
        margin-bottom: 10px;
    }
    
    #title-mid {
        font-size: 2rem !important;
        text-align: center !important;
        padding: 10px !important;
        line-height: 1.2 !important;
    }
    
    /* 主框架響應式 */
    .main-frame {
        width: 100% !important;
        max-width: 1000px;
        position: relative !important;
        top: 20px !important;
        left: 0 !important;
        right: 0 !important;
        margin: 0 auto !important;
        padding: 0 15px;
    }
    
    .menu-frame {
        width: 32% !important;
        max-width: 250px !important;
        height: auto !important;
        display: inline-block !important;
        margin: 0.5% !important;
        padding: 8px !important;
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    /* 登入頁面響應式 */
    .main {
        width: 90% !important;
        max-width: 700px;
        height: auto !important;
        position: relative !important;
        top: 20px !important;
        left: 0 !important;
        right: 0 !important;
        margin: 20px auto !important;
        padding: 20px;
    }

    .main-left1, .main-left2 {
        width: 100% !important;
        text-align: center !important;
        float: none !important;
    }

    .main-right {
        width: 100% !important;
        float: none !important;
        margin: 0 !important;
    }
}

/* 桌機尺寸 (992px 以上) - 恢復原始設計 */
@media (min-width: 992px) {
    /* 恢復圖片原始尺寸 */
    .menu-frame img {
        width: auto !important;
        height: auto !important;
        max-width: none !important;
        display: inline-block;
    }
    
    /* 恢復桌機版選單框架原始設定 */
    .menu-frame {
        width: auto !important;
        height: auto !important;
        max-width: none !important;
        min-height: auto !important;
        padding: 0 !important;
        margin: auto !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }
    
    /* 按鈕在桌機版使用預設寬度 */
    .btn-responsive {
        width: auto;
    }
}

/* 手機尺寸 (767px 以下) */
@media (max-width: 767px) {
    /* 主要標題區域響應式 */
    #title-bar {
        width: 100% !important;
        max-width: 1200px;
        padding: 10px 15px;
        position: relative !important;
        height: auto !important;
        min-height: 80px;
    }

    #title-left {
        font-size: 2rem !important;
        text-align: center !important;
        margin-bottom: 10px;
        float: none !important;
    }
    
    #title-mid {
        font-size: 1.5rem !important;
        text-align: center !important;
        padding: 10px !important;
        line-height: 1.2 !important;
        float: none !important;
    }
    
    /* 主框架響應式 */
    .main-frame {
        width: 100% !important;
        max-width: 1000px;
        position: relative !important;
        top: 20px !important;
        left: 0 !important;
        right: 0 !important;
        margin: 0 auto !important;
        padding: 0 15px;
    }
    
    /* 選單框架響應式 */
    .menu-frame {
        width: 100% !important;
        max-width: 300px;
        height: auto !important;
        margin: 10px auto !important;
        display: block !important;
    }
    
    /* 登入頁面響應式 */
    .main {
        width: 95% !important;
        max-width: 600px;
        height: auto !important;
        position: relative !important;
        top: 10px !important;
        left: 0 !important;
        right: 0 !important;
        margin: 10px auto !important;
        padding: 15px 10px !important;
        min-height: auto !important;
    }

    .main-left1, .main-left2 {
        width: 100% !important;
        text-align: center !important;
        float: none !important;
        margin-bottom: 5px !important;
        font-size: 1.2rem !important;
        line-height: 1.3 !important;
        padding: 5px 0 !important;
    }
    
    .main-left1 {
        font-size: 1.5rem !important;
    }

    .main-right {
        width: 100% !important;
        float: none !important;
        margin: 10px 0 0 0 !important;
        padding: 0 !important;
    }
    
    /* 選單框架手機版觸控改善 */
    .menu-frame {
        width: 48% !important;
        max-width: 200px !important;
        height: auto !important;
        margin: 1% !important;
        padding: 5px !important;
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        display: inline-block !important;
        vertical-align: top;
    }
    
    .menu-frame a {
        display: block;
        width: 100%;
        text-decoration: none;
        padding: 5px;
        border-radius: 6px;
        transition: all 0.2s ease;
    }
    
    .menu-frame:active {
        transform: scale(0.95);
        box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    }
    
    /* 進度百分比手機版調整 */
    .progress-badge {
        right: 5px !important;
        bottom: 5px !important;
        padding: 4px 8px !important;
        border-radius: 6px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    }
    
    .progress-text {
        font-size: 12px !important;
    }
    
    /* 階段圖片手機版調整 */
    .stage-container {
        margin-top: 30px;
        padding: 0 15px;
    }
    
    .stage-image {
        max-height: 150px !important;
        width: 100%;
        object-fit: contain;
    }
    
    /* 按鈕響應式 */
    .btn-responsive {
        width: 100%;
        margin-bottom: 10px;
        min-height: 44px; /* iOS 建議最小觸控目標 */
    }
    
    /* 表單響應式 */
    .form-responsive .container {
        padding: 2px;
    }

    .form-responsive .row {
        margin: 3px 0;
    }

    .form-responsive .col, .form-responsive [class*="col-"] {
        padding: 3px;
    }
    
    .form-responsive .form-control {
        font-size: 16px; /* 防止iOS縮放 */
        height: 38px;
        padding: 8px 12px;
    }
    
    .form-responsive .form-title {
        font-size: 18px !important;
        margin: 5px 0 10px 0 !important;
        padding: 5px !important;
    }
    
    /* 隱藏不必要的文字在小螢幕上 */
    .hide-on-mobile {
        display: none;
    }
    
    /* 觸控反饋改善 */
    .touch-device .menu-frame:hover {
        background-color: rgba(255, 0, 5, 0.05);
    }
    
    .touched {
        background-color: rgba(255, 0, 5, 0.1) !important;
        transform: scale(0.98);
    }
}

/* 極小螢幕 (320px 以下) */
@media (max-width: 320px) {
    #title-left {
        font-size: 1.3rem !important;
    }
    
    #title-mid {
        font-size: 1rem !important;
    }
    
    .main {
        margin: 5px !important;
        padding: 10px 5px !important;
        width: 98% !important;
    }
    
    .main-left1 {
        font-size: 1.3rem !important;
    }
    
    .main-left2 {
        font-size: 1rem !important;
    }
    
    .form-responsive .row {
        margin: 2px 0;
    }
    
    .form-responsive .form-control {
        font-size: 14px;
        height: 36px;
        padding: 6px 10px;
    }
    
    .form-responsive .form-title {
        font-size: 16px !important;
    }
    
    /* 極小螢幕選單調整 */
    .menu-frame {
        width: 100% !important;
        max-width: none !important;
        margin: 5px 0 !important;
        padding: 3px !important;
    }
}

/* 中等手機螢幕 (375px - 414px) */
@media (min-width: 375px) and (max-width: 414px) {
    .menu-frame {
        width: 48% !important;
        max-width: 180px !important;
    }
    
    .main {
        width: 90% !important;
        padding: 15px 8px !important;
    }
    
    .main-left1 {
        font-size: 1.4rem !important;
    }
    
    .main-left2 {
        font-size: 1.1rem !important;
    }
}

/* DataTables 響應式支援 */
.dataTables_wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    margin-bottom: 10px;
}

/* 手機版 DataTables 調整 */
@media (max-width: 767px) {
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        float: none !important;
        text-align: center;
        margin-bottom: 10px;
    }
    
    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        max-width: 200px;
        margin-left: 0 !important;
    }
    
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        float: none !important;
        text-align: center;
        margin-top: 10px;
    }
    
    table.dataTable {
        font-size: 12px;
    }
    
    table.dataTable th,
    table.dataTable td {
        padding: 4px !important;
        word-wrap: break-word;
    }
    
    /* 隱藏不重要的欄位在手機版 */
    .hide-mobile {
        display: none !important;
    }
}

/* 背景響應式調整 */
.html-contain {
    height: auto !important;
    min-height: 100vh;
}

/* Canvas 背景調整 */
canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

/* 打印樣式保持原樣 */
@media print {
    .btn, .noprint {
        display: none !important;
    }
    
    .main-frame, #title-bar {
        position: static !important;
        width: 100% !important;
    }
}