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

:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --success-color: #10b981;
    --error-color: #ef4444;
    --bg-color: #f9fafb;
    --card-bg: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.container {
    max-width: 600px;
    width: 100%;
    background: var(--card-bg);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    padding: 40px 30px;
    text-align: center;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 10px;
    font-weight: 700;
}

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

main {
    padding: 40px 30px;
}

.upload-section {
    margin-bottom: 30px;
}

.mode-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    background: var(--bg-color);
    padding: 8px;
    border-radius: 12px;
}

.mode-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: 2px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-btn svg {
    width: 20px;
    height: 20px;
}

.mode-btn:hover {
    background: white;
    color: var(--primary-color);
}

.mode-btn.active {
    background: white;
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.camera-section {
    margin-bottom: 20px;
}

.camera-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    border-radius: 16px;
    overflow: hidden;
    background: #000;
    aspect-ratio: 4/3;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

#video.active {
    display: block;
}

.camera-controls {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.btn-camera {
    flex: 1;
    min-width: 150px;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
}

.btn-camera svg {
    width: 20px;
    height: 20px;
}

.btn-camera:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-camera.btn-secondary {
    background: var(--error-color);
}

.btn-camera.btn-secondary:hover {
    background: #dc2626;
}

.upload-mode {
    margin-bottom: 20px;
}

.drop-zone {
    border: 3px dashed var(--border-color);
    border-radius: 16px;
    padding: 60px 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg-color);
}

.drop-zone:hover {
    border-color: var(--primary-color);
    background: #eef2ff;
}

.drop-zone.drag-over {
    border-color: var(--primary-color);
    background: #eef2ff;
    transform: scale(1.02);
}

.upload-icon {
    width: 64px;
    height: 64px;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.drop-text {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-weight: 600;
}

.drop-hint {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.preview-section {
    text-align: center;
    margin: 30px 0;
}

#imagePreview {
    max-width: 100%;
    max-height: 400px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.btn-primary, .btn-secondary {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    margin-top: 20px;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

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

.btn-secondary {
    background: var(--bg-color);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.loader {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

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

.result-section {
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-card {
    background: var(--bg-color);
    border-radius: 16px;
    padding: 40px 30px;
    text-align: center;
}

.result-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
}

.result-icon.success {
    background: #d1fae5;
    color: var(--success-color);
}

.result-icon.error {
    background: #fee2e2;
    color: var(--error-color);
}

#resultTitle {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.result-details {
    text-align: left;
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-top: 20px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.detail-label {
    font-weight: 600;
    color: var(--text-secondary);
}

.detail-value {
    font-weight: 600;
    color: var(--text-primary);
}

.detail-value.highlight {
    color: var(--primary-color);
    font-size: 1.1rem;
}

footer {
    background: var(--bg-color);
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

@media (max-width: 640px) {
    header h1 {
        font-size: 1.5rem;
    }
    
    .drop-zone {
        padding: 40px 20px;
    }
    
    main {
        padding: 30px 20px;
    }
}
