/* 全域樣式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 標題區域 */
header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* 示範區域 */
.demo-container {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 30px;
}

.video-wrapper {
    position: relative;
    width: 640px;
    height: 480px;
    margin: 0 auto 20px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

#webcam {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* 鏡像顯示 */
}

#output {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* 控制按鈕 */
.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

button {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

select {
    background: white;
    border: 2px solid #667eea;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    outline: none;
}

select:focus {
    border-color: #764ba2;
    box-shadow: 0 0 5px rgba(102, 126, 234, 0.3);
}

label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    cursor: pointer;
    background: white;
    padding: 12px 16px;
    border: 2px solid #667eea;
    border-radius: 8px;
    transition: all 0.3s ease;
}

label:hover {
    background: #f8f9fa;
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* 資訊區域 */
.info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    flex-wrap: wrap;
    gap: 10px;
}

.status {
    font-weight: 500;
    color: #495057;
}

.fps {
    font-family: 'Courier New', monospace;
    background: #28a745;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.9rem;
}

/* 說明區域 */
.instructions {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.instructions h3 {
    color: #495057;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.instructions ul {
    list-style: none;
    padding-left: 0;
}

.instructions li {
    padding: 8px 0;
    padding-left: 25px;
    position: relative;
    color: #6c757d;
    line-height: 1.5;
}

.instructions li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #28a745;
    font-weight: bold;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .video-wrapper {
        width: 100%;
        height: auto;
        aspect-ratio: 4/3;
        max-width: 640px;
    }
    
    .controls {
        flex-direction: column;
        align-items: center;
    }
    
    button, select {
        width: 100%;
        max-width: 300px;
    }
    
    .info {
        flex-direction: column;
        text-align: center;
    }
    
    .demo-container {
        padding: 20px;
    }
}

/* 載入動畫 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

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

/* 錯誤狀態 */
.error {
    background: #dc3545;
    color: white;
}

.success {
    background: #28a745;
    color: white;
}