@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
    --bg-color: #0f172a;      /* Bleu nuit très sombre */
    --card-bg: #1e293b;       /* Bleu gris pour les cartes */
    --text-light: #f8fafc;    /* Blanc cassé */
    --text-muted: #94a3b8;    /* Gris clair */
    --primary: #8b5cf6;       /* Violet fluo */
    --secondary: #ec4899;     /* Rose fluo */
    --success: #10b981;       /* Vert émeraude */
    --danger: #ef4444;        /* Rouge corail */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Poppins', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-light);
    min-height: 100vh;
    padding-bottom: 50px;
    background-image: radial-gradient(circle at top right, rgba(139, 92, 246, 0.15), transparent 40%),
                      radial-gradient(circle at bottom left, rgba(236, 72, 153, 0.1), transparent 40%);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    animation: fadeIn 0.8s ease-out;
}

/* Animations globales */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- NAVBAR ---- */
.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(10px); /* Effet verre dépoli */
    padding: 20px 30px;
    border-radius: 20px;
    margin-bottom: 40px;
    border: 1px solid rgba(255,255,255,0.05);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.nav h2 {
    background: linear-gradient(to right, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
}

/* ---- BOUTONS ---- */
.btn {
    padding: 10px 20px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    text-align: center;
    color: white;
}

.btn-primary { background: linear-gradient(135deg, var(--primary), var(--secondary)); box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4); }
.btn-primary:hover { transform: translateY(-3px) scale(1.02); box-shadow: 0 8px 25px rgba(139, 92, 246, 0.6); }

.btn-success { background: var(--success); }
.btn-success:hover { background: #059669; box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4); transform: translateY(-2px); }

.btn-danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: var(--danger); color: white; box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4); transform: translateY(-2px); }

.btn-outline { background: transparent; border: 1px solid var(--text-muted); color: var(--text-light); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

/* ---- FORMULAIRES ET INPUTS ---- */
.form-box {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.05);
    margin-bottom: 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

input, textarea {
    width: 100%;
    padding: 15px;
    margin-bottom: 15px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    color: var(--text-light);
    font-size: 1em;
    transition: all 0.3s ease;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

/* ---- GRILLE & CARTES (MANHWAS) ---- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 30px;
}

.card {
    background: var(--card-bg);
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255,255,255,0.05);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    border-color: rgba(139, 92, 246, 0.3);
}

.card-img-wrapper {
    overflow: hidden;
    height: 350px;
    position: relative;
}

.card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.card:hover img {
    transform: scale(1.1);
}

.card-img-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50%;
    background: linear-gradient(to top, var(--card-bg) 10%, transparent);
}

.card-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    z-index: 2;
    margin-top: -30px; /* Remonte le texte sur l'image */
}

.card-title {
    font-size: 1.2em;
    font-weight: 600;
    margin-bottom: 5px;
    line-height: 1.3;
}

.badge {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 600;
    display: inline-block;
    width: fit-content;
    margin-bottom: 10px;
}

.date-text { color: var(--text-muted); font-size: 0.8em; margin-bottom: 10px; }
.desc-text { color: var(--text-muted); font-size: 0.9em; margin-bottom: 20px; flex-grow: 1; }

.actions { display: flex; gap: 10px; margin-top: 15px; }
.actions .btn { flex: 1; padding: 10px 5px; font-size: 0.85em; }

/* ---- TUILES ACCUEIL ---- */
.menu-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 30px; }

.menu-tile {
    background: var(--card-bg);
    padding: 50px 20px;
    border-radius: 20px;
    text-align: center;
    text-decoration: none;
    color: var(--text-light);
    font-size: 1.5em;
    font-weight: 600;
    border: 1px solid rgba(255,255,255,0.05);
    position: relative;
    overflow: hidden;
    z-index: 1;
    transition: all 0.4s ease;
}

.menu-tile::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    z-index: -1;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.menu-tile:hover { transform: translateY(-10px); box-shadow: 0 15px 30px rgba(139, 92, 246, 0.3); border-color: transparent;}
.menu-tile:hover::before { opacity: 1; }
.tile-icon { font-size: 2.5em; display: block; margin-bottom: 15px; transition: transform 0.3s ease; }
.menu-tile:hover .tile-icon { transform: scale(1.2) rotate(5deg); }

/* Recherche */
.search-bar { display: flex; gap: 10px; margin-bottom: 30px; }
.search-bar input { margin-bottom: 0; }

/* ---- EFFET VERRE (GLASSMORPHISM) POUR LOGIN / REGISTER / EDIT ---- */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 85vh;
    padding: 20px;
}

.glass-form {
    background: rgba(30, 41, 59, 0.3); /* Fond très transparent */
    backdrop-filter: blur(16px); /* Le flou magique du verre */
    -webkit-backdrop-filter: blur(16px); /* Pour la compatibilité Safari */
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 
                inset 0 1px 0 rgba(255, 255, 255, 0.1); /* Petit reflet interne */
    padding: 50px 40px;
    border-radius: 24px;
    width: 100%;
    max-width: 450px;
    position: relative;
    overflow: hidden;
    animation: fadeIn 0.8s ease-out;
}

/* Reflet lumineux subtil en haut à gauche du verre */
.glass-form::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(circle at center, rgba(255,255,255,0.03) 0%, transparent 50%);
    pointer-events: none;
}

.glass-form h2 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 2em;
}

/* On assombrit un peu les inputs pour qu'ils ressortent sur le verre */
.glass-form input, .glass-form textarea {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 20px;
}

.glass-form input:focus, .glass-form textarea:focus {
    background: rgba(0, 0, 0, 0.4);
    border-color: var(--primary);
}

.auth-links {
    text-align: center;
    margin-top: 25px;
    font-size: 0.9em;
}

.auth-links a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.3s;
}

.auth-links a:hover {
    color: var(--primary);
}

/* ---- TABLEAUX (PANEL ADMIN) ---- */
.admin-table { width: 100%; border-collapse: collapse; margin-top: 20px; background: var(--card-bg); border-radius: 12px; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.1); }
.admin-table th, .admin-table td { padding: 15px; text-align: left; border-bottom: 1px solid rgba(255,255,255,0.05); color: var(--text-light); }
.admin-table th { background: rgba(0,0,0,0.2); font-weight: 600; color: var(--primary); }
.admin-table tr:hover { background: rgba(255,255,255,0.02); }
.admin-section {
    text-align: center;
    margin-top: 50px;
}

.btn-admin {
    padding: 15px 40px;
    font-size: 1.2em;
    display: inline-block;
}
/* =========================================
   📱 RESPONSIVE WEB DESIGN (Mobiles & Tablettes)
   ========================================= */

@media (max-width: 768px) {
    /* 1. Ajustement des marges globales */
    .container {
        padding: 10px;
    }

    /* 2. La barre de navigation s'empile au lieu d'être côte à côte */
    .nav {
        flex-direction: column;
        text-align: center;
        gap: 15px;
        padding: 15px;
        border-radius: 15px;
    }

    /* 3. La barre de recherche s'empile */
    .search-bar {
        flex-direction: column;
        gap: 10px;
    }
    
    .search-bar input, 
    .search-bar select, 
    .search-bar button {
        width: 100%;
        margin-bottom: 0;
    }

    /* 4. Les champs de formulaires (Titre + Chapitre) passent en colonne */
    .form-box form > div[style*="display: flex"] {
        flex-direction: column !important;
        gap: 0 !important;
    }

    .form-box form > div[style*="display: flex"] > input {
        width: 100% !important;
        margin-bottom: 15px !important;
    }

    /* 5. Réduction de la hauteur des images sur mobile pour gagner de la place */
    .card-img-wrapper {
        height: 250px; 
    }

    /* 6. Panel Admin : on casse les grilles forcées en 2 colonnes */
    .grid[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* 7. Les formulaires de connexion / verre dépoli */
    .glass-form {
        padding: 30px 20px;
        border-radius: 15px;
    }

    /* 8. Ajustement des textes */
    .glass-form h2 { font-size: 1.5em; }
    .menu-tile { padding: 30px 15px; font-size: 1.2em; }

    .btn-admin {
        padding: 12px 20px !important;
        font-size: 1em !important;
        width: 100%;
        max-width: 280px; /* Évite qu'il soit trop large sur petit mobile */
    }
}

/* Écrans vraiment très petits (ex: vieux iPhone) */
@media (max-width: 400px) {
    .grid {
        grid-template-columns: 1fr; /* Force 1 seule carte par ligne */
    }
}