/* 基本設定 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* 頂部標題列 */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background-color: #f8f9fa;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
}

/* 主要內容區域 */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* 側邊選單 */
.side-menu-container {
    width: 250px;
    background-color: #f5f5f5;
    border-right: 1px solid #ddd;
    overflow-y: auto;
    height: 100%;
    flex-shrink: 0;
    transition: width 0.3s ease;
    position: relative;
}

.side-menu-container.collapsed {
    width: 30px;
}

/* 選單列表樣式 */
.menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu-item {
    margin: 0;
    padding: 0;
}

.menu-title {
    padding: 8px 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #e9ecef;
    border-bottom: 1px solid #dee2e6;
    font-weight: 500;
}

.menu-title:hover {
    background-color: #dee2e6;
}

.menu-title::after {
    content: '▼';
    font-size: 0.8em;
    transition: transform 0.3s ease;
}

.menu-title.collapsed::after {
    transform: rotate(-90deg);
}

.menu-children {
    padding-left: 20px;
    overflow: hidden;
    max-height: 1000px; /* 足夠大的高度 */
    transition: max-height 0.3s ease;
}

.menu-children.collapsed {
    max-height: 0;
}

.menu-leaf {
    padding: 8px 15px;
    cursor: pointer;
    color: #495057;
    transition: background-color 0.2s;
}

.menu-leaf:hover {
    background-color: #e2e6ea;
}

/* 收合按鈕 */
.menu-toggle {
    position: absolute;
    right: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.menu-toggle::after {
    content: '◀';
    font-size: 12px;
    transition: transform 0.3s ease;
}

.menu-toggle.collapsed::after {
    transform: rotate(180deg);
}

/* 當選單收合時的樣式 */
.side-menu-container.collapsed .menu-title span,
.side-menu-container.collapsed .menu-leaf span {
    display: none;
}

.side-menu-container.collapsed .menu-children {
    display: none;
}

/* 報表內容區域 */
.report-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

/* 報表控制項 */
.report-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 1rem;
    position: sticky;
    top: 0;
    background-color: white;
    padding: 10px 0;
    z-index: 1;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
}

.report-table thead th {
    position: sticky;
    top: 60px; /* 調整這個值以配合你的控制項高度 */
    background-color: #f5f5f5;
    z-index: 1;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }

    .side-menu-container {
        width: 100%;
        height: auto;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid #ddd;
    }

    .report-controls {
        flex-direction: column;
    }

    .form-group {
        width: 100%;
    }

    .report-table {
        font-size: 14px;
    }

    .report-table th,
    .report-table td {
        padding: 4px;
    }
}

/* 其他原有的樣式保持不變 */
.menu-item, .menu-title, .menu-leaf,
.form-group, .error-message, .modal,
.modal-content, .close, .config-form,
.settings-button {
    /* 保持原有樣式 */
}

/* 表格數字對齊 */
.report-table .number {
    text-align: right;
}

/* 表格固定表頭 */
.report-table thead th {
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    padding: 8px;
}

.report-table tbody td {
    border: 1px solid #ddd;
    padding: 8px;
}

/* 滾動條美化 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.text-right {
    text-align: right !important;
}

.number {
    text-align: right !important;
}