/* Variables CSS globales */
:root {
    /* === COULEURS DE LA MARQUE === */
    /* Couleurs principales par ordre d'importance */
    --brand-primary: #c20e1a;            /* Rouge principal de la marque */
    --brand-secondary: #6c7fa0;          /* Bleu-gris secondaire */
    --brand-tertiary: #723988;           /* Violet tertiaire */
    
    /* === COULEURS DE L'APPLICATION === */
    /* Utilisation des couleurs de marque pour l'application */
    --primary-color: var(--brand-primary);
    --secondary-color: var(--brand-secondary);
    --accent-color: var(--brand-tertiary);
    --success-color: #2ecc71;
    --error-color: #e74c3c;
    --warning-color: #f39c12;
    --bg-color: #f8f9fa;
    --text-color: #333;
    --border-color: #e1e5e9;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    
    /* === CONFIGURATION POUR L'AUTHENTIFICATION === */
    /* Variables par défaut pour le composant d'authentification */
    /* Dégradé de fond basé sur les couleurs de marque */
    --auth-bg-primary: var(--brand-primary);
    --auth-bg-secondary: var(--brand-secondary);
    
    /* Formulaire d'authentification */
    --auth-form-background: white;
    --auth-form-box-shadow: 0 20px 40px rgba(194, 14, 26, 0.15);
    --auth-form-radius: 20px;
    --auth-form-inner-padding: 40px;
    --auth-form-width: 400px;
    
    /* Typographie */
    --auth-typography-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --auth-primary-text: #333;
    --auth-secondary-text: #555;
    
    /* Champs de saisie */
    --auth-input-border-color: #e1e5e9;
    --auth-input-focus-color: var(--brand-primary);
    
    /* Messages */
    --auth-error-text: #e74c3c;
    --auth-warning-background: #f39c12;
    
    /* Footer de version */
    --auth-version-text: rgba(255, 255, 255, 0.7);
    
    /* Variables pour le footer de version de l'application */
    --version-footer-color: var(--app-version-text-color, rgba(255, 255, 255, 0.9));
    --version-footer-size: var(--app-version-font-size, 11px);
    --version-footer-weight: var(--app-version-font-weight, 400);
    --version-footer-bottom: var(--app-version-spacing-bottom, 15px);
    --version-footer-right: var(--app-version-spacing-right, 15px);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ===================================== */
/* BARRES GLOBALES DE L'APPLICATION    */
/* ===================================== */

/* Structure de l'application avec barres fixes */
#app {
    flex: 1;
    
    margin-top: 0;
    margin-bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Barre supérieure - Boutons d'accueil et de déconnexion */
.global-top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: var(--brand-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.global-top-bar.hidden {
    display: none;
}

.left-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.right-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.global-title {
    color: white;
    font-size: 16px;
    font-weight: 500;
    text-align: center;
    flex: 1;
    margin: 0 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.home-button,
.scanner-button,
.info-button,
.power-button {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.home-button:hover,
.scanner-button:hover,
.info-button:hover,
.power-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Barre inférieure - Status et version */
.global-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid #e1e5e9;
    border-bottom: 1px solid var(--brand-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    z-index: 1000;
    font-size: 0.85rem;
}

.global-bottom-bar.hidden {
    display: none;
}

/* Status réseau à gauche */
.network-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 100px;
}

.network-status.online .network-icon {
    color: var(--success-color);
}

.network-status.offline .network-icon {
    color: var(--error-color);
}

.network-text {
    color: #666;
    font-size: 0.8rem;
}

/* Numéro de scanner au centre */
.scanner-info {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.scanner-text {
    color: #999;
    font-size: 0.75rem;
    font-weight: normal;
}

/* Version à droite */
.version-info {
    display: flex;
    align-items: center;
    min-width: 100px;
    justify-content: flex-end;
}

.version-text {
    color: #999;
    font-size: 0.75rem;
    font-weight: normal;
}

/* Ajustement du contenu de l'app - la barre du bas est toujours présente */
#app {
    margin-bottom: 40px; /* Toujours de la place pour la barre du bas */
}

/* Quand la barre du haut est visible (utilisateur connecté) */
body:has(.global-top-bar:not(.hidden)) #app {
    margin-top: 50px;
}

/* Fallback pour les navigateurs qui ne supportent pas :has() */
.global-bars-visible #app {
    margin-top: 50px;
}

/* Styles pour le loading */
.loading {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: var(--primary-color);
    color: white;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top: 5px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Styles pour l'application principale */
.main-app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    background: var(--primary-color);
    color: white;
    padding: 1rem 0;
    box-shadow: var(--shadow);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content h1 {
    font-size: 1.8em;
    font-weight: 300;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logout-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Contenu principal */
.app-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* Message de bienvenue */
.welcome-message {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: var(--shadow);
    text-align: center;
}

.welcome-message h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-weight: 300;
}

.welcome-message p {
    color: #666;
    font-size: 1.1em;
    line-height: 1.6;
}

/* Toast d'erreur */
.error-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--error-color);
    color: white;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Footer de version */
.version-footer {
    position: fixed;
    bottom: var(--version-footer-bottom);
    right: var(--version-footer-right);
    color: var(--version-footer-color);
    font-size: var(--version-footer-size);
    font-weight: var(--version-footer-weight);
    z-index: 1000;
    
    /* Amélioration de la visibilité */
    background: rgba(0, 0, 0, 0.7);
    padding: 4px 8px;
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.9);
    font-family: monospace;
    letter-spacing: 0.5px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(2px);
}

@media (max-width: 768px) {
    .version-footer {
        bottom: calc(var(--version-footer-bottom) / 2);
        right: calc(var(--version-footer-right) / 2);
        font-size: calc(var(--version-footer-size) - 1px);
    }
}

/* === INDICATEUR DE STATUT RÉSEAU === */
.network-status-indicator {
    --network-indicator-bottom: var(--app-network-spacing-bottom, 20px);
    --network-indicator-left: var(--app-network-spacing-left, 20px);
    --network-online-color: var(--app-network-online-color, #2ecc71);
    --network-offline-color: var(--app-network-offline-color, #e74c3c);
    --network-bg-color: var(--app-network-background, rgba(255, 255, 255, 0.9));
    --network-border-radius: var(--app-network-border-radius, 20px);
    --network-font-size: var(--app-network-font-size, 11px);
    
    position: fixed;
    bottom: var(--network-indicator-bottom);
    left: var(--network-indicator-left);
    background: var(--network-bg-color);
    backdrop-filter: blur(10px);
    border-radius: var(--network-border-radius);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--network-font-size);
    font-weight: 500;
    z-index: 1000;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.network-status-indicator.online {
    color: var(--network-online-color);
    border-color: var(--network-online-color);
}

.network-status-indicator.offline {
    color: var(--network-offline-color);
    border-color: var(--network-offline-color);
}

.network-status-indicator .network-icon {
    font-size: 14px;
    line-height: 1;
}

@media (max-width: 768px) {
    .version-footer {
        bottom: calc(var(--version-footer-bottom) / 2);
        right: calc(var(--version-footer-right) / 2);
        font-size: calc(var(--version-footer-size) - 1px);
    }
    
    .network-status-indicator {
        bottom: calc(var(--network-indicator-bottom) / 2) !important;
        left: calc(var(--network-indicator-left) / 2) !important;
        font-size: 10px !important;
        padding: 6px 8px !important;
    }
    
    .network-status-indicator .network-text {
        display: none;
    }
    
    .network-status-indicator .network-icon {
        font-size: 12px !important;
    }
}

/* Modal d'erreur d'authentification */
.error-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.error-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    max-width: 400px;
    margin: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.error-content h3 {
    color: #e74c3c;
    margin-bottom: 15px;
}

.error-content p {
    margin-bottom: 20px;
    color: #333;
}

.error-content button {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
}

.error-content button:hover {
    background: #c0392b;
}

/* Notifications temporaires */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: 8px;
    padding: 15px 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 10001;
    max-width: 400px;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 4px solid;
}

.notification-show {
    transform: translateX(0);
}

.notification-error {
    border-left-color: #e74c3c;
    background: #fdf2f2;
}

.notification-success {
    border-left-color: #27ae60;
    background: #f2f9f2;
}

.notification-info {
    border-left-color: #3498db;
    background: #f2f8ff;
}

.notification-warning {
    border-left-color: #f39c12;
    background: #fff9f2;
}

.notification-message {
    flex: 1;
    color: #333;
    font-size: 14px;
    line-height: 1.4;
}

.notification-close {
    background: none;
    border: none;
    font-size: 18px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.notification-close:hover {
    background-color: rgba(0, 0, 0, 0.1);
    color: #666;
}

@media (max-width: 480px) {
    .welcome-message {
        padding: 20px;
    }

    .welcome-message h2 {
        font-size: 1.3em;
    }
    
    .notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
}
