/* Variables CSS */
:root {
    --primary-color: #2E7D32;
    --primary-dark: #1B5E20;
    --secondary-color: #1976D2;
    --accent-color: #FF9800;
    --success-color: #4CAF50;
    --warning-color: #FF9800;
    --error-color: #F44336;
    --text-primary: #212121;
    --text-secondary: #757575;
    --background: #FAFAFA;
    --surface: #FFFFFF;
    --border: #E0E0E0;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --header-height: 60px;
    --nav-height: 70px;
}

/* Reset et base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Corrections iOS - permettre le scroll */
    width: 100%;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

/* Top Bar for Authentication */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--primary-color);
    color: white;
    z-index: 1001;
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 50px;
    box-shadow: var(--shadow);
}

.home-link {
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: opacity 0.3s ease;
}

.home-link:hover {
    opacity: 0.8;
}

.auth-section {
    display: flex;
    align-items: center;
}

.user-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 0.8rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

.user-name {
    color: white;
    font-size: 13px;
    font-weight: 500;
}

.btn-logout {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 0.3rem 0.8rem;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

/* Header */
.app-header {
    position: fixed;
    top: 50px;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--primary-color);
    color: white;
    z-index: 1000;
    box-shadow: var(--shadow);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    height: 100%;
}

.header-icon {
    font-size: 20px;
    margin-right: 8px;
}

.header-text h1 {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.5px;
}

.header-text p {
    font-size: 10px;
    opacity: 0.9;
    margin: 0;
    font-weight: 400;
}

.header-status {
    display: flex;
    align-items: center;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #f44336;
    transition: background-color 0.3s ease;
}

.status-dot.online {
    background: #4CAF50;
}

.status-dot.offline {
    background: #f44336;
}

/* Main Content */
.app-main {
    margin-top: calc(50px + var(--header-height));
    margin-bottom: var(--nav-height);
    min-height: calc(100vh - 50px - var(--header-height) - var(--nav-height));
    background: var(--background);
    padding-bottom: 60px;
    /* Scroll moins sensible - il faut vraiment atteindre le bas pour retourner en haut */
    overscroll-behavior-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Empêcher le retour automatique trop sensible */
    scroll-behavior: smooth;
}

/* Zone Management Modal - Style cohérent avec l'application */
.zone-add-section {
    margin-bottom: 24px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.zone-add-section h4 {
    margin: 0 0 16px 0;
    color: #2E7D32;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.zone-add-section h4::before {
    content: "➕";
    font-size: 14px;
}

.zone-input-container {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.zone-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    background: white;
    transition: border-color 0.3s ease;
}

.zone-input:focus {
    outline: none;
    border-color: #2E7D32;
}

.zone-input::placeholder {
    color: #999;
}

.zone-add-btn {
    padding: 12px 20px;
    background: #2E7D32;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.3s ease;
}

.zone-add-btn:hover {
    background: #1B5E20;
}

.zone-list-section h4 {
    margin: 0 0 16px 0;
    color: #2E7D32;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.zone-list-section h4::before {
    content: "📋";
    font-size: 14px;
}

.zone-list {
    max-height: 300px;
    overflow-y: auto;
}

.zone-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    margin-bottom: 8px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.zone-item:last-child {
    margin-bottom: 0;
}

.zone-item:hover {
    border-color: #2E7D32;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.zone-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.zone-name {
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.zone-code {
    font-size: 12px;
    color: #666;
    font-family: 'Courier New', monospace;
}

.zone-type {
    font-size: 10px;
    color: #888;
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 10px;
    display: inline-block;
    margin-top: 2px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    width: fit-content;
}

.zone-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.zone-edit-btn {
    padding: 6px 10px;
    background: #2E7D32;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
}

.zone-edit-btn:hover {
    background: #1B5E20;
}

.zone-delete-btn {
    padding: 6px 10px;
    background: #f44336;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
}

.zone-delete-btn:hover {
    background: #d32f2f;
}

.zone-delete-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.zone-item.default {
    background: #f0f8f0;
    border-color: #c8e6c9;
}

.zone-item.default .zone-name {
    color: #2E7D32;
}

.zone-item.default .zone-type {
    background: #c8e6c9;
    color: #1B5E20;
}

/* Responsive pour la modal */
@media (max-width: 480px) {
    .zone-input-container {
        flex-direction: column;
        gap: 10px;
    }
    
    .zone-add-btn {
        width: 100%;
    }
    
    .zone-item {
        padding: 10px 12px;
    }
    
    .zone-actions {
        gap: 4px;
    }
    
    .zone-edit-btn,
    .zone-delete-btn {
        min-width: 28px;
        height: 28px;
        padding: 4px 8px;
        font-size: 11px;
    }
}

/* Product Details Modal - Style cohérent avec la modal de gestion des zones */
.product-details-container {
    padding: 0;
}

.product-main-info {
    margin-bottom: 24px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.product-title {
    font-size: 18px;
    font-weight: 600;
    color: #2E7D32;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.product-title::before {
    content: "📦";
    font-size: 16px;
}

.product-status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    display: inline-block;
}

.product-status-badge.expired {
    background: #FFEBEE;
    color: #C62828;
    border: 1px solid #FFCDD2;
}

.product-status-badge.warning {
    background: #FFF3E0;
    color: #E65100;
    border: 1px solid #FFCC02;
}

.product-status-badge.caution {
    background: #FFFDE7;
    color: #F57F17;
    border: 1px solid #FFF176;
}

.product-status-badge.ok {
    background: #E8F5E8;
    color: #2E7D32;
    border: 1px solid #C8E6C9;
}

.product-info-grid {
    display: grid;
    gap: 8px;
    margin-bottom: 24px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.info-item:hover {
    border-color: #2E7D32;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.info-label {
    font-weight: 500;
    color: #333;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.info-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.info-value {
    font-weight: 600;
    color: #333;
    font-size: 14px;
    text-align: right;
    margin-left: auto;
    flex-shrink: 0;
}

.product-actions-section {
    display: flex;
    gap: 8px;
    padding: 0;
}

.action-btn-modal {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.edit-btn-modal {
    background: #2E7D32;
    color: white;
}

.edit-btn-modal:hover {
    background: #1B5E20;
}

.delete-btn-modal {
    background: #f44336;
    color: white;
}

.delete-btn-modal:hover {
    background: #d32f2f;
}

.btn-icon {
    font-size: 16px;
}

/* Responsive pour la modal de détails produit */
@media (max-width: 480px) {
    .product-main-info {
        padding: 16px;
    }
    
    .product-title {
        font-size: 16px;
    }
    
    .info-item {
        padding: 8px 12px;
    }
    
    .info-label {
        font-size: 12px;
    }
    
    .info-value {
        font-size: 12px;
        text-align: right;
    }
    
    .product-actions-section {
        flex-direction: column;
        gap: 8px;
    }
    
    .action-btn-modal {
        padding: 12px 16px;
        font-size: 14px;
    }
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Main Content - règle supprimée car dupliquée plus haut */

/* Onglets */
.tab-content {
    display: none;
    padding: 20px;
    animation: fadeIn 0.3s ease-in-out;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Formulaire de scan */
.form-container {
    max-width: 400px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    font-size: 15px;
}

/* Champ produit */
.input-with-button {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.input-with-button input {
    flex: 1;
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    background: var(--surface);
    transition: border-color 0.3s ease;
}

.input-with-button input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.scan-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    padding: 0;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
    flex-shrink: 0;
}

.scan-btn:hover {
    background: #1565C0;
}

.scan-icon {
    width: 28px;
    height: 20px;
    color: white;
    display: block;
}

/* Suggestions de produits */
.product-suggestions {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-top: 8px;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background-color 0.2s ease;
}

.suggestion-item:hover {
    background: #f5f5f5;
}

.suggestion-item:last-child {
    border-bottom: none;
}

/* Sélection */
.selection-display {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    min-height: 60px;
}

.selection-icon {
    font-size: 20px;
    color: var(--text-secondary);
}

.selection-text {
    flex: 1;
    color: var(--text-secondary);
    font-style: italic;
}

.selection-display.has-product {
    border-color: var(--success-color);
    background: #E8F5E8;
}

.selection-display.has-product .selection-text {
    color: var(--text-primary);
    font-style: normal;
    font-weight: 500;
}

.clear-btn {
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 14px;
    display: none;
}

.selection-display.has-product .clear-btn {
    display: block;
}

/* Quantité */
.quantity-container {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    padding: 16px;
    border-radius: 12px;
    border: 2px solid var(--border);
}

.quantity-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s ease;
    /* Empêcher spécifiquement le zoom sur ces boutons */
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* Empêcher le zoom sur double-tap */
    -webkit-tap-highlight-color: transparent;
    /* Centrage simple et efficace */
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    margin: 0;
    /* Police système pour meilleur rendu */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}

.quantity-btn:hover {
    background: var(--primary-dark);
}

.quantity-slider {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: var(--border);
    outline: none;
    -webkit-appearance: none;
}

.quantity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
}

.quantity-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
}

.quantity-number {
    width: 80px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    text-align: center;
    font-size: 16px;
}

/* Zone */
.zone-container {
    display: flex;
    gap: 8px;
}

.zone-container select {
    flex: 1;
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    background: var(--surface);
}

.add-zone-btn {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 12px;
    background: var(--accent-color);
    color: white;
    font-size: 20px;
    cursor: pointer;
}

.custom-zone-input {
    width: 100%;
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    margin-top: 8px;
}

/* Date */
.date-container {
    display: flex;
    gap: 12px;
}

.date-container select {
    flex: 1;
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    background: var(--surface);
}

/* Bouton enregistrer */
.save-button {
    width: 100%;
    padding: 14px;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 12px;
    transition: background-color 0.3s ease;
}

.save-button:hover {
    background: #1565C0;
}

.save-button:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
}

/* Onglet Produits */
.products-container {
    max-width: 600px;
    margin: 0 auto;
}

.filters-container {
    background: var(--surface);
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.filter-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.filter-select {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
}

.search-row {
    display: flex;
    gap: 12px;
}

.search-input {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
}

.clear-filters-btn {
    padding: 12px 16px;
    background: var(--text-secondary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}

/* Liste des produits */
.products-list {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    max-height: 400px;
    overflow-y: auto;
}

.product-item {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.product-item:hover {
    background-color: #f8f9fa;
}

.product-item:last-child {
    border-bottom: none;
}

.product-info {
    flex: 1;
}

.product-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.product-details {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.product-expiry {
    font-size: 11px;
    color: var(--text-secondary);
    font-style: italic;
}

.product-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.product-status {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.action-buttons {
    display: flex;
    gap: 4px;
}

.action-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.edit-btn {
    background: var(--secondary-color);
    color: white;
}

.edit-btn:hover {
    background: #1565C0;
    transform: scale(1.1);
}

.delete-btn {
    background: var(--error-color);
    color: white;
}

.delete-btn:hover {
    background: #D32F2F;
    transform: scale(1.1);
}

.product-status.expired {
    background: #FFEBEE;
    color: #C62828;
}

.product-status.warning {
    background: #FFF3E0;
    color: #E65100;
}

.product-status.caution {
    background: #FFFDE7;
    color: #F57F17;
}

.product-status.ok {
    background: #E8F5E8;
    color: #2E7D32;
}

/* Stats rapides */
.quick-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.stat-item {
    background: var(--surface);
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-number {
    display: block;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 10px;
    color: var(--text-secondary);
}

.stat-item.expired .stat-number {
    color: var(--error-color);
}

.stat-item.warning .stat-number {
    color: var(--warning-color);
}

.stat-item.caution .stat-number {
    color: #F57F17;
}

.stat-item.ok .stat-number {
    color: var(--success-color);
}

/* Onglet Paramètres */
.settings-container {
    max-width: 400px;
    margin: 0 auto;
}

.settings-group {
    background: var(--surface);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.settings-group h3 {
    margin-bottom: 16px;
    color: var(--text-primary);
    font-size: 16px;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.setting-item:last-child {
    margin-bottom: 0;
}

/* Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.settings-btn {
    width: 100%;
    padding: 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 8px;
    transition: background-color 0.3s ease;
}

.settings-btn:hover {
    background: var(--primary-dark);
}

.settings-btn.danger {
    background: var(--error-color);
}

.settings-btn.danger:hover {
    background: #D32F2F;
}

.settings-info-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}

/* Modal Scanner */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    padding: 20px;
    box-sizing: border-box;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: calc(100vh - 40px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
    color: var(--text-primary);
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.camera-container {
    position: relative;
    width: 100%;
    height: 300px;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 16px;
}

#scannerVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scanner-frame {
    width: 200px;
    height: 200px;
    border: 2px solid #00FF00;
    border-radius: 8px;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.5);
}

.scanner-status {
    text-align: center;
    padding: 12px;
    background: var(--background);
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--text-primary);
}

.scanner-controls {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.scanner-btn {
    padding: 12px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}

.scanner-btn:hover {
    background: var(--primary-dark);
}

/* Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 1000;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-secondary);
}

.nav-item.active {
    color: var(--primary-color);
    background: rgba(46, 125, 50, 0.1);
}

.nav-icon {
    font-size: 20px;
    margin-bottom: 4px;
}

.nav-label {
    font-size: 12px;
    font-weight: 500;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: calc(var(--header-height) + 20px);
    left: 20px;
    right: 20px;
    z-index: 3000;
    pointer-events: none;
}

.toast {
    background: var(--surface);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 8px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary-color);
    animation: slideIn 0.3s ease-out;
    pointer-events: auto;
}

.toast.success {
    border-left-color: var(--success-color);
}

.toast.error {
    border-left-color: var(--error-color);
}

.toast.warning {
    border-left-color: var(--warning-color);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-secondary);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 480px) {
    .header-content {
        padding: 10px 16px;
    }
    
    .tab-content {
        padding: 16px;
    }
    
    .form-container {
        max-width: none;
    }
    
    .quantity-container {
        flex-wrap: wrap;
    }
    
    .quantity-slider {
        order: 3;
        width: 100%;
        margin-top: 8px;
    }
    
    /* Garder les sélecteurs de date sur la même ligne */
    .date-container {
        flex-direction: row;
        gap: 8px;
    }
    
    .date-container select {
        padding: 12px 8px;
        font-size: 14px;
    }
    
    .filter-row {
        flex-direction: column;
        gap: 8px;
    }
    
    .quick-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Optimisations spécifiques pour les modals sur mobile */
    .modal {
        padding: 10px;
    }
    
    .modal-content {
        max-height: calc(100vh - 20px);
        min-height: 300px;
    }
    
    .modal-body {
        padding: 16px;
        max-height: calc(100vh - 120px);
    }
    
    /* Amélioration du scroll sur iOS */
    .modal-body {
        -webkit-overflow-scrolling: touch;
        overflow-y: scroll;
    }
    
    /* Styles spécifiques pour la modal de détails produit sur mobile */
    .product-details-container {
        min-height: 400px;
    }
    
    .product-main-info {
        margin-bottom: 16px;
        padding: 16px;
    }
    
    .product-info-grid {
        gap: 6px;
        margin-bottom: 16px;
    }
    
    .info-item {
        padding: 8px 12px;
    }
    
    .info-label {
        font-size: 12px;
        flex: 1;
    }
    
    .info-value {
        font-size: 12px;
        text-align: right;
        max-width: 60%;
        word-break: break-word;
    }
    
    .product-actions-section {
        margin-top: 16px;
        gap: 6px;
    }
    
    .action-btn-modal {
        padding: 10px 16px;
        font-size: 14px;
        min-height: 44px;
    }
}

/* Optimisations spécifiques pour iPhone */
@media (max-width: 414px) and (-webkit-min-device-pixel-ratio: 2) {
    .modal-content {
        border-radius: 8px;
    }
    
    .modal-body {
        padding: 12px;
    }
    
    .product-main-info {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .product-title {
        font-size: 14px;
    }
    
    .product-status-badge {
        font-size: 10px;
        padding: 4px 8px;
    }
    
    .info-item {
        padding: 6px 10px;
        min-height: 36px;
    }
    
    .info-label {
        font-size: 11px;
    }
    
    .info-value {
        font-size: 11px;
    }
    
    .action-btn-modal {
        padding: 8px 12px;
        font-size: 13px;
        min-height: 40px;
    }
}

/* Onglet Promotions */
.promotions-container {
    max-width: 600px;
    margin: 0 auto;
}

.promotion-settings {
    background: var(--surface);
    border-radius: 12px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.promotion-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    width: 100%;
}

.action-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    white-space: nowrap;
}

.print-btn {
    background: var(--secondary-color);
    color: white;
}

.print-btn:hover {
    background: #1565C0;
}

.email-btn {
    background: var(--accent-color);
    color: white;
}

.email-btn:hover {
    background: #F57C00;
}

.threshold-input, .email-input {
    width: 80px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    text-align: center;
}

.email-input {
    width: 200px;
    text-align: left;
}

.email-config {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.promotion-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--surface);
    padding: 16px;
    border-radius: 8px;
    text-align: center;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--accent-color);
}

.stat-card .stat-number {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.promotions-list {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.zone-group {
    border-bottom: 1px solid var(--border);
}

.zone-group:last-child {
    border-bottom: none;
}

.zone-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.zone-header .zone-icon {
    font-size: 18px;
    margin-right: 8px;
}

.zone-count {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.promotion-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.2s ease;
}

.promotion-item:hover {
    background-color: #f8f9fa;
}

.promotion-item:last-child {
    border-bottom: none;
}

.promotion-info {
    flex: 1;
}

.promotion-name {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
    font-size: 14px;
}

.promotion-details {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.promotion-expiry {
    font-size: 11px;
    color: var(--text-secondary);
    font-style: italic;
}

.promotion-status {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    min-width: 60px;
}

.promotion-status.urgent {
    background: #FFEBEE;
    color: #C62828;
    border: 1px solid #FFCDD2;
}

.promotion-status.warning {
    background: #FFF3E0;
    color: #E65100;
    border: 1px solid #FFCC02;
}

.promotion-status.caution {
    background: #FFFDE7;
    color: #F57F17;
    border: 1px solid #FFF176;
}

/* Badge de notification */
.nav-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--error-color);
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 600;
    min-width: 16px;
    text-align: center;
    line-height: 1.2;
}

.nav-item {
    position: relative;
}

/* Styles d'impression */
@media print {
    .promotions-print-view {
        font-family: Arial, sans-serif;
        color: #000;
        background: #fff;
    }
    
    .print-header {
        text-align: center;
        margin-bottom: 30px;
        border-bottom: 2px solid #000;
        padding-bottom: 20px;
    }
    
    .print-title {
        font-size: 24px;
        font-weight: bold;
        margin-bottom: 10px;
    }
    
    .print-date {
        font-size: 14px;
        color: #666;
    }
    
    .print-zone-group {
        margin-bottom: 25px;
        break-inside: avoid;
    }
    
    .print-zone-header {
        background: #f0f0f0;
        padding: 10px;
        font-weight: bold;
        font-size: 16px;
        border: 1px solid #ccc;
        margin-bottom: 5px;
    }
    
    .print-product-item {
        padding: 8px 10px;
        border-bottom: 1px solid #eee;
        display: flex;
        justify-content: space-between;
    }
    
    .print-product-info {
        flex: 1;
    }
    
    .print-product-name {
        font-weight: 500;
        margin-bottom: 3px;
    }
    
    .print-product-details {
        font-size: 12px;
        color: #666;
    }
    
    .print-expiry-date {
        font-weight: bold;
        color: #d32f2f;
    }
    
    /* Masquer les éléments non nécessaires à l'impression */
    .app-header,
    .bottom-nav,
    .promotion-settings,
    .promotion-actions,
    .promotion-stats,
    .toast-container {
        display: none !important;
    }
    
    .app-main {
        margin: 0;
        padding: 20px;
    }
    
    .promotions-container {
        max-width: none;
    }
}

/* Responsive pour l'onglet Promotions */
@media (max-width: 480px) {
    .promotion-actions {
        flex-direction: column;
        gap: 12px;
        width: 100%;
    }
    
    .action-btn {
        width: 100%;
        padding: 14px 16px;
        font-size: 16px;
        min-height: 48px;
        justify-content: center;
        text-align: center;
    }
    
    .promotion-stats {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .stat-card {
        padding: 12px;
    }
    
    .stat-card .stat-number {
        font-size: 20px;
    }
    
    .zone-header {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .promotion-item {
        padding: 10px 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .promotion-status {
        align-self: flex-end;
    }
    
    .threshold-input {
        width: 60px;
    }
    
    .email-input {
        width: 100%;
        margin-top: 8px;
    }
}

/* Optimisations spécifiques pour iPhone et petits écrans */
@media (max-width: 375px) {
    /* Réduire les espacements généraux */
    .form-group {
        margin-bottom: 12px; /* Réduire encore plus */
    }
    
    .form-group label {
        font-size: 14px; /* Réduire de 16px à 14px */
        margin-bottom: 4px; /* Réduire encore plus */
    }
    
    /* Optimiser tous les inputs */
    .input-with-button input,
    .zone-container select,
    .selection-display {
        padding: 12px; /* Réduire de 16px à 12px */
        font-size: 15px; /* Légèrement plus petit */
    }
    
    /* Bouton scanner plus compact sur mobile */
    .scan-btn {
        width: 44px; /* Plus petit sur mobile */
        height: 44px;
        font-size: 16px; /* Ajuster la taille de l'icône */
    }
    
    /* Ajuster le gap pour mobile */
    .input-with-button {
        gap: 6px; /* Réduire l'espace entre input et bouton */
    }
    
    /* Quantité plus compacte */
    .quantity-container {
        padding: 12px; /* Réduire de 16px à 12px */
        gap: 8px; /* Réduire de 12px à 8px */
    }
    
    .quantity-btn {
        width: 36px; /* Réduire de 40px à 36px */
        height: 36px;
        font-size: 20px; /* Réduire de 24px à 20px */
    }
    
    .quantity-number {
        width: 60px; /* Réduire de 80px à 60px */
        padding: 6px; /* Réduire de 8px à 6px */
        font-size: 14px; /* Réduire de 16px à 14px */
    }
    
    /* Zone plus compacte */
    .zone-container {
        gap: 6px; /* Réduire de 8px à 6px */
    }
    
    .add-zone-btn {
        width: 44px; /* Réduire de 50px à 44px */
        height: 44px;
        font-size: 18px; /* Réduire de 20px à 18px */
    }
    
    /* Date d'expiration optimisée */
    .date-container {
        gap: 6px; /* Réduire encore l'espace */
    }
    
    .date-container select {
        padding: 10px 6px; /* Encore plus compact */
        font-size: 13px; /* Plus petit */
    }
    
    /* Bouton enregistrer plus compact */
    .save-button {
        padding: 14px; /* Réduire de 18px à 14px */
        font-size: 16px; /* Réduire de 18px à 16px */
        margin-top: 20px; /* Réduire de 32px à 20px */
    }
    
    /* Réduire le padding du contenu principal */
    .tab-content {
        padding: 12px; /* Réduire de 16px à 12px */
    }
}

/* Corrections spécifiques pour iPhone */
@media (max-width: 414px) {
    .promotion-actions {
        flex-direction: column;
        gap: 10px;
        width: 100%;
        margin-bottom: 16px;
    }
    
    .action-btn {
        width: 100%;
        padding: 16px 20px;
        font-size: 16px;
        min-height: 50px;
        border-radius: 10px;
        font-weight: 600;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        text-align: center;
        white-space: nowrap;
        box-sizing: border-box;
    }
    
    .print-btn {
        background: var(--secondary-color);
        color: white;
        border: none;
    }
    
    .email-btn {
        background: var(--accent-color);
        color: white;
        border: none;
    }
}

/* PWA */
@media (display-mode: standalone) {
    .app-header {
        padding-top: env(safe-area-inset-top);
    }
    
    .bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
    }
}
