/**
 * 主要樣式表 (style.css)
 * 
 * 這個樣式表提供了網站的主要樣式，包括：
 * 1. 響應式布局
 * 2. 深色模式支援
 * 3. 表格樣式
 * 4. 側邊欄樣式
 * 5. 儀表板卡片樣式
 * 
 * 使用方式：
 * 
 * 1. 響應式布局
 *    - 使用 Bootstrap 的網格系統
 *    - 側邊欄在手機版會自動收合
 *    - 主內容區域會自動調整寬度
 * 
 * 2. 深色模式
 *    - 自動支援系統深色模式
 *    - 可手動切換深色模式（添加 dark-mode 類別）
 *    - 所有元件都會自動適應深色模式
 * 
 * 3. 表格樣式
 *    - 使用 .table 類別
 *    - 支援懸停效果
 *    - 自動適應深色模式
 *    範例：
 *    <table class="table">
 *      <tr><td>內容</td></tr>
 *    </table>
 * 
 * 4. 側邊欄
 *    - 使用 .sidebar 類別
 *    - 支援折疊功能
 *    - 響應式設計
 *    範例：
 *    <div class="sidebar">
 *      <div class="sidebar-heading">標題</div>
 *    </div>
 * 
 * 5. 儀表板卡片
 *    - 使用 .dashboard-card 類別
 *    - 支援懸停效果
 *    - 自適應高度
 *    範例：
 *    <div class="dashboard-card">
 *      <div class="card-header">標題</div>
 *      <div class="card-body">內容</div>
 *    </div>
 * 
 * 注意事項：
 * - 確保已引入 Bootstrap 的 CSS 檔案
 * - 深色模式需要配合 JavaScript 切換 dark-mode 類別
 * - 所有顏色使用 rgba 格式以支援透明度
 * - 使用 !important 確保樣式優先級
 * 
 * 版本：1.0.0
 * 最後更新：2025-03-28
 */

/* 主要樣式表 */
body {
    min-height: 100vh;
    overflow-x: hidden;
}

.sidebar {
    width: 200px;
    min-height: 100vh;
    transition: margin 0.25s ease-out;
}

.sidebar-heading {
    padding: 0.875rem 1.25rem;
    font-size: 1.2rem;
}

#page-content-wrapper {
    min-width: 0;
    width: calc(100% - 200px);
    margin-left: 200px;
    margin-top: 60px; /* 導航欄高度 */
    transition: all 0.25s ease-out;
}

/* 側邊欄折疊時的主內容區域樣式 */
body.sidebar-toggled #page-content-wrapper {
    margin-left: 0;
    width: 100%;
}

.navbar-fixed-top {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 1040;
}

.sidebar.collapsed {
    margin-left: -200px;
}

.menu-card {
    transition: all 0.3s;
}

.menu-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

/* 定義深色模式變數 */
:root {
    --hover-bg-color: rgba(0, 123, 255, 0.1);
}

/* 深色模式樣式 */
.dark-mode {
    background-color: #212529;
    color: #ffffff !important;
}

.dark-mode .bg-white,
.dark-mode .bg-light {
    background-color: #343a40 !important;
    color: #ffffff !important;
}

.dark-mode .border-end {
    border-color: #495057 !important;
}

.dark-mode .border {
    border-color: #495057 !important;
}

.dark-mode .card {
    background-color: #343a40;
    color: #ffffff !important;
    border-color: #495057;
}

.dark-mode .list-group-item {
    background-color: #343a40;
    color: #ffffff !important;
    border-color: #495057;
}

.dark-mode .list-group-item:hover {
    background-color: #495057;
}

.dark-mode .navbar {
    background-color: #343a40 !important;
    color: #ffffff !important;
    border-color: #495057;
}

.dark-mode .navbar-light .navbar-nav .nav-link {
    color: #ffffff !important;
}

/* 確保深色模式下所有文字都是白色 */
.dark-mode h1, .dark-mode h2, .dark-mode h3, .dark-mode h4, .dark-mode h5, .dark-mode h6,
.dark-mode p, .dark-mode span, .dark-mode a, .dark-mode label, .dark-mode small,
.dark-mode .text-dark, .dark-mode .text-body, .dark-mode .text-black,
.dark-mode .form-control, .dark-mode .form-select, .dark-mode .form-check-label,
.dark-mode .dropdown-item, .dark-mode .nav-link, .dark-mode .btn-close,
.dark-mode .modal-title, .dark-mode .card-title, .dark-mode .card-text,
.dark-mode .card-header, .dark-mode .card-footer,
.dark-mode .tab-content, .dark-mode .nav-tabs .nav-link {
    color: #ffffff !important;
}

.dark-mode .text-primary.dark-mode-text {
    color: #ffffff !important;
}
.dark-mode .text-muted.dark-mode-text {
    color: #ffffff !important;
}
.dark-mode .text-muted {
    color: #ffffff !important;
}

/* 確保深色模式下的表格文字為白色 */
.dark-mode table, .dark-mode th, .dark-mode td,
.dark-mode .table, .dark-mode .table th, .dark-mode .table td,
.dark-mode .table tbody tr td {
    color: #ffffff !important;
}

/* 移除斑馬條紋，統一背景色 */
.dark-mode .table > tbody > tr:nth-child(odd) {
    background-color: rgba(0, 0, 0, 0.02) !important;
}

.dark-mode .table > tbody > tr:nth-child(even) {
    background-color: rgba(0, 0, 0, 0.05) !important;
}

/* 確保深色模式下的表格頭部有白色文字 */
.dark-mode .table-light,
.dark-mode .table-light > th,
.dark-mode .table-light > td,
.dark-mode .table > thead,
.dark-mode .table > thead > tr > th {
    background-color: #495057 !important;
    color: #ffffff !important;
    border-color: #495057 !important;
}

/* 深色模式下的表格懸停效果 */
.dark-mode .table > tbody > tr:hover {
    background-color: rgba(0, 123, 255, 0.1) !important;
}

/* 深色模式下的表格懸停效果文字顏色 */
.dark-mode .table > tbody > tr:hover > * {
    color: inherit !important;
}

/* 確保深色模式下的輸入框文字為白色，背景為深色 */
.dark-mode input, .dark-mode textarea, .dark-mode select,
.dark-mode .form-control, .dark-mode .form-select {
    background-color: #343a40 !important;
    color: #ffffff !important;
    border-color: #495057 !important;
}

/* 確保深色模式下的按鈕文字為白色 */
.dark-mode .btn:not(.btn-primary):not(.btn-success):not(.btn-danger):not(.btn-warning):not(.btn-info) {
    color: #ffffff !important;
}

/* 確保深色模式下的下拉選單項目文字為白色 */
.dark-mode .dropdown-menu {
    background-color: #343a40 !important;
}

.dark-mode .dropdown-item {
    color: #ffffff !important;
}

.dark-mode .dropdown-item:hover, .dark-mode .dropdown-item:focus {
    background-color: #495057 !important;
}

/* 確保深色模式下的選項卡文字為白色 */
.dark-mode .nav-tabs .nav-link {
    color: #ffffff !important;
}

.dark-mode .nav-tabs .nav-link.active {
    background-color: #343a40 !important;
    color: #ffffff !important;
    border-color: #495057 !important;
}

/* 確保深色模式下的表單元素文字為白色 */
.dark-mode option {
    background-color: #343a40 !important;
    color: #ffffff !important;
}

/* 確保深色模式下的提示文字為白色 */
.dark-mode ::placeholder {
    color: rgba(255, 255, 255, 0.6) !important;
}

/* 確保深色模式下的標籤文字為白色 */
.dark-mode .badge:not(.bg-primary):not(.bg-success):not(.bg-danger):not(.bg-warning):not(.bg-info) {
    background-color: #495057 !important;
    color: #ffffff !important;
}

/* 確保深色模式下的模態框文字為白色 */
.dark-mode .modal-content {
    background-color: #343a40 !important;
    color: #ffffff !important;
    border-color: #495057 !important;
}

/* 確保深色模式下的分頁文字為白色 */
.dark-mode .pagination .page-link {
    background-color: #343a40 !important;
    color: #ffffff !important;
    border-color: #495057 !important;
}

/* 深色模式下的分頁選中狀態樣式 */
.dark-mode .pagination .page-item.active .page-link {
    background-color: #495057 !important;
    color: #ffffff !important;
}

/* 深色模式下的手機版側邊欄樣式 */
@media (max-width: 768px) {
    .sidebar {
        margin-left: -200px;
    }
    
    .sidebar.show {
        margin-left: 0;
        position: fixed;
        
        left: 0;
        height: calc(100vh - 50px);
        z-index: 1030;
        width: 200px;
        overflow-y: auto; /* 添加垂直滾動 */
    }
    
    #page-content-wrapper {
        width: 100%;
        margin-left: 0;
        
    }
    
   
}

/* 手機版側邊欄滾動向上動畫 */
@keyframes scrollUp {
    0% { top: 100%; }
    100% { top: -100%; }
}

/* 確保主內容區域在側邊欄折疊時調整 */
@media (min-width: 769px) {
    body.sidebar-toggled #sidebar-wrapper {
        margin-left: -200px;
    }
    
    body.sidebar-toggled #page-content-wrapper {
        margin-left: 0;
        width: 100%;
    }
}

/* 四方區塊樣式 */
.dashboard-card {
    height: 100%;
    border-radius: 10px;
    transition: all 0.3s ease;
    overflow: hidden;
}

/* 卡片懸停效果 */
.dashboard-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

/* 卡片標題樣式 */
.dashboard-card .card-header {
    font-weight: 500;
    padding: 15px;
}

/* 卡片內容區域樣式 */
.dashboard-card .card-body {
    padding: 20px;
}

/* 卡片底部區域樣式 */
.dashboard-card .card-footer {
    background-color: transparent;
    border-top: 1px solid rgba(0,0,0,0.125);
    padding: 15px;
}

/* 卡片列表項目樣式 */
.dashboard-card .list-group-item {
    border-left: none;
    border-right: none;
    padding: 12px 20px;
}

/* 卡片列表第一個項目樣式 */
.dashboard-card .list-group-item:first-child {
    border-top: none;
}

/* 卡片列表最後一個項目樣式 */
.dashboard-card .list-group-item:last-child {
    border-bottom: none;
}

/* 公布事項滾動區域 */
.announcement-scroll {
    height: 300px;
    overflow-y: auto;
}

/* 工作統計區塊的圖標樣式 */    
.dashboard-icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

/* 工作統計區塊的圖標樣式 */    
.dashboard-icon i {
    font-size: 2.5rem;
}

/* 手機版側邊欄樣式 */
@media (max-width: 767.98px) {
    .mobile-sidebar {
        transform: translateX(-100%);
        width: 80% !important;
        max-width: 300px;
        box-shadow: none;
        z-index: 1050 !important;
    }
    
    /* 手機版側邊欄展開時的樣式 */
    .mobile-sidebar.show {
        transform: translateX(0);
        box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
    }
    
    /* 移除手機版第一個選單上方的空白和間隔 */
    .mobile-sidebar .sidebar-content {
        padding: 0 !important;
        margin: 0 !important;
    }
    
    /* 移除手機版第一個選單上方的空白和間隔 */
    .mobile-sidebar .sidebar-menu:first-child {
        margin-top: 0 !important;
    }
    
    /* 移除手機版第一個選單上方的空白和間隔 */
    .mobile-sidebar .list-group-item:first-child,
    .mobile-sidebar .first-menu-item {
        border-top: none !important;
        border-top-left-radius: 0 !important;
        border-top-right-radius: 0 !important;
        margin-top: 0 !important;
        padding-top: 10px !important;
    }

    /* 防止側邊欄在手機版上自動收合 */
    .mobile-sidebar .submenu-item,
    .mobile-sidebar a[data-bs-toggle="collapse"],
    .mobile-sidebar .bi-chevron-down {
        -webkit-tap-highlight-color: transparent;
        position: relative;
        z-index: 10;
    }
    
    /* 側邊欄遮罩 */
    .sidebar-backdrop {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1040;
    }
    
    /* 側邊欄遮罩顯示時的樣式 */
    .sidebar-backdrop.show {
        display: block;
    }
}

/* 表格樣式 */
/* 一般模式下的表格樣式 */
.table > tbody > tr:nth-child(odd) {
    background-color: rgba(0, 0, 0, 0.02) !important;
}

/* 一般模式下的表格偶數行背景顏色 */
.table > tbody > tr:nth-child(even) {
    background-color: rgba(0, 0, 0, 0.05) !important;
}

/* 連結和可點擊元素的手型指標 */
.table a, 
.btn,
.page-link,
select,
input[type="text"] {
    cursor: pointer;
}

/* 一般輸入框的指標 */
input[type="text"] {
    cursor: text;
}

/* 自動深色模式下的表格樣式 */
@media (prefers-color-scheme: dark) {
    
    /* 自動深色模式下的表格奇數行背景顏色 */
    .table > tbody > tr:nth-child(odd) {
        background-color: rgba(0, 0, 0, 0.02) !important;
    }
    
    /* 自動深色模式下的表格偶數行背景顏色 */
    .table > tbody > tr:nth-child(even) {
        background-color: rgba(0, 0, 0, 0.05) !important;
    }

    /* 自動深色模式下的表格懸停效果 */
    .table > tbody > tr:hover {
        background-color: rgba(0, 123, 255, 0.1) !important;
    }

    /* 自動深色模式下的表格懸停效果文字顏色 */
    .table > tbody > tr:hover > * {
        color: inherit !important;
    }
}

/* 表單驗證樣式 */
.needs-validation {
    display: flex;
    flex-direction: column;
}

/* 表單驗證錯誤樣式 */
.invalid-feedback {
    color: #dc3545;
}

/* 表單驗證成功樣式 */
.valid-feedback {
    color: #28a745;
}

/* 表單驗證必填標籤樣式 */
.required {
    color: #dc3545;
}

/* 合約狀態標籤 */
.contract-status {
    font-size: 0.85rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-weight: 500;
}

/* 一般模式下的狀態標籤 */
.expiring {
    background-color: #fff3cd;
    color: #856404;
}

.expired {
    background-color: #f8d7da;
    color: #721c24;
}

.active {
    background-color: #d4edda;
    color: #155724;
}

/* 深色模式下的狀態標籤 */
@media (prefers-color-scheme: dark) {
    .contract-status {
        background-color: rgba(0, 0, 0, 0.8) !important;
    }
    
    .expiring {
        background-color: rgba(0, 0, 0, 0.8) !important;
        color: #ffd43b !important;
    }
    
    .expired {
        background-color: rgba(0, 0, 0, 0.8) !important;
        color: #ff6b6b !important;
    }
    
    .active {
        background-color: rgba(0, 0, 0, 0.8) !important;
        color: #75b798 !important;
    }
}

/* 深色模式類別下的狀態標籤 */
.dark-mode .contract-status {
    background-color: rgba(0, 0, 0, 0.8) !important;
}

.dark-mode .expiring {
    background-color: rgba(0, 0, 0, 0.8) !important;
    color: #ffd43b !important;
}

.dark-mode .expired {
    background-color: rgba(0, 0, 0, 0.8) !important;
    color: #ff6b6b !important;
}

.dark-mode .active {
    background-color: rgba(0, 0, 0, 0.8) !important;
    color: #75b798 !important;
}

/* 通知相關樣式 */
.notification-area {
    position: relative;
    height: 40px; /* 減少高度，只顯示一則訊息 */
    overflow: hidden;
    background-color: #f8f9fa; /* 添加背景色 */
    width: 100%;
}

.notification-area .list-group {
    position: absolute;
    bottom: 0;
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
    animation: scrollUp 9s steps(1) infinite;
}

/* 通知訊息滾動動畫 */
@keyframes scrollUp {
    0%, 33% { transform: translateY(80px); }
    33%, 66% { transform: translateY(40px); }
    66%, 100% { transform: translateY(0); }
}

.notification-area .list-group-item {
    padding: 8px 15px;
    border: none;
    text-align: center;
    height: 40px;
    line-height: 24px;
}

/* 通知徽章樣式 */
.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 0.6rem;
    padding: 0.25rem 0.5rem;
    border-radius: 50%;
    background-color: #dc3545;
    color: white;
    line-height: 1;
}

.notification-dropdown {
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
}

.notification-item {
    padding: 10px 15px;
}

.notification-item.unread {
    background-color: rgba(13, 110, 253, 0.05);
}

.notification-item a:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* 深色模式下的通知樣式 */
.dark-mode .notification-area {
    background-color: #343a40;
}

.dark-mode .notification-item.unread {
    background-color: #1c3a5e;
}

/* 通知列表.客戶列表頁面樣式 */
/* 深色模式下的表格樣式 */
.dark-mode .table > tbody > tr:nth-child(odd) {
    background-color: rgba(255, 255, 255, 0.05) !important;
}

.dark-mode .table > tbody > tr:nth-child(even) {
    background-color: rgba(0, 0, 0, 0.2) !important;
}

/* 懸停樣式 */
.dark-mode .table > tbody > tr:hover {
    background-color: rgba(111, 66, 193, 0.3) !important;
    color: #fff !important;
}

/* 未讀通知樣式 */
.dark-mode .table > tbody > tr.notification-unread {
    background-color: rgba(111, 66, 193, 0.3) !important;
    color: #fff !important;
    font-weight: 500;
}

/* 一般模式下的表格樣式 */
/* 斑馬條紋樣式 */
.table > tbody > tr:nth-child(odd) {
    background-color: rgba(0, 0, 0, 0.02) !important;
}

.table > tbody > tr:nth-child(even) {
    background-color: rgba(0, 0, 0, 0.05) !important;
}

/* 懸停樣式 */
.table > tbody > tr:hover {
    background-color: rgba(111, 66, 193, 0.1) !important;
}

/* 未讀通知樣式 */
.table > tbody > tr.notification-unread {
    background-color: rgba(111, 66, 193, 0.1) !important;
    font-weight: 500;
}

/* 連結和可點擊元素的手型指標 */
.table a, 
.btn,
.page-link,
select,
input[type="text"] {
    cursor: pointer;
}

/* 一般輸入框的指標 */
input[type="text"] {
    cursor: text;
}

@media (prefers-color-scheme: dark) {
  .modal .alert-warning,
  .alert-warning {
    background-color: #222 !important;
    color: #fff !important;
    border-color: #444 !important;
  }
  .contract-amount, .contract-eye {
    color: #ffe066 !important;
  }
  .contract-status-label.expired {
    background: #dc3545 !important;
    color: #fff !important;
  }
}



/* 客戶詳情頁面的備註樣式 */
.memo-content {
    background-color: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 0.375rem;
    padding: 1rem;
    margin-top: 0.5rem;
    line-height: 1.6;
}

.memo-content p {
    margin-bottom: 0.5rem;
}

.memo-content p:last-child {
    margin-bottom: 0;
}

.memo-content ol,
.memo-content ul {
    margin-bottom: 0.5rem;
    padding-left: 1.5rem;
}

.memo-content li {
    margin-bottom: 0.25rem;
}

/* 深色模式下的備註樣式 */
.dark-mode .memo-content {
    background-color: rgba(255, 193, 7, 0.15);
    border-color: rgba(255, 193, 7, 0.4);
    color: #fff;
}

/* 系統自動深色模式下的備註樣式 */
@media (prefers-color-scheme: dark) {
    .memo-content {
        background-color: rgba(255, 193, 7, 0.15);
        border-color: rgba(255, 193, 7, 0.4);
        color: #fff;
    }
}