/* ============================================================================
   通用组件样式 (Common Components)
   ============================================================================ */

/* 分页控件 */
.pagination {
    margin-top: 20px;
}

.page-item.disabled .page-link {
    pointer-events: none;
}

.input-group-text {
    background-color: #f8f9fa;
}

.pagination-wrapper {
    grid-row: 2;
    margin-top: 2rem;
}

/* 表单控件 */
.form-select-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    border-radius: 0.25rem;
}

.form-label {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 8px;
    display: block;
}

.is-invalid {
    border-color: #dc3545;
}

.invalid-feedback {
    display: none;
    color: #dc3545;
    font-size: 0.875em;
}

.is-invalid ~ .invalid-feedback {
    display: block;
}

/* 表格通用样式 */
.table th {
    white-space: nowrap;
}

.progress {
    height: 1rem;
}

/* 加载遮罩层 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.3s ease;
    pointer-events: auto;
}

.loading-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.circle-loader {
    width: 50px;
    height: 50px;
    position: relative;
}

.circle-loader:before,
.circle-loader:after {
    content: "";
    position: absolute;
    border-radius: 50%;
    top: 0;
    left: 0;
}

.circle-loader:before {
    width: 100%;
    height: 100%;
    border: 5px solid rgba(13, 110, 253, 0.1);
}

.circle-loader:after {
    width: 100%;
    height: 100%;
    border: 5px solid transparent;
    border-top-color: #0d6efd;
    border-right-color: #0d6efd;
    animation: spin 1s linear infinite;
}

/* Select2 样式 */
.select-elevated {
    border: none;
    border-radius: 8px;
    background-color: #f8f9fa;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    padding: 0.75rem 1.25rem;
    height: 48px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 2.5rem;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    border-left: 4px solid transparent;
    font-family: inherit;
    line-height: 1.5;
}

.position-relative:has(label) {
    padding-top: 1.5rem;
}

.select-elevated:focus {
    box-shadow: 0 4px 8px rgba(13,110,253,0.15);
    border-left-color: #0d6efd;
    background-color: white;
    outline: none;
}

.select-elevated:hover {
    background-color: #e9ecef;
}

.select2-container--bootstrap-5 {
    z-index: 1060 !important;
}

.select2-container--bootstrap-5 .select2-dropdown {
    border: 1px solid #dee2e6;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.select2-container--bootstrap-5 .select2-selection {
    min-height: 38px;
    padding: 0.375rem 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
}

.select2-container--bootstrap-5 .select2-selection.select-elevated {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
}

.select2-dropdown {
    max-height: min(400px, 70vh) !important;
    overflow-y: auto;
}

.select2-container--default .select2-selection--multiple {
    max-height: 100px;
    max-width: 100%;
    overflow-y: auto !important;
    white-space: normal !important;
}

.select2-selection__choice {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.select2-selection__choice[title^="已选择"] {
    background-color: #e6f7ff !important;
    border-color: #91d5ff !important;
}

.select2-selection__choice__remove {
    display: inline-block !important;
    color: #999 !important;
    margin-right: 5px !important;
}

.select2-container--default .select2-search--inline .select2-search__field {
    height: 100% !important;
    min-height: 40px;
}

.select2-container--default .select2-selection--single {
    height: 38px;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 36px;
    padding-left: 12px;
    color: #495057;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 36px;
}

.select2-container--default .select2-dropdown {
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    padding: 8px 12px;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #0d6efd;
}

.select2-container {
    z-index: 9999;
}

/* 侧边栏 */
.sidebar-content {
    opacity: 0;
    transition: opacity 0.3s ease;
}

#sidebar.open .sidebar-content {
    opacity: 1;
}

#sidebar {
    position: fixed;
    right: -300px;
    top: 56px; /* 从固定头部下方开始 */
    width: 300px;
    height: calc(100vh - 56px); /* 减去头部高度 */
    background: #f8f9fa;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    transition: right 0.3s ease;
    z-index: 1000;
    overflow-y: auto;
    border-left: 1px solid #dee2e6;
}

#sidebar.open {
    right: 0;
}

#sidebar-toggle {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 80px;
    background: #343a40;
    color: white;
    border-radius: 5px 0 0 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 999;
    box-shadow: -2px 0 5px rgba(0,0,0,0.2);
}

#sidebar-toggle i {
    font-size: 1.5rem;
    transition: transform 0.3s;
}

#sidebar-toggle.open i {
    transform: rotate(180deg);
}

.sidebar-header {
    padding: 15px;
    background: #343a40;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-content {
    padding: 15px;
}

.contact-card {
    background: white;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    border: 1px solid #dee2e6;
}

.contact-card h5 {
    color: #343a40;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.contact-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.contact-item i {
    width: 30px;
    color: #6c757d;
}

.quick-links {
    list-style: none;
    padding: 0;
}

.quick-links li {
    margin-bottom: 8px;
}

.quick-links a {
    display: block;
    padding: 8px 10px;
    color: #495057;
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.2s;
}

.quick-links a:hover {
    background: #e9ecef;
    color: #212529;
}

.quick-links i {
    margin-right: 8px;
    width: 20px;
    text-align: center;
}

@media (min-width: 992px) {
    body.sidebar-open {
        padding-right: 300px;
    }
}

/* Header Navbar - Fixed at top */
.navbar {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    width: 100%;
}

/* Footer */
.footer {
    background-color: #f8f9fa !important;
    border-top: 1px solid #dee2e6 !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    width: 100%;
    padding: 0.5rem 0 !important;
}

.footer p {
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
}

.footer a {
    color: #6c757d !important;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer a:hover {
    color: #495057 !important;
    text-decoration: underline;
}

body {
    min-height: 100vh;
    padding-top: 56px; /* 为固定头部留出空间 */
    padding-bottom: 60px; /* 为固定底部留出空间 */
}

.container {
    flex: 1;
}

@media (max-width: 576px) {
    .footer {
        padding: 0.4rem 0 !important;
    }
    
    .footer p {
        font-size: 0.7rem;
        margin-bottom: 0.2rem;
    }
    
    body {
        padding-top: 56px; /* 移动端头部高度保持一致 */
        padding-bottom: 50px;
    }
    
    /* 移动端侧边栏调整 */
    #sidebar {
        top: 56px;
        height: calc(100vh - 56px);
    }
}

/* Toast 通知 */
.toast {
    min-width: 250px;
    margin-bottom: 10px;
}

