/* Admin Layout 專用樣式 */
.admin-body {
    margin: 0;
    padding: 0;
    background-color: #F6F7F9;
    font-family: var(--eip-font-family);
}

/* 左側選單樣式 */
.admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background-color: #FFFFFF;
    border-right: 1px solid #E2E8F0;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.25s ease;
    padding-bottom: 80px; /* 為 footer 預留空間 */
}

.admin-sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #E2E8F0;
    background: linear-gradient(135deg, #14256A 0%, #1462CC 100%);
}

.admin-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #FFFFFF;
    font-weight: 600;
    font-size: 18px;
}

.admin-brand-info {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
    min-width: 0;
}

.admin-brand i {
    color: #FFFFFF;
    flex-shrink: 0;
}

/* Sidebar Toggle Button */
.sidebar-toggle-btn {
    color: rgba(255, 255, 255, 0.65);
    padding: 4px 6px;
    line-height: 1;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 6px;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.sidebar-toggle-btn:hover,
.sidebar-toggle-btn:focus {
    color: #FFFFFF;
    background-color: rgba(255, 255, 255, 0.15);
    box-shadow: none;
}

.sidebar-toggle-icon {
    display: block;
    font-size: 14px;
    transition: transform 0.25s ease;
}

/* 選單區域 */
.admin-sidebar-menu {
    padding: 0;
}

.menu-section {
    margin-bottom: 0;
}

.menu-section-header {
    padding: 16px 20px 8px 20px;
    font-size: 12px;
    font-weight: 600;
    color: #6B7280;
    background-color: #F8FAFC;
    border-bottom: 1px solid #E2E8F0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.menu-items {
    padding: 0;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #475569;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 1px solid #F1F5F9;
    transition: all 0.2s ease;
}

.menu-item:hover {
    background-color: #F8FAFC;
    color: #1E40AF;
    text-decoration: none;
}

.menu-item.active {
    background-color: #DBEAFE;
    color: #1E40AF;
    border-left: 3px solid #2563EB;
    font-weight: 600;
}

.menu-item i {
    width: 16px;
    text-align: center;
}

/* 底部區域 */
.admin-sidebar-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 280px;
    padding: 20px;
    border-top: 1px solid #E2E8F0;
    background-color: #FFFFFF;
    z-index: 1001; /* 確保在選單內容之上 */
}

/* 主要內容區域 */
.admin-main {
    margin-left: 280px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.25s ease;
}

/* ===== Sidebar 收合狀態 ===== */
.admin-sidebar.sidebar-collapsed {
    width: 64px;
}

/* 收合時隱藏系統名稱文字 */
.admin-sidebar.sidebar-collapsed .admin-brand-text {
    display: none;
}

/* 收合時旋轉小箭頭（指向右側表示可展開） */
.admin-sidebar.sidebar-collapsed .sidebar-toggle-icon {
    transform: rotate(180deg);
}

/* 收合時區塊標題：圖示置中，文字字級歸零隱藏 */
.admin-sidebar.sidebar-collapsed .menu-section-header {
    justify-content: center;
    padding: 10px 0;
    font-size: 0;
}

.admin-sidebar.sidebar-collapsed .menu-section-header i {
    font-size: 12px;
    margin: 0;
}

/* 收合時選單項目：圖示置中，文字與徽章隱藏 */
.admin-sidebar.sidebar-collapsed .menu-item {
    justify-content: center;
    padding: 14px 0;
}

.admin-sidebar.sidebar-collapsed .menu-item > span {
    display: none;
}

.admin-sidebar.sidebar-collapsed .menu-item > .badge {
    display: none;
}

/* 收合時 footer 寬度同步，按鈕僅顯示圖示 */
.admin-sidebar.sidebar-collapsed .admin-sidebar-footer {
    width: 64px;
}

.admin-sidebar.sidebar-collapsed .admin-sidebar-footer .btn {
    padding: 6px 0;
    text-align: center;
    font-size: 0;
}

.admin-sidebar.sidebar-collapsed .admin-sidebar-footer .btn i {
    font-size: 16px;
}

/* 收合時主內容區左側縮小 */
.admin-main.sidebar-collapsed {
    margin-left: 64px;
}

.admin-header {
    background-color: #FFFFFF;
    border-bottom: 1px solid #E2E8F0;
    padding: 16px 24px;
    position: sticky;
    top: 0;
    z-index: 999;
}

.admin-header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-header-title h4 {
    color: #0F172A;
    font-weight: 600;
}

.admin-header-actions {
    display: flex;
    align-items: center;
}

.admin-content {
    flex: 1;
    padding: 24px;
    padding-bottom: 280px; /* 預留底部可捲動空間，避免 selector 清單被視窗底部遮擋 */
    background-color: #F6F7F9;
}

/* 卡片樣式調整 */
.admin-content .card {
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    box-shadow: none;
}

.admin-content .card-header {
    background-color: #F8FAFC;
    border-bottom: 1px solid #E2E8F0;
    font-weight: 600;
}

/* 表格樣式調整 */
.admin-content .table {
    background-color: #FFFFFF;
    border-radius: 8px;
    overflow: hidden;
}

.admin-content .table thead th {
    background-color: #F8FAFC;
    border-bottom: 1px solid #E2E8F0;
    font-weight: 600;
    font-size: 12px;
    color: #6B7280;
    text-align: left;
    white-space: nowrap;
}

/* 表格 body 預設靠左 */
.admin-content .table tbody td {
    text-align: left;
}

/* 金額靠右 */
.admin-content .table tbody td.text-right {
    text-align: right;
}

/* 置中輔助類別，需要時自行加上 */
.admin-content .table thead th.text-center,
.admin-content .table tbody td.text-center {
    text-align: center;
}

/* 響應式設計 */
@media (max-width: 991.98px) {
    .admin-sidebar {
        display: none;
    }
    
    .admin-main {
        margin-left: 0;
    }
    
    .admin-sidebar-footer {
        display: none;
    }
}

/* EIP Avatar 樣式 */
.eip-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #6B7280;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

/* 保險：確保 .bi 圖示有最小可見尺寸（即使字型載入失敗也保留點擊熱點） */
.admin-header-actions .bi {
    display: inline-block;
    min-width: 1.25rem;
    min-height: 1.25rem;
    line-height: 1;
}

/* 主題切換按鈕：固定可點擊熱點與 hover 視覺 */
#themeToggleBtn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 32px;
    padding: 4px 6px;
    border-radius: 6px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

#themeToggleBtn:hover,
#themeToggleBtn:focus {
    background-color: rgba(0, 0, 0, 0.06);
    text-decoration: none;
    outline: none;
}

[data-theme="dark"] #themeToggleBtn:hover,
[data-theme="dark"] #themeToggleBtn:focus {
    background-color: rgba(255, 255, 255, 0.08);
}

/* Header 內下拉/連結文字在深色底色上的可讀性 */
[data-theme="dark"] .admin-header-actions a,
[data-theme="dark"] .admin-header-actions button {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .admin-header-actions .dropdown-toggle::after {
    color: var(--text-primary);
}
