/**
 * 人脸识别签到系统 - 主样式表
 * 移动端优先设计，简约科技风格
 * @author 人脸识别签到系统
 */

/* ========== CSS变量 ========== */
:root {
    --primary: #4A6CF7;
    --primary-light: #6B8AFF;
    --primary-dark: #3451D1;
    --primary-gradient: linear-gradient(135deg, #4A6CF7 0%, #6B8AFF 100%);
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.3);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    --glass-blur: 12px;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.1);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

/* ========== 全局重置 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.6;
    color: var(--gray-800);
    background: var(--gray-50);
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    color: var(--primary);
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

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

/* ========== 页面容器 ========== */
.page-container {
    max-width: 420px;
    margin: 0 auto;
    padding: 20px 16px 40px;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

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

.glass-card-header {
    text-align: center;
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--gray-200);
}

.glass-card-header .icon {
    font-size: 40px;
    margin-bottom: 8px;
}

.glass-card-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--gray-900);
}

.glass-card-header p {
    font-size: 14px;
    color: var(--gray-500);
    margin-top: 4px;
}

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

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-group .label-required::after {
    content: ' *';
    color: var(--danger);
}

.form-input {
    width: 100%;
    height: 48px;
    padding: 0 16px;
    font-size: 16px;
    font-family: var(--font);
    color: var(--gray-800);
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    outline: none;
    transition: all 0.25s ease;
    -webkit-appearance: none;
}

.form-input:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(74, 108, 247, 0.1);
}

.form-input.error {
    border-color: var(--danger);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
}

.form-input::placeholder {
    color: var(--gray-400);
}

textarea.form-input {
    height: auto;
    padding: 12px 16px;
    resize: vertical;
}

select.form-input {
    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='%236B7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    appearance: none;
}

.form-tip {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 4px;
}

.form-error {
    font-size: 12px;
    color: var(--danger);
    margin-top: 4px;
    display: none;
}

.form-input.error + .form-error {
    display: block;
}

/* ========== 按钮 ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    padding: 0 28px;
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.25s ease;
    user-select: none;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.btn:active {
    transform: scale(0.97);
}

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

.btn-primary {
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: 0 4px 14px rgba(74, 108, 247, 0.35);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(74, 108, 247, 0.45);
}

.btn-primary:active:not(:disabled) {
    box-shadow: 0 2px 8px rgba(74, 108, 247, 0.3);
}

.btn-success {
    background: linear-gradient(135deg, #10B981 0%, #34D399 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.btn-danger {
    background: linear-gradient(135deg, #EF4444 0%, #F87171 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-outline:hover:not(:disabled) {
    background: rgba(74, 108, 247, 0.05);
}

.btn-sm {
    height: 36px;
    padding: 0 16px;
    font-size: 14px;
    width: auto;
}

.btn-lg {
    height: 52px;
    font-size: 18px;
}

.btn-block {
    display: flex;
}

.btn .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 8px;
}

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

/* ========== 摄像头区域 ========== */
.camera-container {
    position: relative;
    width: 100%;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--gray-900);
    margin-bottom: 16px;
}

.camera-container video {
    width: 100%;
    display: block;
    min-height: 320px;
    object-fit: cover;
    background: #000;
}

.camera-container .camera-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.camera-container .camera-overlay .face-frame {
    width: 240px;
    height: 300px;
    border: 2px dashed rgba(255,255,255,0.5);
    border-radius: 12px;
    animation: pulse-border 2s ease-in-out infinite;
}

@keyframes pulse-border {
    0%, 100% { border-color: rgba(255,255,255,0.3); }
    50% { border-color: rgba(74, 108, 247, 0.7); }
}

.camera-container .camera-hint {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.8);
    font-size: 13px;
    background: rgba(0,0,0,0.5);
    padding: 6px 16px;
    border-radius: 20px;
    white-space: nowrap;
}

.photo-preview {
    width: 100%;
    border-radius: var(--radius-sm);
    overflow: hidden;
    display: none;
    margin-bottom: 16px;
}

.photo-preview img {
    width: 100%;
    display: block;
    border-radius: var(--radius-sm);
}

.camera-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.camera-actions .btn {
    flex: 1;
}

/* ========== 加载动画 ========== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
    flex-direction: column;
}

.loading-overlay.active {
    display: flex;
}

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

.loading-text {
    margin-top: 16px;
    font-size: 15px;
    color: var(--gray-600);
}

/* ========== Toast提示 ========== */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 20px 28px;
    border-radius: var(--radius);
    font-size: 15px;
    text-align: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    max-width: 320px;
    backdrop-filter: blur(8px);
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.toast .toast-icon {
    font-size: 36px;
    margin-bottom: 12px;
}

.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }

.toast .toast-msg {
    font-size: 14px;
    line-height: 1.5;
    margin-top: 4px;
    opacity: 0.9;
}

/* ========== 状态标签 ========== */
.status-tag {
    display: inline-block;
    padding: 2px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-tag.pending {
    background: #FEF3C7;
    color: #D97706;
}

.status-tag.approved {
    background: #D1FAE5;
    color: #059669;
}

.status-tag.rejected {
    background: #FEE2E2;
    color: #DC2626;
}

/* ========== 列表样式 ========== */
.list-item {
    display: flex;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--gray-100);
}

.list-item:last-child {
    border-bottom: none;
}

.list-item .item-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    flex-shrink: 0;
    margin-right: 12px;
}

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

.list-item .item-info .item-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-800);
}

.list-item .item-info .item-sub {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 2px;
}

.list-item .item-action {
    flex-shrink: 0;
    margin-left: 12px;
}

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

.empty-state .empty-icon {
    font-size: 56px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.empty-state h3 {
    font-size: 17px;
    color: var(--gray-600);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    color: var(--gray-400);
}

/* ========== 顶部导航 ========== */
.nav-bar {
    display: flex;
    align-items: center;
    padding: 12px 0;
    margin-bottom: 16px;
}

.nav-bar .nav-back {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    cursor: pointer;
    font-size: 18px;
    color: var(--gray-700);
    transition: all 0.2s;
}

.nav-bar .nav-back:active {
    transform: scale(0.92);
}

.nav-bar .nav-title {
    flex: 1;
    text-align: center;
    font-size: 17px;
    font-weight: 700;
    color: var(--gray-900);
    margin-right: 40px;
}

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

.stat-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 16px 10px;
    text-align: center;
}

.stat-card .stat-number {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 2px;
}

/* ========== 签到成功动画 ========== */
.success-animation {
    text-align: center;
    padding: 30px 0;
}

.success-animation .checkmark {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10B981, #34D399);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    animation: scaleIn 0.5s ease;
}

.success-animation .checkmark svg {
    width: 40px;
    height: 40px;
    fill: none;
    stroke: #fff;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@keyframes scaleIn {
    0% { transform: scale(0); }
    60% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.success-animation h2 {
    font-size: 20px;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.success-animation p {
    font-size: 14px;
    color: var(--gray-500);
}

/* ========== 管理员审核按钮组 ========== */
.action-btns {
    display: flex;
    gap: 8px;
}

.action-btns .btn {
    flex: 1;
    height: 36px;
    font-size: 13px;
    padding: 0 12px;
}

/* ========== 日志表格样式 ========== */
.log-table {
    width: 100%;
    border-collapse: collapse;
}

.log-table th {
    font-size: 12px;
    color: var(--gray-500);
    font-weight: 600;
    text-transform: uppercase;
    padding: 8px 4px;
    text-align: left;
    border-bottom: 2px solid var(--gray-200);
}

.log-table td {
    padding: 10px 4px;
    font-size: 14px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

.log-table tr:last-child td {
    border-bottom: none;
}

/* ========== 响应式微调 ========== */
@media (max-width: 360px) {
    .page-container {
        padding: 16px 12px 32px;
    }
    .glass-card {
        padding: 18px 14px;
    }
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
}

@media (min-width: 768px) {
    .page-container {
        padding: 40px 16px;
    }
}

/* ========== 滚动条美化 ========== */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 2px;
}

/* ========== 底部链接 ========== */
.footer-links {
    text-align: center;
    padding: 20px 0 10px;
}

.footer-links a {
    font-size: 13px;
    color: var(--gray-400);
    margin: 0 8px;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--primary);
}

/* ========== 结果面板 ========== */
.result-panel {
    display: none;
    margin-top: 16px;
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    text-align: center;
}

.result-panel.show {
    display: block;
}

.result-panel.success {
    background: #D1FAE5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

.result-panel.error {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FCA5A5;
}

.result-panel .result-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.result-panel .result-text {
    font-size: 15px;
    font-weight: 600;
}

.result-panel .result-sub {
    font-size: 13px;
    margin-top: 4px;
    opacity: 0.8;
}

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

.filter-bar .filter-btn {
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--gray-200);
    background: #fff;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.2s;
}

.filter-bar .filter-btn:active {
    transform: scale(0.95);
}

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

/* ========== 密码输入 ========== */
.password-input-wrap {
    position: relative;
}

.password-input-wrap .toggle-pwd {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--gray-400);
    padding: 4px;
}

/* ========== 语音播报指示器 ========== */
.speaking-indicator {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    margin-top: 12px;
    background: rgba(74, 108, 247, 0.08);
    border-radius: var(--radius-sm);
    color: var(--primary);
    font-size: 14px;
}

.speaking-indicator.show {
    display: flex;
}

.speaking-indicator .wave {
    width: 4px;
    height: 16px;
    background: var(--primary);
    border-radius: 2px;
    animation: wave 0.8s ease-in-out infinite;
}

.speaking-indicator .wave:nth-child(2) { animation-delay: 0.2s; }
.speaking-indicator .wave:nth-child(3) { animation-delay: 0.4s; }

@keyframes wave {
    0%, 100% { height: 8px; }
    50% { height: 20px; }
}

/* ========== Tab导航 ========== */
.tab-nav {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 4px;
}

.tab-nav .tab-item {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-500);
    text-decoration: none;
    transition: all 0.2s;
}

.tab-nav .tab-item.active {
    background: var(--primary);
    color: #fff;
}

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

/* ========== 筛选栏（记录页） ========== */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar .form-input {
    height: 36px;
    font-size: 13px;
}

.filter-bar .btn {
    height: 36px;
    width: auto;
    padding: 0 12px;
    font-size: 13px;
    white-space: nowrap;
}

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

.pagination .btn {
    height: 32px;
    font-size: 12px;
    padding: 0 10px;
}

/* ========== 网络状态指示器（顶部小条） ========== */
.net-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 6px 12px;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    z-index: 9999;
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.net-indicator.loading {
    background: var(--warning);
    color: #fff;
    transform: translateY(0);
    opacity: 1;
}

.net-indicator.error {
    background: var(--danger);
    color: #fff;
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.net-indicator.ok {
    background: var(--success);
    color: #fff;
    transform: translateY(0);
    opacity: 1;
}

.net-indicator.hidden {
    transform: translateY(-100%);
    opacity: 0;
}
