/**
 * QioQips - Mobile First CSS
 * Optimisations spécifiques pour smartphones et tablettes
 */

/* ===== BASE MOBILE (320px+) ===== */

/* Réduire les marges et padding sur mobile */
.container {
    padding: 0.75rem;
    max-width: 100%;
}

main.container {
    padding: 0.75rem;
    padding-bottom: 2rem;
}

/* Header compact sur mobile */
header {
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 0.75rem 0 !important;
}

header .container {
    padding: 0 0.75rem;
}

header h1 {
    font-size: 1.25rem !important;
    margin: 0 !important;
}

header button {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.875rem;
}

/* Touch-friendly: Taille minimale 44x44px pour les boutons */
button,
a[role="button"] {
    min-height: 44px;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
}

.action-card {
    min-height: 80px;
    padding: 0.75rem;
    cursor: pointer;
}

.action-icon {
    font-size: 2rem;
}

.action-title {
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* Tableaux scrollables horizontalement */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -0.5rem;
    padding: 0 0.5rem;
}

table {
    min-width: 600px; /* Force scroll horizontal si nécessaire */
}

/* Grilles responsive */
.stats-grid,
.actions-rapides {
    grid-template-columns: repeat(2, 1fr); /* 2 colonnes sur mobile */
    gap: 0.75rem;
}

.bilan-grid {
    grid-template-columns: repeat(2, 1fr); /* 2 colonnes sur mobile */
    gap: 0.75rem;
}

/* Cards plus compactes sur mobile */
.stat-card {
    padding: 1rem 0.75rem;
}

.stat-icon {
    font-size: 2rem;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.5rem;
    margin: 0.25rem 0;
}

.stat-label {
    font-size: 0.8rem;
}

.stat-detail {
    font-size: 0.75rem;
}

/* Section "Prochain Événement" compacte */
.prochain-event {
    padding: 1rem;
}

.event-date {
    font-size: 0.9rem;
}

/* Texte adapté au mobile */
h1 {
    font-size: 1.35rem;
}

h2 {
    font-size: 1.15rem;
    margin-bottom: 1rem;
}

h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

p {
    font-size: 0.9rem;
}

/* Forms: Inputs pleine largeur */
input,
select,
textarea {
    font-size: 16px; /* Évite le zoom auto sur iOS */
}

/* Modal plein écran sur mobile */
dialog {
    max-width: 100%;
    max-height: 100%;
    margin: 0;
}

dialog article {
    max-height: 90vh;
    overflow-y: auto;
}

/* Modal compact pour match-live (modalEvenement) */
dialog#modalEvenement {
    /* Le dialog lui-même est juste le backdrop */
    overflow-x: hidden !important;
}

dialog#modalEvenement article {
    max-width: 320px !important;
    width: 90% !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
}

/* Calendrier adaptatif */
.calendar-grid {
    font-size: 0.85rem;
}

.calendar-day {
    min-height: 60px;
    padding: 0.25rem;
}

.day-number {
    font-size: 0.9rem;
}

.event-item {
    font-size: 0.7rem;
    padding: 0.15rem 0.25rem;
}

/* Bottom Navigation pour mobile (optionnel) */
.mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e5e7eb;
    padding: 0.5rem;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    z-index: 999;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #6b7280;
    font-size: 0.7rem;
    padding: 0.5rem;
}

.mobile-nav-item.active {
    color: var(--qioqips-primary);
}

/* Cacher sur desktop */
@media (min-width: 768px) {
    .mobile-nav {
        display: none;
    }
}

/* ===== TABLETTE (768px+) ===== */
@media (min-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .stats-grid,
    .actions-rapides {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }
    
    .bilan-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    table {
        min-width: auto; /* Pas de scroll sur tablette */
    }
    
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    /* Exclure #modalEvenement des règles générales */
    dialog:not(#modalEvenement) {
        max-width: 600px;
        margin: auto;
    }
    
    /* Modal compact pour match-live (tablette) */
    dialog#modalEvenement article {
        max-width: 320px !important;
        width: 85% !important;
    }
}

/* ===== DESKTOP (1024px+) ===== */
@media (min-width: 1024px) {
    .container {
        max-width: 1200px;
        padding: 1.5rem;
    }
    
    /* Header compact sur desktop */
    header {
        padding: 1rem 0 !important;
    }
    
    header h1 {
        font-size: 1.5rem !important;
    }
    
    header button {
        padding: 0.5rem 1rem !important;
        font-size: 0.9rem;
    }
    
    /* Grilles 4 colonnes sur desktop */
    .stats-grid,
    .actions-rapides {
        grid-template-columns: repeat(4, 1fr);
        gap: 1rem;
    }
    
    /* Cards compactes */
    .stat-card {
        padding: 1rem;
    }
    
    .action-card {
        padding: 1rem;
        min-height: 100px;
    }
    
    .stat-icon {
        font-size: 2rem;
    }
    
    .action-icon {
        font-size: 2rem;
    }
    
    .stat-value {
        font-size: 1.75rem;
    }
    
    /* Textes compacts */
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.25rem;
    }
    
    h3 {
        font-size: 1.1rem;
    }
    
    /* Boutons standards */
    button {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
    
    /* Prochain événement compact */
    .prochain-event {
        padding: 1.25rem;
    }
    
    /* Tables */
    table {
        font-size: 0.9rem;
    }
    
    table thead th {
        padding: 0.75rem;
    }
    
    table tbody td {
        padding: 0.75rem;
    }
    
    /* Modales */
    /* Exclure #modalEvenement des règles générales */
    dialog:not(#modalEvenement) {
        max-width: 700px;
    }
    
    dialog article {
        padding: 1.5rem;
    }
    
    /* Modal compact pour match-live (desktop) */
    dialog#modalEvenement article {
        max-width: 320px !important;
    }
}

/* ===== LARGE DESKTOP (1440px+) ===== */
@media (min-width: 1440px) {
    .container {
        max-width: 1400px;
    }
}

/* ===== FIXES IOS ===== */
/* Safe area pour iPhone X+ */
@supports (padding: max(0px)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    
    .mobile-nav {
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
    }
}

/* Éviter le bounce sur iOS */
body {
    overscroll-behavior-y: none;
}

/* ===== UTILITAIRES MOBILE ===== */
/* Cacher sur mobile, visible sur desktop */
.hide-mobile {
    display: none;
}

@media (min-width: 768px) {
    .hide-mobile {
        display: block;
    }
}

/* Visible sur mobile, cacher sur desktop */
.hide-desktop {
    display: block;
}

@media (min-width: 768px) {
    .hide-desktop {
        display: none !important;
    }
}

/* ===== STYLES INTERNES MODAL MATCH-LIVE ===== */
/* Optimisation ergonomique pour dialog#modalEvenement */
dialog#modalEvenement article {
    padding: 0 !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
}

dialog#modalEvenement article > header {
    padding: 1.4rem 0.85rem 0.4rem 0.85rem !important;
    margin-bottom: 0 !important;
    position: relative !important;
    display: flex !important;
    align-items: flex-start !important;
    justify-content: center !important;
}

dialog#modalEvenement article > header h3 {
    font-size: 1rem !important;
    margin: 0.35rem 0 0 0 !important;
    padding: 0 2rem !important;
    text-align: center !important;
    flex: 1 !important;
    line-height: 1.3 !important;
}

/* Bouton de fermeture optimisé */
dialog#modalEvenement article > header button[aria-label="Close"] {
    position: absolute !important;
    top: calc(1.4rem + 0.35rem + 0.65rem) !important;
    right: 0.75rem !important;
    transform: translateY(-50%) !important;
    width: 1.5rem !important;
    height: 1.5rem !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 2px solid var(--qioqips-primary) !important;
    background: var(--qioqips-primary) !important;
    color: white !important;
    border-radius: 50% !important;
    cursor: pointer;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 1rem !important;
    font-weight: bold !important;
    line-height: 1 !important;
    transition: all 0.2s;
    z-index: 10 !important;
}

dialog#modalEvenement article > header button[aria-label="Close"]:hover {
    opacity: 0.8 !important;
    transform: translateY(-50%) scale(1.1) !important;
}

dialog#modalEvenement article > header button[aria-label="Close"]::before {
    content: "×" !important;
    display: block !important;
    line-height: 1 !important;
    margin-top: -1px !important;
}

dialog#modalEvenement form {
    padding: 0.6rem 0.85rem !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
}

dialog#modalEvenement form label {
    margin-bottom: 0.35rem !important;
    font-size: 0.9rem !important;
}

dialog#modalEvenement form label:last-of-type {
    margin-bottom: 0.6rem !important;
}

dialog#modalEvenement form input,
dialog#modalEvenement form select,
dialog#modalEvenement form textarea {
    padding: 0.5rem !important;
    font-size: 0.9rem !important;
    margin-top: 0.2rem !important;
}

dialog#modalEvenement form textarea {
    min-height: 60px !important;
    max-height: 120px !important;
}

dialog#modalEvenement form small {
    font-size: 0.8rem !important;
    margin-top: 0.2rem !important;
}

dialog#modalEvenement #joueurContainer,
dialog#modalEvenement #remplacantContainer,
dialog#modalEvenement #malusContainer {
    margin-bottom: 0.35rem !important;
}

dialog#modalEvenement form > footer {
    padding: 0.6rem 0.85rem !important;
    margin-top: 0 !important;
    gap: 0.5rem !important;
    display: flex !important;
    flex-direction: row !important;
    justify-content: flex-end !important;
    align-items: center !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
}

dialog#modalEvenement form > footer button {
    padding: 0.5rem 1rem !important;
    font-size: 0.85rem !important;
}

dialog#modalEvenement form > footer button.secondary {
    flex: 0 0 auto !important;
    margin-right: auto !important;
}

dialog#modalEvenement form > footer button[type="submit"] {
    flex: 0 0 auto !important;
    padding: 0.5rem 0.8rem !important;
    min-width: auto !important;
    width: auto !important;
}

@media (max-width: 768px) {
    dialog#modalEvenement article {
        max-width: 320px !important;
        width: 90% !important;
    }
    
    dialog#modalEvenement article > header {
        padding: 1.2rem 0.7rem 0.3rem 0.7rem !important;
    }
    
    dialog#modalEvenement article > header h3 {
        font-size: 0.95rem !important;
        padding: 0 1.75rem !important;
        text-align: center !important;
        line-height: 1.3 !important;
        margin: 0.3rem 0 0 0 !important;
    }
    
    dialog#modalEvenement article > header button[aria-label="Close"] {
        top: calc(1.2rem + 0.3rem + 0.62rem) !important;
    }
    
    dialog#modalEvenement form {
        padding: 0.5rem 0.7rem !important;
    }
    
    dialog#modalEvenement form > footer {
        padding: 0.5rem 0.7rem !important;
        flex-direction: row !important;
        justify-content: flex-end !important;
        align-items: center !important;
    }
    
    dialog#modalEvenement form > footer button {
        font-size: 0.85rem !important;
    }
    
    dialog#modalEvenement form > footer button.secondary {
        flex: 0 0 auto !important;
        margin-right: auto !important;
    }
    
    dialog#modalEvenement form > footer button[type="submit"] {
        flex: 0 0 auto !important;
        padding: 0.5rem 0.8rem !important;
        min-width: auto !important;
        width: auto !important;
    }
}

