/* ===== 后台管理系统基础样式 ===== */

/* CSS重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    background-color: #f5f5f5;
}

/* 全局变量 */
:root {
    --primary-color: #1890ff;
    --primary-hover: #40a9ff;
    --primary-active: #096dd9;
    --success-color: #52c41a;
    --warning-color: #faad14;
    --error-color: #f5222d;
    --text-color: #333;
    --text-secondary: #666;
    --text-disabled: #999;
    --border-color: #d9d9d9;
    --border-light: #f0f0f0;
    --bg-color: #f5f5f5;
    --bg-white: #ffffff;
    --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 4px 12px rgba(0, 0, 0, 0.15);
    --border-radius: 6px;
    --sidebar-width: 240px;
    --header-height: 64px;
}

/* 清除浮动 */
.clearfix::after {
    content: "";
    display: table;
    clear: both;
}

/* 卡片组件 */
.card {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
}

.card-body {
    padding: 24px;
}

.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    background-color: #fafafa;
}

/* 按钮样式 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    color: #fff;
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-primary:active {
    background-color: var(--primary-active);
    border-color: var(--primary-active);
}

.btn-secondary {
    color: var(--text-color);
    background-color: #fff;
    border-color: var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-success {
    color: #fff;
    background-color: var(--success-color);
    border-color: var(--success-color);
}

.btn-warning {
    color: #fff;
    background-color: var(--warning-color);
    border-color: var(--warning-color);
}

.btn-danger {
    color: #fff;
    background-color: var(--error-color);
    border-color: var(--error-color);
}

.btn-sm {
    padding: 4px 12px;
    font-size: 12px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 16px;
}

/* 表单样式 */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
    color: var(--text-color);
}

.form-control {
    display: block;
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-color);
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}

.form-control:disabled {
    background-color: #f5f5f5;
    opacity: 1;
}

.form-control.is-invalid {
    border-color: var(--error-color);
}

.form-control.is-invalid:focus {
    box-shadow: 0 0 0 2px rgba(245, 34, 45, 0.2);
}

.invalid-feedback {
    display: block;
    width: 100%;
    margin-top: 4px;
    font-size: 12px;
    color: var(--error-color);
}

/* 表格样式 */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    margin-bottom: 0;
    background-color: transparent;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.table th {
    font-weight: 600;
    color: var(--text-color);
    background-color: #fafafa;
    border-top: 1px solid var(--border-light);
}

.table tbody tr:hover {
    background-color: #f5f5f5;
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.02);
}

/* 表格复选框样式 */
.table th:first-child,
.table td:first-child {
    width: 50px;
    text-align: center;
    padding: 12px 8px;
}

.table input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* 表格操作列样式 */
.table td:last-child {
    white-space: nowrap;
}

.table td:last-child .btn {
    margin-right: 8px;
}

.table td:last-child .btn:last-child {
    margin-right: 0;
}

/* 分页样式 */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 24px;
    gap: 8px;
}

.page-item {
    display: inline-flex;
}

.page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    color: var(--text-color);
    text-decoration: none;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
    min-width: 40px;
    height: 40px;
}

.page-link:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.page-item.active .page-link {
    color: #fff;
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.page-item.disabled .page-link {
    color: var(--text-disabled);
    cursor: not-allowed;
    background-color: #f5f5f5;
}

/* 表格工具栏与搜索框样式 */
.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.table-toolbar .toolbar-left,
.table-toolbar .toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.table-toolbar .toolbar-right {
    margin-left: auto;
}

/* 各管理页：将右侧工具栏稍微向左移动，避免贴边 */
.station-management .toolbar-right,
.region-management .toolbar-right,
.campus-management .toolbar-right,
.user-management .toolbar-right {
    margin-right: 80px;
}
.charge-user-usage-management .toolbar-right {
    margin-right: 500px;
}

/* 使用记录与用户管理页：搜索框容器适度放宽，容纳时间区间控件 */
.user-management .search-box {
    max-width: 750px;
}

/* 输入组（搜索框）统一样式 */
.search-box {
    display: inline-flex;
    align-items: stretch;
    max-width: 500px;
}
.search-box .form-control,
.search-box .btn {
    height: 36px;
}
/* 搜索框内控件宽度：下拉与输入分别设置 */
.search-box select.form-control {
    width: 160px;
}
.search-box input.form-control {
    width: 260px;
}
.search-box .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}
.search-box .btn {
    border-radius: 0;
}
.search-box .btn#searchBtn {
    border-top-right-radius: var(--border-radius);
    border-bottom-right-radius: var(--border-radius);
}

/* 滑动开关（toggle switch） */
.toggle-switch {
    --switch-width: 52px;
    --switch-height: 28px;
    --switch-bg: #ccc;
    --switch-active: var(--primary-color);
    position: relative;
    display: inline-block;
    width: var(--switch-width);
    height: var(--switch-height);
    vertical-align: middle;
}
.toggle-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--switch-bg);
    transition: 0.3s ease;
    border-radius: 999px;
}
.toggle-switch .slider:before {
    content: "";
    position: absolute;
    height: calc(var(--switch-height) - 4px);
    width: calc(var(--switch-height) - 4px);
    left: 2px;
    top: 2px;
    background-color: #fff;
    transition: 0.3s ease;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.toggle-switch input:checked + .slider {
    background-color: var(--switch-active);
}
.toggle-switch input:checked + .slider:before {
    transform: translateX(calc(var(--switch-width) - var(--switch-height)));
}
.toggle-switch.small {
    --switch-width: 40px;
    --switch-height: 22px;
}

/* 按钮外观（描边） */
.btn-outline-primary {
    color: var(--primary-color);
    background-color: #fff;
    border-color: var(--primary-color);
}
.btn-outline-primary:hover:not(:disabled) {
    color: #fff;
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}
.btn-outline-secondary {
    color: var(--text-color);
    background-color: #fff;
    border-color: var(--border-color);
}
.btn-outline-secondary:hover:not(:disabled) {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

/* 工具类 */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--primary-color); }
.text-success { color: var(--success-color); }
.text-warning { color: var(--warning-color); }
.text-danger { color: var(--error-color); }
.text-muted { color: var(--text-secondary); }

.bg-primary { background-color: var(--primary-color); }
.bg-success { background-color: var(--success-color); }
.bg-warning { background-color: var(--warning-color); }
.bg-danger { background-color: var(--error-color); }

.d-none { display: none; }
.d-block { display: block; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.d-flex { display: flex; }

.justify-content-start { justify-content: flex-start; }
.justify-content-end { justify-content: flex-end; }
.justify-content-center { justify-content: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-around { justify-content: space-around; }

.align-items-start { align-items: flex-start; }
.align-items-end { align-items: flex-end; }
.align-items-center { align-items: center; }
.align-items-baseline { align-items: baseline; }
.align-items-stretch { align-items: stretch; }

.flex-column { flex-direction: column; }
.flex-row { flex-direction: row; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.p-0 { padding: 0; }
.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }
.p-4 { padding: 32px; }

/* 响应式设计 */
@media (max-width: 768px) {
    .card-body {
        padding: 16px;
    }
    
    .table-responsive {
        font-size: 12px;
    }
    
    .table th,
    .table td {
        padding: 8px;
    }
    .table-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .table-toolbar .toolbar-right {
        width: 100%;
        justify-content: flex-end;
    }
    .search-box {
        max-width: 100%;
        width: 100%;
    }
    /* 小屏覆盖：自适应宽度避免挤压 */
    .search-box select.form-control,
    .search-box input.form-control {
        width: auto;
        flex: 1 1 auto;
    }
}

@media (max-width: 480px) {
    .btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .form-control {
        padding: 6px 8px;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

.slide-in-right {
    animation: slideInRight 0.3s ease-in-out;
}

.slide-in-left {
    animation: slideInLeft 0.3s ease-in-out;
}

/* 加载状态样式 */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: var(--text-muted);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 错误状态样式 */
.error-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: var(--text-muted);
}

.error-container h3 {
    color: var(--danger-color);
    margin-bottom: 10px;
}

.error-container .btn {
    margin-top: 20px;
}

/* 使用记录页头部用户信息样式 */
.page-header .page-description {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
}

.page-header .page-description span#userNameDisplay,
.page-header .page-description span#userIdDisplay,
.page-header .page-description span#userEmailDisplay {
    font-weight: 500;
    color: var(--text-color);
    background: rgba(0, 0, 0, 0.03);
    padding: 2px 8px;
    border-radius: 4px;
}

@media (max-width: 768px) {
    .page-header .page-description {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
}
/* 站点管理页：搜索框容器宽度适当放宽，避免拥挤换行 */
.station-management .search-box {
    max-width: 700px;
}
