/* Dashboard principal */
.dashboard-screen {
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-secondary);
    overflow: hidden;
}

/* Navbar responsive - VERSION COMPACTE */
.navbar {
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 0.3rem 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 2.5rem;
}

@media (min-width: 640px) {
    .navbar {
        padding: 0.3rem 0.75rem;
        min-height: 2.625rem;
    }
}

@media (min-width: 1024px) {
    .navbar {
        padding: 0.35rem 1rem;
        min-height: 2.75rem;
    }
}

.navbar-brand {
    flex-shrink: 0;
}

.navbar-brand h1 {
    color: var(--primary-color);
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.navbar-user span {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Styles pour les éléments de la navbar */
.navbar-user select {
    font-size: 0.65rem;
    padding: 0.063rem 0.125rem;
    border: 1px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.1);
    color: white;
    border-radius: 3px;
}

.navbar-user button {
    font-size: 0.7rem;
    padding: 0.188rem 0.375rem;
    border: 1px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.1);
    color: white;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.navbar-user button:hover {
    background: rgba(255,255,255,0.2);
}

/* Responsive pour navbar - DÉSACTIVÉ pour éviter conflits avec main.css */
@media (max-width: 768px) {
    /* Règles déplacées vers main.css pour uniformisation */
    /* .navbar, .navbar-brand, .navbar-user - voir main.css */
}

/* Mobile portrait - DÉSACTIVÉ - Géré par main.css */
@media (max-width: 480px) {
    /* Règles déplacées vers main.css pour éviter les conflits */
    /* .navbar - voir main.css pour la gestion mobile unifiée */
}

/* Mode extrême pour très petits écrans */
@media (max-width: 400px) {
    .navbar {
        padding: 0.1rem 0.2rem !important;
        min-height: 2rem !important;
    }
    
    .navbar-brand h1 {
        font-size: 0.8rem !important;
    }
    
    .navbar-user select {
        font-size: 0.55rem !important;
        min-width: 30px !important;
        max-width: 30px !important;
    }
    
    .navbar-user button {
        font-size: 0.55rem !important;
        min-width: 2.5rem !important;
        max-width: 2.5rem !important;
        padding: 0 0.125rem !important;
    }
}

/* Bouton de toggle de thème */
#theme-toggle-btn {
    background: transparent;
    border: 2px solid var(--border-color);
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
}

#theme-toggle-btn:hover {
    background: var(--bg-secondary);
    transform: scale(1.1);
}

#theme-icon {
    font-size: 1.2rem;
    line-height: 1;
}

/* Contenu principal */
.dashboard-content {
    flex: 1 1 auto;
    padding: 0.5rem;
    max-width: 100%;
    margin: 0 auto;
    width: 100%;
    min-height: 0;
    box-sizing: border-box;
    overflow: hidden;
    margin-top: 0;
}

/* Quand un module plein écran est ouvert : supprimer le padding pour que
   height: var(--available-height) remplisse exactement l'espace disponible */
.dashboard-screen:has(.module-content:not(.hidden)) .dashboard-content {
    padding: 0;
}

/* Optimisation pour tablette 1009x706 */
@media (max-width: 1100px) and (max-height: 800px) {
    .dashboard-content {
        padding: 0.25rem;
        height: calc(100vh - 2.5rem);
        overflow-y: auto;
    }
    
    .dashboard-modules {
        gap: 0.5rem;
        margin-bottom: 0.5rem;
    }
    
    .module-card {
        padding: 0.75rem;
    }
    
    .module-icon {
        width: 2.25rem;
        height: 2.25rem;
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }
    
    .module-title {
        font-size: 0.95rem;
        margin-bottom: 0.25rem;
    }
    
    .module-description {
        font-size: 0.75rem;
    }
}

/* Responsive padding pour différentes tailles d'écran */
@media (min-width: 640px) {
    .dashboard-content {
        padding: 1rem;
    }
}

@media (min-width: 1024px) {
    .dashboard-content {
        padding: 1.25rem;
        max-width: 100%;
    }
}

@media (min-width: 1440px) {
    .dashboard-content {
        max-width: 100%;
    }
}

/* Modules du tableau de bord responsive */
.dashboard-modules {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
    width: 100%;
    max-width: 100%;
}

/* Assure que les cartes ne débordent jamais */
@media (max-width: 639px) {
    .dashboard-modules {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        padding: 0;
    }
    
    .module-card {
        max-width: 100%;
        padding: 1rem;
        margin: 0;
        box-sizing: border-box;
    }
}

/* Responsive grid pour les modules */
@media (min-width: 640px) {
    .dashboard-modules {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 1.5rem;
        margin-bottom: 2rem;
    }
}

@media (min-width: 1024px) {
    .dashboard-modules {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    }
}

@media (min-width: 1440px) {
    .dashboard-modules {
        grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    }
}

.module-card {
    background-color: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    border: 1px solid transparent;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

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

.module-card.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.module-card.disabled:hover {
    transform: none;
    box-shadow: var(--shadow);
    border-color: transparent;
}

.module-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.module-icon.primary {
    background-color: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
}

.module-icon.success {
    background-color: rgba(22, 163, 74, 0.1);
    color: var(--success-color);
}

.module-icon.warning {
    background-color: rgba(234, 88, 12, 0.1);
    color: var(--warning-color);
}

.module-icon.info {
    background-color: rgba(14, 165, 233, 0.1);
    color: var(--info-color);
}

.module-icon.danger {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
}

.module-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.module-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
}

.module-badge {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* Couleur par rôle requis */
.module-badge.role-listen_only {
    background-color: rgba(148, 163, 184, 0.15);
    color: var(--text-muted);
}

.module-badge.role-user {
    background-color: rgba(34, 197, 94, 0.15);
    color: #16a34a;
}

.module-badge.role-coach {
    background-color: rgba(6, 182, 212, 0.15);
    color: #0891b2;
}

.module-badge.role-target_supervisor {
    background-color: rgba(249, 115, 22, 0.15);
    color: #ea580c;
}

.module-badge.role-site_shooting_officer {
    background-color: rgba(168, 85, 247, 0.15);
    color: #7c3aed;
}

.module-badge.role-race_shooting_officer {
    background-color: rgba(236, 72, 153, 0.15);
    color: #db2777;
}

.module-badge.role-super_user {
    background-color: rgba(220, 38, 38, 0.15);
    color: var(--error-color);
}

/* Contenu des modules */
.module-content {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    background-color: transparent;
    border-radius: 0;
    box-shadow: none;
}

.module-content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    min-height: 44px;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.module-content-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.module-content-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
    flex-shrink: 0;
}

/* Ensure module pages (Users, etc.) can scroll when content exceeds viewport. */
.module-content-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Responsive */
@media (max-width: 1024px) {
    .dashboard-content {
        padding: 1rem;
    }
    
    .dashboard-modules {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 0.75rem;
    }
    
    .module-card {
        padding: 1rem;
    }
}

@media (max-width: 768px) {
    /* TOUTES les règles navbar désactivées - voir main.css pour uniformisation */
    
    /* Garder seulement les règles non-navbar */
    
    .dashboard-content {
        padding: 0.75rem;
    }
    
    .dashboard-modules {
        grid-template-columns: 1fr;
    }
    
    .module-content {
        padding: 1rem;
    }
    
    .module-content-header {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 0.5rem;
        align-items: center;
        justify-content: space-between;
    }
    
    .module-content-actions {
        width: auto;
        flex-shrink: 0;
        justify-content: flex-end;
    }
}

/* Paysage tablette compacte (≈1130x706) : réduire les espaces verticaux */
@media (max-height: 750px) and (min-width: 1020px) {
    .dashboard-screen .navbar {
        padding: 0.2rem 0.5rem !important;
        min-height: 2.25rem !important;
    }

    .dashboard-content {
        padding: 0.35rem 0.55rem !important;
    }

    .dashboard-modules {
        gap: 0.5rem !important;
        margin-bottom: 0.5rem !important;
    }

    .module-card,
    .module-content {
        padding: 0.75rem !important;
    }

    .module-content-header {
        margin-bottom: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }
}

/* Responsive pour navbar-user */
@media (max-width: 640px) {
    .navbar-user {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-end;
    }
    
    .navbar-user span {
        font-size: 0.75rem;
    }
    
    .dashboard-header {
        margin-bottom: 1.5rem;
        text-align: center;
    }
    
    .dashboard-header h2 {
        font-size: 1.5rem;
    }
    
    .dashboard-header p {
        font-size: 0.875rem;
    }
}

@media (max-width: 480px) {
    .navbar {
        padding: 0.15rem 0.3rem;
        min-height: 2rem;
    }
    
    .navbar-brand h1 {
        font-size: 0.9rem;
    }
    
    .navbar-user {
        gap: 0.1rem;
        flex-shrink: 2;
    }
    
    .navbar-user span {
        font-size: 0.6rem;
        max-width: 60px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .navbar-user select {
        font-size: 0.6rem;
        padding: 0.063rem 0.125rem;
        min-width: 2.5rem;
    }
    
    .navbar-user button {
        font-size: 0.6rem;
        padding: 0.063rem 0.188rem;
        min-width: 50px;
    }
}

/* Navbar ultra-compacte pour écrans très étroits */
@media (max-width: 360px) {
    .navbar {
        padding: 0.1rem 0.2rem;
        min-height: 1.75rem;
    }
    
    .navbar-brand h1 {
        font-size: 0.8rem;
    }
    
    .navbar-user {
        gap: 0.05rem;
        flex-shrink: 3;
    }
    
    .navbar-user span:nth-child(2) {
        display: none; /* Cache complètement "UTILISATEUR" */
    }
    
    .navbar-user select {
        font-size: 0.55rem;
        padding: 0 0.063rem;
        min-width: 35px;
    }
    
    .navbar-user button {
        font-size: 0.55rem;
        padding: 0.063rem 0.125rem;
        min-width: 2.5rem;
    }
}

/* Mode minimal pour écrans extrêmement petits */
@media (max-width: 320px) {
    .navbar-user {
        flex-shrink: 4;
    }
    
    .navbar-user span {
        display: none; /* Cache tous les textes */
    }
    
    .navbar-user select {
        min-width: 25px;
        font-size: 0.5rem;
    }
    
    .navbar-user button {
        min-width: 30px;
        font-size: 0.5rem;
        padding: 0.063rem;
    }
    
    .navbar {
        gap: 0.3rem;
        padding: 0.1rem 0.15rem;
    }
}

@media (max-width: 480px) {
    .dashboard-content {
        padding: 0.75rem;
    }
    
    .module-card {
        padding: 1rem;
    }
    
    .module-content {
        padding: 1rem;
    }
}

/* Animations */
.dashboard-modules .module-card {
    animation: fadeIn 0.3s ease-in-out;
}

.dashboard-modules .module-card:nth-child(1) { animation-delay: 0.1s; }
.dashboard-modules .module-card:nth-child(2) { animation-delay: 0.2s; }
.dashboard-modules .module-card:nth-child(3) { animation-delay: 0.3s; }
.dashboard-modules .module-card:nth-child(4) { animation-delay: 0.4s; }
.dashboard-modules .module-card:nth-child(5) { animation-delay: 0.5s; }
.dashboard-modules .module-card:nth-child(6) { animation-delay: 0.6s; }

/* États spéciaux */
.dashboard-empty {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.dashboard-empty h3 {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.dashboard-empty p {
    font-size: 0.875rem;
}

/* Indicateurs de statut */
.status-indicator {
    display: inline-block;
    width: 8px;
    height: 0.5rem;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.status-indicator.online {
    background-color: var(--success-color);
}

.status-indicator.offline {
    background-color: var(--error-color);
}

.status-indicator.maintenance {
    background-color: var(--warning-color);
}

/* === OPTIMISATIONS NAVBAR MOBILE === */
@media (max-width: 480px) {
    .navbar {
        padding: 0.2rem 0.4rem;
        min-height: 2.188rem;
    }
    
    .navbar-brand h1 {
        font-size: 0.9rem;
    }
    
    .navbar-user {
        gap: 0.15rem;
    }
    
    .navbar-user span {
        display: none; /* Masquer les infos utilisateur */
    }
    
    .navbar-user button {
        font-size: 0.6rem;
        padding: 0.125rem 0.25rem;
    }
    
    .navbar-user select {
        font-size: 0.6rem;
        padding: 0.063rem;
    }
    
    /* Optimiser le sélecteur de langue */
    .language-selector-mini .language-current {
        padding: 0.063rem 0.188rem !important;
        font-size: 0.6rem !important;
        height: 1.375rem !important;
    }
}
