/**
 * ============================================
 * 人脸识别闸机系统 - 全局样式表（升级版）
 * ============================================
 * 设计风格：蓝色简约粒子科技 + 毛玻璃 + 渐变
 */

/* ====== CSS变量体系 ====== */
:root {
    --primary: #4A90D9;
    --primary-dark: #357ABD;
    --primary-light: #6BA3E0;
    --accent: #a855f7;
    --success: #52c41a;
    --warning: #faad14;
    --danger: #ff4d4f;
    --bg-dark: #0f0f1a;
    --bg-card: rgba(255,255,255,0.05);
    --bg-card-solid: #1a1a2e;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --border-color: rgba(74,144,217,0.2);
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
    --radius: 16px;
    --radius-sm: 10px;
    --transition: all 0.3s ease;
}

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

html, body {
    width: 100%;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ====== 页面容器 ====== */
.page-container {
    min-height: 100vh;
    padding: 20px 16px;
    padding-top: env(safe-area-inset-top, 20px);
    padding-bottom: env(safe-area-inset-bottom, 20px);
    position: relative;
    z-index: 1;
}

.page-container.has-nav {
    padding-bottom: 80px;
}

/* ====== 粒子背景画布 ====== */
#particle-canvas {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* ====== 页面标题 ====== */
.page-header {
    text-align: center;
    margin-bottom: 24px;
    padding: 20px 0;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    letter-spacing: 2px;
}

.page-header p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ====== 状态指示器 ====== */
.status-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ====== 卡片 ====== */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.card:hover {
    border-color: rgba(74,144,217,0.4);
    box-shadow: 0 4px 30px rgba(74,144,217,0.15);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title .icon { font-size: 20px; }

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

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

.form-label .required {
    color: var(--danger);
    margin-left: 2px;
}

.form-input {
    width: 100%;
    height: 48px;
    padding: 0 16px;
    font-size: 15px;
    color: var(--text-primary);
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    transition: var(--transition);
}

.form-input:focus {
    border-color: var(--primary);
    background: rgba(74,144,217,0.08);
    box-shadow: 0 0 0 3px rgba(74,144,217,0.15);
}

.form-input::placeholder {
    color: rgba(160,160,176,0.5);
}

/* ====== 摄像头区域 ====== */
.camera-container {
    position: relative;
    width: 100%;
    aspect-ratio: 3/4;
    max-height: 400px;
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
    border: 2px solid var(--border-color);
    box-shadow: 0 0 20px rgba(74,144,217,0.15), inset 0 0 30px rgba(0,0,0,0.3);
}

.camera-container video {
    width: 100%; height: 100%;
    object-fit: cover;
}

.camera-container canvas { display: none; }

.camera-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    gap: 12px;
}

.camera-placeholder .icon {
    font-size: 48px;
    opacity: 0.5;
}

.photo-preview {
    width: 100%; height: 100%;
    object-fit: cover;
    display: none;
}

/* 人脸框 */
.face-guide {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 65%; height: 70%;
    border: 2px dashed rgba(74,144,217,0.6);
    border-radius: 50%;
    pointer-events: none;
    animation: faceGuidePulse 3s infinite;
}

@keyframes faceGuidePulse {
    0%, 100% { border-color: rgba(74,144,217,0.6); }
    50% { border-color: rgba(74,144,217,0.3); }
}

.face-guide-text {
    position: absolute;
    bottom: 12%; left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: rgba(74,144,217,0.8);
    white-space: nowrap;
}

/* ====== 按钮 ====== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 48px;
    padding: 0 24px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: 1px;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* 主按钮 - 蓝紫渐变 */
.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 4px 15px rgba(74,144,217,0.4);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 6px 25px rgba(74,144,217,0.5);
    transform: translateY(-1px);
}

/* 拍照按钮 - 渐变发光 */
.btn-camera {
    width: 64px; height: 64px;
    border-radius: 50%;
    background: #fff;
    border: 4px solid var(--primary);
    padding: 0;
    box-shadow: 0 0 0 4px rgba(74,144,217,0.2), 0 0 20px rgba(74,144,217,0.3);
}

.btn-camera:hover {
    box-shadow: 0 0 0 6px rgba(74,144,217,0.3), 0 0 30px rgba(74,144,217,0.4);
}

.btn-camera .inner {
    width: 48px; height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
}

/* 成功按钮 - 绿色渐变 */
.btn-success {
    background: linear-gradient(135deg, var(--success), #3ba50e);
    color: #fff;
    box-shadow: 0 4px 15px rgba(82,196,26,0.4);
}

/* 危险按钮 - 红色渐变 */
.btn-danger {
    background: linear-gradient(135deg, var(--danger), #d4373a);
    color: #fff;
    box-shadow: 0 4px 15px rgba(255,77,79,0.4);
}

/* 小按钮 */
.btn-sm {
    height: 36px;
    padding: 0 16px;
    font-size: 13px;
    border-radius: 8px;
}

/* 按钮组 */
.btn-group {
    display: flex;
    gap: 10px;
    width: 100%;
}

.btn-group .btn { flex: 1; }

/* 拍照操作栏 */
.camera-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    margin-top: 16px;
    padding: 12px 0;
}

/* ====== 结果展示 ====== */
.result-container {
    text-align: center;
    padding: 20px;
}

.result-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.result-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
}

.result-desc {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.result-info {
    display: inline-flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
    padding: 16px 24px;
    background: rgba(255,255,255,0.04);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.result-info-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.result-info-item .label {
    color: var(--text-secondary);
}

.result-info-item .value {
    color: var(--primary-light);
    font-weight: 600;
}

/* ====== 签到成功/失败动画 ====== */
.success-animation {
    animation: successBounce 0.6s ease;
}

@keyframes successBounce {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

/* 结果卡片顶部彩线 */
.result-success-line {
    border-top: 3px solid var(--success);
    box-shadow: 0 -4px 20px rgba(82,196,26,0.2);
}

.result-fail-line {
    border-top: 3px solid var(--danger);
    box-shadow: 0 -4px 20px rgba(255,77,79,0.2);
}

/* ====== 学生卡片 ====== */
.student-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: rgba(255,255,255,0.03);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 12px;
    transition: var(--transition);
    animation: cardFadeIn 0.3s ease;
}

@keyframes cardFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.student-card:hover {
    border-color: var(--primary);
}

.student-avatar {
    width: 52px; height: 52px;
    border-radius: 12px;
    object-fit: cover;
    border: 2px solid transparent;
    background: linear-gradient(var(--bg-card-solid), var(--bg-card-solid)) padding-box,
                linear-gradient(135deg, var(--primary), var(--accent)) border-box;
}

.student-info { flex: 1; min-width: 0; }

.student-name {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
}

.student-meta {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    gap: 12px;
}

.student-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* 状态标签 */
.status-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    font-size: 12px;
    border-radius: 20px;
    font-weight: 500;
}

.status-tag.pending {
    background: rgba(250,173,20,0.15);
    color: var(--warning);
}

.status-tag.approved {
    background: rgba(82,196,26,0.15);
    color: var(--success);
}

.status-tag.rejected {
    background: rgba(255,77,79,0.15);
    color: var(--danger);
}

/* ====== 签到记录 ====== */
.log-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: rgba(255,255,255,0.03);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 10px;
    gap: 12px;
}

.log-result {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.log-result.pass { background: rgba(82,196,26,0.15); }
.log-result.fail { background: rgba(255,77,79,0.15); }

.log-content { flex: 1; min-width: 0; }

.log-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 3px;
}

.log-detail {
    font-size: 12px;
    color: var(--text-secondary);
}

.log-time { text-align: right; flex-shrink: 0; }
.log-time .time { font-size: 13px; color: var(--text-primary); }
.log-time .date { font-size: 11px; color: var(--text-secondary); }

/* ====== 底部导航 ====== */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    display: flex;
    background: rgba(15,15,26,0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 100;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 0;
    font-size: 10px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    gap: 4px;
}

.nav-item .nav-icon { font-size: 22px; }

.nav-item.active {
    color: var(--primary);
}

.nav-item:hover {
    color: var(--primary-light);
}

.nav-item.nav-logout:hover {
    color: var(--danger);
}

/* ====== 加载动画 ====== */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15,15,26,0.8);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 999;
    gap: 16px;
}

.spinner {
    width: 44px; height: 44px;
    border: 3px solid rgba(74,144,217,0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ====== Toast ====== */
.toast {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    padding: 12px 24px;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(10px);
    color: #fff;
    border-radius: 10px;
    font-size: 14px;
    z-index: 1000;
    animation: toastIn 0.3s ease;
    pointer-events: none;
}

@keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ====== 空状态 ====== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state p { font-size: 14px; }

/* ====== 登录页 ====== */
.login-logo {
    width: 80px; height: 80px;
    border-radius: 24px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    margin: 0 auto 24px;
    box-shadow: 0 8px 32px rgba(74,144,217,0.3);
}

.login-card {
    margin-top: 15vh;
    position: relative;
}

.login-card::before {
    content: '';
    position: absolute;
    top: -1px; left: -1px; right: -1px; bottom: -1px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, rgba(74,144,217,0.3), rgba(168,85,247,0.2));
    z-index: -1;
    filter: blur(20px);
    opacity: 0.5;
}

/* ====== 筛选栏 ====== */
.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-bar .form-input {
    flex: 1;
    min-width: 120px;
    height: 40px;
    font-size: 13px;
}

/* ====== 统计卡片 ====== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.stat-card {
    text-align: center;
    padding: 14px 8px;
    background: rgba(255,255,255,0.03);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-light);
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ====== 管理员页 Tab ====== */
.tab-bar {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    background: rgba(255,255,255,0.03);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.tab-item {
    flex: 1;
    text-align: center;
    padding: 10px 0;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    border-right: 1px solid var(--border-color);
}

.tab-item:last-child { border-right: none; }

.tab-item.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    font-weight: 600;
}

.tab-item:hover:not(.active) {
    background: rgba(74,144,217,0.1);
}

.tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px; height: 18px;
    border-radius: 9px;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    padding: 0 5px;
    margin-left: 4px;
}

/* ====== 照片弹窗 ====== */
.photo-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    display: none;
}

.photo-modal.show { display: flex; }

.photo-modal img {
    max-width: 90%;
    max-height: 80vh;
    border-radius: 12px;
}

.photo-modal .close-btn {
    position: absolute;
    top: 20px; right: 20px;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    color: #fff;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.photo-modal .close-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* ====== 四格统计（学生列表页） ====== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.stats-grid .stat-card {
    padding: 12px 4px;
}

.stats-grid .stat-value {
    font-size: 20px;
}

.stats-grid .stat-label {
    font-size: 10px;
}

/* ====== 筛选胶囊 ====== */
.filter-pills {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.filter-pills::-webkit-scrollbar { display: none; }

.filter-pill {
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    white-space: nowrap;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.filter-pill.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-color: var(--primary);
    color: #fff;
}

.filter-pill:hover:not(.active) {
    border-color: var(--primary);
    color: var(--primary-light);
}

/* ====== 删除按钮 ====== */
.btn-delete {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    background: rgba(255,77,79,0.1);
    border: 1px solid rgba(255,77,79,0.2);
    color: rgba(255,77,79,0.7);
    cursor: pointer;
    transition: var(--transition);
}

.btn-delete:hover {
    background: rgba(255,77,79,0.2);
    border-color: var(--danger);
    color: var(--danger);
}

/* ====== 加载更多 ====== */
.load-more {
    text-align: center;
    padding: 16px;
}

.load-more button {
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 10px 32px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.load-more button:hover {
    border-color: var(--primary);
    color: var(--primary-light);
}

/* ====== 响应式 ====== */
@media (min-width: 480px) {
    .page-container {
        max-width: 480px;
        margin: 0 auto;
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    .camera-container { max-height: 280px; }
}

/* ====== 滚动条 ====== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(74,144,217,0.3); border-radius: 2px; }
