/* sidebar.css (refined theme) */

:root {
    /* Primary (你的主藍調) */
    --primary-900: #083245;
    --primary-800: #0B3E58;
    --primary-700: #0E4A6B;
    --primary-600: #0E5475;
    /* 主色(側欄背景) */
    --primary-400: #2A7FA3;

    /* Accent / UI */
    --accent-blue: #1E88E5;
    /* 互動藍(按鈕/active) */
    --accent-blue-dark: #1163B5;

    /* Neutrals */
    --bg-app: #F6F8FB;
    /* App 背景 */
    --bg-topbar: #F9FBFD;
    /* Topbar 淡白 */
    --surface: #FFFFFF;
    /* 卡片/白底 */
    --border: #E6EEF5;
    /* 分隔線 */

    /* Text */
    --text-900: #0F2940;
    /* 主文字 */
    --text-700: #355067;
    /* 次要文字 */
    --text-500: #6A8395;
    /* 弱化文字 */
    --sidebar-text: #E6EFF4;
    /* 側欄文字(淺藍白) */
    --inverse: #FFFFFF;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Microsoft Sans Serif', Arial, sans-serif;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-app);
    color: var(--text-900);
}

a {
    text-decoration: none;
}

/* ---------- Topbar ---------- */
.topbar {
    height: 74px;
    background-color: var(--bg-topbar);
    color: var(--text-900);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 1000;
    border-bottom: 1px solid var(--border);
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-900);
}

.menu-toggle {
    font-size: 24px;
    background: none;
    border: none;
    color: var(--text-900);
    cursor: pointer;
}

.title {
    font-family: 'Poppins', system-ui, -apple-system, Arial, sans-serif;
    font-weight: 500;
    color: var(--text-900);
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    max-width: max-content;
}

.title:hover,
.title:focus {
    color: var(--text-900);
    text-decoration: none;
}

/* ---------- User dropdown ---------- */
.user {
    margin-left: auto;
    cursor: pointer;
    position: relative;
}

.user-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background-color: var(--surface);
    color: var(--text-900);
    max-width: max-content;
    border-radius: 8px;
    padding: 10px;
    z-index: 1000;
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.12);
    border: 1px solid var(--border);
}

.user-dropdown.show {
    display: block;
}

.user-dropdown li {
    list-style-type: none;
    text-align: center;
}

.dropdown-header {
    cursor: default;
    color: var(--text-700);
}

.dropdown-item {
    cursor: pointer;
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    color: var(--text-900);
    transition: background-color .2s, color .2s;
    border-radius: 6px;
}

.dropdown-item:hover {
    background-color: #F2F6FB;
    color: var(--accent-blue);
}

.dropdown-divider {
    border: 0;
    border-top: 1px solid var(--border);
    margin: .5rem 0;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: 300px;
    background-color: var(--primary-600);
    color: var(--sidebar-text);
    position: fixed;
    top: 74px;
    left: -301px;
    height: calc(100vh - 74px);
    padding: 15px;
    overflow-y: auto;
    z-index: 999;
    transition: transform .3s ease-in-out;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.sidebar ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.sidebar ul li {
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    /* 調整成淺白分隔線 */
    transition: background-color .2s, color .2s;
    border-radius: 8px;
    margin: 2px 0;
}

.sidebar ul li a {
    color: var(--sidebar-text);
    text-decoration: none;
    display: flex;
    align-items: center;
}

/* 統一側欄圖示寬度，讓所有項目的文字起始位置對齊 */
.sidebar ul li a i {
    width: 1.6em;
    text-align: center;
    flex: 0 0 auto;
    font-size: 1.05em;
}

/* 圖示與文字間距改由 flex gap 控制，覆蓋各項目的 inline margin */
.sidebar ul li a span {
    margin-left: 4px !important;
}

.sidebar ul li:hover {
    background-color: rgba(255, 255, 255, 0.08);
    /* 深藍上的 hover 透明白 */
}

/* 子清單 hover 背景稍深即可，避免過黑 */
.sidebar ul li:hover ul {
    background-color: rgba(0, 0, 0, 0.06);
}

/* ---------- Main ---------- */
main {
    margin-top: 74px;
    padding: 20px;
}

main div:not(:last-child) {
    margin-bottom: 10px;
}

/* ---------- Footer ---------- */
.footer {
    width: 100%;
    bottom: 0;
    border-top: 1px solid var(--border);
}

/* ---------- Utilities ---------- */
.py-4 {
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
}

.text-center {
    text-align: center !important;
}

#btn-back-to-top {
    position: fixed;
    border-radius: 50%;
    bottom: 20px;
    right: 20px;
    display: block;
    opacity: 0;
    transition: opacity .1s ease;
}

.modal {
    z-index: 2000;
}

.modal-backdrop {
    z-index: 1999;
}

.with-divider {
    position: relative;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.with-divider::after {
    content: '';
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--border);
    position: absolute;
    bottom: 0;
    left: 0;
}

.sub-nav-content {
    min-width: 160px;
    max-width: max-content;
}

/* ---------- Active nav item (側欄選取態) ---------- */
.nav-item.active {
    color: var(--inverse);
    background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-blue-dark) 100%);
    font-weight: 700;
    box-shadow: 0 6px 16px rgba(17, 99, 181, 0.24);
    transition: background .2s ease, color .2s ease;
    border-radius: 10px;
}

.nav-item.active:hover {
    background: linear-gradient(135deg, var(--accent-blue-dark) 0%, #0D4D8A 100%);
}

/* ===== micro-fix pack ===== */

/* 1) 統一圓角與邊線強度（卡片、控件） */
:root {
    --radius: 12px;
    --border-strong: #D9E5EF;
    /* 比原來更明顯一點點 */
}

.card,
.card *:where(.card) {
    border-radius: var(--radius);
}

.card {
    border: 1px solid var(--border-strong);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

/* 2) topbar 用陰影取代硬邊線，層次更自然 */
.topbar {
    border-bottom: none !important;
    box-shadow: 0 2px 10px rgba(16, 24, 40, .06);
    background: var(--bg-topbar);
}

/* 3) sidebar 與內容區的分隔更銳利一點點 */
.sidebar {
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, .10);
}

@media (min-width: 1200px) {
    main {
        padding-left: 8px;
    }

    /* 打掉左邊那條灰帶感 */
}

/* 4) 統一互動藍（按鈕、link、active 狀態） */
:root {
    --accent-blue: #1E88E5;
    --accent-blue-dark: #1163B5;
}

a,
.link,
.btn-link {
    color: var(--accent-blue);
}

a:hover {
    color: var(--accent-blue-dark);
}

/* 讓 .nav-item.active 跟按鈕一致 */
.nav-item.active {
    background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-blue-dark) 100%) !important;
    color: #fff !important;
    border: none !important;
}

/* 5) 表頭/標題顏色與字重，拉開層次 */
h1,
h2,
h3,
.section-title {
    color: #0F2940;
    font-weight: 700;
}

.card .card-title,
.panel-title {
    color: #1C344A;
    font-weight: 600;
}

/* 6) 次要/弱化文字，避免過灰或過淡 */
.text-muted,
.subtitle,
.helper {
    color: #6A8395 !important;
}

/* 7) 控件 focus 樣式（藍色外圈），感覺更「產品級」 */
input,
select,
button,
.btn,
.form-control {
    border-radius: 10px;
}

input:focus,
select:focus,
.form-control:focus,
.btn:focus {
    outline: 0;
    box-shadow: 0 0 0 3px rgba(30, 136, 229, .25);
    border-color: var(--accent-blue);
}

/* 8) 儀表/圖表藍、警示粉統一（如果你能改到圖表顏色） */
:root {
    --chart-blue: #1E88E5;
    --chart-pink: #FF6B8B;
}