* {
    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;
    color: #333;
}

.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.2rem;
    opacity: 0.9;
}

main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

@media (max-width: 768px) {
    main {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

.camera-section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.camera-container {
    position: relative;
    background: #f8f9fa;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 20px;
    aspect-ratio: 4/3;
}

#video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

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

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

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

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

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #0056b3;
}

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

.btn-success:hover:not(:disabled) {
    background: #1e7e34;
}

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

.btn-secondary:hover:not(:disabled) {
    background: #545b62;
}

.results-section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

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

#results-container {
    min-height: 200px;
}

.no-documents {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 40px 20px;
}

.document-item {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid #e9ecef;
}

.document-item img {
    width: 100%;
    max-width: 300px;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    margin-bottom: 10px;
}

.document-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.9rem;
}

.instructions {
    background: rgba(255,255,255,0.95);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

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

.instructions ol {
    margin-left: 20px;
}

.instructions li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #333;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

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

.status-message {
    background: #d4edda;
    color: #155724;
    padding: 10px 15px;
    border-radius: 5px;
    margin: 10px 0;
    border-left: 4px solid #28a745;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 10px 15px;
    border-radius: 5px;
    margin: 10px 0;
    border-left: 4px solid #dc3545;
}

/* Computer Vision Parameter Controls */
.cv-parameters {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin-top: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
}

.cv-parameters h3 {
    color: #333;
    margin-bottom: 20px;
    text-align: center;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.parameter-group {
    margin-bottom: 25px;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    border-left: 4px solid #667eea;
}

.parameter-group h4 {
    color: #495057;
    margin-bottom: 15px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.parameter-row {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    gap: 15px;
}

.parameter-row label {
    min-width: 120px;
    font-weight: 500;
    color: #495057;
    font-size: 0.9rem;
}

.parameter-row input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

.parameter-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.parameter-row input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.parameter-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #667eea;
    cursor: pointer;
}

.parameter-row span {
    min-width: 60px;
    font-weight: bold;
    color: #667eea;
    text-align: center;
    background: #e9ecef;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
}

.parameter-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #dee2e6;
}

.btn.btn-small {
    padding: 8px 16px;
    font-size: 0.85rem;
}

/* Performance indicator */
.performance-info {
    background: #e3f2fd;
    border: 1px solid #2196f3;
    border-radius: 8px;
    padding: 15px;
    margin-top: 15px;
}

.performance-info h4 {
    color: #1976d2;
    margin-bottom: 10px;
    font-size: 1rem;
}

.performance-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
}

.stat-item {
    background: white;
    padding: 8px 12px;
    border-radius: 4px;
    text-align: center;
    border: 1px solid #bbdefb;
}

.stat-label {
    font-size: 0.8rem;
    color: #666;
    display: block;
}

.stat-value {
    font-weight: bold;
    color: #1976d2;
    font-size: 1.1rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .cv-parameters {
        margin-top: 15px;
        padding: 15px;
    }
    
    .parameter-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .parameter-row label {
        min-width: auto;
    }
    
    .parameter-actions {
        flex-direction: column;
    }
    
    .performance-stats {
        grid-template-columns: 1fr;
    }
}
