/* static/css/style.css - FINAL & COMPLETE VERSION */

/* Color Palette Variables (for easier management) */
:root {
    --primary-blue: #007bff; /* 主要藍色 */
    --secondary-gray: #6c757d; /* 次要灰色 */
    --accent-orange: #fd7e14; /* 強調橘色 (用於主要按鈕) */
    --light-gray-bg: #f8f9fa; /* 淺灰色背景 */
    --dark-text: #212529; /* 深色文字 (用於淺色背景) */
    --light-text: #ffffff; /* 淺色文字 (用於深色背景) */
    --success-green: #28a745; /* 成功提示的綠色 */
    --danger-red: #dc3545; /* 錯誤提示的紅色 */
    --info-teal: #17a2b8; /* 信息提示的青色 */
    --warning-yellow: #ffc107; /* 警告提示的黃色 */
}

/* Custom Liquid Glass Button Style */
.btn {
    border: none;
    box-shadow: none;
    text-shadow: none;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease-in-out;
    padding: 0.75rem 1.25rem;
    border-radius: 0.5rem;
    font-weight: bold;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 80px;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.4) 0%,
        rgba(255, 255, 255, 0.15) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    z-index: 1;
    pointer-events: none;
    border-radius: 0.5rem;
}

.btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1),
                inset 0 -1px 0 rgba(0, 0, 0, 0.05);
    border-radius: 0.5rem;
    z-index: 2;
    pointer-events: none;
}

/* Specific button colors */
.btn-primary { background-color: var(--accent-orange); color: var(--light-text); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); }
.btn-primary:hover { background-color: #e66a00; box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3); }
.btn-success { background-color: var(--success-green); color: var(--light-text); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); }
.btn-success:hover { background-color: #218838; box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3); }
.btn-danger { background-color: var(--danger-red); color: var(--light-text); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); }
.btn-danger:hover { background-color: #c82333; box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3); }
.btn-info { background-color: var(--info-teal); color: var(--light-text); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); }
.btn-info:hover { background-color: #138496; box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3); }
.btn-warning { background-color: var(--warning-yellow); color: var(--dark-text); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); }
.btn-warning:hover { background-color: #e0a800; box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3); }
.btn-secondary { background-color: var(--secondary-gray); color: var(--light-text); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); }
.btn-secondary:hover { background-color: #5a6268; box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3); }

/* ★★★【新增點：專為圖示按鈕設計的樣式】★★★ */
.btn.btn-icon-only {
    min-width: auto; /* 移除最小寬度限制 */
    padding: 0.375rem 0.75rem; /* 微調內距，讓它看起來更緊湊 */
    line-height: 1; /* 確保圖示垂直置中 */
}

/* Base body and general text colors */
body {
    background-color: #ffffff; /* 我們改用純白當底色，讓網格更清晰 */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cg fill='%23e9ecef' fill-opacity='0.4'%3E%3Crect x='0' y='0' width='1' height='20'/%3E%3Crect x='0' y='0' width='20' height='1'/%3E%3C/g%3E%3C/svg%3E");
    padding-top: 70px; 
}

/* Navbar color to primary blue */
.navbar { background-color: var(--primary-blue) !important; }
.navbar .nav-link { color: var(--light-text) !important; }
.navbar .nav-link:hover { background-color: #0056b3 !important; }
.navbar-brand { color: var(--light-text) !important; }

/* Headings colors */
h1, h3, h4, h5, h6 { color: var(--dark-text); }
h2 { color: var(--dark-text); font-weight: bold; }

/* Card headers background to secondary gray for unified look */
.card-header {
    background-color: var(--secondary-gray);
    color: var(--light-text);
    border-bottom: none;
    padding: 1rem 1.25rem;
}

/* --- ★★★【隱私模式樣式 - 修正版】★★★ --- */
/* 預設情況下，隱藏用來偽裝的星號 */
.sensitive-data .privacy-asterisks {
    display: none;
}
/* 當隱私模式啟用時 */
.privacy-mode-on .sensitive-data .privacy-original-value {
    display: none; /* 隱藏原始數字 */
}
.privacy-mode-on .sensitive-data .privacy-asterisks {
    display: inline !important; /* 顯示偽裝用的星號 */
    font-weight: bold;
}
/* --- ★★★【修正結束】★★★ --- */

/* --- ★★★ 新增：投資項目卡片化樣式 ★★★ --- */
.investment-item-card {
    border: 1px solid var(--bs-border-color-translucent, rgba(0, 0, 0, 0.175));
    border-radius: var(--bs-border-radius-lg, 0.5rem);
    padding: 1rem;
    background-color: var(--bs-body-bg, #fff);
    box-shadow: var(--bs-box-shadow-sm, 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075));
}

/* 讓卡片之間有固定的間距，但最後一張卡片下方沒有多餘的間距 */
.investment-item-card:not(:last-child) {
    margin-bottom: 1rem;
}

/* 專為圖表設計的緊湊型藥丸按鈕 */
.nav-pills-custom-wrapper.compact .nav-link {
    padding: 0.25rem 0.8rem; /* 減少上下內距，讓按鈕變矮 */
    font-size: 0.875rem;     /* 稍微縮小字體 */
    font-weight: 400;
}

/* 緊湊型按鈕的 active 狀態，陰影也縮小一些 */
.nav-pills-custom-wrapper.compact .nav-link.active {
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.25);
}

/* (檔案中其餘所有樣式維持不變) */
.form-label { font-weight: bold; }
.form-control, .form-select { border-color: #ced4da; border-radius: 0.3rem; }
.card { border-radius: 0.75rem; overflow: hidden; border: 1px solid rgba(0,0,0,.125); }
.table { margin-bottom: 0; }
.my-4 { margin-top: 1.5rem !important; margin-bottom: 1.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.text-center { text-align: center !important; }
.float-end { float: right !important; }
.fs-5 { font-size: 1.25rem !important; }
.fs-4 { font-size: 1.5rem !important; }
.fw-bold { font-weight: bold !important; }
.progress { height: 1.25rem; border-radius: 0.25rem; background-color: rgba(var(--secondary-gray), 0.25); }
.progress-bar { border-radius: 0.25rem; }
.event-income, .event-income:hover { background-color: #198754; border-color: #198754; color: white; }
.event-expense, .event-expense:hover { background-color: #dc3545; border-color: #dc3545; color: white; }
.custom-autocomplete-container { position: relative; display: inline-block; width: 100%; z-index: 2; }
.autocomplete-items { position: absolute; border: 1px solid #d4d4d4; border-bottom: none; border-top: none; z-index: 999; top: 100%; left: 0; right: 0; background-color: #fff; }
.autocomplete-items div { padding: 10px; cursor: pointer; background-color: #fff; border-bottom: 1px solid #d4d4d4; }
.autocomplete-items div:hover { background-color: #e9e9e9; }
.autocomplete-active { background-color: DodgerBlue !important; color: #ffffff; }
.autocomplete-scrollable { max-height: 200px; overflow-y: auto; }
.nav-pills-custom-wrapper { background-color: rgba(0, 0, 0, 0.05); border-radius: 50rem; padding: 0.25rem; display: inline-flex; box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.05); }
.nav-pills-custom-wrapper .nav-item { flex: 1; }
.nav-pills-custom-wrapper .nav-link { color: #6c757d; text-align: center; padding: 0.5rem 1rem; border-radius: 50rem; font-weight: 500; transition: all 0.3s cubic-bezier(.55, .085, .68, .53); border: none; background-color: transparent; white-space: nowrap; }
.nav-pills-custom-wrapper .nav-link:not(.active):hover { color: #343a40; background-color: rgba(0, 0, 0, 0.025); }
.nav-pills-custom-wrapper .nav-link.active { background-color: var(--primary-blue); color: var(--light-text); box-shadow: 0 3px 6px rgba(0, 123, 255, 0.3); }
.accordion-button { background-color: var(--secondary-gray); color: var(--light-text); }
.accordion-button:not(.collapsed) { background-color: var(--secondary-gray); color: var(--light-text); box-shadow: none; }
.accordion-button::after { filter: brightness(0) invert(1); }
.accordion-button:hover { z-index: 2; }
.accordion-button:focus { box-shadow: 0 0 0 0.25rem rgba(0, 123, 255, 0.25); z-index: 3; }
.card-header .card-title, .accordion-button { font-size: 1.2rem; font-weight: 500; }
.accordion-button:focus { box-shadow: none; border-color: rgba(0,0,0,.125); }

/* 專為放在卡片標頭內的篩選器設計的樣式 */
.nav-pills-custom-wrapper.nav-pills-card-header {
    /* 讓膠囊背景色更融入深色標頭 */
    background-color: rgba(0, 0, 0, 0.15);
    box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.1);
}

.nav-pills-custom-wrapper.nav-pills-card-header .nav-link {
    /* 預設文字顏色改為白色，並帶有透明度 */
    color: var(--light-text);
    opacity: 0.7;
}
.nav-pills-custom-wrapper.nav-pills-card-header .nav-link:not(.active):hover {
    /* 滑鼠懸停時變為不透明，並加上淡淡的亮色背景 */
    opacity: 1.0;
    background-color: rgba(255, 255, 255, 0.1);
}
.nav-pills-custom-wrapper.nav-pills-card-header .nav-link.active {
    /* 選中狀態維持藍底白字，並確保不透明 */
    background-color: var(--primary-blue);
    color: var(--light-text);
    opacity: 1.0;
}
/* ★★★ 修改區域結束 ★★★ */

/* =========================================================================
   ★★★ 手機響應式優化 (Mobile Responsive) ★★★
   ========================================================================= */

/* --- 平板與手機共用 (< 992px) --- */
@media (max-width: 991.98px) {
    body {
        padding-top: 60px; /* 減少頂部間距 */
    }
    
    .navbar-brand {
        font-size: 0.95rem;
    }
    
    /* 讓 container 邊距更小 */
    .container {
        padding-left: 10px;
        padding-right: 10px;
    }
}

/* --- 手機專用 (< 768px) --- */
@media (max-width: 767.98px) {
    body {
        padding-top: 56px;
    }
    
    /* 標題縮小 */
    h2 {
        font-size: 1.4rem;
    }
    
    h3, .card-title {
        font-size: 1.1rem;
    }
    
    /* 卡片標頭縮小間距 */
    .card-header {
        padding: 0.75rem 1rem;
    }
    
    /* 卡片內容縮小間距 */
    .card-body {
        padding: 0.75rem;
    }
    
    /* 按鈕在手機上更緊湊 */
    .btn {
        padding: 0.5rem 0.875rem;
        font-size: 0.875rem;
    }
    
    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    /* 時間篩選器：允許水平滾動 */
    .nav-pills-custom-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        justify-content: flex-start;
        width: 100%;
        padding: 0.25rem 0.5rem;
    }
    
    .nav-pills-custom-wrapper .nav-link {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
        white-space: nowrap;
    }
    
    /* 表格響應式優化 */
    .table-responsive {
        font-size: 0.85rem;
    }
    
    .table th, .table td {
        padding: 0.5rem 0.4rem;
        white-space: nowrap;
    }
    
    /* 隱藏手機上不重要的表格欄位 */
    .table .d-mobile-none {
        display: none !important;
    }
    
    /* 表單輸入框調整 */
    .form-control, .form-select {
        font-size: 16px; /* 防止 iOS 自動縮放 */
        padding: 0.5rem 0.75rem;
    }
    
    /* 表單 row 在手機上垂直排列 */
    .row.align-items-end > [class*="col-md"] {
        margin-bottom: 0.75rem;
    }
    
    /* 財務總覽頁面數字縮小 */
    .fs-4 {
        font-size: 1.2rem !important;
    }
    
    .fs-5 {
        font-size: 1rem !important;
    }
    
    /* 收支匯總區塊垂直排列 */
    .d-flex.justify-content-around.text-center {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .d-flex.justify-content-around.text-center > div {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        border-bottom: 1px solid rgba(0,0,0,0.1);
    }
    
    .d-flex.justify-content-around.text-center > div:last-child {
        border-bottom: none;
    }
    
    .d-flex.justify-content-around.text-center > div > span.d-block {
        display: inline !important;
    }
    
    /* 投資卡片優化 */
    .investment-item-card {
        padding: 0.75rem;
    }
    
    /* Modal 對話框全螢幕 */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    /* 圖表容器高度調整 */
    canvas {
        max-height: 250px !important;
    }
    
    /* Accordion 標題縮小 */
    .accordion-button {
        font-size: 1rem;
        padding: 0.75rem 1rem;
    }
    
    /* AI 顧問聊天視窗調整 */
    #chat-window {
        height: 50vh;
    }
    
    .message {
        max-width: 90%;
    }
    
    .avatar {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }
    
    .example-question-btn {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }
}

/* --- 超小螢幕手機 (< 576px) --- */
@media (max-width: 575.98px) {
    h2 {
        font-size: 1.2rem;
    }
    
    /* 讓按鈕組在極小螢幕上堆疊 */
    .btn-group-vertical-xs {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group-vertical-xs .btn {
        width: 100%;
        margin-bottom: 0.25rem;
    }
    
    /* 隱藏更多不重要的元素 */
    .d-xs-none {
        display: none !important;
    }
    
    /* 財務匯總數字進一步縮小 */
    .fs-4 {
        font-size: 1.1rem !important;
    }
    
    /* Lottie 動畫縮小 */
    lottie-player {
        width: 30px !important;
        height: 30px !important;
    }
}

/* --- 觸控裝置優化 --- */
@media (hover: none) and (pointer: coarse) {
    /* 增加可點擊區域 */
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .nav-link {
        padding: 0.75rem 1rem;
    }
    
    /* 移除 hover 效果以避免觸控裝置的黏著狀態 */
    .btn:hover {
        transform: none;
    }
    
    /* 表格行增加觸控間距 */
    .table td, .table th {
        padding: 0.75rem 0.5rem;
    }
    
    /* 下拉選單項目增加間距 */
    .dropdown-item {
        padding: 0.75rem 1rem;
    }
}

/* --- FullCalendar 日曆響應式優化 --- */
@media (max-width: 767.98px) {
    /* 縮小日曆標題 */
    .fc .fc-toolbar-title {
        font-size: 1rem;
    }
    
    /* 工具列垂直排列 */
    .fc .fc-toolbar {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .fc .fc-toolbar-chunk {
        display: flex;
        justify-content: center;
    }
    
    /* 縮小日曆按鈕 */
    .fc .fc-button {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    /* 日曆事件文字縮小 */
    .fc-event-title {
        font-size: 0.65rem;
    }
    
    /* 日期數字縮小 */
    .fc .fc-daygrid-day-number {
        font-size: 0.75rem;
        padding: 2px 4px;
    }
}

@media (max-width: 575.98px) {
    /* 極小螢幕隱藏週視圖按鈕 */
    .fc .fc-timeGridWeek-button {
        display: none;
    }
    
    /* 日曆高度限制 */
    .fc {
        font-size: 0.7rem;
    }
}