/* Reset and base styles */
* {
    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;
    line-height: 1.6;
    color: #333;
}

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

/* Header */
header {
    text-align: center;
    padding: 20px 0;
    color: white;
    margin-bottom: 20px;
}

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

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

/* Step containers */
.step {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
}

.step h2 {
    color: #2196F3;
    margin-bottom: 20px;
    font-size: 1.5rem;
    border-bottom: 2px solid #e3f2fd;
    padding-bottom: 10px;
}

/* Camera and video */
.camera-container {
    position: relative;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 20px;
}

#cameraFeed, #recordedVideo {
    width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: cover;
    display: block;
}

/* Controls */
.controls, .processing-controls, .result-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.btn {
    padding: 15px 20px;
    border: none;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    position: relative;
    overflow: hidden;
}

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

.btn-primary {
    background: linear-gradient(45deg, #2196F3, #21CBF3);
    color: white;
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.3);
}

.btn-success {
    background: linear-gradient(45deg, #4CAF50, #8BC34A);
    color: white;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.btn-danger {
    background: linear-gradient(45deg, #f44336, #ff7043);
    color: white;
    box-shadow: 0 4px 15px rgba(244, 67, 54, 0.3);
}

.btn-secondary {
    background: linear-gradient(45deg, #607D8B, #90A4AE);
    color: white;
    box-shadow: 0 4px 15px rgba(96, 125, 139, 0.3);
}

.btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.6;
}

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

/* Instructions */
.instructions {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 15px;
    border-left: 4px solid #2196F3;
}

.instructions h3 {
    color: #2196F3;
    margin-bottom: 10px;
}

.instructions ul {
    padding-left: 20px;
}

.instructions li {
    margin-bottom: 8px;
    color: #555;
}

/* Processing controls */
.processing-controls label {
    font-weight: bold;
    color: #555;
}

.processing-controls input[type="range"] {
    width: 100%;
    margin: 10px 0;
}

#frameRateValue {
    background: #2196F3;
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-weight: bold;
}

/* Progress bar */
.progress-container {
    margin: 20px 0;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.progress {
    height: 100%;
    background: linear-gradient(45deg, #4CAF50, #8BC34A);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

#progressText {
    text-align: center;
    margin-top: 10px;
    font-weight: bold;
    color: #555;
}

/* Frames grid */
.frames-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 10px;
}

.frame-thumbnail {
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
}

.frame-thumbnail:hover {
    transform: scale(1.05);
}

/* Result container */
.result-container {
    text-align: center;
    margin-bottom: 20px;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
}

#resultCanvas {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

/* Status messages */
.status {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    z-index: 1000;
    display: none;
    backdrop-filter: blur(10px);
}

.status.show {
    display: block;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Responsive design */
@media (min-width: 768px) {
    .container {
        max-width: 800px;
        padding: 20px;
    }
    
    .controls, .processing-controls, .result-controls {
        flex-direction: row;
        justify-content: center;
        align-items: center;
    }
    
    .btn {
        flex: 1;
        max-width: 200px;
    }
    
    .frames-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
    }
    
    header p {
        font-size: 1rem;
    }
    
    .step {
        padding: 15px;
    }
    
    .btn {
        padding: 12px 15px;
        font-size: 1rem;
    }
}

/* Loading animation */
.loading {
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2196F3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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