/* RESET */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Segoe UI", Roboto, sans-serif;
    background: #f5f6fa;
    color: #333;
    display: flex;
    min-height: 100vh;
    line-height: 1.5;
}

/* SIDEBAR */
.sidebar {
    width: 240px;
    background: #2c3e50;
    color: #ecf0f1;
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transition: transform 0.3s ease;
}

.sidebar a {
    color: #ecf0f1;
    padding: 12px 20px;
    display: block;
    text-decoration: none;
}

.sidebar a:hover {
    background: #34495e;
}

.sidebar .active {
    background: #3498db;
}

/* HEADER */
.header {
    position: fixed;
    top: 0;
    left: 240px;
    right: 0;
    height: 60px;
    background: #fff;
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
    padding: 0 20px;
    justify-content: space-between;
    z-index: 1000;
}

.header .burger {
    display: none;
    font-size: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
}

.header h1 {
    font-size: 1.2rem;
    margin: 0;
}

/* CONTENT */
.content {
    margin-left: 240px;
    padding: 80px 20px 20px;
    flex: 1;
}

.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 20px;
    margin: 0 auto 20px;
    max-width: 1200px;
}

.card h2 {
    margin-bottom: 15px;
    color: #2c3e50;
}

/* GRID NEWS */
.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.news-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

.news-title h3 {
    text-align: center;
    margin: 0;
}

.news-image img {
    width: 100%;
    height: 160px;
    object-fit: cover;
}

.news-content {
    padding: 12px 15px;
    flex: 1;
}

.news-content h3 {
    margin-bottom: 8px;
    font-size: 1.1rem;
    color: #2c3e50;
}

.news-content p {
    margin: 4px 0;
    font-size: 0.9rem;
    color: #555;
}

.news-actions {
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    border-top: 1px solid #eee;
    justify-content: flex-start;
}

/* BUTTONS */
.btn {
    padding: 6px 12px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
}

.btn-primary {
    background: #3498db;
    color: #fff;
}

.btn-primary:hover {
    background: #2980b9;
}

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

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

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

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

/* PAGINATION */
.pagination {
    margin-top: 20px;
    text-align: center;
}

.pagination a,
.pagination span {
    display: inline-block;
    padding: 6px 12px;
    margin: 2px;
    border-radius: 4px;
    border: 1px solid #ccc;
    color: #333;
    text-decoration: none;
}

.pagination .active {
    background: #3498db;
    color: #fff;
    border-color: #3498db;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        transform: translateX(-100%);
        z-index: 2000;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .header {
        left: 0;
    }

    .header .burger {
        display: block;
    }

    .content {
        margin-left: 0;
        padding: 70px 10px 20px;
    }

    .card {
        padding: 15px;
    }
}

/* Champs du formulaire uniformisés */
.form-control {
    display: block;
    width: 100%;
    /* ✅ prend toute la largeur */
    padding: 10px 12px;
    /* un peu plus de confort */
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 3px rgba(52, 152, 219, 0.3);
}

/* Labels au-dessus, bien alignés */
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #2c3e50;
}

/* Checkbox alignée correctement */
.form-group.checkbox {
    display: flex;
    align-items: center;
}

.form-group.checkbox label {
    font-weight: normal;
    margin: 0;
}

/* Conteneur de l’image dans le formulaire */
.image-preview {
    width: 150px;
    /* largeur fixe */
    height: 150px;
    /* hauteur fixe */
    border: 1px dashed #ccc;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
}

/* Partie image = 75% */
.image-preview img {
    width: 100%;
    height: 75%;
    /* occupe 75% de la hauteur */
    object-fit: cover;
    /* ✅ remplit sans déformation */
    display: block;
}

/* rendre le cadre interactif */
.image-preview {
    cursor: pointer;
    /* pointeur main */
    transition: transform 0.2s ease, border-color 0.2s ease;
}

/* petite animation au survol */
.image-preview:hover {
    transform: scale(1.02);
    border-color: #3498db;
}

/* Partie texte = 25% */
#news-media-filename,
#dispositif-media-filename {
    flex: 1;
    /* occupe le reste (25%) */
    display: flex;
    align-items: center;
    /* centrage vertical */
    justify-content: center;
    /* centrage horizontal */
    font-size: 0.85rem;
    color: #333;
    background: #f9f9f9;
    border-top: 1px solid #ddd;
    text-align: center;
    padding: 2px 4px;
    word-break: break-word;
}

/* Texte par défaut quand aucune image n’est choisie */
#news-media-placeholder,
#dispositif-media-placeholder {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    color: #999;
    background: #f9f9f9;
    border-top: 1px solid #ddd;
    text-align: center;
}

/* Image de la carte actu → cliquable */
.news-image {
    cursor: pointer;
    transition: transform 0.2s ease;
    overflow: hidden;
}

.news-image:hover {
    transform: scale(1.02);
}


/* ================================
   GRILLE DISPOSITIFS
================================= */
.dispositif-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* Zone de drag : bordure supérieure */
.dispositif-card {
    /* Identique aux news-cards (pas de marge en bas : la grille gère l'espacement) */
    margin: 0;
}

/* Image cliquable */


/* Quand pas d’image */
.dispositif-image .no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 160px;
    background: #f9f9f9;
    color: #999;
    font-size: 0.9rem;
}

/* .dispositif-actions {
    Identique aux news-actions
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    border-top: 1px solid #eee;
    justify-content: flex-start;
} */

/* Poignée de drag & drop */
.drag-handle {
    cursor: grab;
    margin-right: 10px;
    font-size: 18px;
    user-select: none;
    color: #555;
}

.drag-handle:active {
    cursor: grabbing;
}

/* Décalage pour scrollIntoView sur le formulaire */
#newsForm {
    scroll-margin-top: 150px;
    /* espace sous le header fixe */
}

/* ================================
   POPUP IMPORT NEWS
================================= */

/* Désactive le flex global hérité du body */
body#import-popup {
    display: block;
    background: #f5f6fa;
    padding: 30px;
    font-family: "Segoe UI", Roboto, sans-serif;
}

/* Conteneur principal centré */
#import-popup .popup-container {
    max-width: 900px;
    margin: 0 auto;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: 90vh;
}

/* Titre */
#import-popup h2 {
    margin-bottom: 15px;
    color: #2c3e50;
}

/* Zone des filtres */
#import-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

#import-controls input,
#import-controls button {
    width: auto;
}

/* Zone des résultats */
#import-results {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 15px;
    background: #fafafa;
}

/* Pagination en bas */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    position: sticky;
    bottom: 0;
    background: #fff;
    padding: 10px 0;
    border-top: 1px solid #ddd;
    flex-wrap: wrap;
}

/* Boutons numérotés */
.page-btn {
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid #ccc;
    background: #f9f9f9;
    cursor: pointer;
    font-size: 14px;
}

.page-btn:hover {
    background: #eaeaea;
}

.page-btn.active-page {
    background: #3498db;
    color: #fff;
    border-color: #3498db;
}

/* Ellipses */
.ellipsis {
    padding: 6px 10px;
    color: #888;
}

/* Bouton importer */
#importSelectedNews {
    margin-left: auto;
    margin-top: 15px;
}

/* Pagination numéros */
#pageNumbers {
    display: flex;
    gap: 5px;
    align-items: center;
}

#pageNumbers .page-btn {
    padding: 4px 8px;
    border: 1px solid #ccc;
    background: #f9f9f9;
    cursor: pointer;
    border-radius: 4px;
}

#pageNumbers .page-btn:hover {
    background: #eee;
}

#pageNumbers .active-page {
    background: #3498db;
    color: #fff;
    border-color: #3498db;
}

#pageNumbers .ellipsis {
    padding: 4px 6px;
    color: #666;
}

/* Conteneur URL avec bouton intégré */
.url-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.url-wrapper input {
    flex: 1;
    padding-right: 40px;
    /* laisse de la place pour le bouton 🔗 */
}

.open-url-btn {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: #3498db;
}

.open-url-btn:hover {
    color: #2980b9;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    /* espace entre titre et bouton */
}

.page-action a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #007bff;
    color: #fff;
    font-size: 16px;
    text-decoration: none;
    transition: background 0.2s ease;
}

.page-action a:hover {
    background: #0056b3;
}

.user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info {
    text-align: right;
    font-size: 0.9em;
    line-height: 1.2em;
}

.user-info::first-line {
    font-weight: bold;
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #ccc;
}

.sidebar h2 {
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 20px;
    color: #fff;
}

.logout-btn {
    margin-top: auto;
    padding: 20px;
    text-align: center;
}

.logout-btn .btn {
    width: 100%;
    text-align: center;
}

/* =====================================================
   AUTH PAGES (login, reset-password admin)
===================================================== */
.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: #f5f6fa;
}

.auth-box {
    background: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    width: 340px;
    text-align: center;
}

.auth-box h2 {
    margin-bottom: 15px;
    font-size: 1.2rem;
    color: #2c3e50;
}

.auth-box input {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 0.95rem;
}

.auth-box input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 4px rgba(52, 152, 219, 0.5);
}

.auth-box button {
    width: 100%;
    padding: 10px;
    background: #3498db;
    border: none;
    color: #fff;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background 0.2s ease;
}

.auth-box button:hover {
    background: #2980b9;
}

.auth-box .error {
    color: #e74c3c;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.auth-box .success {
    color: #27ae60;
}

.auth-box p {
    margin-top: 10px;
    font-size: 0.9rem;
}

.auth-box p a {
    color: #3498db;
    text-decoration: none;
}

.auth-box p a:hover {
    text-decoration: underline;
}

/* ========= 🔢 Compteur demandes (sidebar) ========= */
.badge {
    display: inline-block;
    background-color: #d9534f;
    /* rouge admin / couleur d’alerte */
    color: white;
    font-size: 0.8em;
    font-weight: bold;
    border-radius: 10px;
    padding: 2px 6px;
    margin-left: 6px;
    min-width: 20px;
    text-align: center;
    vertical-align: middle;
}

.sidebar a .badge {
    position: relative;
    top: -1px;
}