/* SmartPass Admin 管理后台全局样式 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-color: #667eea;
    --primary-dark: #764ba2;
    --success-color: #10b981;
    --danger-color: #f5576c;
    --warning-color: #f59e0b;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-900: #111827;
    --sidebar-width: 240px;
    --topbar-height: 64px;
    --text-color: #656d77;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
}

/* ===== 布局 ===== */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* ===== 顶部导航栏 ===== */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: white;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 1000;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-600);
    padding: 8px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.notification-icon {
    position: relative;
    color: var(--gray-600);
    cursor: pointer;
    padding: 8px;
}

.notification-icon i {
    font-size: 1.25rem;
}

.notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--danger-color);
    color: white;
    font-size: 0.7rem;
    padding: 2px 5px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.user-menu {
    position: relative;
}

.user-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 0.2s;
}

.user-trigger:hover {
    background: var(--gray-100);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-name {
    font-weight: 500;
    color: var(--gray-700);
}

.dropdown-arrow {
    font-size: 0.75rem;
    color: var(--gray-600);
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    min-width: 180px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.user-menu.active .user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: block;
    padding: 12px 16px;
    color: var(--gray-700);
    text-decoration: none;
    transition: background 0.2s;
    border: none;
    width: 100%;
    text-align: left;
    background: none;
    cursor: pointer;
    font-size: 0.95rem;
}

.dropdown-item:first-child {
    border-radius: 8px 8px 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 8px 8px;
}

.dropdown-item:hover {
    background: var(--gray-100);
}

.dropdown-item i {
    margin-right: 8px;
    width: 16px;
    text-align: center;
}

.dropdown-divider {
    height: 1px;
    background: var(--gray-200);
    margin: 4px 0;
}

/* ===== 侧边栏 ===== */
.sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--topbar-height));
    background: white;
    border-right: 1px solid var(--gray-200);
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 999;
}

.sidebar-nav {
    padding: 20px 0;
}

.nav-group {
    margin-bottom: 8px;
}

.nav-group-title {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px 8px;

    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 一级菜单图标样式 */
.nav-group-title i {
    font-size: inherit;
}

.nav-group-title i::before {
    font-weight: 600 !important;
}

.nav-item {
    margin: 2px 12px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px 8px 42px;
    color: var(--gray-700);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    font-size: 0.95rem;
    font-weight: 400;
}

.nav-link:hover {
    background: var(--gray-100);
    color: var(--primary-color);
}

.nav-link.active {
    background: var(--gray-100);
    color: var(--primary-color);
}


/* ===== 主内容区 ===== */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--topbar-height);
    padding: 24px;
    width: calc(100% - var(--sidebar-width));
    min-height: calc(100vh - var(--topbar-height));
}

.page-header {
    margin-bottom: 24px;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.page-subtitle {
    color: var(--gray-600);
    font-size: 0.95rem;
}

/* ===== 卡片 ===== */
.card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    margin-bottom: 24px;
}

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

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-900);
}

/* ===== 表格 ===== */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead {
    background: var(--gray-50);
}

.table th {
    padding: 12px 16px;
    text-align: center;
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.875rem;
    border-bottom: 2px solid var(--gray-200);
}

.table td {
    padding: 16px;
    border-bottom: 1px solid var(--gray-200);
    color: var(--gray-700);
    text-align: center;
}

.table td.text-left {
    text-align: left;
}

.table tbody tr:hover {
    background: var(--gray-50);
}

/* ===== 按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
    white-space: nowrap;
}

.btn i::before {
    font-weight: 500 !important;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #e13a4f;
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.875rem;
}

/* ===== 状态标签 ===== */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.badge-primary {
    color: #fff;
    background-color: #007bff;
}

.badge-secondary {
    color: #374151;
    background-color: #e5e7eb;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-light {
    color: #212529;
    background-color: #f8f9fa;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-dark {
    color: #fff;
    background-color: #343a40;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

/* ===== 表单 ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--gray-700);
}

.form-control-static {
    min-height: 38px;
    padding: 8px 0;
    margin-bottom: 0;
    font-size: 1rem;
    color: var(--text-color);
    word-break: break-all;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234b5563' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ===== 工具栏 ===== */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    max-width: 600px;
}

.search-input {
    flex: 1;
}

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

.pagination-info {
    color: var(--gray-600);
    font-size: 0.9rem;
    font-weight: 500;
}

.pagination-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.pagination-btn {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--gray-100);
}

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

.pagination-btn.enable {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
}

.pagination-ellipsis {
    padding: 8px 12px;
    color: var(--gray-600);
}


/* ===== 响应式设计 ===== */
@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    :root {
        --sidebar-width: 0px;
    }

    .logo {
        font-size: 1.25rem;
    }

    .user-name {
        display: none;
    }
}

/* ===== 动画 ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* ===== Loading ===== */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--gray-600);
}

.spinner {
    border: 3px solid var(--gray-200);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

    100% {
        transform: rotate(360deg);
    }
}

/* ===== 加载遮罩层 ===== */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.loading-overlay-content {
    /*background: white;*/
    border-radius: 12px;
    padding: 40px 60px;
    /*box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);*/
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

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

.loading-overlay-text {
    font-size: 1.1rem;
    font-weight: 500;
    color: white;
}

/* ===== 模态框样式 ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

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

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--gray-600);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.modal-close:hover {
    background: var(--gray-100);
}

.modal-body {
    padding: 24px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
}

/* ===== 文件上传区域 ===== */
.file-upload-area {
    position: relative;
}

.file-upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    border: 2px dashed var(--gray-300);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--gray-50);
}

.file-upload-placeholder:hover {
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.05);
}

.file-upload-placeholder i {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 12px;
}

.file-upload-placeholder p {
    font-size: 1rem;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.file-hint {
    font-size: 0.875rem;
    color: var(--gray-600);
}

.file-upload-info {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    background: var(--gray-50);
}

.file-upload-info i {
    font-size: 2rem;
    color: var(--danger-color);
}

.file-name {
    flex: 1;
    font-weight: 500;
    color: var(--gray-900);
}

.file-size {
    color: var(--gray-600);
    font-size: 0.875rem;
}

.btn-remove {
    background: none;
    border: none;
    color: var(--gray-600);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    line-height: 1;
}

.btn-remove:hover {
    background: var(--gray-200);
    color: var(--danger-color);
}

.upload-progress {
    margin-top: 12px;
}

.progress-bar {
    height: 4px;
    background: var(--gray-200);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
    position: relative;
}

.progress-bar::before {
    content: '';
    display: block;
    height: 100%;
    background: var(--primary-gradient);
    width: 100%;
    animation: progressIndeterminate 1.5s ease-in-out infinite;
}

@keyframes progressIndeterminate {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

.progress-text {
    font-size: 0.875rem;
    color: var(--gray-600);
}

.required {
    color: var(--danger-color);
}

/* 配置表单分组样式 */
.config-section {
    margin-bottom: 24px;
    padding: 20px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    background: var(--gray-50);
}

.config-section:last-child {
    margin-bottom: 0;
}

.config-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-top: 0;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-color);
}

/* Toggle Switch 开关样式 */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.toggle-switch input[type="checkbox"] {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--gray-300);
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked+.toggle-slider {
    background-color: var(--primary-color);
}

.toggle-switch input:checked+.toggle-slider:before {
    transform: translateX(24px);
}

.toggle-switch input:disabled+.toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 开关标签布局 */
.switch-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.switch-label .toggle-switch {
    flex-shrink: 0;
}

/* Select 下拉框样式与 input 一致 */
select.form-control {
    /*height: 42px;*/
    padding: 10px 12px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

select.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 页码范围布局 */
.page-range-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-range-group input {
    flex: 1;
    min-width: 0;
}

.page-range-group .separator {
    color: var(--gray-600);
    font-weight: 500;
    flex-shrink: 0;
}

/* 自定义确认对话框 */
#customConfirmModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

#customConfirmModal.show {
    display: flex;
}

.custom-confirm-content {
    background: white;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-width: 400px;
    width: 90%;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.custom-confirm-message {
    font-size: 1rem;
    color: var(--gray-800);
    margin-bottom: 24px;
    line-height: 1.5;
}

.custom-confirm-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.custom-confirm-buttons .btn {
    min-width: 80px;
}

/* 禁用状态的按钮样式 */
.btn-disabled {
    opacity: 0.6;
    cursor: not-allowed !important;
    pointer-events: auto !important;
}

.btn-disabled:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* 复选框样式优化 - 增大尺寸 */
input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color, #4CAF50);
}

/* 表头的全选复选框 */
thead input[type="checkbox"] {
    width: 20px;
    height: 20px;
}

/* 题目列表的复选框 */
.question-checkbox {
    width: 18px;
    height: 18px;
    margin: 0 auto;
    display: block;
}

/* 题目列表顶部搜索栏布局优化 */
.search-box {
    width: 100% !important;
    display: flex;
    align-items: center;
    justify-content: flex-start !important;
    gap: 12px;
    flex-wrap: wrap;
}

/* 搜索输入框固定宽度 */
.search-box .search-input {
    width: 400px !important;
    max-width: 400px;
}

/* 图书筛选下拉框 */
.search-box .form-select {
    width: 280px !important;
}

/* 确保所有元素靠左对齐 */
.search-box>* {
    margin-left: 0;
}

/* 禁止搜索栏换行 */
.search-box {
    flex-wrap: nowrap !important;
}

/* 修复toolbar和search-box宽度限制 */
.toolbar {
    width: 100% !important;
}

.toolbar .search-box {
    max-width: none !important;
    flex: 1 !important;
}

.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
    vertical-align: middle;
    margin-bottom: 0 !important;
    /* 防止被 .form-group label 的样式覆盖 */
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--success-color);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--success-color);
}

input:checked+.slider:before {
    transform: translateX(24px);
}