/*
 * RFID Cashless - Feuille de styles principale
 *
 * Design : Industriel / Point de vente (POS)
 * - Thème sombre pour usage en extérieur (lisibilité au soleil)
 * - Boutons larges pour interface tactile
 * - Responsive portrait/paysage téléphone et tablette
 *
 * Organisation :
 * 1. Variables CSS (tokens de design)
 * 2. Reset et base
 * 3. Navigation
 * 4. Layout principal
 * 5. Composants réutilisables
 * 6. Pages spécifiques
 * 7. Modal et overlay
 * 8. Toast notifications
 * 9. Responsive (media queries)
 * 10. Animations
 *
 * Réf CSS Custom Properties:
 *   https://developer.mozilla.org/fr/docs/Web/CSS/Using_CSS_custom_properties
 */

/* ==========================================================================
   1. VARIABLES CSS
   ========================================================================== */

:root {
    /* --- Couleurs principales --- */
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-input: #0f0f1a;

    /* --- Accents --- */
    --accent-gold: #d4a843;
    --accent-gold-dim: #b8922f;
    --accent-green: #2ecc71;
    --accent-red: #e74c3c;
    --accent-blue: #3498db;
    --accent-orange: #e67e22;

    /* --- Texte --- */
    --text-primary: #e8e8e8;
    --text-secondary: #8892a4;
    --text-muted: #556070;
    --text-on-accent: #0f0f1a;

    /* --- Bordures --- */
    --border-color: #2a2a4a;
    --border-focus: var(--accent-gold);

    /* --- Ombres --- */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);

    /* --- Espacements --- */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;

    /* --- Rayons de bordure --- */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    /* --- Typographie --- */
    --font-body: 'DM Sans', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* --- Tailles tactiles --- */
    /* Taille minimum recommandée pour les cibles tactiles : 44px
       Réf: https://www.w3.org/WAI/WCAG21/Understanding/target-size.html */
    --touch-min: 48px;

    /* --- Transitions --- */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;

    /* --- Navigation --- */
    --nav-height: 60px;
    --topbar-height: 48px;
}


/* ==========================================================================
   2. RESET ET BASE
   ========================================================================== */

/*
 * box-sizing: border-box sur tous les éléments.
 * Simplifie le calcul des dimensions (padding inclus dans width/height).
 * Réf: https://developer.mozilla.org/fr/docs/Web/CSS/box-sizing
 */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    /* Empêche le scroll horizontal sur mobile */
    overflow-x: hidden;
    /* Taille de base pour les unités rem */
    font-size: 16px;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    /* Empêche le pull-to-refresh sur mobile qui interfère avec le scroll */
    overscroll-behavior: none;
    /* Hauteur minimum = viewport complet */
    min-height: 100dvh;
    /* dvh = dynamic viewport height, gère la barre d'adresse mobile
       Réf: https://developer.mozilla.org/en-US/docs/Web/CSS/length#dvh */
}

/* Suppression du outline par défaut au profit d'un style personnalisé */
:focus-visible {
    outline: 2px solid var(--accent-gold);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}


/* ==========================================================================
   3. NAVIGATION : TOPBAR (haut) + BOTTOM NAV (bas)
   ========================================================================== */

/* --- TOPBAR FIXE EN HAUT --- */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height, 48px);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    z-index: 1001;
    padding-top: env(safe-area-inset-top, 0);
    overflow: hidden;
}

.top-bar-info,
.top-bar-toast {
    position: absolute;
    top: env(safe-area-inset-top, 0);
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-md);
    transition: transform 200ms ease, opacity 200ms ease;
}

.top-bar-info.hidden {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
}

.top-bar-toast {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0 var(--space-sm);
    text-align: center;
}
.top-bar-toast:not(.hidden) {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* Couleurs du toast selon le type */
.top-bar-toast.toast-success { background: rgba(46,204,113,0.18); color: #2ecc71; }
.top-bar-toast.toast-error   { background: rgba(231,76,60,0.18);  color: #e74c3c; }
.top-bar-toast.toast-warning { background: rgba(243,156,18,0.18); color: #f39c12; }
.top-bar-toast.toast-info    { background: rgba(52,152,219,0.18); color: #3498db; }

/* Brand : logo + nom + version */
.top-bar-brand {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    min-width: 0;
}
.top-bar-logo {
    width: 24px;
    height: 21px;
    flex-shrink: 0;
}
.top-bar-name {
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.04em;
    color: var(--text-primary);
}
.top-bar-name i {
    font-style: italic;
    font-weight: 400;
    color: var(--accent-gold);
}
.top-bar-version {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
    opacity: 0.7;
}

/* Actions : etat serveur + aide + logout */
.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.server-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 12px;
    background: rgba(255,255,255,0.04);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.server-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #888;
}
.server-status-online .server-status-dot {
    background: #2ecc71;
    box-shadow: 0 0 6px rgba(46,204,113,0.6);
}
.server-status-offline .server-status-dot {
    background: #e74c3c;
}
.server-status-pending .server-status-dot {
    background: #f39c12;
    animation: pulse-dot 1.4s infinite;
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.server-status-online  { color: #2ecc71; }
.server-status-offline { color: #e74c3c; }
.server-status-pending { color: #f39c12; }

.top-bar-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    font-size: 1rem;
    text-decoration: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: background 120ms ease, color 120ms ease;
}
.top-bar-icon-btn:hover, .top-bar-icon-btn:active {
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
}
.top-bar-logout:hover, .top-bar-logout:active {
    background: rgba(231,76,60,0.15);
    color: #e74c3c;
}


/* --- BOTTOM NAV : ONGLETS UNIQUEMENT --- */
.main-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 var(--space-md);
    z-index: 1000;
    /* safe-area-inset-bottom : gère le "home indicator" des iPhones récents. */
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-links {
    display: flex;
    gap: var(--space-xs);
    width: 100%;
    justify-content: space-around;
}

.nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: var(--space-sm);
    min-width: var(--touch-min);
    min-height: var(--touch-min);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    flex: 1;
    max-width: 100px;
}

.nav-link:active {
    transform: scale(0.95);
}

.nav-link.active {
    color: var(--accent-gold);
    background: rgba(212, 168, 67, 0.12);
}

.nav-icon {
    font-size: 1.3rem;
    line-height: 1;
}

.nav-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}


/* ==========================================================================
   4. LAYOUT PRINCIPAL
   ========================================================================== */

.app-container {
    /* Espace pour la nav fixe en bas */
    padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0) + var(--space-md));
    /* Espace pour la topbar fixe en haut */
    padding-top: calc(var(--topbar-height) + env(safe-area-inset-top, 0) + var(--space-md));
    padding-left: var(--space-md);
    padding-right: var(--space-md);
    min-height: 100dvh;
    /* Container max pour grands écrans */
    max-width: 900px;
    margin: 0 auto;
}

.page {
    animation: fadeIn 200ms ease;
}

.page-header {
    margin-bottom: var(--space-lg);
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.page-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: var(--space-xs);
}


/* ==========================================================================
   5. COMPOSANTS RÉUTILISABLES
   ========================================================================== */

/* --- Card / Panel --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-sm);
}

.card-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
}

/* --- Balance Display --- */
.balance-display {
    text-align: center;
    padding: var(--space-lg) 0;
}

.balance-amount {
    font-family: var(--font-mono);
    font-size: 3rem;
    font-weight: 700;
    color: var(--accent-gold);
    line-height: 1;
}

.balance-currency {
    font-size: 1.5rem;
    color: var(--accent-gold-dim);
    margin-left: var(--space-xs);
}

.balance-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: var(--space-sm);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    min-height: var(--touch-min);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    /* user-select: none empêche la sélection de texte au tap long.
       Réf: https://developer.mozilla.org/fr/docs/Web/CSS/user-select */
    user-select: none;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--accent-gold);
    color: var(--text-on-accent);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-gold-dim);
}

.btn-success {
    background: var(--accent-green);
    color: #fff;
}

.btn-danger {
    background: var(--accent-red);
    color: #fff;
}

.btn-warning {
    background: var(--accent-orange);
    color: #fff;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-ghost:hover:not(:disabled) {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.btn-full {
    width: 100%;
}

.btn-lg {
    min-height: 56px;
    font-size: 1.1rem;
    padding: var(--space-md) var(--space-xl);
}

.btn-sm {
    min-height: 36px;
    font-size: 0.8rem;
    padding: var(--space-sm) var(--space-md);
}

.btn-group {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

/* --- Input --- */
.input-group {
    margin-bottom: var(--space-md);
}

.input-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.input-field {
    width: 100%;
    min-height: var(--touch-min);
    padding: var(--space-md);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    transition: border-color var(--transition-fast);
}

.input-field:focus {
    border-color: var(--border-focus);
    outline: none;
}

.input-field::placeholder {
    color: var(--text-muted);
}

.input-field-mono {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    text-align: center;
    letter-spacing: 0.05em;
}

/* --- Quick Amount Buttons (for credit) --- */
.amount-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.amount-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.amount-btn:active {
    transform: scale(0.95);
}

.amount-btn.selected {
    border-color: var(--accent-gold);
    background: rgba(212, 168, 67, 0.15);
    color: var(--accent-gold);
}

/* --- NFC Scan Area --- */
.nfc-area {
    text-align: center;
    padding: var(--space-xl) var(--space-md);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-lg);
    transition: all var(--transition-normal);
}

.nfc-area.scanning {
    border-color: var(--accent-gold);
    background: rgba(212, 168, 67, 0.05);
    animation: pulse-border 1.5s ease-in-out infinite;
}

.nfc-area.success {
    border-color: var(--accent-green);
    background: rgba(46, 204, 113, 0.08);
}

.nfc-area.error {
    border-color: var(--accent-red);
    background: rgba(231, 76, 60, 0.08);
}

.nfc-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    display: block;
}

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

.nfc-uid {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--accent-gold);
    margin-top: var(--space-sm);
    word-break: break-all;
}

/* --- Product Grid (Sale page) --- */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: var(--space-sm);
}

.product-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    min-height: 90px;
    padding: var(--space-md) var(--space-sm);
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    cursor: pointer;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    text-align: center;
    position: relative;
}

.product-btn:active {
    transform: scale(0.95);
}

.product-btn.in-cart {
    border-color: var(--accent-gold);
    background: rgba(212, 168, 67, 0.1);
}

.product-name {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.2;
    /* Limite à 2 lignes avec ellipsis.
       Réf: https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-line-clamp */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-price {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent-gold);
}

.product-qty-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 26px;
    height: 26px;
    background: var(--accent-gold);
    color: var(--text-on-accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

/* --- Tabs (Page tabs for sale) --- */
.tabs {
    display: flex;
    gap: var(--space-xs);
    overflow-x: auto;
    /* Masque la scrollbar tout en gardant le scroll tactile.
       Réf: https://developer.mozilla.org/en-US/docs/Web/CSS/scrollbar-width */
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-xs);
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    flex-shrink: 0;
    padding: var(--space-sm) var(--space-lg);
    min-height: 40px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    white-space: nowrap;
}

.tab-btn.active {
    background: var(--accent-gold);
    color: var(--text-on-accent);
    border-color: var(--accent-gold);
}

/* --- Cart Summary --- */
.cart-summary {
    position: sticky;
    bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0) + var(--space-md));
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    box-shadow: var(--shadow-lg);
    z-index: 100;
}

.cart-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.cart-total-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
}

.cart-total-amount {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-gold);
}

.cart-items-list {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
    max-height: 100px;
    overflow-y: auto;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    padding: var(--space-xs) 0;
    border-bottom: 1px solid var(--border-color);
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-actions {
    display: flex;
    gap: var(--space-sm);
}

/* --- History List --- */
.history-list {
    list-style: none;
}

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

.history-item:last-child {
    border-bottom: none;
}

.history-type {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.history-type.credit {
    background: rgba(46, 204, 113, 0.15);
    color: var(--accent-green);
}

.history-type.debit {
    background: rgba(231, 76, 60, 0.15);
    color: var(--accent-red);
}

.history-type.reset {
    background: rgba(149, 165, 166, 0.15);
    color: var(--text-secondary);
}

.history-type.refund {
    background: rgba(230, 126, 34, 0.15);
    color: var(--accent-orange);
}

/* --- Stat tiles (clickable) --- */
.stat-tile {
    transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.stat-tile:hover {
    border-color: var(--accent-gold);
    transform: translateY(-2px);
}

.stat-tile:active {
    transform: scale(0.97);
}

.history-amount {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.95rem;
}

.history-amount.credit {
    color: var(--accent-green);
}

.history-amount.debit {
    color: var(--accent-red);
}

.history-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.history-date {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.history-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* --- Admin Form --- */
.admin-section {
    margin-bottom: var(--space-xl);
}

.admin-list {
    list-style: none;
}

.admin-list-item {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-color);
    gap: var(--space-sm);
}

.admin-list-item:last-child {
    border-bottom: none;
}

.admin-item-info {
    flex: 1;
    min-width: 0;
}

.admin-item-name {
    font-weight: 600;
    font-size: 0.9rem;
    /* Empêcher les longs noms de déborder.
       Réf: https://developer.mozilla.org/fr/docs/Web/CSS/word-break */
    word-break: break-word;
}

.admin-item-detail {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.admin-item-price {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--accent-gold);
    white-space: nowrap;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

.empty-state-text {
    font-size: 0.9rem;
}

/* --- Status Indicator --- */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.active {
    background: var(--accent-green);
}

.status-dot.inactive {
    background: var(--accent-red);
}

/* --- Select --- */
.select-field {
    width: 100%;
    min-height: var(--touch-min);
    padding: var(--space-md);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    /* appearance: none permet de personnaliser le style du select.
       Réf: https://developer.mozilla.org/fr/docs/Web/CSS/appearance */
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238892a4' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.select-field:focus {
    border-color: var(--border-focus);
    outline: none;
}

/* --- Chip / Tag --- */
.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

/* --- Event banner --- */
.event-banner {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: rgba(212, 168, 67, 0.1);
    border: 1px solid rgba(212, 168, 67, 0.3);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    font-size: 0.8rem;
    color: var(--accent-gold);
    /* Empêcher le débordement sur petits écrans */
    overflow: hidden;
    word-break: break-word;
}

.event-banner-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.offline-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: rgba(230, 126, 34, 0.15);
    border: 1px solid rgba(230, 126, 34, 0.4);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-orange);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    animation: offlinePulse 2s ease-in-out infinite;
}

@keyframes offlinePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}


/* ==========================================================================
   6. PAGES SPÉCIFIQUES
   ========================================================================== */

/* Rien de spécifique ici pour le moment, les composants génériques
   sont combinés dans chaque page via JavaScript. */


/* ==========================================================================
   7. MODAL ET OVERLAY
   ========================================================================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    /* backdrop-filter pour le flou de fond.
       Réf: https://developer.mozilla.org/fr/docs/Web/CSS/backdrop-filter */
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: var(--space-md);
    animation: fadeIn 150ms ease;
}

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

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    max-width: 440px;
    width: 100%;
    max-height: 80dvh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 200ms ease;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: var(--space-lg);
}

.modal-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
    justify-content: flex-end;
}


/* ==========================================================================
   8. TOAST NOTIFICATIONS
   ========================================================================== */

.toast-container {
    position: fixed;
    top: var(--space-md);
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    width: calc(100% - var(--space-md) * 2);
    max-width: 400px;
    /* pointer-events: none permet de cliquer à travers le conteneur vide.
       Réf: https://developer.mozilla.org/fr/docs/Web/CSS/pointer-events */
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideDown 250ms ease;
}

.toast.success {
    background: var(--accent-green);
    color: #fff;
}

.toast.error {
    background: var(--accent-red);
    color: #fff;
}

.toast.info {
    background: var(--accent-blue);
    color: #fff;
}

.toast.warning {
    background: var(--accent-orange);
    color: #fff;
}

.toast.fade-out {
    animation: fadeOut 300ms ease forwards;
}


/* ==========================================================================
   9. RESPONSIVE
   ========================================================================== */

/* Très petits écrans portrait (< 380px, ex: iPhone SE) */
@media (max-width: 379px) {
    .amount-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .amount-btn {
        min-height: 48px;
        font-size: 0.95rem;
    }

    .balance-amount {
        font-size: 2rem;
    }

    .balance-currency {
        font-size: 1.1rem;
    }

    .btn-lg {
        font-size: 0.9rem;
        min-height: 46px;
        padding: var(--space-sm) var(--space-md);
    }

    .card {
        padding: var(--space-md);
        margin-bottom: var(--space-sm);
    }

    .card-title {
        margin-bottom: var(--space-sm);
    }

    .btn-group {
        flex-direction: column;
    }

    .app-container {
        padding-left: var(--space-sm);
        padding-right: var(--space-sm);
    }

    .event-banner {
        font-size: 0.7rem;
        padding: var(--space-xs) var(--space-sm);
        margin-bottom: var(--space-md);
    }
}

/* Petits écrans portrait (380-599px) — mobile standard */
@media (max-width: 599px) {
    .balance-amount {
        font-size: 2.5rem;
    }

    .balance-display {
        padding: var(--space-md) 0;
    }

    .amount-btn {
        min-height: 50px;
    }

    .admin-list-item {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }

    .admin-list-item .btn-group {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .admin-list-item .btn-group .btn {
        font-size: 0.7rem;
        padding: var(--space-xs) var(--space-sm);
        min-height: 32px;
    }
}

/* Tablette portrait (>= 600px) */
@media (min-width: 600px) {
    .nav-link {
        flex-direction: row;
        gap: var(--space-sm);
    }

    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .amount-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .balance-amount {
        font-size: 3.5rem;
    }

    /* Remettre les admin-list-item en horizontal sur grands écrans */
    .admin-list-item {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-md);
    }
}

/* Tablette paysage / Desktop (>= 768px) */
@media (min-width: 768px) {
    :root {
        --nav-height: 64px;
        --topbar-height: 56px;
    }

    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
}

/* Grand écran (>= 1024px) */
@media (min-width: 1024px) {
    .app-container {
        max-width: 1100px;
    }

    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    }
}

/* Paysage mobile (hauteur < 500px) */
@media (max-height: 500px) and (orientation: landscape) {
    .nfc-area {
        padding: var(--space-md);
    }

    .nfc-icon {
        font-size: 2rem;
        margin-bottom: var(--space-sm);
    }

    .balance-amount {
        font-size: 2.5rem;
    }

    .product-btn {
        min-height: 70px;
    }
}


/* ==========================================================================
   10. ANIMATIONS
   ========================================================================== */

/*
 * @keyframes définit les étapes d'une animation CSS.
 * Réf: https://developer.mozilla.org/fr/docs/Web/CSS/@keyframes
 */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

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

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

@keyframes pulse-border {
    0%, 100% { border-color: var(--accent-gold); opacity: 1; }
    50% { border-color: rgba(212, 168, 67, 0.3); opacity: 0.8; }
}


/* ==========================================================================
   11. OVERLAY DE SCAN NFC
   ========================================================================== */

/*
 * Overlay plein écran affiché pendant l'attente de scan NFC.
 * Centré verticalement et horizontalement avec flexbox.
 * Fond semi-transparent avec flou (backdrop-filter).
 */

.scan-overlay-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 26, 0.92);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
    animation: fadeIn 200ms ease;
    padding: var(--space-lg);
}

.scan-overlay-content {
    text-align: center;
    max-width: 320px;
    width: 100%;
}

/* --- Animation d'ondes concentriques --- */
.scan-overlay-animation {
    position: relative;
    width: 160px;
    height: 160px;
    margin: 0 auto var(--space-xl);
    display: flex;
    align-items: center;
    justify-content: center;
}

.scan-ring {
    position: absolute;
    border: 2px solid var(--accent-gold);
    border-radius: 50%;
    animation: scan-pulse 2s ease-in-out infinite;
}

.scan-ring-1 {
    width: 80px;
    height: 80px;
    animation-delay: 0s;
}

.scan-ring-2 {
    width: 120px;
    height: 120px;
    animation-delay: 0.4s;
}

.scan-ring-3 {
    width: 160px;
    height: 160px;
    animation-delay: 0.8s;
}

.scan-icon {
    position: relative;
    z-index: 1;
    font-size: 2.5rem;
    animation: scan-bob 1.5s ease-in-out infinite;
}

.scan-overlay-message {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.scan-overlay-detail {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent-gold);
    margin-bottom: var(--space-xl);
    min-height: 1.5em;
}

.scan-overlay-cancel {
    min-width: 140px;
}

/* --- Résultat (succès / erreur) --- */
.scan-result-icon {
    font-size: 4rem;
    animation: scan-pop 300ms ease;
}

.scan-result-icon.success {
    /* Pas de style supplémentaire, l'emoji suffit */
}

.scan-result-icon.error {
    /* Idem */
}

/* --- Animations scan --- */

@keyframes scan-pulse {
    0% {
        transform: scale(0.6);
        opacity: 0.8;
    }
    50% {
        opacity: 0.3;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

@keyframes scan-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes scan-pop {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-10px); }
    40% { transform: translateX(10px); }
    60% { transform: translateX(-6px); }
    80% { transform: translateX(6px); }
}
