:root { 
    --primary: #0ea5e9; 
    --accent: #3b82f6;
    --bg: #0f172a; 
    --sidebar: #1e293b; 
    --card-bg: #1e293b; 
    --text: #f1f5f9; 
    --danger: #ef4444;
    --cancel: green;
    --card-width: 260px;
}

html, body {
    -webkit-user-select: none; /* Safari */
    user-select: none;         /* Empêche de surligner le texte */    
}

/* --- BASE & LAYOUT --- */
body { 
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; 
    background: var(--bg); 
    color: var(--text); 
    margin: 0; 
    display: flex; 
    height: 100vh; 
    overflow: hidden; 
}

/* --- SIDEBAR & CATALOGUE --- */
#sidebar { 
    width: 300px; 
    background: var(--sidebar); 
    border-right: 1px solid #475569; 
    display: flex; 
    flex-direction: column; 
    padding: 20px; 
    flex-shrink: 0;
}

.system-select { 
    width: 100%; 
    padding: 12px; 
    border-radius: 8px; 
    background: #0f172a; 
    color: white; 
    border: 1px solid #475569; 
    margin-bottom: 20px; 
    cursor: pointer; 
    outline: none;
}

#game-list-container { 
    flex: 1; 
    overflow-y: auto; 
    background: rgba(0,0,0,0.2); 
    border-radius: 8px; 
}

#catalog-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.catalog-item { 
    padding: 6px 15px; 
    border-bottom: 1px solid #334155; 
    cursor: pointer; 
    font-size: 0.8rem; 
    display: flex;
    align-items: center;
    transition: all 0.2s;
    color: #94a3b8;
}

/* La case vide par défaut */
.catalog-item::before {
    content: "";
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 1px solid #475569;
    border-radius: 3px;
    margin-right: 10px;
    flex-shrink: 0;
    background: #0f172a;
}

.catalog-item:hover { 
    background: rgba(59, 130, 246, 0.1); 
    color: white;
    padding-left: 20px; 
}

.catalog-item.owned {
    color: #10b981 !important; /* Un vert plus sympa */
    font-weight: bold;
    background: rgba(16, 185, 129, 0.1);
	border-left: 4px solid #10b981;
	transition: background 0.3s ease;
}

.catalog-item.owned::before {
    content: "✓";
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    background: #10b981;
    border-color: #10b981;
    font-size: 10px;
}

.catalog-item:active {
    transform: scale(0.98);
    background: var(--primary);
}

/* --- MAIN CONTENT & GRID --- */
#main-content {
    flex: 1;
	/* padding: 15px; */
	padding-top: 0px;
	overflow-y: auto;
	scroll-behavior: smooth;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: var(--sidebar);
    border-bottom: 1px solid #475569;
}

.admin-tools {
    gap: 5px;
    display: flex;
    flex-flow: row;
    float: right;
}

.grid {
    flex: 1;
    overflow-y: auto; /* Le scroll revient ici uniquement */
    padding: 25px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--card-width), 1fr));
    gap: 20px;
    align-content: start; /* Évite les étirements de Height bizarres */
    scroll-behavior: smooth;
}

/* --- CARDS --- */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    border: 1px solid #475569;
    display: flex;
    flex-direction: column;
	height: fit-content;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.4);
}

.carousel {
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    width: 100%;
    aspect-ratio: 4 / 3;
    flex-shrink: 0;
}

.carousel img { 
    width: 100%; 
    height: 100%; 
    object-fit: contain; 
}

.card-body { 
    padding: 12px; 
    text-align: center; 
    font-size: 0.9rem; 
    font-weight: 600; 
    background: rgba(0,0,0,0.2); 
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- MODE LISTE (Body class) --- */
body.is-list-mode .grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

body.is-list-mode .card {
    flex-direction: row;
    height: 70px;
    align-items: center;
}

body.is-list-mode .card:hover { transform: none; }

body.is-list-mode .card .carousel {
    width: 100px;
    height: 70px;
    aspect-ratio: auto;
}

body.is-list-mode .card .card-body {
    flex: 1;
    text-align: left;
    padding-left: 20px;
    background: transparent;
}

body.is-list-mode .nav-btn { display: none; }

/* --- BUTTONS & TOOLS --- */
.view-selector {
	display: flex;
    background: #0f172a;
    padding: 4px;
    border-radius: 10px;
    border: 1px solid #475569;
    gap: 5px;
}

.view-btn {
	background: transparent;
    border: none;
    color: #94a3b8;
    width: 35px;
    height: 35px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.view-btn:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}

.view-btn.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

.nav-btn { 
    position: absolute;
	top: 50%;
	transform: translateY(-50%);
	background: rgba(255, 255, 255, 0.1);
	color: white;
	border: none;
	border-radius: 2px;
	padding: 12px 8px;
	cursor: pointer;
	z-index: 5;
}

/* --- SCROLLBARS --- */
/* 1. Largeur de la barre */
::-webkit-scrollbar {
	width: 12px;  /* Verticale */
	height: 12px; /* Horizontale */
}

/* 2. Fond de la barre (le rail) */
::-webkit-scrollbar-track {
	background: var(--bg);
}

/* 3. La partie mobile (le curseur) */
::-webkit-scrollbar-thumb {
	background: #475569; /* Une couleur entre le gris et le bleu */
	border-radius: 10px;
	border: 2px solid var(--bg); /* Crée un petit espace autour pour l'esthétique */
}

/* 4. Effet au survol */
::-webkit-scrollbar-thumb:hover {
	background: var(--primary); /* Devient bleue quand on passe dessus */
}

/* Firefox (version simplifiée car moins personnalisable) */
* {
	scrollbar-width: thin;
	scrollbar-color: #475569 var(--bg);
}

/* --- RECHERCHE --- */
.search-wrapper {
	position: relative;
	width: 100%;
	margin-bottom: 10px;
}

#search-bar {
    width: 100%;
	padding: 10px 35px 10px 10px; /* Plus d'espace à droite pour la croix */
	border-radius: 8px;
	background: #0f172a;
	color: white;
	border: 1px solid #475569;
	box-sizing: border-box;
	outline: none;
}

.clear-search {
    position: absolute;
	right: 10px;
	top: 50%;
	transform: translateY(-50%);
	cursor: pointer;
	color: #475569;
	font-weight: bold;
	display: none; /* Cachée par défaut */
	font-size: 18px;
	transition: color 0.2s;
}

/* --- BOUTONS --- */
.btn-tool, .view-btn {
    box-shadow:inset 0px 1px 3px 0px #91b8b3;
	background:linear-gradient(to bottom, #768d87 5%, #6c7c7c 100%);
	background-color:#768d87;
	border-radius:5px;
	border:1px solid #566963;
	display:inline-block;
	cursor:pointer;
	color:#ffffff;
	font-family:Arial;
	font-size:15px;
	font-weight:bold;
	padding:11px 23px;
	text-decoration:none;
	text-shadow:0px -1px 0px #2b665e;
}

.btn-tool:hover {
	background:linear-gradient(to bottom, #6c7c7c 5%, #768d87 100%);
	background-color:#6c7c7c;
}
.btn-tool:active {
	position:relative;
	top:1px;
}

/* --- PREVIEW IMAGE LIST --- */

#game-preview {
	position: fixed;
	z-index: 1000;
	pointer-events: none;
	display: none;
	background: #000;
	border: 2px solid var(--primary);
	border-radius: 8px;
	width: 256px;
	height: 256px;
}

#game-preview img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

/* --- AJUSTEMENTS HEADER --- */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: var(--sidebar);
    border-bottom: 1px solid #475569;
    flex-wrap: nowrap; /* Empêche le header de passer sur deux lignes */
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

#main-title {
    font-size: 1.2rem; /* Taille plus raisonnable */
    margin: 0;
    white-space: nowrap;
}

#mobile-menu-toggle {
    display: none; /* Caché sur PC */
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

/* --- RESPONSIVE MOBILE --- */
/* --- MOBILE MEDIA QUERIES --- */
@media (max-width: 768px) {
    #mobile-menu-toggle {
        display: block !important;
        background: none;
        border: none;
        color: white;
        font-size: 1.8rem;
        cursor: pointer;
    }

    /* On réduit le titre sur mobile */
    #main-title {
        font-size: 1rem !important;
    }

	.hide-mobile { display: none !important; }

	.btn-text { display: none; } /* On cache le texte des boutons d'admin */

    /* Alignement des outils à droite */
    .header-right {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 0px;
    }

    /* On réduit la taille des boutons de vue pour qu'ils tiennent sur une ligne */
    .view-selector {
        gap: 4px;
    }

    .view-btn {
        width: 35px;
        height: 35px;
    }

    .admin-tools {
        gap: 8px;
    }

    .btn-tool {
        width: 45px;  /* Largeur fixe pour faire un carré */
        height: 45px; /* Hauteur fixe */
        padding: 0 !important;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.2rem !important; /* Emoji plus grand */
        border-radius: 10px !important;
    }

    /* --- FIX DES CARDS SUR MOBILE --- */
    .grid {
        /* On force le calcul des colonnes pour qu'elles ne dépassent jamais l'écran */
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
        padding: 10px !important;
        gap: 12px !important;
        display: grid !important;
    }

    /* Adaptation des cartes */
    .card .carousel {
        max-width: 100%;
    }

	/* La sidebar */
    #sidebar {
        position: fixed;
        left: -110%;
        top: 0;
        width: 90% !important; /* Plein écran */
		max-width: 90vw !important;
        height: 100vh;
        z-index: 10000;
        background: var(--sidebar);
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex !important;
        flex-direction: column;
		border: none !important;
		box-shadow: none;
    }

	#sidebar.open {
        left: 0 !important; /* Elle sort du bord (dépliée) */
		box-shadow: 10px 0 30px rgba(0,0,0,0.5);
    }

	/* En-tête de la sidebar pour le bouton fermer */
    .sidebar-header-mobile {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        margin-bottom: 20px;
        padding-bottom: 10px;
        border-bottom: 1px solid #475569;
    }

	.sidebar-header-mobile h2 {
        margin: 0;
        font-size: 1.2rem;
    }

	/* LA GROSSE CROIX X */
    .close-sidebar-btn {
        display: flex !important;
        background: var(--danger);
        color: white;
        border: none;
        width: 40px;  /* Très large pour le pouce */
        height: 40px;
        border-radius: 12px;
        font-size: 1.8rem;
        font-weight: bold;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }

	/* On cache le bouton hamburger du header quand la sidebar est ouverte 
       pour éviter les superpositions visuelles si besoin */
    body.menu-open #mobile-menu-toggle {
        opacity: 0;
    }

	.main-header {
        padding: 10px;
    }

	/* On agrandit la modale pour qu'elle occupe plus de largeur sur mobile */
    #modal-content {
        width: 90% !important;
        max-width: none !important;
        padding: 20px !important;
        border-radius: 15px !important;
    }

    #modal-text {
        font-size: 1.1rem !important;
        margin-bottom: 25px !important;
        line-height: 1.4;
    }

    /* On passe les boutons l'un au-dessus de l'autre ou on les agrandit */
    .modal-footer {
        display: flex;
        flex-direction: column; /* Boutons empilés pour plus de place */
        gap: 12px;
        width: 100%;
    }

    #modal-confirm-btn, #modal-close-btn { /* Adapte selon tes classes de boutons de modale */
        width: 100% !important;
        height: 50px !important; /* Taille idéale pour le pouce */
        font-size: 1rem !important;
        margin: 0 !important;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 10px !important;
    }
}

/* Sur PC, on cache l'en-tête mobile de la sidebar */
.sidebar-header-mobile {
    display: none;
}
