* {
    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;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
    padding: 20px 0;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 8px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.subtitle {
    font-size: 1rem;
    opacity: 0.9;
}

main {
    background: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

#scanner-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto 20px;
    border-radius: 15px;
    overflow: hidden;
    background: #000;
    aspect-ratio: 1;
}

#video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#scanner-container::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    height: 60%;
    border: 3px solid rgba(255, 255, 255, 0.5);
    border-radius: 15px;
    pointer-events: none;
}

.camera-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 15px 0;
    padding: 15px;
    background: #f7fafc;
    border-radius: 10px;
}

.camera-selector label {
    font-weight: 600;
    color: #2d3748;
    font-size: 1rem;
}

.camera-select {
    flex: 1;
    max-width: 300px;
    padding: 10px 15px;
    font-size: 0.95rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    color: #2d3748;
    cursor: pointer;
    transition: all 0.3s ease;
}

.camera-select:hover {
    border-color: #667eea;
}

.camera-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 20px 0;
}

.btn {
    padding: 15px 30px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.btn span {
    font-size: 1.2rem;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #e53e3e;
    color: white;
}

.btn-secondary:hover {
    background: #c53030;
    transform: translateY(-2px);
}

.btn-primary:active, .btn-secondary:active {
    transform: translateY(0);
}

.status {
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
    text-align: center;
    font-weight: 600;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.status.success {
    background: #c6f6d5;
    color: #22543d;
    border: 2px solid #48bb78;
}

.status.error {
    background: #fed7d7;
    color: #742a2a;
    border: 2px solid #f56565;
}

#status-icon {
    font-size: 1.5rem;
    font-weight: bold;
}

.hidden {
    display: none !important;
}

#scan-history {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #e2e8f0;
}

#scan-history h3 {
    font-size: 1.2rem;
    color: #2d3748;
    margin-bottom: 15px;
}

#history-list {
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 8px;
    background: #f7fafc;
    border-left: 4px solid;
    transition: all 0.2s ease;
}

.history-item:hover {
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.history-item.valid {
    border-left-color: #48bb78;
}

.history-item.invalid {
    border-left-color: #f56565;
}

.history-icon {
    font-size: 1.5rem;
    font-weight: bold;
}

.history-item.valid .history-icon {
    color: #48bb78;
}

.history-item.invalid .history-icon {
    color: #f56565;
}

.history-info {
    flex: 1;
}

.history-code {
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 4px;
}

.history-time {
    font-size: 0.85rem;
    color: #718096;
}

/* Scrollbar personnalisée */
#history-list::-webkit-scrollbar {
    width: 8px;
}

#history-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

#history-list::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

#history-list::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

/* Responsive */
@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .btn {
        padding: 12px 24px;
        font-size: 0.9rem;
    }

    .camera-selector {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .camera-select {
        max-width: 100%;
    }

    #scan-history h3 {
        font-size: 1rem;
    }

    .history-code {
        font-size: 0.9rem;
    }
}

/* Animation de chargement */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Pulse animation pour le statut */
.status.success::before,
.status.error::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 10px;
    animation: pulse 0.5s ease-out;
    pointer-events: none;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(72, 187, 120, 0.7);
    }
    100% {
        box-shadow: 0 0 0 20px rgba(72, 187, 120, 0);
    }
}
