/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #3b82f6;
    --secondary-color: #6b7280;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #06b6d4;
    --background-color: #f8fafc;
    --surface-color: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* 顶部导航栏 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 30px;
}

.header h1 {
    color: var(--primary-color);
    font-size: 28px;
    font-weight: 700;
}

.status {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 14px;
}

.status-offline {
    background: var(--danger-color);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-online {
    background: var(--success-color);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    animation: pulse 2s infinite;
}

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

/* 主要内容区域 */
.main-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 25px;
    align-items: start;
}

/* 视频区域 */
.video-section {
    background: var(--surface-color);
    border-radius: 16px;
    padding: 30px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.video-container {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    background: #000;
    margin-bottom: 25px;
    aspect-ratio: 16/9;
    width: 100%;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

#video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 16px;
}

#canvas {
    position: absolute;
    top: 0;
    left: 0;
    max-width: 100%;
    max-height: 100%;
    pointer-events: none;
    object-fit: contain;
    border-radius: 16px;
}

.video-overlay {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 10;
}

.count-display {
    background: rgba(59, 130, 246, 0.95);
    color: white;
    padding: 12px 20px;
    border-radius: 30px;
    font-weight: 700;
    font-size: 16px;
    backdrop-filter: blur(15px);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

/* 控制面板 */
.control-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 15px;
    justify-content: center;
    margin-top: 10px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    min-height: 50px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.btn:not(:disabled):hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.btn:not(:disabled):active {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
}

.btn-primary:not(:disabled):hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
}

.btn-secondary {
    background: linear-gradient(135deg, #6b7280, #4b5563);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.btn-info {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.btn-outline {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.3);
}

.btn-icon {
    font-size: 18px;
}

/* 数据看板 */
.dashboard {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 380px;
}

.dashboard-card {
    background: var(--surface-color);
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

.dashboard-card h3 {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dashboard-card h3::before {
    content: '';
    width: 4px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 2px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.stat-item {
    text-align: center;
    padding: 20px 15px;
    background: linear-gradient(135deg, var(--background-color), rgba(59, 130, 246, 0.05));
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.stat-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.1);
}

.stat-value {
    display: block;
    font-size: 32px;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 8px;
    line-height: 1;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

/* 人脸库管理 */
.face-library {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.face-count {
    text-align: center;
    padding: 15px;
    background: linear-gradient(135deg, var(--success-color), #059669);
    color: white;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.2);
}

/* 抽选历史 */
.selection-history {
    max-height: 250px;
    overflow-y: auto;
    padding: 5px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

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

.history-item:hover {
    background: var(--background-color);
    border-radius: 8px;
    padding-left: 10px;
    padding-right: 10px;
}

.history-name {
    font-weight: 700;
    color: var(--text-primary);
}

.history-time {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--background-color);
    padding: 4px 8px;
    border-radius: 12px;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 30px 20px;
    background: var(--background-color);
    border-radius: 12px;
    border: 2px dashed var(--border-color);
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    animation: modalFadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--surface-color);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    width: 90%;
    animation: modalSlideIn 0.3s ease;
}

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

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

.modal-header h2 {
    margin: 0;
    color: var(--primary-color);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--background-color);
    color: var(--text-primary);
}

.modal-body {
    padding: 25px;
}

.selected-person {
    display: flex;
    align-items: center;
    gap: 20px;
    text-align: left;
}

.person-avatar {
    width: 60px;
    height: 60px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    animation: selectedPulse 1s infinite;
}

@keyframes selectedPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.person-info h3 {
    margin: 0 0 5px 0;
    color: var(--text-primary);
}

.person-info p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 20px 25px;
    border-top: 1px solid var(--border-color);
    justify-content: flex-end;
}

/* 加载指示器 */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(248, 250, 252, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
}

.loading.hidden {
    display: none;
}

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

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

.loading p {
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 500;
}

/* 键盘快捷键提示 */
.keyboard-hints {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 15px;
    border-radius: 8px;
    font-size: 12px;
    z-index: 100;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.keyboard-hints:hover {
    opacity: 1;
}

.hint-item {
    margin-bottom: 5px;
}

.hint-item:last-child {
    margin-bottom: 0;
}

/* 人脸识别框样式 */
.face-box {
    position: absolute;
    border: 3px solid var(--success-color);
    border-radius: 4px;
    background: rgba(16, 185, 129, 0.1);
    backdrop-filter: blur(2px);
    animation: faceDetected 0.3s ease;
}

@keyframes faceDetected {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.face-label {
    position: absolute;
    top: -25px;
    left: 0;
    background: var(--success-color);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: var(--shadow);
}

.face-box.selected {
    border-color: var(--warning-color);
    background: rgba(245, 158, 11, 0.2);
    animation: selectedFace 1s infinite;
}

.face-box.selected .face-label {
    background: var(--warning-color);
    animation: selectedLabel 1s infinite;
}

@keyframes selectedFace {
    0%, 100% { 
        border-color: var(--warning-color);
        transform: scale(1);
    }
    50% { 
        border-color: var(--danger-color);
        transform: scale(1.05);
    }
}

@keyframes selectedLabel {
    0%, 100% { background: var(--warning-color); }
    50% { background: var(--danger-color); }
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 25px;
    }
    
    .dashboard {
        order: -1;
        max-width: 100%;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 20px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
        padding: 15px 0;
    }
    
    .header h1 {
        font-size: 24px;
    }
    
    .control-panel {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .btn {
        font-size: 13px;
        padding: 12px 16px;
        min-height: 45px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .video-section {
        padding: 20px;
    }
    
    .dashboard {
        grid-template-columns: 1fr;
    }
    
    .dashboard-card {
        padding: 20px;
    }
    
    .keyboard-hints {
        position: relative;
        bottom: auto;
        right: auto;
        margin-top: 20px;
        background: var(--surface-color);
        color: var(--text-secondary);
        border: 1px solid var(--border-color);
        opacity: 1;
    }
}

@media (max-width: 480px) {
    .modal-content {
        margin: 20px;
        width: calc(100% - 40px);
    }
    
    .selected-person {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .control-panel {
        grid-template-columns: 1fr;
    }
    
    .btn {
        font-size: 14px;
        padding: 14px 20px;
    }
    
    .header h1 {
        font-size: 20px;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* 焦点状态 */
.btn:focus,
input:focus,
button:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* 打印样式 */
@media print {
    .keyboard-hints,
    .control-panel,
    .loading {
        display: none !important;
    }
}

/* 图表容器样式 */
#peopleChart {
    max-width: 100% !important;
    max-height: 200px !important;
    width: 100% !important;
    height: 200px !important;
}

.chart-container {
    position: relative;
    height: 200px;
    width: 100%;
    overflow: hidden;
    background: var(--background-color);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid var(--border-color);
} 