/* Variables et Design Tokens (Thème Écureuil) */
:root {
    --primary: #F26722;      /* Orange vif de l'écureuil */
    --primary-hover: #D95319;
    --danger: #E32613;       /* Rouge de l'alerte */
    --danger-bg: #FEE2E2;
    --warning: #F59E0B;
    --warning-bg: #FEF3C7;
    
    --bg-main: #D2EBE7;      /* Vert d'eau doux du fond */
    --bg-card: #FFFFFF;
    --text-main: #2B3A4A;    /* Bleu marine/Gris foncé (chapeau/gilet) */
    --text-muted: #5C7080;
    --border: #B2D8D2;       /* Vert d'eau plus soutenu pour les bordures */
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    --radius-full: 9999px;
    
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Automatique */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-main: #1A262C;      /* Bleu marine très foncé */
        --bg-card: #2B3A4A;      /* Bleu marine (couleur du chapeau) */
        --text-main: #F9FAFB;
        --text-muted: #A8B2C1;
        --border: #3A4E61;
        --danger-bg: rgba(227, 38, 19, 0.2);
        --warning-bg: rgba(245, 158, 11, 0.2);
    }
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Layout */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.app-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 40;
    box-shadow: var(--shadow-sm);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (min-width: 768px) {
    .header-content {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.logo-container {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.db-status {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-main);
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    width: fit-content;
}

.status-icon {
    height: 14px;
    width: auto;
}

.logo-icon {
    font-size: 1.5rem;
}

.mascot-header {
    height: 40px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.logo-text {
    font-weight: 700;
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--primary), #FF8C42);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.search-container {
    display: flex;
    gap: 0.5rem;
    flex: 1;
    max-width: 600px;
}

.search-input-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
}

.search-input-wrapper input {
    width: 100%;
    padding: 0.75rem 2.5rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--bg-main);
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
}

.search-input-wrapper input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.clear-btn {
    position: absolute;
    right: 1rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.scan-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: white;
    border: none;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.scan-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Main Content */
.app-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    flex: 1;
    width: 100%;
}

@media (min-width: 1024px) {
    .app-main {
        flex-direction: row;
        align-items: flex-start;
    }
}

/* Sidebar */
.sidebar {
    width: 100%;
}

@media (min-width: 1024px) {
    .sidebar {
        width: 250px;
        position: sticky;
        top: 6rem;
    }
}

.filters-panel {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.filters-panel h3 {
    margin-bottom: 1rem;
    font-size: 1.125rem;
    font-weight: 600;
}

.filter-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.select-wrapper select {
    width: 100%;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-main);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.875rem;
    cursor: pointer;
    appearance: none;
}

/* Results Section */
.results-section {
    flex: 1;
    min-width: 0; /* Empêche le débordement CSS Grid */
}

.results-header {
    margin-bottom: 1.5rem;
}

.results-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* Grid des rappels */
.recalls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* Card Produit */
.recall-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.recall-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.card-image-container {
    height: 160px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
    padding: 1rem;
}

.card-image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: var(--transition);
}

.recall-card:hover .card-image-container img {
    transform: scale(1.05);
}

.no-image {
    font-size: 2rem;
    color: var(--border);
}

.card-content {
    padding: 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.card-brand {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary);
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: auto;
}

.hazard-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--danger-bg);
    color: var(--danger);
    width: fit-content;
    margin-top: 0.5rem;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal-overlay.hidden {
    display: none;
    opacity: 0;
}

.modal {
    background: var(--bg-card);
    width: 100%;
    max-width: 500px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-large {
    max-width: 800px;
}

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

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

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.close-modal-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    border-radius: var(--radius-sm);
}

.close-modal-btn:hover {
    background: var(--bg-main);
    color: var(--text-main);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

#reader {
    width: 100%;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 2px dashed var(--border);
}

.scanner-help {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Détails Modal */
.details-layout {
    display: grid;
    gap: 2rem;
}

@media (min-width: 640px) {
    .details-layout {
        grid-template-columns: 300px 1fr;
    }
}

.details-image {
    width: 100%;
    background: #fff;
    border-radius: var(--radius-md);
    padding: 1rem;
    border: 1px solid var(--border);
}

.details-image img {
    width: 100%;
    height: auto;
}

.details-info h3 {
    color: var(--primary);
    font-size: 0.875rem;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.details-info h1 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

.info-block {
    background: var(--bg-main);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

.info-block.danger {
    background: var(--danger-bg);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.info-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.info-block.danger .info-label {
    color: var(--danger);
}

.info-value {
    font-size: 0.875rem;
}

/* Utilitaires */
.hidden {
    display: none !important;
}

.primary-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

.secondary-btn {
    background: var(--bg-main);
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

.pagination {
    display: flex;
    justify-content: center;
    margin-top: 2rem;
}

/* Loading & Empty states */
.loading-state, .empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.mascot-empty {
    height: 120px;
    width: auto;
    margin: 0 auto 1rem;
    object-fit: contain;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.spinner {
    border: 3px solid rgba(79, 70, 229, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
