* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px 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, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* PWA 支持 */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

/* PWA 全屏模式樣式 */
@media (display-mode: standalone) {
    body {
        /* 全屏模式下的額外樣式 */
    }
    
    .app-header {
        padding-top: env(safe-area-inset-top);
    }
    
    .app-footer {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

.app-container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--bg-color);
    display: flex;
    flex-direction: column;
}

/* 头部样式 */
.app-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 {
    font-size: 24px;
    margin-bottom: 15px;
    font-weight: 600;
}

.name-input {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--text-primary);
}

.name-input::placeholder {
    color: var(--text-secondary);
}

/* 主内容区域 */
.main-content {
    flex: 1;
    padding: 20px;
    padding-bottom: 100px;
}

/* 卡片样式 */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fafafa;
}

.card-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: 20px;
}

/* 按钮样式 */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:not(:disabled):hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--text-secondary);
    color: white;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-large {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    margin-bottom: 10px;
}

.btn-large:last-child {
    margin-bottom: 0;
}

/* 状态消息 */
.status-message {
    padding: 12px;
    background: #f3f4f6;
    border-radius: 8px;
    color: var(--text-secondary);
    text-align: center;
    font-size: 14px;
}

/* 位置資訊 */
.location-info {
    margin-top: 15px;
}

/* 地圖容器 */
.map-container {
    margin: 15px 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
    position: relative;
}

.map {
    width: 100%;
    height: 200px;
    background: #e5e7eb;
}

/* GPS 驗證狀態 */
.gps-verification {
    margin: 10px 0;
    padding: 10px;
    border-radius: 8px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.gps-verification.verified {
    background: #d1fae5;
    color: #065f46;
}

.gps-verification.suspicious {
    background: #fef3c7;
    color: #92400e;
}

.gps-verification.fake {
    background: #fee2e2;
    color: #991b1b;
}

.gps-verification-icon {
    font-size: 16px;
}

/* Google Maps API 狀態 */
.maps-api-status {
    margin: 10px 0;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    text-align: center;
}

.maps-api-status.success {
    background: #d1fae5;
    color: #065f46;
}

.maps-api-status.error {
    background: #fee2e2;
    color: #991b1b;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.info-item:last-child {
    border-bottom: none;
}

.label {
    font-weight: 500;
    color: var(--text-secondary);
}

/* 相机预览 */
.camera-preview {
    margin: 15px 0;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
}

.camera-preview video {
    width: 100%;
    height: auto;
    display: block;
}

/* 照片预览 */
.photo-preview {
    margin: 15px 0;
    text-align: center;
}

.photo-preview img {
    width: 100%;
    max-width: 300px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 15px;
}

/* 考勤类型 */
.attendance-type {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* 考勤历史 */
.attendance-history {
    max-height: 300px;
    overflow-y: auto;
}

.attendance-item {
    padding: 15px;
    background: #f9fafb;
    border-radius: 8px;
    margin-bottom: 10px;
    border-left: 4px solid var(--primary-color);
}

.attendance-item.check-out {
    border-left-color: var(--warning-color);
}

.attendance-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.attendance-time {
    font-weight: 600;
    color: var(--text-primary);
}

.attendance-type-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.attendance-type-badge.check-in {
    background: #d1fae5;
    color: #065f46;
}

.attendance-type-badge.check-out {
    background: #fef3c7;
    color: #92400e;
}

.attendance-details {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 5px;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

/* 底部提交按钮 */
.app-footer {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    padding: 15px 20px;
    background: white;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.btn-submit {
    width: 100%;
    padding: 16px;
    font-size: 18px;
    font-weight: 600;
    background: var(--primary-color);
    color: white;
}

.btn-submit:not(:disabled):hover {
    background: var(--primary-dark);
}

/* 加载遮罩 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    color: white;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toast 提示 */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 25px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 2000;
    animation: slideDown 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.toast-success {
    background: var(--success-color);
}

.toast-error {
    background: var(--error-color);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* 响应式设计 */
@media (max-width: 480px) {
    .app-header h1 {
        font-size: 20px;
    }
    
    .card-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .card-header .btn {
        width: 100%;
    }
}

/* 滚动条样式 */
.attendance-history::-webkit-scrollbar {
    width: 6px;
}

.attendance-history::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.attendance-history::-webkit-scrollbar-thumb {
    background: var(--text-secondary);
    border-radius: 10px;
}

.attendance-history::-webkit-scrollbar-thumb:hover {
    background: var(--text-primary);
}

