/* static/css/main.css - 企業亮色風格 */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@300;400;500;700&display=swap');

:root {
    /* 企業亮色配色方案 */
    --primary-blue: #0066cc;
    --primary-blue-dark: #004d99;
    --primary-blue-light: #3385d6;
    --success-green: #28a745;
    --danger-red: #dc3545;
    --warning-orange: #ffc107;
    --info-cyan: #17a2b8;

    /* 背景色 */
    --bg-main: #f5f7fa;
    --bg-white: #ffffff;
    --bg-light-gray: #f8f9fa;
    --bg-card: #ffffff;
    --bg-panel: #ffffff;
    --bg-tertiary: #f0f2f5;

    /* 文字色 */
    --text-primary: #2c3e50;
    --text-secondary: #6c757d;
    --text-muted: #95a5a6;

    /* 邊框色 */
    --border-color: #dee2e6;
    --border-light: #e9ecef;

    /* 陰影 */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);

    /* 尺寸 */
    --header-height: 60px;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;

    /* 字體 */
    --font-primary: 'Noto Sans TC', sans-serif;

    /* ========== 向後兼容：舊變數映射 ========== */
    /* 這些變數讓舊的 HTML 模板繼續工作 */
    --neon-cyan: #0066cc;
    --neon-blue: #1976d2;
    --neon-purple: #7c3aed;
    --neon-green: #28a745;
    --neon-red: #dc3545;
    --neon-orange: #fd7e14;
    --neon-pink: #e91e63;
    --text-main: #2c3e50;
    --text-dim: #6c757d;
    --border: #dee2e6;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-primary);
    overflow-x: hidden;
    min-height: 100vh;
}

/* === 佈局 === */
.layout-container {
    display: flex;
    min-height: 100vh;
    padding-top: var(--header-height);
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 30px;
    transition: margin-left 0.3s ease;
    width: 100%;
    position: relative;
    background-color: var(--bg-main);
}

body.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* === Header === */
header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-height);
    z-index: 1000;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.navbar {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.logo-glitch {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-blue);
    letter-spacing: 0.5px;
}

.system-status {
    color: var(--text-secondary);
    display: none;
}

@media (min-width: 768px) {
    .system-status {
        display: block;
    }
}

.status-online {
    color: var(--success-green);
    font-weight: 600;
}

/* === Sidebar === */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    background: var(--bg-white);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    transition: width 0.3s ease;
    z-index: 900;
    box-shadow: var(--shadow-sm);
}

body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .sidebar-text,
body.sidebar-collapsed .menu-header {
    display: none;
}

/* 收合後滑入側邊欄，自動暫時展開 */
body.sidebar-collapsed .sidebar:hover {
    width: var(--sidebar-width);
}

body.sidebar-collapsed .sidebar:hover .sidebar-text {
    display: inline;
}

body.sidebar-collapsed .sidebar:hover .menu-header {
    display: flex !important;
    padding: 12px 20px;
    justify-content: space-between;
}

body.sidebar-collapsed .sidebar:hover .menu-header .menu-title,
body.sidebar-collapsed .sidebar:hover .menu-header .menu-arrow {
    display: inline;
}

body.sidebar-collapsed .sidebar:hover .menu-header .menu-icon {
    margin-right: 12px;
    font-size: 1.1rem;
}

body.sidebar-collapsed .sidebar:hover .menu-submenu {
    position: static;
    left: auto;
    top: auto;
    width: auto;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

body.sidebar-collapsed .sidebar:hover ~ .main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width)) !important;
}

.sidebar-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.3s;
    border-left: 3px solid transparent;
    white-space: nowrap;
}

.sidebar-item:hover,
.sidebar-item.active {
    color: var(--primary-blue);
    background: rgba(0, 102, 204, 0.05);
    border-left-color: var(--primary-blue);
    font-weight: 500;
}

.sidebar-item i {
    margin-right: 12px;
    font-size: 1.1rem;
    min-width: 24px;
    text-align: center;
}

/* 選單群組 */
.menu-group {
    position: relative;
    margin-bottom: 2px;
}

body.sidebar-collapsed .menu-group .menu-header {
    display: flex !important;
}

.menu-group .menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    cursor: pointer;
    transition: 0.3s;
    border-left: 3px solid transparent;
    background: transparent;
    user-select: none;
    border-bottom: none;
    margin-bottom: 0;
    white-space: nowrap;
}

.menu-header-content {
    display: flex;
    align-items: center;
}

.menu-header .menu-icon {
    margin-right: 12px;
    font-size: 1.1rem;
    min-width: 24px;
    text-align: center;
    color: var(--text-secondary);
    transition: 0.3s;
}

.menu-header .menu-title {
    font-size: 1rem;
    font-weight: normal;
    color: var(--text-secondary);
    transition: 0.3s;
}

.menu-header .menu-arrow {
    font-size: 0.65rem;
    color: var(--text-secondary);
    transition: transform 0.3s ease, color 0.3s ease;
    opacity: 0.5;
    margin-left: 8px;
}

.menu-group:hover>.menu-header,
.menu-group.expanded>.menu-header {
    color: var(--primary-blue);
    background: rgba(0, 102, 204, 0.05);
    border-left-color: var(--primary-blue);
}

.menu-group:hover>.menu-header .menu-icon,
.menu-group:hover>.menu-header .menu-title,
.menu-group.expanded>.menu-header .menu-icon,
.menu-group.expanded>.menu-header .menu-title {
    color: var(--primary-blue);
}

.menu-group:hover>.menu-header .menu-arrow,
.menu-group.expanded>.menu-header .menu-arrow {
    transform: rotate(180deg);
    color: var(--primary-blue);
    opacity: 1;
}

.menu-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    opacity: 0;
    background: var(--bg-light-gray);
}

.menu-group:hover .menu-submenu,
.menu-group.expanded .menu-submenu {
    max-height: 500px;
    opacity: 1;
}

.sidebar-item.sub-item {
    padding: 11px 20px 11px 48px;
    font-size: 0.95rem;
    position: relative;
    border-left: 3px solid transparent;
}

.sidebar-item.sub-item::before {
    content: '';
    position: absolute;
    left: 26px;
    top: 50%;
    transform: translateY(-50%);
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-muted);
    opacity: 0.4;
    transition: all 0.3s ease;
}

.sidebar-item.sub-item:hover::before,
.sidebar-item.sub-item.active::before {
    background: var(--primary-blue);
    opacity: 1;
}

.sidebar-item.sub-item i {
    font-size: 1rem;
    min-width: 20px;
    margin-right: 10px;
    opacity: 0.8;
}

/* Sidebar Collapsed 狀態 */
body.sidebar-collapsed .menu-group .menu-header {
    display: flex !important;
    padding: 12px;
    justify-content: center;
}

body.sidebar-collapsed .menu-header .menu-title,
body.sidebar-collapsed .menu-header .menu-arrow {
    display: none;
}

body.sidebar-collapsed .menu-header .menu-icon {
    margin: 0;
    font-size: 1.2rem;
}

body.sidebar-collapsed .menu-submenu {
    position: absolute;
    left: var(--sidebar-collapsed-width);
    top: 0;
    width: 220px;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 0 8px 8px 0;
    box-shadow: var(--shadow-md);
    z-index: 1000;
}

.menu-group+.menu-group {
    border-top: 1px solid var(--border-light);
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.sidebar-toggle-wrap {
    position: sticky;
    bottom: 0;
    padding: 10px;
    border-top: 1px solid var(--border-light);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, #ffffff 100%);
    z-index: 2;
}

.sidebar-toggle-btn {
    width: 100%;
    height: 38px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-toggle-btn:hover {
    color: var(--primary-blue);
    background: rgba(0, 102, 204, 0.08);
}

.sidebar-toggle-btn i {
    font-size: 1rem;
}

.sidebar-toggle-label {
    font-size: 0.9rem;
    white-space: nowrap;
}

body.sidebar-collapsed .sidebar-toggle-wrap {
    padding: 8px;
}

body.sidebar-collapsed .sidebar-toggle-btn {
    width: 100%;
    height: 36px;
    gap: 0;
    padding: 0;
}

.sidebar-toggle-btn:focus,
.sidebar-toggle-btn:focus-visible,
.sidebar-toggle-btn:active {
    outline: none;
    box-shadow: none;
}

body.sidebar-collapsed .sidebar-toggle-label {
    display: none;
}

body.sidebar-collapsed .sidebar:hover .sidebar-toggle-label {
    display: inline;
}

/* === 頁面元件 === */
h2.page-title {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--text-primary);
    border-left: 4px solid var(--primary-blue);
    padding-left: 24px;
    /* 對齊 card (20px) + table cell padding (≈8px) */
    margin-bottom: 25px;
}

.card {
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    padding: 20px;
    transition: box-shadow 0.3s;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

/* 包含表格的 card 特殊處理 */
.card-body table {
    margin: 0;
    border-radius: 6px;
    overflow: hidden;
}

.card-header {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-body {
    padding: 0;
}

/* === 表單 === */
.toolbar {
    display: flex;
    flex-direction: row;
    /* 強制橫排，防止 Bootstrap .card 的 flex-direction:column 覆蓋 */
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

input,
select,
textarea {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: 0.3s;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 5px;
    display: block;
}

.form-control {
    height: 38px !important;
    font-size: 0.95rem !important;
    padding: 6px 12px !important;
    line-height: 1.5 !important;
    width: 100%;
}

/* === 按鈕 === */
.btn {
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    border: 1px solid var(--border-color);
    background: var(--bg-white);
    color: var(--text-primary);
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    font-size: 0.95rem;
}

.btn:hover {
    background: var(--bg-light-gray);
    border-color: var(--text-secondary);
}

.btn-primary {
    background: var(--primary-blue);
    border-color: var(--primary-blue);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--primary-blue-dark);
    border-color: var(--primary-blue-dark);
    box-shadow: var(--shadow-md);
}

.btn-success {
    background: var(--success-green);
    border-color: var(--success-green);
    color: #ffffff !important;
}

.btn-success:hover {
    background: #218838;
    border-color: #1e7e34;
    box-shadow: var(--shadow-md);
}

.btn-danger {
    background: var(--danger-red);
    border-color: var(--danger-red);
    color: #ffffff;
}

.btn-danger:hover {
    background: #c82333;
    border-color: #bd2130;
    box-shadow: var(--shadow-md);
}

.btn-warning {
    background: var(--warning-orange);
    border-color: var(--warning-orange);
    color: #212529;
}

.btn-warning:hover {
    background: #e0a800;
    border-color: #d39e00;
}

.btn-info {
    background: var(--info-cyan);
    border-color: var(--info-cyan);
    color: #ffffff;
}

.btn-info:hover {
    background: #138496;
    border-color: #117a8b;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-outline:hover {
    background: var(--bg-light-gray);
    border-color: var(--text-secondary);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.85rem;
}

/* Outline 按鈕變體 */
.btn-outline-primary {
    background: transparent;
    border: 1px solid var(--primary-blue);
    color: var(--primary-blue);
}

.btn-outline-primary:hover {
    background: var(--primary-blue);
    color: #ffffff;
}

.btn-outline-danger {
    background: transparent;
    border: 1px solid var(--danger-red);
    color: var(--danger-red);
}

.btn-outline-danger:hover {
    background: var(--danger-red);
    color: #ffffff;
}

.btn-outline-info {
    background: transparent;
    border: 1px solid var(--info-cyan);
    color: var(--info-cyan);
}

.btn-outline-info:hover {
    background: var(--info-cyan);
    color: #ffffff;
}

.btn-outline-success {
    background: transparent;
    border: 1px solid var(--success-green);
    color: var(--success-green);
}

.btn-outline-success:hover {
    background: var(--success-green);
    color: #ffffff;
}

.btn-outline-warning {
    background: transparent;
    border: 1px solid var(--warning-orange);
    color: #856404;
}

.btn-outline-warning:hover {
    background: var(--warning-orange);
    color: #212529;
}

.btn-outline-secondary {
    background: transparent;
    border: 1px solid #6c757d;
    color: #6c757d;
}

.btn-outline-secondary:hover {
    background: #6c757d;
    color: #ffffff;
}

/* === 表格 (DataTables) === */
.table-container {
    overflow-x: auto;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-white);
}

thead {
    background: linear-gradient(180deg, #e3f2fd 0%, #bbdefb 100%);
}

th {
    background: linear-gradient(180deg, #e3f2fd 0%, #bbdefb 100%);
    color: #1565c0;
    padding: 14px 15px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #1976d2;
    border-top: 1px solid #90caf9;
    position: sticky;
    top: 0;
    font-size: 0.9rem;
    letter-spacing: 0.3px;
}

td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

/* 斑馬紋效果 */
tbody tr:nth-child(odd) {
    background-color: #ffffff;
}

tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

/* Hover 效果 */
tbody tr:hover {
    background-color: #e3f2fd !important;
    transition: background-color 0.2s ease;
}

tbody tr:hover td {
    color: #1565c0;
    font-weight: 500;
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

/* 狀態標籤 */
.badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-block;
}

.badge-info {
    background: #d1ecf1;
    color: #0c5460;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
}

.badge-danger {
    background: #f8d7da;
    color: #721c24;
}

.badge-secondary {
    background: #e2e3e5;
    color: #383d41;
}

.badge-primary {
    background: #cce5ff;
    color: #004085;
}

/* === Modal === */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

/* 自訂 modal 卡片：覆蓋 Bootstrap .modal { display:none; position:fixed } 的衝突 */
.modal-overlay .modal {
    display: block;
    position: relative;
    background: var(--bg-white);
    width: 90%;
    max-width: 700px;
    height: auto;
    /* 覆蓋 Bootstrap 預設的 height: 100% 避免變得太長 */
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    transform: scale(0.9);
    transition: transform 0.3s;
    z-index: auto;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 600;
}

.modal-body {
    padding: 20px;
    padding-right: 25px !important;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: var(--bg-light-gray);
}

.modal-close {
    background: transparent !important;
    color: var(--text-muted) !important;
    border: none !important;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.3s;
    cursor: pointer;
}

.modal-close:hover {
    background: var(--bg-light-gray) !important;
    color: var(--danger-red) !important;
}

.modal::-webkit-scrollbar {
    width: 8px;
}

.modal::-webkit-scrollbar-track {
    background: var(--bg-light-gray);
}

.modal::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.modal::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* 全局滾動條樣式 */
*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-track {
    background: var(--bg-light-gray);
}

*::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* === DataTables 企業風格 === */
.dataTables_filter,
.dataTables_length {
    display: none;
}

.dataTables_info {
    color: var(--text-secondary) !important;
    font-size: 0.85rem;
    padding-top: 15px !important;
}

.dataTables_paginate {
    padding-top: 15px !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    color: var(--primary-blue) !important;
    background: var(--bg-white) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 4px;
    margin-left: 5px;
    padding: 4px 10px;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--primary-blue) !important;
    color: #ffffff !important;
    border-color: var(--primary-blue) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--primary-blue) !important;
    color: #ffffff !important;
    border: 1px solid var(--primary-blue) !important;
    font-weight: 600;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
    color: var(--text-muted) !important;
    border-color: var(--border-light) !important;
    background: transparent !important;
    cursor: default !important;
}

.dt-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-light);
    margin-top: 10px;
    padding-top: 10px;
}

.dataTables_wrapper {
    position: relative;
}

.dataTables_processing {
    position: absolute !important;
    top: 60px !important;
    /* Offset for header */
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: rgba(255, 255, 255, 0.8) !important;
    /* Light overlay */
    color: var(--primary-blue) !important;
    border: none !important;
    box-shadow: none !important;
    font-weight: 600;
    font-size: 1.1rem;
    display: flex;
    align-items: flex-start;
    /* Align to top of body */
    justify-content: center;
    padding-top: 50px !important;
    /* Push text down a bit */
    z-index: 100;
}

table.dataTable tbody tr {
    transition: background-color 0.2s ease;
}

/* DataTables 斑馬紋 */
table.dataTable tbody tr:nth-child(odd) {
    background-color: #ffffff;
}

table.dataTable tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

/* DataTables Hover 效果 */
table.dataTable tbody tr:hover {
    background-color: #e3f2fd !important;
}

table.dataTable tbody tr:hover td {
    color: #1565c0;
    font-weight: 500;
}

/* DataTables 表頭美化 */
table.dataTable thead th {
    background: linear-gradient(180deg, #e3f2fd 0%, #bbdefb 100%) !important;
    color: #1565c0 !important;
    border-bottom: 2px solid #1976d2 !important;
    border-top: 1px solid #90caf9 !important;
}

.dataTables_wrapper .dataTables_scrollBody {
    height: auto !important;
    max-height: none !important;
    overflow-y: visible !important;
    overflow-x: auto !important;
}

/* === Select2 企業風格 === */
.select2-container .select2-selection--single {
    height: 38px !important;
    background: var(--bg-white) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 6px !important;
    display: flex !important;
    align-items: center !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--text-primary) !important;
    line-height: 36px !important;
    padding-left: 12px !important;
}

.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: var(--text-muted) !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 36px !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: var(--text-muted) transparent transparent transparent !important;
}

.select2-dropdown {
    background: var(--bg-white) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 6px !important;
    box-shadow: var(--shadow-md);
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    background: var(--bg-white) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 4px !important;
    color: var(--text-primary) !important;
    padding: 8px 12px !important;
}

.select2-container--default .select2-search--dropdown .select2-search__field:focus {
    outline: none !important;
    border-color: var(--primary-blue) !important;
}

.select2-container--default .select2-results__option {
    color: var(--text-primary) !important;
    padding: 10px 12px !important;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background: rgba(0, 102, 204, 0.1) !important;
    color: var(--primary-blue) !important;
}

.select2-container--default .select2-results__option[aria-selected=true] {
    background: rgba(0, 102, 204, 0.05) !important;
}

/* === 日期選擇器 === */
input[type="date"],
input[type="month"],
input[type="datetime-local"] {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    font-family: inherit;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.7;
    filter: none;
}

input[type="date"]:hover::-webkit-calendar-picker-indicator,
input[type="month"]:hover::-webkit-calendar-picker-indicator {
    opacity: 1;
}

/* === SweetAlert2 Toast 樣式增強 === */
.toast-popup-custom {
    z-index: 9999 !important;
    box-shadow: var(--shadow-lg) !important;
    border: 1px solid var(--border-color) !important;
    font-weight: 500 !important;
}

/* === 工具類 === */
.text-muted {
    color: var(--text-muted) !important;
}

.text-dim {
    color: var(--text-secondary) !important;
}

.text-xs {
    font-size: 0.8rem;
}

.font-mono {
    font-family: 'Courier New', monospace;
}

.amount-negative {
    color: var(--danger-red);
    font-weight: 600;
}

.amount-positive {
    color: var(--success-green);
    font-weight: 600;
}

/* === 響應式設計 === */
@media (max-width: 768px) {
    .sidebar {
        width: 0;
        transform: translateX(-100%);
    }

    body.sidebar-open .sidebar {
        width: var(--sidebar-width);
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
        padding: 15px;
    }

    .toolbar {
        flex-direction: column;
    }

    .navbar {
        padding: 0 10px;
    }

    .menu-submenu {
        max-height: none;
        opacity: 1;
    }
}

/* === 移除背景特效 === */
.bg-layer {
    display: none;
}

/* === 鎖定欄位樣式 === */
.locked-field {
    pointer-events: none !important;
    background-color: #e9ecef !important;
    color: var(--text-muted) !important;
    border-color: var(--border-color) !important;
    opacity: 0.7;
}

.locked-select2+.select2-container .select2-selection {
    background-color: #e9ecef !important;
    border-color: var(--border-color) !important;
    pointer-events: none !important;
}

.locked-select2+.select2-container .select2-selection__rendered {
    color: var(--text-muted) !important;
}

/* === SweetAlert2 Z-Index Fix === */
/* Ensure SweetAlert2 (Toasts & Modals) are always on top of custom .modal-overlay (z-index: 2000) */
.swal2-container {
    z-index: 10000 !important;
}

/* === Go to Top Button === */
.go-to-top-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 45px;
    height: 45px;
    /* Soft dark background with transparency for a glass effect */
    background-color: rgba(44, 62, 80, 0.7);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: none;
    /* hidden by default */
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    /* Soft aesthetic shadow */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    /* Smooth transitions and backdrop filter */
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.go-to-top-btn:hover {
    background-color: rgba(44, 62, 80, 0.95);
    color: #ffffff;
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

@media (max-width: 768px) {
    .go-to-top-btn {
        bottom: 20px;
        right: 20px;
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}
