/* ============================================
   Variables CSS - Thème moderne et sobre
   ============================================ */
:root {
    /* Palette de couleurs */
    --primary-color: #2c7a7b;
    --primary-hover: #234e52;
    --primary-light: #e6f7f7;
    --secondary-color: #4a5568;
    --danger-color: #e53e3e;
    --danger-hover: #c53030;
    --success-color: #38a169;
    --warning-color: #dd6b20;

    /* Couleurs de fond */
    --bg-primary: #ffffff;
    --bg-secondary: #f7fafc;
    --bg-overlay: rgba(0, 0, 0, 0.7);

    /* Couleurs de texte */
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --text-muted: #a0aec0;

    /* Bordures */
    --border-color: #e2e8f0;
    --border-radius: 12px;
    --border-radius-sm: 8px;

    /* Ombres */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

    /* Espacements */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    /* Animations */
    --transition-fast: 150ms ease;
    --transition-normal: 300ms ease;
}

/* ============================================
   Reset et base
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ============================================
   En-tête de l'application
   ============================================ */
.app-header {
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: var(--spacing-sm) var(--spacing-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.logo-emoji {
    font-size: 2rem;
    line-height: 1;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
}

.icon-button {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.icon-button:hover {
    background-color: var(--bg-secondary);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

/* ============================================
   Conteneur principal
   ============================================ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-lg);
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-lg);
}

@media (min-width: 768px) {
    .container {
        grid-template-columns: 1fr 1fr;
    }
}

/* ============================================
   Section scanner
   ============================================ */
.scanner-section {
    background-color: var(--bg-primary);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-md);
}

.video-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    background-color: #000;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    margin-bottom: var(--spacing-md);
}

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

/* Overlay de scan avec cadre */
.scan-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.scan-frame {
    width: 70%;
    height: 70%;
    border: 3px solid var(--primary-color);
    border-radius: var(--border-radius-sm);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.3);
    position: relative;
}

/* Coins du cadre de scan */
.scan-frame::before,
.scan-frame::after {
    content: '';
    position: absolute;
    width: 30px;
    height: 30px;
    border: 4px solid var(--success-color);
}

.scan-frame::before {
    top: -3px;
    left: -3px;
    border-right: none;
    border-bottom: none;
    border-top-left-radius: var(--border-radius-sm);
}

.scan-frame::after {
    top: -3px;
    right: -3px;
    border-left: none;
    border-bottom: none;
    border-top-right-radius: var(--border-radius-sm);
}

/* Status de scan */
.scan-status {
    position: absolute;
    bottom: var(--spacing-md);
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 0.9rem;
    backdrop-filter: blur(10px);
}

.status-icon {
    font-size: 1.2rem;
}

.scan-status.scanning {
    background-color: rgba(44, 122, 123, 0.9);
}

.scan-status.success {
    background-color: rgba(56, 161, 105, 0.9);
}

.scan-status.error {
    background-color: rgba(229, 62, 62, 0.9);
}

/* Animation de scanning */
@keyframes scan-animation {
    0%, 100% {
        border-color: var(--primary-color);
    }
    50% {
        border-color: var(--success-color);
    }
}

.scan-frame.scanning {
    animation: scan-animation 1.5s ease-in-out infinite;
}

/* ============================================
   Contrôles
   ============================================ */
.controls {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: center;
}

.button {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-md);
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

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

.button-primary {
    background-color: var(--primary-color);
    color: white;
}

.button-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.button-secondary {
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.button-secondary:hover:not(:disabled) {
    background-color: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
}

/* ============================================
   Section historique
   ============================================ */
.history-section {
    background-color: var(--bg-primary);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    max-height: 600px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 2px solid var(--border-color);
}

.history-header h2 {
    font-size: 1.25rem;
    color: var(--text-primary);
    font-weight: 700;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

/* État vide */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl);
    text-align: center;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-sm);
    opacity: 0.5;
}

.empty-subtitle {
    font-size: 0.9rem;
    margin-top: var(--spacing-xs);
}

/* Élément d'historique */
.history-item {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: var(--spacing-sm);
    display: flex;
    gap: var(--spacing-sm);
    align-items: flex-start;
    transition: all var(--transition-fast);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.history-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.history-item-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.history-item-content {
    flex: 1;
    min-width: 0;
}

.history-item-url {
    display: block;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    word-break: break-all;
    margin-bottom: var(--spacing-xs);
}

.history-item-url:hover {
    text-decoration: underline;
}

.history-item-time {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.history-item-delete {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-fast);
    font-size: 1.25rem;
    line-height: 1;
}

.history-item-delete:hover {
    background-color: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
}

/* ============================================
   Modal d'aide
   ============================================ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--spacing-md);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: var(--bg-primary);
    border-radius: var(--border-radius);
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin: 0;
}

.close-button {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--spacing-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
}

.close-button:hover {
    background-color: var(--bg-secondary);
    color: var(--danger-color);
}

.modal-body {
    padding: var(--spacing-md);
    overflow-y: auto;
}

.help-section {
    margin-bottom: var(--spacing-lg);
}

.help-section:last-child {
    margin-bottom: 0;
}

.help-section h3 {
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-bottom: var(--spacing-sm);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.help-section ol,
.help-section ul {
    margin-left: var(--spacing-md);
}

.help-section li {
    margin-bottom: var(--spacing-xs);
    line-height: 1.6;
}

.help-section p {
    line-height: 1.6;
    color: var(--text-secondary);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 767px) {
    .container {
        padding: var(--spacing-sm);
    }

    .app-header {
        padding: var(--spacing-xs) var(--spacing-sm);
    }

    .logo h1 {
        font-size: 1.25rem;
    }

    .history-section {
        max-height: 400px;
    }
}

/* ============================================
   Scrollbar personnalisée
   ============================================ */
.history-list::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.history-list::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

.history-list::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.history-list::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================
   Animations et transitions
   ============================================ */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.scanning .status-icon {
    animation: pulse 1.5s ease-in-out infinite;
}