/* Reset et base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

/* Container principal */
.container {
    max-width: 1400px;
    width: 100%; /* Force à ne jamais dépasser */
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 2px 2px 10px rgba(0,255,255,0.5),
                -1px -1px 20px rgba(0,255,255,0.5);
    overflow: hidden;
    box-sizing: border-box; /* Inclut padding et border dans la largeur */
}

/* Header */
.header {
    background: linear-gradient(135deg, #3d52a0 0%, #7091e6 100%);
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 20px;
}

.admin-icon {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    margin-left:3px;
    margin-right:22px;

}

.admin-title {
    color: white;
    font-size: 24px;
    font-weight: 300;
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-icon-small {
    font-size: 20px;
}

.logo-main {
    text-align: center;
    display:flex;
    flex-direction:row;
    margin-right: 180px;
    margin-top:-15px;
}

.logo-main img{
    height:100%;
    width:100px;
    margin:20px 20px 0;
    filter: drop-shadow(3px 3px 10px blue);
}

.logo-title {
    font-size: 80px;
    font-weight: bold;
    color: #00d4ff;
    text-shadow: 
        -2px -2px 0 rgba(0,0,255,0.3),
        2px -2px 0px rgba(0,0,255,0.3),
        8px 8px 6px rgba(0,0,255,0.3),
        -5px 5px 6px rgba(0,0,255,0.3);
    margin: 0;
    padding-top:0px;
}

.logo-subtitle {
    color: white;
    font-size: 18px;
    font-style: italic;
    margin-top: 0px;
}

.settings-icon {
    width: 50px;
    height: 50px;
    background: rgba(255,255,255,0.15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: background 0.3s;
}

.settings-icon:hover {
    background: rgba(255,255,255,0.25);
}

/* Navigation tabs */
.tabs {
    display: flex;
    background: #f5f5f5;
    background: linear-gradient(135deg, #3d52a0 0%, #7091e6 100%);
}

.tab {
    flex: 1;
    padding: 5px;
    text-align: center;
    background: #e0e0e0;
    color: #666;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
    position: relative;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
}

.tab.active {
    color: #333;
    font-weight: bold;
    border-bottom-color: currentColor;
}

.icon-tab{
    height:32px;
    vertical-align:middle;
    margin-bottom:6px;
}

/* Couleurs des onglets */
.tab[data-tab="categorie"] { background: #c8f4c8; }
.tab[data-tab="categorie"].active { background: #a8e6a8; border-bottom-color: #5a9e5a; }

.tab[data-tab="kwiz"] { background: #c8e6f4; }
.tab[data-tab="kwiz"].active { background: #a8d6e6; border-bottom-color: #4a8ca8; }

.tab[data-tab="niveau"] { background: #f4d4c8; }
.tab[data-tab="niveau"].active { background: #e6c4b8; border-bottom-color: #a87a5a; }

.tab[data-tab="serie"] { background: #f4ecc8; }
.tab[data-tab="serie"].active { background: #e6dcb8; border-bottom-color: #a89c5a; }

.tab[data-tab="question"] { background: #d4c8f4; }
.tab[data-tab="question"].active { background: #c4b8e6; border-bottom-color: #7a5aa8; }

.tab[data-tab="choix"] { background: #f4c8e6; }
.tab[data-tab="choix"].active { background: #e6b8d6; border-bottom-color: #a85a8c; }

.tab[data-tab="partie"] { background: #c8f4c8; }
.tab[data-tab="partie"].active { background: #a8e6a8; border-bottom-color: #5a9e5a; }

.tab[data-tab="test"] { background: #c8e6f4; }
.tab[data-tab="test"].active { background: #a8d6e6; border-bottom-color: #4a8ca8; }

.tab[data-tab="invitation"] { background: #f4d4c8; }
.tab[data-tab="invitation"].active { background: #e6c4b8; border-bottom-color: #a87a5a; }

.tab[data-tab="direct"] { background: #f4ecc8; }
.tab[data-tab="direct"].active { background: #e6dcb8; border-bottom-color: #a89c5a; }

/* Contenu des tabs */
.tab-content {
    display: none !important;
    padding: 40px;
    min-height: 600px;
    box-sizing: border-box; /* Important pour que le padding soit inclus */
    max-width: 100%; /* Ne jamais dépasser le parent */
    overflow-x: hidden; /* Pas de scroll horizontal */
}

.tab-content.active {
    display: block !important;
}

.tab:not(.active):hover {
    background: linear-gradient(135deg, #3d52a0 0%, #7091e6 30%);
    color:white;
    border-top:1px solid white;
}
/* Couleurs de fond des contenus */
.tab-content[data-tab="categorie"] { background: #e8f8e8; }
.tab-content[data-tab="kwiz"] { background: #e8f3f8; }
.tab-content[data-tab="niveau"] { background: #f8ebe8; }
.tab-content[data-tab="serie"] { background: #f8f4e8; }
.tab-content[data-tab="question"] { background: #ebe8f8; }
.tab-content[data-tab="choix"] { background: #f8e8f3; }
.tab-content[data-tab="partie"] { background: #e8f8e8; }
.tab-content[data-tab="test"] { background: #e8f3f8; }
.tab-content[data-tab="invitation"] { background: #f8ebe8; }
.tab-content[data-tab="direct"] { background: #f8f4e8; }

/* Formulaires */
.form-row {
    display: flex;
    gap: 30px;
    margin-bottom: 30px;
    align-items: flex-start;
    flex-wrap: wrap; /* Permet le retour à la ligne */
    max-width: 100%; /* Ne jamais dépasser */
    box-sizing: border-box;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 200px; /* Largeur minimale */
    max-width: 100%; /* Ne jamais dépasser */
    box-sizing: border-box;
}

.form-label {
    font-size: 14px;
    font-weight: 600;
    color: #444;
    margin-bottom: 8px;
}

.form-label .required {
    color: #e74c3c;
    margin-left: 4px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
    background: white;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 35px;
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

/* Boutons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-block;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #229954;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-move {
    background: blue;
    opacity: 0.7;
    color: white;
}

/* Liste des éléments */
.item-list {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-top: 30px;
}

.item-list h3 {
    margin-bottom: 20px;
    color: #333;
    font-size: 20px;
}

.item {
    padding: 15px;
    border: 2px solid #eee;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
}

.item:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.item-info {
    flex: 1;
}

.item-title {
    font-weight: 600;
    color: #333;
    font-size: 16px;
    margin-bottom: 5px;
}

.item-meta {
    font-size: 13px;
    color: #666;
}

.item-actions {
    display: flex;
    gap: 10px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

/* Messages */
.message {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.message-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Upload de fichiers */
.file-upload {
    display: flex;
    gap: 15px;
    align-items: center;
}

.file-input {
    display: none;
}

.file-label {
    padding: 10px 20px;
    background: #f0f0f0;
    border: 2px dashed #ccc;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    flex: 1;
}

.file-label:hover {
    background: #e8e8e8;
    border-color: #667eea;
}

.file-preview {
    max-width: 150px;
    max-height: 150px;
    border-radius: 8px;
    border: 2px solid #ddd;
}

/* Question Preview */
.preview-section {
    background: white;
    border-radius: 12px;
    padding: 30px;
    margin-top: 30px;
}

.preview-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #333;
}

.preview-layout {
    display: grid;
    gap: 20px;
}

/* Layouts différents selon le mode */
.preview-layout.text-only {
    grid-template-columns: 1fr;
}

.preview-layout.one-media-side {
    grid-template-columns: 1fr 300px;
}

.preview-layout.one-media-below {
    grid-template-columns: 1fr;
}

.preview-layout.four-media-side {
    grid-template-columns: 1fr 300px;
}

.preview-question-text {
    font-size: 18px;
    font-weight: 500;
    color: #333;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}
.preview-media {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e9ecef;
    border-radius: 8px;
    min-height: 200px;
    color: #666;
    font-style: italic;
}

.preview-media img,
.preview-media video {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
}

/* Grille de 4 médias */
.media-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.media-grid-item {
    background: #e9ecef;
    border-radius: 8px;
    min-height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
}

/* Recherche */
.search-box {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.search-input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
}

/* Responsive */
@media (max-width: 1024px) {
    .form-row {
        flex-direction: column;
    }
    
    .preview-layout.one-media-side,
    .preview-layout.four-media-side {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 20px;
    }
    
    .tabs {
        flex-wrap: wrap;
    }
    
    .tab {
        flex: 1 1 50%;
        font-size: 16px;
    }
    
    .tab-content {
        padding: 20px;
    }
}

/* Utilitaires */
.hidden {
    display: none !important;
}

.text-muted {
    color: #666;
}

.text-center {
    text-align: center;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gap-10 {
    gap: 10px;
}

/* ==========================================
   TOASTS - Notifications modernes
   ========================================== */

#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: white;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 400px;
    animation: slideIn 0.3s ease-out, slideOut 0.3s ease-in 2.7s;
    pointer-events: auto;
    border-left: 4px solid;
}

.toast-success {
    border-left-color: #27ae60;
}

.toast-error {
    border-left-color: #e74c3c;
}

.toast-warning {
    border-left-color: #f39c12;
}

.toast-info {
    border-left-color: #3498db;
}

.toast-icon {
    font-size: 24px;
    line-height: 1;
}

.toast-success .toast-icon::before { content: "✓"; color: #27ae60; }
.toast-error .toast-icon::before { content: "✗"; color: #e74c3c; }
.toast-warning .toast-icon::before { content: "⚠"; color: #f39c12; }
.toast-info .toast-icon::before { content: "ℹ"; color: #3498db; }

.toast-message {
    flex: 1;
    color: #333;
    font-size: 15px;
    font-weight: 500;
}

.toast-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    width: 20px;
    height: 20px;
}

.toast-close:hover {
    color: #333;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* Responsive */
@media (max-width: 768px) {
    #toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }
    
    .toast {
        min-width: auto;
        max-width: none;
    }
}

/* ==========================================
   CSS GRID - Règles communes à tous les panneaux
   ========================================== */
[class^="grid-"] > * {
    min-width: 0; /* Empêche les cellules grid de déborder */
}

/* ==========================================
   LARGEURS DES CHAMPS DANS LES GRID
   Cellule span 6 → champ à 80% (≈ 5 colonnes visuelles)
   Cellule span 3 → champ à 80%
   Cellule span 4 → champ à 75% (kwiz)
   Labels toujours au-dessus (flex-direction: column)
   ========================================== */

/* Toutes les cellules grid : label au-dessus, champ en dessous */
[class^="gc-"], [class^="gk-"], [class^="gn-"], [class^="gs-"] {
    display: flex;
    flex-direction: column;
}

/* Champs de recherche : le wrapper positionne la croix, doit avoir la même largeur que le champ */
.gc-recherche .search-wrapper,
.gn-recherche .search-wrapper,
.gs-recherche .search-wrapper,
.gk-recherche .search-wrapper,
.gh-recherche .search-wrapper { width: 80%; display: block; }

/* Le champ input dans le wrapper prend toute la largeur du wrapper */
.search-wrapper .form-input { width: 100% !important; padding-right: 40px; }

/* Span 6 : Catégorie, Niveau, Série (nom, description, mode) — PAS les champs recherche */
.gc-liste .form-select,
.gc-nom .form-input,
.gc-description .form-textarea,
.gn-liste .form-select,
.gn-nom .form-input,
.gn-description .form-textarea,
.gs-nom .form-input,
.gs-description .form-textarea,
.gs-mode .form-select { width: 80%; }

/* Span 3 : Série (catégorie, kwiz, liste, niveau) */
.gs-categorie .form-select,
.gs-kwiz .form-select,
.gs-liste .form-select,
.gs-niveau .form-select { width: 80%; }

/* Span 6 Kwiz : nom, description (PAS recherche — géré par search-wrapper) */
.gk-nom .form-input,
.gk-description .form-textarea { width: 80%; }

/* Span 6 Kwiz : catégorie et liste */
.gk-categorie .form-select,
.gk-liste .form-select { width: 80%; }

/* Boutons grid : chaque bouton occupe 80% de son span 2 */
[class$="-btn-create"] .btn,
[class$="-btn-reset"] .btn,
[class$="-btn-move"] .btn {
    width: 80%;
    display: block;
}

/* Largeurs champs panneau Choix */
.gh-nom .form-input          { width: 80%; }
.gh-categorie .form-select,
.gh-kwiz .form-select,
.gh-serie .form-select,
.gh-niveau .form-select,
.gh-question .form-select    { width: 80%; }
.gh-explication .form-textarea,
.gh-texte .form-textarea     { width: 80%; }
