* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content {
    text-align: left;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

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

.btn-dashboard {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 12px 24px;
    border: 2px solid white;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    display: inline-block;
}

.btn-dashboard:hover {
    background: white;
    color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

main {
    padding: 40px;
    display: grid;
    /* Make video column slightly wider than results */
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    grid-template-areas:
        "video results"
        "feedback feedback"
        "info info";
    gap: 30px;
    align-items: flex-start;
}

.video-section {
    grid-area: video;
}

.results-section {
    grid-area: results;
}

.feedback-prompt {
    grid-area: feedback;
    width: 100%;
}

.info-section {
    grid-area: info;
}

.video-container {
    background: #000;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 20px;
    position: relative;
    /* Slightly reduce height so results are more likely to be visible without scrolling */
    padding-top: 50%; /* ~16:9 but a bit shorter */
}

#webcam {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Flip horizontally to match training data */
}

.controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.btn {
    padding: 12px 24px;
    font-size: 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

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

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

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

.btn-warning {
    background: #ffc107;
    color: #212529;
}

.model-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
}

.model-info label {
    font-weight: 600;
    color: #495057;
}

.model-display {
    font-size: 0.95rem;
    font-weight: 500;
    padding: 4px 12px;
    background: white;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.results-section {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 10px;
}

.results-section h2 {
    margin-bottom: 20px;
    color: #333;
}

.results-box {
    background: white;
    padding: 20px;
    border-radius: 8px;
    min-height: 100px;
}

.placeholder {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 20px;
}

.placeholder.success {
    color: #28a745;
    font-weight: 600;
}

.placeholder.error {
    color: #dc3545;
    font-weight: 600;
}

.placeholder.info {
    color: #17a2b8;
}

.prediction-details {
    margin-top: 20px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 12px;
    border-bottom: 1px solid #e9ecef;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-row .label {
    font-weight: 600;
    color: #495057;
}

.detail-row .value {
    color: #667eea;
    font-weight: 600;
}

.info-section {
    background: #e7f3ff;
    padding: 30px;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.info-section h3 {
    margin-bottom: 15px;
    color: #333;
}

.info-section ol {
    margin-left: 20px;
}

.info-section li {
    margin-bottom: 10px;
    line-height: 1.6;
}

footer {
    background: #f8f9fa;
    padding: 20px;
    text-align: center;
    color: #6c757d;
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        text-align: center;
        gap: 20px;
    }
    
    .header-content {
        text-align: center;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    /* Stack sections on small screens for readability */
    main {
        padding: 20px;
        grid-template-columns: 1fr;
        grid-template-areas:
            "video"
            "results"
            "feedback"
            "info";
    }
    
    .controls {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
}
