﻿/* ===== 響應式設計和印刷樣式 ===== */

/* 基本響應式設計 */
@media (max-width: 768px) {
    .container {
        padding: 0 10px;
    }

    .card-body {
        padding: 1rem;
    }

    .btn-group .btn {
        padding: 0.375rem 0.5rem;
        font-size: 0.875rem;
    }

    .table-responsive {
        font-size: 0.875rem;
    }

    /* 表格響應式優化 */
    .table td,
    .table th {
        padding: 0.5rem;
        font-size: 0.85rem;
    }

    /* 卡片響應式調整 */
    .card {
        margin-bottom: 1rem;
    }

    .card-header {
        padding: 0.75rem 1rem;
    }

    /* 按鈕響應式調整 */
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
    }

    /* 表單響應式調整 */
    .form-control,
    .form-select {
        font-size: 16px; /* 防止 iOS 縮放 */
    }

    /* 模態框響應式 
    .modal-dialog {
        margin: 0.5rem;
    }*/

    .modal-body {
        padding: 1rem;
        max-height: 60vh;
    }

    /* 導航響應式 - 已在 navigation.css 中處理 */
}

/* 小型設備 (576px 以下) */
@media (max-width: 576px) {
    .container {
        padding: 0 5px;
    }

    /* 字體大小調整 */
    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    h4 {
        font-size: 1.1rem;
    }

    h5 {
        font-size: 1rem;
    }

    h6 {
        font-size: 0.9rem;
    }

    /* 卡片超小螢幕調整 */
    .card-body {
        padding: 0.75rem;
    }

    .card-header {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }

    /* 按鈕組在小螢幕的調整 */
    .btn-group {
        display: flex;
        flex-direction: column;
        width: 100%;
    }

        .btn-group .btn {
            border-radius: 0.375rem !important;
            margin-bottom: 0.25rem;
        }

            .btn-group .btn:last-child {
                margin-bottom: 0;
            }

    /* 表格極小螢幕調整 */
    .table-responsive {
        border: none;
    }

    .table {
        font-size: 0.8rem;
    }

        .table td,
        .table th {
            padding: 0.25rem;
            white-space: nowrap;
        }

    /* 分頁響應式 */
    .pagination {
        justify-content: center;
        font-size: 0.8rem;
    }

        .pagination .page-link {
            padding: 0.25rem 0.5rem;
        }

    /* 徽章小螢幕調整 */
    .badge {
        font-size: 0.65rem;
        padding: 0.3em 0.5em;
    }
}

/* 大型設備 (1200px 以上) */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }

    /* 卡片大螢幕增強 */
    .card {
        transition: all 0.3s ease;
    }

        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
        }

    /* 表格大螢幕優化 */
    .table {
        font-size: 0.95rem;
    }

        .table td,
        .table th {
            padding: 1rem;
        }
}

/* 印刷樣式 */
@media print {
    /* 隱藏不需要的元素 */
    .btn,
    .breadcrumb,
    .card-header .btn-group,
    nav,
    .no-print,
    .pagination,
    .modal,
    .dropdown-menu,
    #toast-container,
    .chat-panel-container,
    #backToTopBtn {
        display: none !important;
    }

    /* 頁面設定 */
    @page {
        margin: 1cm;
        size: A4;
    }

    body {
        font-size: 12pt;
        line-height: 1.4;
        color: #000;
        background: #fff;
    }

    /* 容器印刷調整 */
    .container,
    .container-fluid {
        margin: 0;
        padding: 0;
        max-width: 100%;
    }

    /* 卡片印刷樣式 */
    .card {
        border: 1px solid #000 !important;
        box-shadow: none !important;
        break-inside: avoid;
        margin-bottom: 1rem;
    }

    .card-header {
        background: #f5f5f5 !important;
        border-bottom: 1px solid #000 !important;
        font-weight: bold;
    }

    .card-body {
        padding: 10px !important;
    }

    /* 表格印刷樣式 */
    .table {
        border-collapse: collapse;
        font-size: 10pt;
    }

        .table th,
        .table td {
            border: 1px solid #000 !important;
            padding: 0.5rem !important;
        }

        .table th {
            background: #f5f5f5 !important;
            font-weight: bold;
        }

    /* 徽章印刷樣式 */
    .badge {
        border: 1px solid #000 !important;
        color: #000 !important;
        background: #fff !important;
        padding: 2px 4px;
    }

    /* 文字印刷優化 */
    h1, h2, h3, h4, h5, h6 {
        color: #000;
        page-break-after: avoid;
    }

    p, li {
        orphans: 3;
        widows: 3;
    }

    /* 連結印刷處理 */
    a {
        color: #000;
        text-decoration: underline;
    }

    /* 分頁處理 */
    .page-break {
        page-break-before: always;
    }

    .no-page-break {
        page-break-inside: avoid;
    }

    /* 時間軸印刷調整 */
    .timeline::before {
        background: #000 !important;
    }

    .timeline-marker {
        background: #fff !important;
        border: 2px solid #000 !important;
        color: #000 !important;
    }

    .timeline-content {
        border-left: 3px solid #000 !important;
        background: #f9f9f9 !important;
    }

    /* 標籤印刷樣式 */
    .custom-tag {
        border: 1px solid #000 !important;
        background: #fff !important;
        color: #000 !important;
    }

        .custom-tag .tag-remove-btn {
            display: none !important;
        }
}

/* 高對比度模式 */
@media (prefers-contrast: high) {
    .card {
        border: 2px solid #000;
    }

    .btn {
        border-width: 2px;
    }

    .form-control,
    .form-select {
        border-width: 2px;
    }

    .table th,
    .table td {
        border-width: 2px;
    }
}

/* 減少動畫模式 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .card:hover {
        transform: none;
    }

    .btn:hover {
        transform: none;
    }
}

/* 深色模式支援 */
@media (prefers-color-scheme: dark) {
    :root {
        --dark-color: #f8f9fa;
        --light-color: #212529;
    }

    body {
        background-color: #212529;
        color: #f8f9fa;
    }

    .card {
        background-color: #343a40;
        border-color: #495057;
    }

    .card-header {
        background-color: #495057;
        border-color: #6c757d;
    }

    .table {
        color: #f8f9fa;
    }

        .table th {
            background-color: #495057;
            border-color: #6c757d;
        }

        .table td {
            border-color: #495057;
        }

    .form-control,
    .form-select {
        background-color: #495057;
        border-color: #6c757d;
        color: #f8f9fa;
    }

        .form-control:focus,
        .form-select:focus {
            background-color: #495057;
            border-color: #80bdff;
            color: #f8f9fa;
        }
}

/* 橫屏模式調整 */
@media screen and (orientation: landscape) and (max-height: 500px) {
    .navbar {
        min-height: 50px;
        padding: 0.25rem 0;
    }

    .navbar-brand {
        font-size: 1.1rem;
        padding: 0.25rem 0;
    }

    main {
        margin-top: 60px;
        padding: 1rem 0;
    }

    .modal-dialog {
        max-height: 90vh;
    }

    .modal-body {
        max-height: 60vh;
    }
}

/* 超寬螢幕優化 */
@media (min-width: 1600px) {
    .container {
        max-width: 1400px;
    }

    .card-columns {
        column-count: 4;
    }

    .table {
        font-size: 1rem;
    }
}

/* 觸控設備優化 */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        min-width: 44px;
    }

    .form-control,
    .form-select {
        min-height: 44px;
        font-size: 16px;
    }

    .table td,
    .table th {
        padding: 0.75rem;
    }

    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}
