/* 大元 CRM 系統自定義樣式 */

:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --border-radius: 8px;
    --box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    --transition: all 0.3s ease;
}

/* 全域樣式 */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f6fa;
    /* 效能優化 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    padding-bottom: 80px; /* 為手機版底部導航預留空間 */
    /* 防止橫向捲軸 */
    overflow-x: hidden;
}

/* 表格排序樣式 */
.table thead th a {
    color: #343a40;
    text-decoration: none;
    display: block;
    position: relative;
    padding-right: 20px;
}

.table thead th a:hover {
    color: var(--primary-color);
}

.table thead th a i {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8em;
    color: var(--primary-color);
}

/* 修復 compact-layout 在手機版的問題 */
@media (max-width: 767px) {
    body.compact-layout {
        padding-bottom: 80px !important;
    }
}

/* 全域防止橫向溢出 */
html {
    overflow-x: hidden;
}

/* 確保所有容器不會超出視窗 */
.container,
.container-fluid {
    max-width: 100%;
    overflow-x: hidden;
}

/* 手機版全域文字換行 */
@media (max-width: 767px) {
    body {
        word-break: break-word;
        overflow-wrap: break-word;
    }
    
    /* 確保主要容器不會溢出 */
    main {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }
    
    /* 確保表格響應式 */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* 防止固定寬度元素溢出 */
    img, video, iframe, embed, object {
        max-width: 100% !important;
        height: auto !important;
    }
    
    /* 防止容器溢出 */
    .container-fluid,
    .container,
    .row {
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
    
    /* 修正 Bootstrap 的負邊距 */
    .row {
        margin-left: -7.5px !important;
        margin-right: -7.5px !important;
    }
    
    .col, [class*="col-"] {
        padding-left: 7.5px !important;
        padding-right: 7.5px !important;
    }
    
    /* 長文字強制換行 */
    p, span, div, td, th, h1, h2, h3, h4, h5, h6 {
        word-break: break-word !important;
        overflow-wrap: break-word !important;
        hyphens: auto !important;
    }
    
    /* 防止按鈕組溢出 */
    .btn-toolbar,
    .btn-group {
        flex-wrap: wrap !important;
    }
    
    /* 防止卡片溢出 */
    .card {
        max-width: 100% !important;
    }
    
    /* 防止模態框溢出 */
    .modal-dialog {
        margin: 10px !important;
        max-width: calc(100% - 20px) !important;
    }
    
    /* 防止絕對定位元素溢出 */
    [style*="position: fixed"],
    [style*="position: absolute"] {
        max-width: calc(100vw - 20px) !important;
    }
}

/* 側邊導航 */
.sidebar {
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    padding: 0;
    box-shadow: var(--box-shadow);
}

/* 精簡版側邊欄 */
.sidebar-compact {
    width: 80px;
    min-height: 100vh;
    background: linear-gradient(180deg, #ffffff 0%, #f8f9fa 100%);
    border-right: 1px solid #e9ecef;
    transition: width 0.3s ease; /* 寬度平滑過渡 */
}

.sidebar-compact .nav-link {
    color: var(--secondary-color);
    padding: 16px 8px;
    border-radius: 8px;
    margin: 0 8px;
    transition: all 0.3s ease; /* 平滑過渡所有屬性 */
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 70px;
    gap: 8px; /* 進一步增加圖示和文字之間的間距 */
}

.sidebar-compact .nav-link:hover {
    background-color: rgba(var(--bs-primary-rgb), 0.1);
    color: var(--primary-color);
    transform: translateY(-2px);
}

.sidebar-compact .nav-link.active {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(var(--bs-primary-rgb), 0.3);
}

.sidebar-compact .nav-link.active:hover {
    background-color: var(--primary-color);
    color: white;
}

.sidebar-compact .nav-link i {
    width: auto;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem !important; /* 確保圖示在平板模式下有適當大小 */
    margin-bottom: 4px; /* 進一步增加圖示底部間距 */
}


.sidebar-compact .nav-link small {
    font-size: 0.7rem;
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
    margin-top: 3px; /* 進一步增加文字頂部間距 */
    white-space: nowrap; /* 防止文字換行 */
}

/* 公司標誌樣式 */
.sidebar-compact .text-primary i {
    font-size: 1.5rem !important; /* 公司標誌稍大一些 */
}

/* 側邊欄底部版本資訊 */
.sidebar-compact .text-center.text-muted i {
    font-size: 1rem; /* 底部圖示適中大小 */
}

/* 傳統側邊欄樣式（保留向下相容） */
.sidebar:not(.sidebar-compact) .nav-link {
    color: var(--dark-color);
    padding: 15px 20px;
    border-radius: 0;
    transition: var(--transition);
}

.sidebar:not(.sidebar-compact) .nav-link:hover {
    background-color: var(--primary-color);
    color: white;
}

.sidebar:not(.sidebar-compact) .nav-link.active {
    background-color: var(--primary-color);
    color: white;
}

.sidebar:not(.sidebar-compact) .nav-link i {
    margin-right: 10px;
    width: 20px;
}

/* 主要內容區域 */
main {
    margin-left: 0;
    padding-top: 20px;
}

@media (min-width: 768px) {
    main {
        margin-left: 80px; /* 預設側邊欄寬度 */
    }
    
    body {
        padding-bottom: 0;
    }
}

/* 卡片樣式 */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: var(--transition);
}

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

.card-header {
    background-color: var(--light-color);
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
}

/* 統計卡片 */
.stats-card {
    background: linear-gradient(135deg, var(--primary-color), #0056b3);
    color: white;
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
}

.stats-card.success {
    background: linear-gradient(135deg, var(--success-color), #1e7e34);
}

.stats-card.warning {
    background: linear-gradient(135deg, var(--warning-color), #d39e00);
    color: var(--dark-color);
}

.stats-card.danger {
    background: linear-gradient(135deg, var(--danger-color), #bd2130);
}

.stats-card .stats-number {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.stats-card .stats-label {
    opacity: 0.9;
    font-size: 0.9rem;
}

/* 按鈕樣式 */
.btn {
    border-radius: var(--border-radius);
    padding: 8px 16px;
    font-weight: 500;
    transition: var(--transition);
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #0056b3;
    border-color: #0056b3;
    transform: translateY(-1px);
}

/* 表格樣式 */
.table {
    background-color: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--box-shadow);
}

.table th {
    background-color: var(--light-color);
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
}

.table-hover tbody tr:hover {
    background-color: #f8f9fa;
}

/* 客戶等級徽章 */
.badge.level-vip {
    background-color: #ffd700;
    color: var(--dark-color);
}

.badge.level-normal {
    background-color: var(--info-color);
}

.badge.level-potential {
    background-color: var(--secondary-color);
}

/* 報價階段 */
.stage-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.stage-潛在客戶 {
    background-color: #e3f2fd;
    color: #1976d2;
}

.stage-初步接觸 {
    background-color: #fff3e0;
    color: #f57c00;
}

.stage-報價中 {
    background-color: #f3e5f5;
    color: #7b1fa2;
}

.stage-成交確認 {
    background-color: #e8f5e8;
    color: #388e3c;
}

/* 管道看板 */
.pipeline-column {
    background-color: #f8f9fa;
    border-radius: var(--border-radius);
    padding: 15px;
    min-height: 500px;
    margin-bottom: 20px;
}

.pipeline-header {
    font-weight: 600;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
}

.deal-card {
    background-color: white;
    border-radius: var(--border-radius);
    padding: 15px;
    margin-bottom: 10px;
    cursor: move;
    border-left: 4px solid var(--primary-color);
    transition: var(--transition);
}

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

.deal-card.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.deal-amount {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--success-color);
}

.deal-customer {
    font-weight: 500;
    margin-bottom: 5px;
}

.deal-date {
    font-size: 0.8rem;
    color: var(--secondary-color);
}

/* 手機版底部導航 */
.navbar.fixed-bottom .nav-link {
    color: var(--secondary-color);
    padding: 8px 5px;
    transition: var(--transition);
}

.navbar.fixed-bottom .nav-link:hover {
    color: var(--primary-color);
}

.navbar.fixed-bottom .nav-link.active {
    color: var(--primary-color);
    font-weight: 600;
}

.navbar.fixed-bottom small {
    font-size: 0.7rem;
}

/* 搜尋框 */
.search-box {
    position: relative;
}

.search-box .form-control {
    padding-left: 40px;
    border-radius: 25px;
}

.search-box .search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--secondary-color);
}

/* 快速操作按鈕 */
.quick-actions {
    position: fixed;
    bottom: 100px;
    right: 20px;
    z-index: 1000;
}

@media (min-width: 992px) {
    .quick-actions {
        bottom: 20px;
    }
}

.quick-action-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: var(--transition);
}

.quick-action-btn:hover {
    transform: scale(1.1);
}

/* 載入動畫 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 空狀態 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--secondary-color);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .btn {
        padding: 6px 12px;
        font-size: 0.875rem;
    }
    
    .card {
        margin-bottom: 15px;
    }
    
    .stats-card .stats-number {
        font-size: 1.5rem;
    }
}

/* 打印樣式 */
@media print {
    .sidebar,
    .navbar,
    .quick-actions,
    .btn,
    .modal {
        display: none !important;
    }
    
    main {
        margin-left: 0 !important;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* 拖放區域高亮 */
.drop-zone {
    border: 2px dashed var(--primary-color);
    background-color: rgba(0, 123, 255, 0.1);
}

.drop-zone.drag-over {
    border-color: var(--success-color);
    background-color: rgba(40, 167, 69, 0.1);
}

/* 工具提示樣式 */
.tooltip {
    font-size: 0.875rem;
}

.tooltip-inner {
    background-color: var(--dark-color);
    border-radius: var(--border-radius);
}

/* 模態框樣式 */
.modal-content {
    border-radius: var(--border-radius);
    border: none;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

/* 客戶搜尋下拉選單樣式 */
#customer_dropdown {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    background-color: white;
    z-index: 10002;
}

#customer_dropdown .dropdown-item {
    border: none;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
}

#customer_dropdown .dropdown-item:hover {
    background-color: #f8f9fa;
}

#customer_dropdown .dropdown-item.active {
    background-color: #007bff;
    color: white;
}

#customer_dropdown .dropdown-divider {
    margin: 0.5rem 0;
    border-top: 1px solid #dee2e6;
}

/* 螢幕大小適應樣式 */
@media (max-width: 575.98px) {
    /* 小手機 */
    #customer_dropdown {
        max-height: 300px;
        font-size: 0.9rem;
    }
    
    #customer_dropdown .dropdown-item {
        padding: 0.6rem 0.8rem;
        min-height: 40px;
    }
}


@media (min-width: 992px) {
    /* 桌面模式 */
    #customer_dropdown {
        max-height: 400px;
    }
}

/* 側邊欄基本樣式 */
.sidebar-compact {
    min-height: 100vh;
    width: 80px;
}

.sidebar-compact .nav-link {
    color: #6c757d !important;
    text-decoration: none !important;
    border-radius: 0.375rem;
    margin: 0.2rem 0.1rem;
    transition: all 0.15s ease-in-out;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    padding: 0.75rem 0.25rem !important;
}

.sidebar-compact .nav-link:hover {
    background-color: #e9ecef !important;
    color: #495057 !important;
}

.sidebar-compact .nav-link.active {
    background-color: #007bff !important;
    color: white !important;
}

.sidebar-compact .nav-link i {
    font-size: 1.5rem !important;
    margin-bottom: 0.25rem !important;
    display: block !important;
    width: 100%;
}

.sidebar-compact .nav-link small {
    font-size: 0.7rem !important;
    line-height: 1.1 !important;
    margin-top: 0.2rem !important;
    display: block !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}


/* 桌面模式：768px 以上統一使用側邊導航 */
@media (min-width: 768px) {
    /* 桌面模式側邊導航 */
    .sidebar-compact {
        width: 80px !important;
        display: block !important;
    }
    
    /* 桌面版隱藏底部導航 */
    .mobile-bottom-nav,
    .navbar.fixed-bottom {
        display: none !important;
    }
    
    /* 移除底部空間 */
    body {
        padding-bottom: 0 !important;
    }
    
    .sidebar-compact .nav-link {
        padding: 0.75rem 0.25rem !important;
        min-height: 65px !important;
    }
    
    .sidebar-compact .nav-link i {
        font-size: 1.5rem !important;
    }
    
    .sidebar-compact .nav-link small {
        font-size: 0.7rem !important;
        display: block !important;
    }
    
    /* 調整主內容區域邊距 */
    main {
        margin-left: 80px !important;
    }
}

@media (min-width: 992px) {
    /* 大螢幕優化 */
    .sidebar-compact {
        width: 90px !important;
    }
    
    main {
        margin-left: 90px !important;
    }
    
    .sidebar-compact .nav-link {
        padding: 0.8rem 0.3rem !important;
    }
    
    .sidebar-compact .nav-link i {
        font-size: 1.6rem !important;
    }
    
    .sidebar-compact .nav-link small {
        font-size: 0.75rem !important;
    }
}

@media (min-width: 1200px) {
    /* 大桌面模式：更寬的側邊欄 */
    .sidebar-compact {
        width: 100px !important;
    }
    .sidebar-compact .nav-link {
        padding: 0.9rem 0.4rem !important;
    }
    .sidebar-compact .nav-link i {
        font-size: 1.8rem !important;
    }
    .sidebar-compact .nav-link small {
        font-size: 0.8rem !important;
    }
}

.modal-header {
    border-bottom: 1px solid #dee2e6;
    background-color: var(--light-color);
}

.modal-footer {
    border-top: 1px solid #dee2e6;
    background-color: var(--light-color);
}

/* 進度條 */
.progress {
    height: 8px;
    border-radius: 4px;
}

.progress-bar {
    border-radius: 4px;
}

/* 輸入群組 */
.input-group-text {
    border-color: #ced4da;
    background-color: var(--light-color);
}

/* 選項卡 */
.nav-tabs .nav-link {
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--secondary-color);
}

.nav-tabs .nav-link.active {
    border-bottom-color: var(--primary-color);
    color: var(--primary-color);
    background: none;
}

/* 通知樣式 */
.alert {
    border: none;
    border-radius: var(--border-radius);
    border-left: 4px solid;
}

.alert-success {
    border-left-color: var(--success-color);
    background-color: #d4edda;
}

.alert-danger {
    border-left-color: var(--danger-color);
    background-color: #f8d7da;
}

.alert-warning {
    border-left-color: var(--warning-color);
    background-color: #fff3cd;
}

.alert-info {
    border-left-color: var(--info-color);
    background-color: #cce7f0;
}

/* ========================================
   手機版觸控優化樣式
======================================== */

/* 觸控目標最小尺寸 */
.mobile-touch-target {
    min-height: 44px;
    min-width: 44px;
}

/* 手機版底部導航優化 - 支援6個圖示 */
.mobile-bottom-nav {
    height: 70px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

/* 確保底部導航只在手機版顯示 */
@media (min-width: 768px) {
    .mobile-bottom-nav {
        display: none !important;
        visibility: hidden !important;
    }
    
    body {
        padding-bottom: 0 !important;
    }
}

/* 6個圖示的手機導航優化 - 統一高度修復版 */
@media (max-width: 767px) {
    .mobile-bottom-nav {
        height: 70px !important; /* 統一使用 70px 高度 */
        min-height: 70px !important;
        max-height: 70px !important;
        padding: 0 !important;
        background-color: white !important;
        overflow: hidden !important;
    }
    
    /* 覆蓋 Bootstrap navbar 的預設樣式 */
    .mobile-bottom-nav.navbar {
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }
    
    .mobile-bottom-nav .container-fluid {
        padding: 0 !important;
        height: 100% !important;
    }
    
    .mobile-bottom-nav .row {
        height: 100% !important;
        margin: 0 !important;
    }
    
    .mobile-bottom-nav .col {
        padding: 0 !important;
        height: 100% !important;
        position: relative !important;
    }
    
    .mobile-nav-item {
        width: 100% !important;
        height: 100% !important;
        min-height: 70px !important;
        padding: 8px 4px !important;
        margin: 0 !important;
        display: flex !important; /* 改用 flexbox 而非絕對定位 */
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        position: relative !important;
        text-decoration: none !important;
        overflow: hidden !important;
        gap: 4px !important;
    }
    
    /* 移除任何 p-2 類別的影響 */
    .mobile-nav-item.p-2 {
        padding: 8px 4px !important;
    }
    
    /* 使用 flexbox 自然流佈局，避免絕對定位 */
    .mobile-nav-item i {
        font-size: 1.2rem !important;
        line-height: 1.2rem !important;
        height: 1.2rem !important;
        margin: 0 !important;
        padding: 0 !important;
        display: block !important;
        flex-shrink: 0 !important;
    }
    
    .mobile-nav-item small {
        font-size: 0.65rem !important;
        line-height: 0.65rem !important;
        height: 0.65rem !important;
        margin: 0 !important;
        padding: 0 !important;
        white-space: nowrap !important;
        text-align: center !important;
        display: block !important;
        font-weight: 500 !important;
        flex-shrink: 0 !important;
    }
    
    /* 確保整個底部導航區域不被其他元素影響 */
    body {
        padding-bottom: 75px !important;
    }
    
    /* 強制覆蓋任何內聯樣式 */
    .mobile-bottom-nav[style] {
        height: 70px !important;
    }
    
    /* 確保底部導航始終固定在視窗底部 */
    .mobile-bottom-nav {
        position: fixed !important;
        bottom: 0 !important;
        top: auto !important; /* 強制取消 top 定位 */
        left: 0 !important;
        right: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        margin: 0 !important;
        padding: 0 !important;
        z-index: 1060 !important; /* 提高 z-index，確保在最上層 */
        isolation: isolate !important; /* 創建新的堆疊上下文 */
        /* 確保完全貼底 */
        transform: translateZ(0) !important; /* 啟用硬體加速 */
    }
    
    /* 強制覆蓋 Bootstrap 的 fixed-bottom 類別 */
    .navbar.fixed-bottom.mobile-bottom-nav {
        position: fixed !important;
        bottom: 0 !important;
        top: auto !important;
    }
    
    /* 重置所有可能被頁面樣式影響的屬性 */
    .mobile-bottom-nav * {
        box-sizing: border-box !important;
        transform: none !important;
        position: relative !important;
    }
    
    /* 確保導航項目的佈局完全一致 */
    .mobile-bottom-nav .mobile-nav-item {
        gap: 4px !important;
        padding: 10px 4px !important;
        box-sizing: border-box !important;
        line-height: 1 !important;
    }
    
    /* 強制統一圖示和文字的位置 */
    .mobile-bottom-nav .mobile-nav-item > * {
        margin: 0 !important;
        padding: 0 !important;
        line-height: 1 !important;
    }
    
    /* 防止內容區域影響底部導航 */
    main {
        margin-bottom: 70px !important;
    }
}

/* 極小螢幕額外修復 (小於 360px) */
@media (max-width: 359px) {
    .mobile-nav-item i {
        font-size: 1rem !important;
    }
    
    .mobile-nav-item small {
        font-size: 0.55rem !important;
    }
}

.mobile-nav-item {
    min-height: 70px; /* 統一為 70px 以匹配容器高度 */
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    text-decoration: none;
    transition: all 0.2s ease;
    border-radius: 8px;
    margin: 0; /* 移除邊距避免高度不一致 */
    position: relative;
    gap: 4px; /* 統一間距 */
    padding: 10px 4px; /* 統一內距 */
}

.mobile-nav-item:hover,
.mobile-nav-item:focus {
    color: var(--primary-color);
    background-color: rgba(0, 123, 255, 0.08);
}

.mobile-nav-item.active {
    color: var(--primary-color);
    background-color: rgba(0, 123, 255, 0.12);
}

.mobile-nav-item.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    background-color: var(--primary-color);
    border-radius: 0 0 3px 3px;
}

/* 手機版覆蓋樣式 */
@media (max-width: 767px) {
    .mobile-nav-item.active small {
        font-weight: 600 !important;
    }
}

/* 移除重複的樣式，使用手機版媒體查詢中的規則 */

/* 手機版更多選單按鈕優化 */
.mobile-menu-btn {
    min-height: 70px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    transition: all 0.2s ease;
    text-decoration: none;
    padding: 12px 8px;
}

.mobile-menu-btn:hover,
.mobile-menu-btn:focus {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.mobile-menu-btn i {
    margin-bottom: 6px;
}

.mobile-menu-btn small {
    font-size: 0.75rem;
    font-weight: 500;
}

/* 觸控友善的按鈕樣式 */
@media (max-width: 768px) {
    /* 增大按鈕尺寸 */
    .btn {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 20px;
        font-size: 0.95rem;
    }
    
    .btn-sm {
        min-height: 38px;
        min-width: 38px;
        padding: 8px 16px;
        font-size: 0.875rem;
    }
    
    .btn-lg {
        min-height: 50px;
        min-width: 50px;
        padding: 16px 24px;
        font-size: 1.1rem;
    }
    
    /* 表單控件優化 */
    .form-control,
    .form-select {
        min-height: 44px;
        padding: 12px 16px;
        font-size: 1rem;
        border-radius: 8px;
        border-width: 2px;
    }
    
    .form-control:focus,
    .form-select:focus {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    }
    
    /* 複選框和單選框優化 */
    .form-check-input {
        width: 1.2em;
        height: 1.2em;
        margin-top: 0.1em;
    }
    
    .form-check-label {
        padding-left: 0.5em;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    /* 卡片間距優化 */
    .card {
        margin-bottom: 20px;
        border-radius: 12px;
    }
    
    .card-body {
        padding: 20px;
    }
    
    /* 表格觸控優化 */
    .table td,
    .table th {
        padding: 12px 16px;
        vertical-align: middle;
    }
    
    /* 導航按鈕優化 */
    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
        padding: 12px 16px;
    }
    
    /* 模態框觸控優化 */
    .modal-header .btn-close {
        min-width: 44px;
        min-height: 44px;
        padding: 12px;
    }
    
    /* 分頁按鈕優化 */
    .page-link {
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 12px 16px;
    }
    
    /* 下拉選單觸控優化 */
    .dropdown-item {
        min-height: 44px;
        display: flex;
        align-items: center;
        padding: 12px 20px;
    }
    
    /* 警告框觸控優化 */
    .alert .btn {
        margin-top: 8px;
        margin-right: 8px;
    }
    
    /* 工具列按鈕優化 */
    .toolbar .btn {
        margin: 4px;
    }
}

/* 超小螢幕優化 (< 576px) */
@media (max-width: 575.98px) {
    /* 容器內距調整 */
    .container-fluid {
        padding-left: 12px;
        padding-right: 12px;
    }
    
    /* 卡片間距進一步優化 */
    .card {
        margin-bottom: 16px;
        border-radius: 10px;
    }
    
    .card-body {
        padding: 16px;
    }
    
    /* 字體大小優化 */
    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; }
    
    /* 統計卡片優化 */
    .stats-card {
        padding: 16px;
        margin-bottom: 16px;
    }
    
    .stats-card .stats-number {
        font-size: 1.75rem;
    }
    
    /* 表格進一步優化 */
    .table-responsive {
        font-size: 0.8rem;
    }
    
    .table td,
    .table th {
        padding: 8px 12px;
    }
    
    /* 底部導航高度已在上方定義，這裡不需要重複 */
}

/* 觸控回饋動畫 */
.touch-feedback {
    position: relative;
    overflow: hidden;
}

.touch-feedback::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
}

.touch-feedback:active::after {
    width: 200px;
    height: 200px;
}

/* 手勢操作提示 */
.gesture-hint {
    position: relative;
}

.gesture-hint::before {
    content: attr(data-gesture);
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.gesture-hint:hover::before {
    opacity: 1;
}

/* 無障礙優化 */
@media (prefers-reduced-motion: reduce) {
    .mobile-nav-item,
    .mobile-menu-btn,
    .btn {
        transition: none;
    }
    
    .touch-feedback::after {
        transition: none;
    }
}

/* 高對比度模式支援 */
@media (prefers-contrast: high) {
    .mobile-bottom-nav {
        border-top-width: 2px;
    }
    
    .mobile-nav-item {
        border: 1px solid transparent;
    }
    
    .mobile-nav-item.active {
        border-color: var(--primary-color);
    }
}

/* PWA 全屏模式優化 */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: calc(80px + env(safe-area-inset-bottom));
    }
    
    .mobile-bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(70px + env(safe-area-inset-bottom));
    }
}

/* iOS Safari 地址欄優化 */
@supports (-webkit-touch-callout: none) {
    .mobile-bottom-nav {
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
    
    body {
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 0));
    }
}

/* 手機版頂部導航優化 */
@media (max-width: 767px) {
    /* 手機版頂部導航欄 */
    .navbar.d-md-none {
        padding: 0.75rem 1rem;
        min-height: 56px;
        position: sticky;
        top: 0;
        z-index: 1030;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    /* 頁面標題樣式 */
    .navbar-brand {
        font-size: 1.1rem;
        font-weight: 600;
        margin-right: auto;
    }
    
    /* 功能按鈕組 */
    .navbar-nav.d-flex.flex-row {
        gap: 0.5rem;
    }
    
    .navbar-nav .btn {
        min-width: 36px;
        min-height: 36px;
        padding: 0.375rem;
        border-radius: 6px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.9rem;
    }
    
    /* 手機版搜尋框 */
    #mobileSearchBar {
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        z-index: 1029;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        background: white;
    }
    
    #mobileSearchBar .input-group {
        max-width: 100%;
    }
    
    #mobileSearchBar .form-control {
        border-radius: 6px 0 0 6px;
    }
    
    #mobileSearchBar .btn {
        border-radius: 0;
        min-width: 44px;
    }
    
    #mobileSearchBar .btn:last-child {
        border-radius: 0 6px 6px 0;
    }
    
    /* 側邊選單 (Offcanvas) 優化 */
    .offcanvas-header {
        padding: 1rem;
        border-bottom: 1px solid rgba(255,255,255,0.2);
    }
    
    .offcanvas-body {
        padding: 1rem;
    }
    
    .offcanvas-body ul li a {
        padding: 0.75rem 0;
        border-radius: 6px;
        transition: all 0.2s ease;
    }
    
    .offcanvas-body ul li a:hover {
        background-color: rgba(0,123,255,0.1);
        padding-left: 0.5rem;
    }
    
    .offcanvas-body ul li a.text-primary {
        background-color: rgba(0,123,255,0.1);
        border-radius: 6px;
    }
    
    /* 主內容區域頂部間距調整 */
    .main-content {
        padding-top: 0 !important;
    }
    
    /* 頁面標題區域調整 */
    .border-bottom {
        margin-top: 0.5rem;
    }
}

/* 手機版觸控優化 */
@media (max-width: 767px) and (pointer: coarse) {
    /* 增大觸控目標 */
    .navbar .btn {
        min-width: 44px !important;
        min-height: 44px !important;
    }
    
    .offcanvas-body ul li a {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .offcanvas-header .btn-close {
        min-width: 44px;
        min-height: 44px;
    }
}

/* 底部導航"新增"按鈕特殊樣式 */
@media (max-width: 767px) {
    .mobile-nav-item .bi-plus-circle.text-primary {
        font-size: 1.5rem;
        color: var(--bs-primary) !important;
        animation: pulse 2s infinite;
    }
    
    @keyframes pulse {
        0% { transform: scale(1); }
        50% { transform: scale(1.1); }
        100% { transform: scale(1); }
    }
    
    /* 新增功能選單按鈕優化 */
    .mobile-menu-btn {
        min-height: 80px;
        padding: 12px 8px;
        border-radius: 12px;
        transition: all 0.2s ease;
    }
    
    .mobile-menu-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    }
    
    .mobile-menu-btn i {
        margin-bottom: 8px;
        font-size: 1.5rem !important;
    }
    
    .mobile-menu-btn small {
        font-weight: 500;
        font-size: 0.85rem;
    }
    
    /* Modal 圓角優化 */
    .modal-content {
        border-radius: 16px;
        border: none;
        box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    }
    
    .modal-header {
        border-radius: 16px 16px 0 0;
    }
    
    /* 底部導航搜尋按鈕樣式 */
    .mobile-nav-item.border-0 {
        transition: all 0.2s ease;
    }
    
    .mobile-nav-item.border-0:hover {
        background-color: rgba(0,123,255,0.1) !important;
        transform: translateY(-2px);
    }
    
    .mobile-nav-item.border-0:active {
        transform: translateY(0);
    }
    
    /* 確保搜尋框在頁面內容之上 */
    #mobileSearchBar.show {
        animation: slideDown 0.3s ease-out;
    }
    
    @keyframes slideDown {
        from {
            transform: translateY(-100%);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
}