/* 
 * FuckCheck 2.0 Style
 * 清爽、现代的后台管理风格
 */

:root {
    --primary: #20a53a;
    --primary-dark: #1b8a31;
    --secondary: #2c3e50;
    --text-main: #333333;
    --text-light: #666666;
    --bg-body: #f5f7fa;
    --bg-card: #ffffff;
    --border: #e4e7eb;

    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #17a2b8;

    --sidebar-width: 240px;
    --header-height: 60px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 全局 SVG 限制 - 防止图标过大 */
svg {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    flex-shrink: 0;
}

body {
    font-family: 'Roboto', -apple-system, sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    overflow: hidden;
    /* 防止body滚动 */
}

/* ================= 通用组件 ================= */
.hidden {
    display: none !important;
}

/* Cookie过期警告横幅 */
.cookie-expired-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 20px;
    color: #856404;
}

.btn-relogin {
    background: #ffc107;
    color: #000;
    border: none;
    border-radius: 6px;
    padding: 7px 16px;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-relogin:hover {
    background: #e0a800;
}

.block {
    display: block;
    width: 100%;
}

.mt-3 {
    margin-top: 1rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-3 {
    margin-bottom: 1rem;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flex-gap {
    display: flex;
    gap: 10px;
}

/* 按钮 */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-outline {
    border-color: var(--border);
    background: white;
    color: var(--text-main);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-text {
    background: none;
    color: var(--primary);
    padding: 0;
}

/* 表单 */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-light);
    font-size: 0.9rem;
}

input,
select,
.form-select {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.95rem;
    background: white;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(32, 165, 58, 0.1);
}

/* Grid System */
.row {
    display: flex;
    margin: 0 -10px;
    flex-wrap: wrap;
}

.col-4 {
    width: 33.33%;
    padding: 0 10px;
}

.col-8 {
    width: 66.66%;
    padding: 0 10px;
}

/* 卡片 */
.card {
    background: var(--bg-card);
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-body {
    padding: 1.5rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 500;
    margin: 0;
}

/* 状态卡片 */
.card-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    border-radius: 6px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.stat-card .icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-card .icon svg {
    width: 24px;
    height: 24px;
}

.stat-card .info .value {
    font-size: 1.5rem;
    font-weight: bold;
    line-height: 1.2;
}

.stat-card .info .label {
    color: var(--text-light);
    font-size: 0.85rem;
}

.stat-card.blue .icon {
    background: #e3f2fd;
    color: #1e88e5;
}

.stat-card.green .icon {
    background: #e8f5e9;
    color: #43a047;
}

.stat-card.purple .icon {
    background: #f3e5f5;
    color: #8e24aa;
}

.stat-card.orange .icon {
    background: #fff3e0;
    color: #fb8c00;
}

/* ================= 登录页 ================= */
.auth-view {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #2c3e50;
    /* 深色背景 */
}

.auth-card {
    background: white;
    width: 400px;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header .logo {
    color: var(--primary);
    margin-bottom: 15px;
}

.auth-header .logo svg {
    width: 64px;
    height: 64px;
}

.auth-tabs {
    display: flex;
    margin-bottom: 25px;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-light);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 500;
}

/* ================= 主界面布局 ================= */
.main-view {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: #2c3e50;
    color: #ecf0f1;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    font-size: 1.2rem;
    font-weight: bold;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    gap: 10px;
}

.sidebar-brand svg {
    width: 24px;
    height: 24px;
    color: var(--primary);
}

.sidebar-menu {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 12px 25px;
    color: #adb5bd;
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.menu-item svg {
    width: 18px;
    height: 18px;
    margin-right: 15px;
}

.menu-item:hover,
.menu-item.active {
    background: rgba(0, 0, 0, 0.2);
    color: white;
    border-left-color: var(--primary);
}

.sidebar-user {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.user-info .username {
    color: white;
    font-size: 0.9rem;
}

.user-info .status {
    font-size: 0.75rem;
    color: #28a745;
}

/* 内容区 */
.content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-body);
    position: relative;
}

.top-header {
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 20px;
}

.content-body {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
}

.page-section {
    display: none;
    animation: fadeIn 0.3s;
}

.page-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-title {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

/* ================= 业务组件 ================= */
/* Stepper */
.stepper {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.step {
    opacity: 0.4;
    pointer-events: none;
    transition: all 0.3s;
}

.step.active {
    opacity: 1;
    pointer-events: all;
}

.step-num {
    width: 30px;
    height: 30px;
    background: #ddd;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-bottom: 10px;
}

.step.active .step-num {
    background: var(--primary);
}

.qr-box {
    background: #f8f9fa;
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    max-width: 300px;
}

/* 图片通用限制 */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* 修复图片过大问题 */
.qr-wrapper img {
    max-width: 200px;
    /* 限制二维码最大宽度 */
    width: 100%;
    height: auto;
    margin: 0 auto;
    border-radius: 4px;
}

/* 确保按钮可点击 */
button,
.btn {
    position: relative;
    z-index: 10;
}

/* Class Grid */
.class-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.class-item {
    background: white;
    border: 1px solid var(--border);
    padding: 15px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.class-item:hover {
    border-color: var(--primary);
}

.class-item.selected {
    border-color: var(--primary);
    background: #f0f9eb;
}

.class-item.selected::after {
    content: '✓';
    position: absolute;
    top: 10px;
    right: 10px;
    color: var(--primary);
    font-weight: bold;
}

/* Logs Table */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    padding: 12px;
    background: #f8f9fa;
    border-bottom: 2px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-light);
}

.table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
}

.status-success {
    background: var(--success);
}

.status-failed {
    background: var(--danger);
}

.status-warning {
    background: var(--warning);
}

/* Loading */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Toast */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
}

.toast {
    min-width: 320px;
    background: white;
    padding: 16px;
    border-radius: 8px;
    /* 更圆润 */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    /* 更高级的阴影 */
    margin-bottom: 12px;
    display: flex;
    align-items: flex-start;
    /* 顶部对齐 */
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-left: 4px solid var(--primary);
    animation: slideIn 0.3s ease-out;
    background: #fff;
    position: relative;
    overflow: hidden;
}

.toast-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(32, 165, 58, 0.1);
    /* 默认绿色背景 */
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    flex-shrink: 0;
}

.toast.error .toast-icon {
    background: rgba(220, 53, 69, 0.1);
    color: var(--danger);
}

.toast.warning .toast-icon {
    background: rgba(255, 193, 7, 0.1);
    color: #d39e00;
}

.toast.info .toast-icon {
    background: rgba(23, 162, 184, 0.1);
    color: var(--info);
}

.toast-icon svg {
    width: 20px;
    height: 20px;
}

.toast-content {
    flex: 1;
    padding-top: 2px;
    /* 微调文字垂直对齐 */
}

.toast-title {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
    color: #333;
    line-height: 1.4;
}

.toast-message {
    font-size: 13px;
    color: #666;
    line-height: 1.5;
}

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #bbb;
    padding: 0 0 0 10px;
    transition: color 0.2s;
    margin-top: 2px;
}

.toast-close:hover {
    color: #666;
}

.toast-close svg {
    width: 16px;
    height: 16px;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Logout Btn specific */
.logout-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-light);
    font-size: 0.9rem;
}

.logout-btn:hover {
    color: var(--danger);
}

.logout-btn svg {
    width: 16px;
    height: 16px;
}

/* 日志为空占位 */
.log-empty {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.log-empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: 10px;
    opacity: 0.5;
}

.log-empty p {
    font-size: 14px;
}

/* 班级选择复选框 */
.class-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
    transition: all 0.2s;
}

.class-checkbox svg {
    width: 14px;
    height: 14px;
    opacity: 0;
    color: white;
}

.class-item.selected .class-checkbox {
    background: var(--primary);
    border-color: var(--primary);
}

.class-item.selected .class-checkbox svg {
    opacity: 1;
}

/* ================= 移动端响应式设计 ================= */

/* 汉堡菜单按钮 */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    background: var(--primary);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.mobile-menu-toggle svg {
    width: 24px;
    height: 24px;
}

/* 遮罩层 */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

/* 平板设备 (≤1024px) */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 200px;
    }

    .card-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .auth-card {
        width: 90%;
        max-width: 400px;
        padding: 30px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 移动设备 (≤768px) */
@media (max-width: 768px) {
    /* 移动端汉堡菜单显示 */
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* 侧边栏移动端样式 */
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        width: 280px;
        z-index: 1000;
        transition: left 0.3s ease;
    }

    .sidebar.active {
        left: 0;
    }

    /* 内容区全宽 */
    .content-wrapper {
        width: 100%;
        margin-left: 0;
    }

    /* 顶部导航 */
    .top-header {
        padding-left: 60px;
        padding-right: 15px;
    }

    /* 内容体间距 */
    .content-body {
        padding: 15px;
    }

    /* 统计卡片单列 */
    .card-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 15px;
    }

    .stat-card .icon {
        width: 40px;
        height: 40px;
    }

    .stat-card .icon svg {
        width: 20px;
        height: 20px;
    }

    .stat-card .info .value {
        font-size: 1.25rem;
    }

    /* 表单布局 */
    .row {
        flex-direction: column;
    }

    .col-4,
    .col-8 {
        width: 100%;
        margin-bottom: 15px;
    }

    /* 按钮组 */
    .flex-gap {
        flex-direction: column;
        gap: 8px;
    }

    .flex-gap .btn {
        width: 100%;
    }

    /* 班级网格 */
    .class-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    /* 表格响应式 */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        min-width: 600px;
    }

    .table th,
    .table td {
        padding: 10px 8px;
        font-size: 0.85rem;
    }

    /* 登录卡片 */
    .auth-card {
        width: 95%;
        padding: 25px 20px;
        margin: 0 10px;
    }

    .auth-header .logo svg {
        width: 48px;
        height: 48px;
    }

    .auth-header h1 {
        font-size: 1.5rem;
    }

    /* 标题 */
    .section-title {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }

    /* 卡片 */
    .card-body {
        padding: 1rem;
    }

    /* Toast通知 */
    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }

    .toast {
        min-width: auto;
        width: 100%;
    }

    /* 二维码容器 */
    .qr-box {
        max-width: 100%;
    }

    /* 管理后台适配 */
    .admin-container {
        flex-direction: column;
    }

    .admin-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e4e7eb;
        display: flex;
        overflow-x: auto;
        padding: 10px 0;
    }

    .admin-nav-item {
        white-space: nowrap;
        border-left: none;
        border-bottom: 3px solid transparent;
        padding: 10px 20px;
    }

    .admin-nav-item.active,
    .admin-nav-item:hover {
        border-left: none;
        border-bottom-color: var(--primary);
    }

    .admin-content {
        padding: 15px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .admin-header {
        padding: 15px;
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .admin-header h1 {
        font-size: 1.25rem;
    }
}

/* 小屏手机 (≤480px) */
@media (max-width: 480px) {
    .auth-card {
        padding: 20px 15px;
    }

    .auth-header h1 {
        font-size: 1.25rem;
    }

    .auth-header p {
        font-size: 0.85rem;
    }

    .form-group label {
        font-size: 0.85rem;
    }

    input,
    select {
        padding: 0.5rem;
        font-size: 0.9rem;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }

    .sidebar-brand {
        font-size: 1rem;
        padding: 0 15px;
    }

    .menu-item {
        padding: 10px 20px;
        font-size: 0.9rem;
    }

    .stat-card {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .stat-card .icon {
        margin: 0 auto;
    }

    .toast {
        padding: 12px;
    }

    .toast-icon {
        width: 30px;
        height: 30px;
    }

    .toast-icon svg {
        width: 16px;
        height: 16px;
    }

    .toast-title {
        font-size: 14px;
    }

    .toast-message {
        font-size: 12px;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    /* 增大可点击区域 */
    .btn,
    button,
    .menu-item,
    .class-item {
        min-height: 44px;
    }

    /* 移除hover效果，使用active */
    .btn:active {
        transform: scale(0.98);
    }

    .menu-item:active,
    .class-item:active {
        opacity: 0.8;
    }
}

/* 横屏优化 */
@media (max-width: 768px) and (orientation: landscape) {
    .auth-view {
        padding: 20px 0;
        align-items: flex-start;
        overflow-y: auto;
    }

    .auth-card {
        margin: 20px auto;
    }

    .sidebar {
        width: 240px;
    }
}