/* --- RESET ET BASE --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

:root {
    --header-bg: #123b7a;
    --header-accent: #d9f99d;
    --card-header-bg: #123b7a;
    --card-header-text: #d9f99d;
}

body {
    background-color: #f4f7f6;
    color: #333;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- NAVIGATION --- */
header {
    background-color: var(--header-bg);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--header-accent);
}

nav ul {
    display: flex;
    list-style: none;
    gap: 15px;
    align-items: center;
}

nav a {
    text-decoration: none;
    color: #fff;
    font-weight: 500;
    transition: all 0.3s;
    padding: 5px 15px;
    border: 1px solid transparent;
    border-radius: 20px;
}

nav a:hover {
    color: var(--header-accent);
}

.btn-actif {
    border: 1px solid var(--header-accent);
    color: var(--header-accent);
    background-color: rgba(217, 249, 157, 0.1);
}

/* --- MENU DÉROULANT --- */
.dropdown {
    position: relative;
}

.dropdown-toggle {
    cursor: pointer;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: #1e293b;
    min-width: 200px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    border-radius: 8px;
    padding: 0.5rem 0;
    margin-top: 5px;
    list-style: none;
    z-index: 1000;
}

.dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-menu li {
    margin: 0;
}

.dropdown-menu a {
    display: block;
    padding: 10px 20px;
    color: #fff;
    text-decoration: none;
    transition: background-color 0.3s;
    border-radius: 0;
}

.dropdown-menu a:hover {
    background-color: var(--header-bg);
    color: var(--header-accent);
}

/* --- STYLE DES DRAPEAUX DANS LE MENU LANGUE --- */
.dropdown-menu .lang-link {
    display: flex !important;
    align-items: center;
    padding: 10px 20px;
    white-space: nowrap;
}

.flag-icon {
    width: 20px;
    height: auto;
    margin-right: 10px;
    border-radius: 2px;
    outline: 1px solid rgba(255, 255, 255, 0.1);
    display: block;
    flex-shrink: 0;
    vertical-align: middle;
}

/* --- CONTENU CENTRAL --- */
main {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.cards-container {
    display: flex;
    gap: 3rem;
    max-width: 1200px;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
}

/* --- CADRES (CARTES) --- */
.card {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    width: 400px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    text-align: center;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
}

.card-image {
    height: 250px;
    width: 100%;
    background-color: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-content {
    padding: 2rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.card h2 {
    margin-bottom: 1rem;
    color: #0f172a;
    font-size: 1.8rem;
}

.card p {
    margin-bottom: 2rem;
    color: #64748b;
}

/* --- BOUTONS D'ACTION --- */
.btn-action {
    display: inline-block;
    padding: 10px;
    margin: 2px;
    font-size: 1.1rem;
    font-weight: bold;
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.3s;
    cursor: pointer;
    border: none;
}

.btn-create {
    background-color: #0f172a;
    color: #d9f99d;
}

.btn-create:hover {
    background-color: #1e293b;
}

.btn-explore {
    background-color: #d9f99d;
    color: #0f172a;
}

.btn-explore:hover {
    background-color: #bef264;
}

/* --- CLASSES POUR LA CRÉATION ET LES POULES --- */
.container-card {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.table-padel {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0;
}

.table-padel thead tr {
    background: #0f172a;
    color: white;
}

.table-padel th, .table-padel td {
    padding: 12px;
    border: 1px solid #ddd;
    text-align: left;
}

.table-padel tr:nth-child(even) {
    background-color: #f8fafc;
}

/* Grille pour les poules */
.grid-poules {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-top: 1.5rem;
}

@media (max-width: 768px) {
    .grid-poules {
        grid-template-columns: 1fr;
    }
}

.card-poule {
    border: 1px solid #0f172a;
    border-radius: 10px;
    overflow: hidden;
    min-width: 0; /* Permet au contenu de se rétrécir */
    display: flex;
    flex-direction: column;
}

.card-poule > div:last-child {
    overflow-x: auto;
    flex: 1;
}

.card-poule-content {
    overflow-x: auto;
    flex: 1;
    min-height: 0; /* Permet au contenu de se rétrécir correctement */
}

.card-poule-header {
    background: var(--card-header-bg);
    color: var(--card-header-text);
    padding: 10px;
    font-weight: bold;
    text-align: center;
}

.poids-badge {
    background: rgba(217, 249, 157, 0.3);
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Bouton Vainqueur */
.btn-winner-toggle {
    background-color: #e2e8f0;
    color: #64748b;
    border: none;
    padding: 5px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: bold;
    transition: all 0.3s ease;
    margin-top: 5px;
    width: 100px;
}

.btn-winner-toggle.active {
    background-color: #ef4444;
    color: white;
    border-color: #ef4444;
}

.btn-winner-toggle:hover {
    opacity: 0.8;
}

.btn-winner-toggle[data-is-bye="true"] {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(1);
}

.radio-card {
    cursor: pointer;
    flex: 1;
}

.radio-card input {
    display: none;
}

.radio-card .card-content {
    border: 2px solid #e2e8f0;
    padding: 15px;
    border-radius: 10px;
    background: white;
    transition: all 0.2s;
}

.radio-card input:checked + .card-content {
    border-color: #3b82f6;
    background: #eff6ff;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.1);
}

.card-content strong {
    display: block;
    color: #1e293b;
    margin-bottom: 5px;
}

.card-content span {
    font-size: 0.8rem;
    color: #64748b;
}

/* --- MESSAGES FLASH --- */
.flash-message {
    position: fixed;
    top: 80px; /* Juste sous le header */
    left: 50%;
    transform: translateX(-50%);
    max-width: 1200px;
    width: calc(100% - 2rem);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    animation: slideDown 0.3s ease-out;
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.flash-message.fade-out {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
    pointer-events: none;
}

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

.flash-success {
    background-color: #d1fae5;
    color: #065f46;
    border-left: 4px solid #10b981;
}

.flash-error {
    background-color: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

.flash-info {
    background-color: #dbeafe;
    color: #1e40af;
    border-left: 4px solid #3b82f6;
}

.flash-warning {
    background-color: #fef3c7;
    color: #92400e;
    border-left: 4px solid #f59e0b;
}

/* --- FORMULAIRE UPLOAD --- */
input[type="file"] {
    font-size: 0.95rem;
}

input[type="file"]:hover {
    border-color: #0f172a;
}

input[type="file"]:focus {
    outline: none;
    border-color: #0f172a;
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.1);
}

/* Amélioration du tableau pour les CSV */
.table-padel {
    font-size: 0.9rem;
}

.table-padel th {
    position: sticky;
    top: 0;
    z-index: 10;
}

.table-padel tbody tr:hover {
    background-color: #f1f5f9;
}

/* --- MODALE --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 0;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    background: #0f172a;
    color: white;
    padding: 1.5rem;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    color: #d9f99d;
}

.modal-close {
    color: #d9f99d;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    opacity: 0.7;
}

.modal-body {
    padding: 2rem;
}

.btn-match {
    background-color: #9d4e7d !important;
    color: #d9f99d !important;
    border: none !important;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: bold;
    transition: all 0.3s;
}

.btn-match:hover:not(:disabled) {
    background-color: #1e293b;
    transform: translateY(-2px);
}

.btn-choix-paire {
    background-color: #f8fafc;
    color: #0f172a;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: left;
}

.btn-choix-paire:hover:not(:disabled) {
    background-color: #e2e8f0;
    border-color: #0f172a;
    transform: translateX(5px);
}

.btn-choix-paire:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- RESPONSIVE MOBILE --- */
@media (max-width: 768px) {
    /* Header et Navigation */
    header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    .logo {
        font-size: 1.2rem;
        text-align: center;
    }
    
    nav {
        width: 100%;
    }
    
    nav ul {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        font-size: 0.85rem;
        width: 100%;
    }
    
    nav a {
        padding: 4px 8px;
        font-size: 0.85rem;
        white-space: nowrap;
    }
    
    .dropdown {
        position: static;
    }
    
    .dropdown {
        width: 100%;
        position: relative;
    }
    
    .dropdown-toggle {
        display: block;
        width: 100%;
        text-align: center;
    }
    
    .dropdown-menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        display: none;
        width: 100%;
        margin-top: 0.5rem;
        min-width: auto;
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
        border-radius: 8px;
        background-color: #1e293b;
        padding: 0.5rem 0;
    }
    
    .dropdown.active .dropdown-menu,
    .dropdown:hover .dropdown-menu,
    .dropdown:focus-within .dropdown-menu {
        display: block;
    }
    
    .dropdown-menu li {
        margin: 0;
    }
    
    .dropdown-menu a {
        padding: 10px 15px;
        font-size: 0.85rem;
        display: block;
    }
    
    /* Main content */
    main {
        padding: 1rem;
    }
    
    .cards-container {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
    }
    
    .card {
        width: 100%;
        max-width: 400px;
    }
    
    /* Container cards */
    .container-card {
        padding: 1rem !important;
        margin: 0;
        border-radius: 10px;
    }
    
    /* Espacement réduit pour les sections */
    .container-card > div {
        margin-bottom: 1rem !important;
    }
    
    .container-card > div:first-child {
        margin-bottom: 1.5rem !important;
    }
    
    /* Tableaux - transformation en scroll horizontal avec indicateur */
    .table-padel {
        font-size: 0.75rem;
        display: table;
        width: 100%;
        table-layout: auto;
    }
    
    .table-padel thead,
    .table-padel tbody,
    .table-padel tr {
        display: table-row;
    }
    
    .table-padel th, 
    .table-padel td {
        padding: 6px 4px;
        white-space: nowrap;
    }
    
    /* Wrapper pour les tableaux avec scroll horizontal */
    div[style*="overflow-x: auto"],
    .card-poule-content {
        position: relative;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: #64748b #f1f5f9;
    }
    
    /* Style pour la scrollbar sur WebKit */
    div[style*="overflow-x: auto"]::-webkit-scrollbar,
    .card-poule-content::-webkit-scrollbar {
        height: 8px;
    }
    
    div[style*="overflow-x: auto"]::-webkit-scrollbar-track,
    .card-poule-content::-webkit-scrollbar-track {
        background: #f1f5f9;
        border-radius: 4px;
    }
    
    div[style*="overflow-x: auto"]::-webkit-scrollbar-thumb,
    .card-poule-content::-webkit-scrollbar-thumb {
        background: #64748b;
        border-radius: 4px;
    }
    
    div[style*="overflow-x: auto"]::-webkit-scrollbar-thumb:hover,
    .card-poule-content::-webkit-scrollbar-thumb:hover {
        background: #475569;
    }
    
    /* Boutons */
    .btn-action {
        font-size: 0.9rem;
        padding: 8px 12px;
    }
    
    /* Grid poules */
    .grid-poules {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* Card poule header */
    .card-poule-header {
        padding: 8px;
        font-size: 0.9rem;
    }
    
    .card-poule-content {
        padding: 0.5rem !important;
    }
    
    /* Flash messages */
    .flash-message {
        width: calc(100% - 1rem);
        margin: 0 0.5rem;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
        top: 70px;
    }
    
    /* Modales */
    .modal-content {
        width: 95%;
        margin: 5% auto;
        max-width: 100%;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-header h2 {
        font-size: 1.2rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    /* Forms */
    .form-group {
        margin-bottom: 0.75rem;
    }
    
    .form-group input {
        padding: 0.6rem;
        font-size: 0.9rem;
    }
}

/* --- RESPONSIVE TRÈS PETIT MOBILE --- */
@media (max-width: 480px) {
    header {
        padding: 0.75rem 0.5rem;
    }
    
    .logo {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }
    
    nav {
        width: 100%;
    }
    
    nav ul {
        gap: 6px;
        font-size: 0.75rem;
        padding: 0;
    }
    
    nav a {
        padding: 4px 6px;
        font-size: 0.75rem;
    }
    
    .dropdown-toggle {
        font-size: 0.75rem;
        padding: 4px 6px;
    }
    
    .dropdown-menu {
        margin-top: 0.25rem;
        padding: 0.25rem 0;
    }
    
    .dropdown-menu a {
        padding: 8px 12px;
        font-size: 0.75rem;
    }
    
    main {
        padding: 0.75rem;
    }
    
    .container-card {
        padding: 0.75rem !important;
        border-radius: 10px;
    }
    
    h1 {
        font-size: 1.5rem !important;
    }
    
    h2 {
        font-size: 1.2rem !important;
    }
    
    h3 {
        font-size: 1rem !important;
    }
    
    .table-padel {
        font-size: 0.7rem;
        min-width: auto;
    }
    
    .table-padel th, 
    .table-padel td {
        padding: 4px 2px;
    }
    
    /* Titres de sections avec boutons */
    div[style*="display: flex"][style*="justify-content: space-between"] {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.75rem !important;
    }
    
    /* Formulaires inline */
    div[style*="display: flex"][style*="align-items"] {
        flex-direction: column;
        gap: 0.75rem !important;
    }
    
    div[style*="flex: 1"] {
        width: 100%;
        min-width: 100% !important;
    }
    
    /* Boutons en colonne sur très petit écran */
    div[style*="display: flex"][style*="gap"] > .btn-action,
    div[style*="display: flex"][style*="gap"] > a.btn-action,
    div[style*="display: flex"][style*="gap"] > button {
        width: 100%;
    }
    
    .btn-action {
        font-size: 0.85rem;
        padding: 10px;
        text-align: center;
        white-space: normal !important;
    }
    
    /* Card poule */
    .card-poule-header {
        font-size: 0.85rem;
        padding: 6px;
        flex-wrap: wrap;
    }
    
    .edit-poule-name {
        font-size: 0.8rem !important;
    }
    
    /* Matchs buttons */
    .btn-match {
        font-size: 0.75rem !important;
        padding: 6px 10px !important;
    }
    
    /* Classement poule */
    table[style*="width: 100%"] {
        font-size: 0.7rem;
        min-width: auto;
    }
    
    table[style*="width: 100%"] th,
    table[style*="width: 100%"] td {
        padding: 4px 2px;
    }
    
    /* Grid poules sur très petit écran - une seule colonne */
    .grid-poules {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }
}

/* --- AMÉLIORATIONS GLOBALES POUR TOUS LES ÉCRANS MOBILES --- */
@media (max-width: 768px) {
    /* Amélioration des inputs file sur mobile */
    input[type="file"] {
        font-size: 0.85rem;
        padding: 8px;
    }
    
    /* Espacement réduit pour les sections */
    .container-card > div[style*="margin-bottom: 2rem"] {
        margin-bottom: 1rem !important;
    }
    
    /* Amélioration du test button */
    .btn-test-poule {
        font-size: 0.7rem !important;
        padding: 3px 8px !important;
    }
    
    /* Tableaux dans les card-poule */
    .card-poule table {
        min-width: 100%;
    }
    
    .card-poule table.table-padel {
        min-width: 500px;
    }
}
