/* Styles généraux */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 17px;
}

html.font-large {
    font-size: 19px;
}

html.font-xlarge {
    font-size: 21px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f4f4f4;
    font-size: 1rem;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
    outline: 3px solid #1a6fa8;
    outline-offset: 2px;
}

/* ══════════════════════════════════════════════════
   Header 2 lignes — sticky
   ══════════════════════════════════════════════════ */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    /* pas de box-shadow global : le "rail" est géré sur header-row2
       pour que l'onglet actif puisse s'y ouvrir sans trait */
    position: sticky;
    top: 0;
    z-index: 100;
}

/* ── Ligne 1 : titre + actions ── */
.header-row1 {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    gap: 1rem;
}

header h1 {
    font-size: 1.15rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
    flex: 1;
    min-width: 0;
}

/* Zone utilisateur — compacte, à droite */
.user-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Chip nom connecté */
#user-display:not(:empty) {
    font-size: 0.82rem;
    font-weight: 600;
    background: rgba(255,255,255,.15);
    padding: 0.22rem 0.7rem;
    border-radius: 20px;
    white-space: nowrap;
    letter-spacing: 0.01em;
}
#user-display:not(:empty)::before {
    content: '● ';
    font-size: 0.6rem;
    color: #7effc4;
    vertical-align: middle;
}

/* Bouton déconnexion — icône compact */
#logout-btn.btn {
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.35);
    color: white;
    padding: 0.28rem 0.65rem;
    font-size: 1.05rem;
    min-height: 34px;
    border-radius: 7px;
    line-height: 1;
}
#logout-btn.btn:hover {
    background: rgba(255,255,255,.28);
    border-color: rgba(255,255,255,.65);
}

/* Bouton connexion — compact */
#login-btn.btn {
    font-size: 0.85rem;
    min-height: 34px;
    padding: 0.3rem 0.9rem;
}

/* ── Ligne 2 : navigation — onglets de classeur ── */
.header-row2 {
    background: rgba(0,0,0,.2);
    border-top: 1px solid rgba(255,255,255,.12);
    /* Pas de border-bottom ici : l'onglet actif gère seul le raccord avec le contenu */
    padding-bottom: 0;
    overflow: visible;  /* indispensable pour que l'onglet actif déborde vers le bas */
    position: relative; /* repère pour les indicateurs de scroll */
}

#main-nav {
    max-width: 1400px;
    margin: 0 auto;
    padding: 7px 20px 2px;           /* 2px en bas : absorbe le débordement de l'onglet actif */
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;             /* fine mais visible (Firefox) */
    scrollbar-color: rgba(255,255,255,.45) transparent;
    scroll-behavior: smooth;
}
/* Fine barre visible — Chrome/Edge/Safari */
#main-nav::-webkit-scrollbar { height: 5px; }
#main-nav::-webkit-scrollbar-track { background: transparent; }
#main-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.45);
    border-radius: 3px;
}
#main-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.7); }

/* Indicateurs de débordement (flèches fondues aux extrémités) */
.nav-fade {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 34px;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
    color: rgba(255,255,255,.85);
    z-index: 5;
    cursor: pointer;
    user-select: none;
}
.nav-fade:hover { color: #fff; }
.nav-fade.left {
    left: 0;
    background: linear-gradient(to right, rgba(40,26,90,.95), transparent);
    border-radius: 0 10px 10px 0;
}
.nav-fade.right {
    right: 0;
    background: linear-gradient(to left, rgba(40,26,90,.95), transparent);
    border-radius: 10px 0 0 10px;
}
.header-row2.nav-overflow-left  .nav-fade.left  { display: flex; }
.header-row2.nav-overflow-right .nav-fade.right { display: flex; }

#main-nav ul {
    display: flex;
    list-style: none;
    gap: 0.4rem;
    flex-wrap: nowrap;
    margin: 0;
    padding: 0;
    align-items: flex-end;
    overflow: visible;
}

/* Onglets inactifs */
#main-nav a {
    display: block;
    color: rgba(255,255,255,.85);
    text-decoration: none;
    padding: 0.36rem 1rem 0.42rem;
    border-radius: 7px 7px 0 0;     /* coins arrondis en haut uniquement */
    border: 1px solid rgba(255,255,255,.22);
    border-bottom: none;
    white-space: nowrap;
    font-size: 0.88rem;
    font-weight: 500;
    background: rgba(255,255,255,.1);
    transition: background 0.18s, border-color 0.18s;
    cursor: pointer;
    user-select: none;
    position: relative;
    margin-bottom: 0;
}
#main-nav a:hover {
    background: rgba(255,255,255,.22);
    border-color: rgba(255,255,255,.45);
    color: white;
}

/* Onglet actif — déborde de 2px sous le header et se fond dans le contenu */
#main-nav a.active {
    background: #f4f4f4;               /* = fond du body, raccord parfait */
    color: #4a35a0;
    border: 1px solid rgba(255,255,255,.55);
    border-bottom: 2px solid #f4f4f4;  /* prolonge la couleur contenu → aucun trait visible */
    font-weight: 700;
    padding-top: 0.48rem;
    margin-bottom: -2px;               /* seul l'onglet actif descend sous le header */
    box-shadow: -2px 0 4px rgba(0,0,0,.1), 2px 0 4px rgba(0,0,0,.1);
    z-index: 2;
}

/* Boutons */
.btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
    font-size: 1rem;
    min-height: 44px;
}

.font-size-controls {
    display: flex;
    gap: 0.3rem;
    align-items: center;
}

.btn-font {
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.5);
    min-width: 34px;
    font-weight: 700;
    padding: 0.22rem 0.5rem;
    font-size: 0.85rem;
    min-height: 34px;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-font:hover {
    background: rgba(255,255,255,0.32);
}

.btn:hover {
    background: #0056b3;
}

.btn-danger {
    background: #dc3545;
}

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

.btn-success {
    background: #28a745;
}

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

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    max-width: 520px;
    width: 95%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    color: #333;
}

.modal-content form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-content input {
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.modal-content input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}

.modal-content button {
    padding: 0.75rem;
    border: none;
    border-radius: 5px;
    background: #007bff;
    color: white;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

.modal-content button:hover {
    background: #0056b3;
}

.modal-content p {
    text-align: center;
    margin-top: 1rem;
}

.modal-content a {
    color: #007bff;
    text-decoration: none;
}

.modal-content a:hover {
    text-decoration: underline;
}

/* Main content */
main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 20px;
    min-height: calc(100vh - 200px);
}

#welcome-message {
    text-align: center;
    padding: 3rem;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Admin panel */
.admin-panel {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 20px;
}

.admin-section {
    background: white;
    margin-bottom: 2rem;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.admin-section h3 {
    margin-bottom: 1rem;
    color: #333;
    border-bottom: 2px solid #007bff;
    padding-bottom: 0.5rem;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

table th, table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
}

table tr:hover {
    background: #f8f9fa;
}

/* Page content */
.page-content {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.page-header {
    border-bottom: 2px solid #007bff;
    padding-bottom: 1rem;
    margin-bottom: 2rem;
}

.page-title {
    font-size: 2rem;
    color: #333;
    margin-bottom: 0.5rem;
}

.page-meta {
    color: #666;
    font-size: 0.9rem;
}

/* Create news section */
.create-news-section {
    margin-bottom: 2rem;
}

.create-news-section button {
    transition: all 0.3s ease;
}

#news-form-container {
    animation: slideDown 0.3s ease-out;
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 10px;
    border: 1px solid #dee2e6;
}

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

/* News Carousel and Tickets */
.news-carousel {
    margin: 2rem 0;
}

.news-timeline {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.news-ticket {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.news-ticket:hover {
    border-color: #007bff;
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.ticket-header {
    padding: 1.5rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.3s ease;
}

.ticket-header:hover {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
}

.ticket-title-section {
    flex: 1;
}

.ticket-title {
    margin: 0 0 0.5rem 0;
    color: #333;
    font-size: 1.3rem;
    font-weight: 600;
}

.ticket-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.9rem;
    color: #666;
}

.ticket-author {
    font-weight: 500;
}

.ticket-likes {
    color: #e91e63;
    font-weight: 500;
}

.ticket-toggle {
    margin-left: 1rem;
}

.toggle-icon {
    font-size: 1.2rem;
    color: #007bff;
    transition: transform 0.3s ease;
}

.ticket-content {
    padding: 1.5rem;
    border-top: 1px solid #dee2e6;
    animation: slideDown 0.3s ease-out;
}

.ticket-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin-bottom: 1rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.ticket-text {
    line-height: 1.6;
    color: #333;
    margin-bottom: 1.5rem;
}

.ticket-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.btn-sm {
    padding: 0.5rem 0.9rem;
    font-size: 0.95rem;
    min-height: 40px;
}

.ticket-comments {
    border-top: 1px solid #e9ecef;
    padding-top: 1rem;
}

.comments-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 5px;
    margin-bottom: 1rem;
    transition: background 0.3s ease;
}

.comments-toggle:hover {
    background: #e9ecef;
}

.comments-icon {
    color: #007bff;
    transition: transform 0.3s ease;
}

.comments-content {
    animation: slideDown 0.3s ease-out;
}

.comments-list {
    margin-bottom: 1rem;
}

.comment {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.8rem;
    border-left: 4px solid #007bff;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.comment-author {
    font-weight: 600;
    color: #333;
}

.comment-date {
    color: #666;
}

.comment-content {
    line-height: 1.5;
    color: #444;
}

.comment-form {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.comment-form textarea {
    min-height: 80px;
    resize: vertical;
}

/* Responsive pour les billets */
@media (max-width: 768px) {
    .news-ticket {
        margin: 0 -1rem;
        border-radius: 0;
    }
    
    .ticket-header {
        padding: 1rem;
    }
    
    .ticket-title {
        font-size: 1.1rem;
    }
    
    .ticket-meta {
        font-size: 0.8rem;
        gap: 0.5rem;
    }
    
    .ticket-content {
        padding: 1rem;
    }
    
    .ticket-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .ticket-actions button {
        width: 100%;
    }
}

/* Animation pour l'expansion des billets */
@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        max-height: 2000px;
        transform: translateY(0);
    }
}

/* News items (legacy - gardé pour compatibilité) */
.news-item {
    background: white;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.news-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.news-title {
    font-size: 1.3rem;
    color: #333;
    margin-bottom: 0.5rem;
}

.news-meta {
    color: #666;
    font-size: 0.9rem;
}

.news-content {
    margin-bottom: 1rem;
    line-height: 1.6;
}

.news-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.like-btn {
    background: none;
    border: 1px solid #ddd;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

.like-btn:hover {
    background: #f8f9fa;
}

.like-btn.liked {
    background: #e3f2fd;
    border-color: #2196f3;
    color: #2196f3;
}

/* Reaction buttons */
.reactions-bar {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-bottom: 0.6rem;
}

.reaction-btn {
    background: #fff;
    border: 1px solid #ccc;
    padding: 0.55rem 1rem;
    border-radius: 22px;
    cursor: pointer;
    font-size: 1.05rem;
    transition: all 0.2s;
    white-space: nowrap;
    line-height: 1.4;
    min-height: 44px;
}

.reaction-btn:hover {
    background: #f8f9fa;
    transform: scale(1.08);
}

.reaction-btn.active {
    background: #e3f2fd;
    border-color: #2196f3;
    color: #1565c0;
    font-weight: 600;
}

.reaction-hand.active {
    background: #e8f5e9;
    border-color: #4caf50;
    color: #2e7d32;
}

/* Voters section */
.voters-section {
    margin-top: 0.4rem;
}

.voters-toggle {
    font-size: 0.95rem;
    padding: 0.45rem 0.9rem;
}

.voters-panel {
    background: #f1f8e9;
    border: 1px solid #c5e1a5;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-top: 0.5rem;
}

.voters-panel strong {
    display: block;
    margin-bottom: 0.5rem;
    color: #33691e;
    font-size: 0.9rem;
}

.voters-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.voter-name {
    background: #dcedc8;
    border: 1px solid #aed581;
    color: #33691e;
    padding: 0.25rem 0.7rem;
    border-radius: 20px;
    font-size: 0.95rem;
    font-weight: 500;
}

.hidden {
    display: none !important;
}

/* Comments */
.comments-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #eee;
}

.comment {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1rem;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.comment-author {
    font-weight: 600;
    color: #333;
}

.comment-date {
    color: #666;
    font-size: 0.9rem;
}

.comment-content {
    line-height: 1.5;
}

.comment-form {
    margin-top: 1rem;
}

.comment-form textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
}

.comment-form textarea:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}

/* Checkbox grid */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-item input[type="checkbox"] {
    width: auto;
}

/* Éditeur de commentaires */
.comment-toolbar {
    display: flex;
    align-items: center;
    gap: .2rem;
    flex-wrap: wrap;
    padding: .25rem .4rem;
    background: #f5f7fa;
    border: 1px solid #dde1ea;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
}

.ctb {
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: .15rem .45rem;
    cursor: pointer;
    font-size: .85rem;
    color: #333;
    line-height: 1.4;
    min-width: 26px;
}

.ctb:hover { background: #e2e6ef; border-color: #c5cad8; }

.ctb-sep {
    width: 1px;
    height: 18px;
    background: #ccc;
    margin: 0 .2rem;
}

.comment-editor {
    min-height: 60px;
    padding: .5rem .6rem;
    border: 1px solid #dde1ea;
    border-radius: 0 0 6px 6px;
    outline: none;
    font-size: .9rem;
    background: #fff;
    margin-bottom: .4rem;
    line-height: 1.5;
}

.comment-editor:empty::before {
    content: attr(data-placeholder);
    color: #aaa;
    pointer-events: none;
}

.comment-attachment img { max-width: 100%; border-radius: 6px; margin-top: .4rem; }
.comment-attachment audio,
.comment-attachment video { max-width: 100%; margin-top: .4rem; }

.comment-actions { margin-left: auto; display: flex; gap: .1rem; }
.comment-actions .ctb { padding: .1rem .3rem; font-size: .8rem; }

/* File viewer modal */
.file-viewer-modal { background: rgba(0,0,0,.55); }
.file-viewer-modal .modal-content { overflow: hidden; }

/* ── Zone d'upload multi-fichiers ─────────────────────────────────────────── */
.upload-zone {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    margin-top: .25rem;
}
.upload-zone-inline { margin-top: .3rem; margin-bottom: .3rem; }

.upload-zone-files {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}

.upload-zone-btn {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    white-space: nowrap;
    align-self: flex-start;
}

.file-chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    background: #f0f4ff;
    border: 1px solid #c8d4f5;
    border-radius: 6px;
    padding: .2rem .45rem .2rem .3rem;
    font-size: .8rem;
    max-width: 220px;
}
.file-chip-thumb {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}
.file-chip-icon { font-size: 1.1rem; }
.file-chip-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #3a3a5c;
}
.file-chip-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: #b44;
    font-size: .85rem;
    padding: 0 .1rem;
    line-height: 1;
    flex-shrink: 0;
}
.file-chip-remove:hover { color: #c00; }

/* ── Lightbox plein écran ─────────────────────────────────────────────────── */
#lb-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.93);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    animation: lb-in .15s ease;
}
@keyframes lb-in { from { opacity:0 } to { opacity:1 } }

#lb-overlay #lb-img {
    max-width: 95vw;
    max-height: 92vh;
    object-fit: contain;
    border-radius: 4px;
    cursor: default;
    box-shadow: 0 8px 40px rgba(0,0,0,.6);
}
#lb-overlay #lb-close {
    position: absolute;
    top: 14px;
    right: 18px;
    background: rgba(255,255,255,.12);
    border: none;
    color: #fff;
    font-size: 1.6rem;
    line-height: 1;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}
#lb-overlay #lb-close:hover { background: rgba(255,255,255,.28); }

.sheet-wrapper { overflow: auto; }
.sheet-wrapper table { border-collapse: collapse; font-size: .82rem; }
.sheet-wrapper td, .sheet-wrapper th {
    border: 1px solid #ddd;
    padding: .2rem .5rem;
    white-space: nowrap;
}
.sheet-wrapper tr:nth-child(even) { background: #f9f9f9; }
.sheet-wrapper tr:first-child td, .sheet-wrapper th { background: #e8f0fe; font-weight: 600; }

.docx-content { padding: .5rem 1rem; line-height: 1.7; }
.docx-content h1, .docx-content h2, .docx-content h3 { margin: .8rem 0 .4rem; }
.docx-content p { margin: .4rem 0; }

/* Matrice permissions */
.rights-table-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 65vh;
    width: 100%;
    border: 1px solid #e8eaf0;
    border-radius: 6px;
    /* Scrollbars toujours visibles pour signaler le contenu caché */
    scrollbar-width: thin;
    scrollbar-color: #b0b8d8 #f0f2fa;
}
.rights-table-wrapper::-webkit-scrollbar { width: 8px; height: 8px; }
.rights-table-wrapper::-webkit-scrollbar-track { background: #f0f2fa; }
.rights-table-wrapper::-webkit-scrollbar-thumb { background: #b0b8d8; border-radius: 4px; }

/* Figer les en-têtes de la matrice */
#rights-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f5f7ff;
}
#rights-table thead tr:first-child th:first-child,
#rights-table tbody td:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    background: #fff;
    border-right: 2px solid #dde0f0;
}
#rights-table thead tr:first-child th:first-child {
    z-index: 4;
}

.matrix-page-header {
    text-align: center;
    background: #eef2ff;
    font-size: .82rem;
    border-left: 2px solid #c7d0f8;
    padding: .4rem .3rem;
}

.matrix-sub-header {
    text-align: center;
    background: #f5f7ff;
    font-size: .78rem;
    color: #555;
    padding: .3rem .2rem;
    min-width: 48px;
}

.matrix-sub-header input[type="checkbox"] {
    display: block;
    margin: 0 auto .2rem;
    cursor: pointer;
    width: 15px;
    height: 15px;
}

.matrix-cell {
    text-align: center;
    padding: .35rem .2rem;
}

.matrix-cell input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.matrix-cell.border-left {
    border-left: 2px solid #eee;
}

/* Footer */
footer {
    background: #333;
    color: white;
    text-align: center;
    padding: 1rem 0;
    margin-top: 2rem;
}

/* Responsive */
@media (max-width: 768px) {
    /* Header ligne 1 : titre plus court sur mobile */
    header h1 {
        font-size: 0.92rem;
    }

    .admin-section {
        padding: 1rem;
    }

    table {
        font-size: 0.9rem;
    }

    .modal-content {
        padding: 1.5rem;
    }
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 5px;
    color: white;
    z-index: 2000;
    animation: slideIn 0.3s ease-out;
}

.notification.success {
    background: #28a745;
}

.notification.error {
    background: #dc3545;
}

.notification.info {
    background: #17a2b8;
}

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

/* ═══════════════════════════════════════════════
   NEWS CAROUSEL — Style Étal Solidaire
═══════════════════════════════════════════════ */
:root {
    --es-green-dark:  #2d5a1b;
    --es-green:       #4a8c35;
    --es-green-light: #6db84e;
    --es-cream:       #f5f7ef;
    --es-gold:        #d4a017;
    --es-earth:       #7a5c3a;
    --es-border:      #c8ddb8;
}

.news-carousel-section {
    background: var(--es-cream);
    border-radius: 14px;
    border: 1px solid var(--es-border);
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(45,90,27,.1);
    margin-top: 1rem;
}

.news-carousel-header {
    background: linear-gradient(135deg, var(--es-green-dark) 0%, var(--es-green) 100%);
    padding: 14px 20px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ncs-logo {
    height: 34px;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.ncs-title  { color: #fff; font-size: 1.05rem; font-weight: 700; text-align: right; }
.ncs-subtitle { font-size: .85rem; color: rgba(255,255,255,.85); text-align: right; }

/* Filter bar */
.ncs-filter-bar {
    display: flex;
    gap: 6px;
    padding: 10px 16px 6px;
    flex-wrap: wrap;
}

.ncs-filter-btn {
    background: #fff;
    border: 1px solid var(--es-border);
    color: #444;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: .95rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all .2s;
    min-height: 40px;
}

.ncs-filter-btn:hover { background: #e8f0df; border-color: var(--es-green-light); }
.ncs-filter-btn.active { background: var(--es-green); border-color: var(--es-green); color: #fff; font-weight: 600; }

/* Carousel track */
.ncs-track-wrap { position: relative; padding: 10px 0 4px; }

.ncs-track {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    padding: 4px 20px 14px;
    -webkit-overflow-scrolling: touch;
}

.ncs-track::-webkit-scrollbar { height: 5px; }
.ncs-track::-webkit-scrollbar-track { background: #e8eee0; border-radius: 4px; }
.ncs-track::-webkit-scrollbar-thumb { background: var(--es-green-light); border-radius: 4px; }

/* Cards */
.ncs-card {
    flex-shrink: 0;
    width: 230px;
    scroll-snap-align: start;
    border-radius: 11px;
    overflow: hidden;
    background: #fff;
    border: 2px solid var(--es-border);
    cursor: pointer;
    transition: transform .25s, box-shadow .25s, border-color .2s;
    position: relative;
}

.ncs-card:hover {
    transform: scale(1.04) translateY(-3px);
    box-shadow: 0 8px 22px rgba(45,90,27,.22);
    border-color: var(--es-green-light);
    z-index: 2;
}

.ncs-card.ncs-card-active {
    border-color: var(--es-green-dark);
    transform: scale(1.05) translateY(-4px);
    box-shadow: 0 10px 28px rgba(45,90,27,.32);
}

.ncs-card.ncs-card-hidden { display: none; }

.ncs-thumb {
    width: 100%;
    height: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.ncs-thumb-logo {
    width: 72%;
    height: 72%;
    object-fit: contain;
    opacity: .5;
    filter: grayscale(15%);
}

.ncs-badge {
    position: absolute;
    top: 7px; left: 7px;
    font-size: .8rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 10px;
    letter-spacing: .3px;
    color: #fff;
}

.ncs-badge-urgent { background: #c0392b; }
.ncs-badge-info   { background: #1a6fa8; }
.ncs-badge-stock  { background: #27ae60; }
.ncs-badge-event  { background: #8e44ad; }

.ncs-card-body  { padding: 11px 13px 13px; }
.ncs-card-author { font-size: .82rem; color: var(--es-earth); font-weight: 600; margin-bottom: 3px; }

.ncs-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--es-green-dark);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ncs-card-reactions { display: flex; gap: 5px; margin-top: 7px; flex-wrap: wrap; }

.ncs-rx {
    font-size: .82rem;
    background: var(--es-cream);
    color: #444;
    padding: 3px 8px;
    border-radius: 9px;
    border: 1px solid var(--es-border);
}

/* Nav arrows */
.ncs-arrow {
    position: absolute;
    top: 45%;
    transform: translateY(-50%);
    background: var(--es-green-dark);
    color: #fff;
    border: none;
    width: 44px; height: 44px;
    border-radius: 50%;
    font-size: 26px;
    cursor: pointer;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,.2);
    transition: background .2s;
}

.ncs-arrow:hover { background: var(--es-green); }
.ncs-arrow-left  { left: 4px; }
.ncs-arrow-right { right: 4px; }

/* Detail panel */
.ncs-detail {
    display: none;
    border-top: 2px solid var(--es-border);
    background: #fff;
    padding: 18px 20px 20px;
}

.ncs-detail.open { display: block; }

.ncs-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.ncs-detail-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--es-green-dark);
}

.ncs-close-btn {
    background: var(--es-cream);
    border: 1px solid var(--es-border);
    color: #555;
    width: 40px; height: 40px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ncs-close-btn:hover { background: var(--es-border); color: var(--es-green-dark); }

.ncs-detail-meta { font-size: .92rem; color: var(--es-earth); margin-bottom: 12px; }

.ncs-detail-img {
    width: 100%;
    max-height: 280px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 12px;
}
/* Curseur zoom sur toutes les images cliquables */
.lb-trigger { cursor: zoom-in; transition: opacity .15s; }
.lb-trigger:hover { opacity: .88; }

.ncs-detail-text { line-height: 1.7; color: #333; margin-bottom: 14px; font-size: 1.05rem; }

.no-news { text-align: center; color: #666; padding: 2rem; }

/* ── Assistant IA Chat ─────────────────────────────────────────────────── */
#ai-chat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 1.4rem;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(102,126,234,.5);
    z-index: 1200;
    display: none;
    align-items: center;
    justify-content: center;
    transition: transform .2s;
}
#ai-chat-toggle:hover { transform: scale(1.08); }
#ai-chat-toggle.visible { display: flex; }

#ai-chat-panel {
    position: fixed;
    top: 0;
    right: -380px;
    width: 360px;
    height: 100vh;        /* fallback */
    height: 100dvh;       /* adapts to virtual keyboard on modern browsers */
    background: #fff;
    box-shadow: -4px 0 20px rgba(0,0,0,.15);
    z-index: 1100;
    display: flex;
    flex-direction: column;
    transition: right .3s ease;
    border-left: 3px solid #667eea;
}
#ai-chat-panel.open { right: 0; }

#ai-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    flex-shrink: 0;
}
#ai-chat-header span { font-weight: 600; font-size: 1rem; }
#ai-chat-header small { display: block; font-size: .75rem; opacity: .85; }
#ai-chat-header button {
    background: rgba(255,255,255,.2);
    border: none;
    color: #fff;
    width: 28px; height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: .9rem;
    display: flex; align-items: center; justify-content: center;
}
#ai-chat-header button:hover { background: rgba(255,255,255,.35); }

#ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f9f9fb;
}

.ai-msg {
    max-width: 88%;
    padding: 8px 12px;
    border-radius: 14px;
    font-size: .92rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}
.ai-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ai-msg.assistant {
    align-self: flex-start;
    background: #fff;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
}
.ai-msg.system-info {
    align-self: center;
    background: #f0f0f0;
    color: #888;
    font-size: .8rem;
    padding: 4px 10px;
    border-radius: 10px;
}
.ai-msg.thinking {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e0e0e0;
    color: #aaa;
    border-bottom-left-radius: 4px;
    font-style: italic;
}

#ai-chat-footer {
    flex-shrink: 0;
    padding: 10px;
    border-top: 1px solid #e8e8e8;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

#ai-chat-ctx-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}
#ai-chat-ctx-btn {
    font-size: .78rem;
    padding: 3px 8px;
    border: 1px solid #667eea;
    background: #fff;
    color: #667eea;
    border-radius: 12px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}
#ai-chat-ctx-btn:hover { background: #667eea; color: #fff; }
#ai-chat-ctx-label { font-size: .75rem; color: #888; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#ai-chat-input-row { display: flex; gap: 6px; align-items: flex-end; }
#ai-chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 8px 10px;
    font-size: .9rem;
    resize: none;
    font-family: inherit;
    outline: none;
    transition: border-color .2s;
}
#ai-chat-input:focus { border-color: #667eea; }
#ai-chat-send {
    width: 38px; height: 38px;
    border: none;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
#ai-chat-send:disabled { opacity: .5; cursor: default; }

@media (max-width: 768px) {
    #ai-chat-toggle {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
    }
    #ai-chat-panel {
        width: 100vw;
        right: -100vw;
        border-left: none;
        border-top: 3px solid #667eea;
    }
    #ai-chat-input {
        font-size: 16px; /* empêche le zoom automatique iOS */
    }
    #ai-chat-footer {
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
    #ai-chat-header {
        padding-top: max(12px, env(safe-area-inset-top));
    }
    #ai-chat-send {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }
    #ai-chat-header button {
        width: 36px;
        height: 36px;
    }
}

/* ══════════════════════════════════════════════════════════════════════════════
   RDV & Planning — Sondages de disponibilité
   ══════════════════════════════════════════════════════════════════════════════ */

.rdv-page {
    padding: 1.5rem 2rem;
    max-width: 1000px;
    margin: 0 auto;
}

.rdv-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: .75rem;
}

.rdv-header h2 { margin: 0; font-size: 1.5rem; color: #2b2d42; }
.rdv-create-btn { font-size: .92rem; }
.rdv-empty { color: #888; text-align: center; padding: 2rem; }

/* Carte sondage */
.poll-card {
    background: #fff;
    border: 1px solid #dde1ea;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

.poll-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: .6rem;
}

.poll-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #2b2d42;
    margin-right: .5rem;
}

.poll-status {
    display: inline-block;
    font-size: .75rem;
    font-weight: 600;
    padding: .18rem .55rem;
    border-radius: 20px;
    vertical-align: middle;
}
.poll-status.open      { background: #e8f5e9; color: #2e7d32; }
.poll-status.confirmed { background: #e3f2fd; color: #1565c0; }
.poll-status.closed    { background: #f3f3f3; color: #666; }

.poll-expires {
    font-size: .78rem;
    color: #e07800;
    margin-left: .4rem;
}

.poll-card-meta {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: .8rem;
    color: #888;
}

.poll-description {
    color: #555;
    font-size: .88rem;
    margin-bottom: .75rem;
    padding: .4rem .6rem;
    background: #f8f9fa;
    border-radius: 6px;
}

/* Tableau Doodle */
.poll-table-wrap { overflow-x: auto; margin: .75rem 0; }

.poll-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}

.poll-table th, .poll-table td {
    border: 1px solid #e5e8ee;
    padding: .4rem .6rem;
    text-align: center;
    white-space: nowrap;
}

.poll-slot-head {
    background: #f0f4ff;
    font-weight: 600;
    font-size: .82rem;
    color: #3a3aaa;
    min-width: 90px;
}
.poll-slot-head.confirmed-slot {
    background: #e3f2fd;
    color: #1565c0;
}

.poll-voter-name {
    text-align: left !important;
    font-weight: 500;
    color: #333;
    min-width: 100px;
    background: #fafbff;
}

.poll-vote-cell { font-size: 1rem; }

/* Ligne de vote */
.poll-my-vote-row { background: #fffef0; }
.poll-my-vote-row .poll-voter-name { color: #4a35a0; font-weight: 700; }

.poll-vote-btns { display: flex; gap: .25rem; justify-content: center; }

.pvb {
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    font-size: .9rem;
    padding: .15rem .35rem;
    transition: transform .1s, background .15s;
    opacity: .55;
}
.pvb:hover { transform: scale(1.15); opacity: 1; }
.pvb.active-yes   { background: #c8f7c5; border-color: #4caf50; opacity: 1; }
.pvb.active-maybe { background: #fff3c4; border-color: #f5a623; opacity: 1; }
.pvb.active-no    { background: #ffd6d6; border-color: #e53935; opacity: 1; }

/* Ligne scores */
.poll-score-row td { background: #f5f7ff; font-size: .82rem; color: #444; }
.poll-score-row .poll-voter-name { color: #555; font-weight: 600; }
.poll-score-cell { line-height: 1.4; }
.best-slot { background: #e3f2fd !important; font-weight: 700; color: #1565c0; }
.best-slot small { color: #1565c0; font-size: .7rem; }

/* Zone commentaire */
.poll-comment-zone {
    display: flex;
    gap: .6rem;
    align-items: center;
    margin-top: .75rem;
    flex-wrap: wrap;
}
.poll-comment-input {
    flex: 1;
    min-width: 200px;
    padding: .38rem .7rem;
    border: 1px solid #cdd1dc;
    border-radius: 6px;
    font-size: .88rem;
}

/* Commentaires */
.poll-comments {
    margin-top: .75rem;
    font-size: .85rem;
    color: #555;
}
.poll-comment {
    padding: .3rem 0;
    border-top: 1px solid #f0f0f0;
}
.poll-comment-author { font-weight: 600; color: #4a35a0; margin-right: .4rem; }

/* Boutons de confirmation */
.poll-actions {
    margin-top: 1rem;
    padding-top: .75rem;
    border-top: 1px dashed #dde1ea;
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
    font-size: .85rem;
}
.poll-confirm-btn  { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.poll-confirm-btn:hover { background: #c8e6c9; }
.poll-close-btn    { background: #f3f3f3; color: #666; border: 1px solid #ccc; }
.poll-close-btn:hover { background: #e0e0e0; }

/* Bandeau créneau confirmé */
.poll-confirmed-banner {
    background: #e3f2fd;
    border: 1px solid #90caf9;
    border-radius: 8px;
    padding: .6rem 1rem;
    color: #1565c0;
    font-size: .92rem;
    margin-bottom: .75rem;
}

/* Bouton suppression */
.btn-icon-danger {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    opacity: .5;
    padding: .1rem .2rem;
    transition: opacity .2s;
}
.btn-icon-danger:hover { opacity: 1; }

/* btn-sm */
.btn-sm {
    font-size: .82rem;
    padding: .3rem .7rem;
    min-height: auto;
}
.btn-outline {
    background: transparent;
    border: 1px solid #aaa;
    color: #555;
}
.btn-outline:hover { background: #f0f0f0; }

/* ══════════════════════════════════════════════════════════════════════════════
   Mode Invité
   ══════════════════════════════════════════════════════════════════════════════ */

.guest-badge {
    display: inline-block;
    background: #fff3cd;
    color: #856404;
    font-size: .65rem;
    font-weight: 700;
    padding: .1rem .4rem;
    border-radius: 8px;
    border: 1px solid #ffc107;
    margin-left: .3rem;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: .05em;
}

/* Toggle switch (accès invité dans admin) */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    border-radius: 20px;
    transition: .3s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: .3s;
}
.toggle-switch input:checked + .toggle-slider { background-color: #4caf50; }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(16px); }

.btn-icon-action {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    opacity: .5;
    padding: .1rem .2rem;
    transition: opacity .2s;
}
.btn-icon-action:hover { opacity: 1; }

/* ══════════════════════════════════════════════════════════════════════════════
   Messagerie interne
   ══════════════════════════════════════════════════════════════════════════════ */

#msg-toggle {
    position: fixed;
    right: 18px;
    bottom: 86px;            /* au-dessus du bouton IA */
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,.3);
    z-index: 900;
    transition: transform .15s;
}
#msg-toggle:hover { transform: scale(1.08); }

.msg-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e53935;
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    border-radius: 9px;
    padding: 0 4px;
    border: 2px solid #fff;
}

#msg-panel {
    position: fixed;
    right: 18px;
    bottom: 152px;
    width: 340px;
    height: 480px;
    max-height: calc(100vh - 190px);
    min-height: 300px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 30px rgba(0,0,0,.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 900;
    font-size: .9rem;
}

#msg-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: .55rem .8rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .4rem;
    font-weight: 600;
    flex-shrink: 0;
}
#msg-header-title { display: flex; align-items: center; gap: .5rem; min-width: 0; }
#msg-header-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; display: inline-block; }
#msg-header button {
    background: rgba(255,255,255,.2);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: .85rem;
}
#msg-header button:hover { background: rgba(255,255,255,.35); }

#msg-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#msg-contact-list, #msg-conversation { flex: 1; min-height: 0; overflow-y: auto; }

/* Liste contacts */
.msg-contact {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .65rem .9rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}
.msg-contact:hover { background: #f6f7ff; }
.msg-contact-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}
.msg-contact-info { flex: 1; min-width: 0; }
.msg-contact-name { font-weight: 600; color: #2b2d42; }
.msg-contact-last {
    font-size: .78rem;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.msg-unread-count {
    background: #e53935;
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    border-radius: 10px;
}
.msg-empty { padding: 2rem; text-align: center; color: #888; }

/* Conversation */
#msg-conversation {
    flex-direction: column;
    gap: .45rem;
    padding: .8rem;
    display: flex;
}
.msg-bubble {
    max-width: 78%;
    padding: .45rem .75rem;
    border-radius: 14px;
    position: relative;
}
.msg-bubble.mine {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.msg-bubble.theirs {
    align-self: flex-start;
    background: #eef0f6;
    color: #222;
    border-bottom-left-radius: 4px;
}
.msg-text { word-wrap: break-word; white-space: pre-wrap; }
.msg-time {
    font-size: .65rem;
    opacity: .7;
    text-align: right;
    margin-top: .15rem;
}

#msg-footer {
    display: flex;
    flex-direction: column;
    padding: .5rem .7rem .6rem;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}
#msg-input-row {
    display: flex;
    gap: .5rem;
    align-items: flex-end;
}
#msg-attach {
    background: #eef0f6;
    border: none;
    color: #555;
    width: 40px;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    flex-shrink: 0;
}
#msg-attach:hover { background: #dde1ee; }
#msg-file-preview {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .45rem;
    padding: .35rem .6rem;
    background: #f3f4fa;
    border: 1px solid #dfe2f0;
    border-radius: 8px;
    font-size: .8rem;
}
#msg-file-preview .msg-file-name {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #333;
}
#msg-file-preview .msg-file-thumb {
    width: 34px;
    height: 34px;
    object-fit: cover;
    border-radius: 6px;
}
#msg-file-preview .msg-file-remove {
    border: none;
    background: none;
    cursor: pointer;
    color: #999;
    font-size: .9rem;
    padding: 2px 4px;
}
#msg-file-preview .msg-file-remove:hover { color: #e53935; }
#msg-input {
    flex: 1;
    min-width: 0;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: .45rem .7rem;
    resize: none;
    font-family: inherit;
    font-size: .88rem;
}
#msg-input-row { overflow: hidden; }
#msg-send {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    color: #fff;
    width: 40px;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    flex-shrink: 0;
}
#msg-send:hover { opacity: .9; }
#msg-send:disabled, #msg-attach:disabled { opacity: .5; cursor: wait; }

/* ── Pièces jointes dans les bulles ── */
.msg-attachment { margin-bottom: .3rem; }
.msg-attachment img.msg-att-image {
    max-width: 200px;
    max-height: 160px;
    border-radius: 8px;
    cursor: zoom-in;
    display: block;
}
.msg-attachment video.msg-att-video {
    max-width: 220px;
    max-height: 160px;
    border-radius: 8px;
    display: block;
    background: #000;
}
.msg-attachment audio.msg-att-audio {
    width: 200px;
    max-width: 100%;
    display: block;
}
.msg-attachment a.msg-att-file {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .7rem;
    background: rgba(255,255,255,.25);
    border-radius: 8px;
    color: inherit;
    text-decoration: none;
    font-size: .82rem;
}
.msg-bubble.theirs .msg-attachment a.msg-att-file {
    background: rgba(0,0,0,.06);
}
.msg-attachment a.msg-att-file:hover { text-decoration: underline; }
.msg-attachment .msg-att-icon { font-size: 1.3rem; }

@media (max-width: 480px) {
    #msg-panel { right: 8px; left: 8px; width: auto; bottom: 130px; }
    #msg-buffer-wrap span { display: none; }
    #msg-buffer-wrap { padding: 2px 5px; }
}

/* ── Message vocal ── */
#msg-voice {
    background: #eef0f6;
    border: none;
    color: #555;
    width: 40px;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    flex-shrink: 0;
}
#msg-voice:hover { background: #dde1ee; }
#msg-voice.recording {
    background: #e53935;
    color: #fff;
    animation: rec-pulse 1.1s infinite;
}
@keyframes rec-pulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(229,57,53,.5); }
    50%     { box-shadow: 0 0 0 8px rgba(229,57,53,0); }
}

/* ── Appel vocal ── */
#call-overlay, #call-incoming {
    position: fixed;
    inset: 0;
    background: rgba(15,10,40,.82);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}
.call-card {
    background: linear-gradient(160deg, #2b2260, #1d1745);
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 20px;
    padding: 2.2rem 2.8rem;
    text-align: center;
    color: #fff;
    min-width: 260px;
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.call-avatar {
    width: 76px;
    height: 76px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}
.call-avatar.ringing { animation: ring-shake 1s infinite; }
@keyframes ring-shake {
    0%,100% { transform: rotate(0); }
    25%     { transform: rotate(-12deg); }
    75%     { transform: rotate(12deg); }
}
.call-name { font-size: 1.25rem; font-weight: 700; margin-bottom: .3rem; }
.call-status { font-size: .9rem; color: #b8b3d9; margin-bottom: 1.4rem; }
.call-actions { display: flex; gap: 1.2rem; justify-content: center; }
.call-btn {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform .15s;
}
.call-btn:hover { transform: scale(1.1); }
.call-btn-end    { background: #e53935; color: #fff; }
.call-btn-accept { background: #43a047; color: #fff; animation: rec-pulse 1.4s infinite; }

/* ── Présence + P2P messagerie ── */
.msg-contact-avatar { position: relative; }
.presence-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #fff;
}
.presence-dot.on  { background: #43a047; }
.presence-dot.off { background: #bdbdbd; }

#msg-peer-status { font-size: .7rem; font-weight: 400; line-height: 1; }
.peer-on  { color: #9ff0c0; }
.peer-off { color: #d8cfe0; }

#msg-buffer-wrap {
    display: flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    font-size: .95rem;
    color: #fff;
    background: rgba(255,255,255,.15);
    border-radius: 8px;
    padding: 3px 7px;
}
#msg-buffer-wrap input { cursor: pointer; accent-color: #43a047; }

/* Carte fichier (envoi P2P, à la demande) */
.msg-filecard {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .3rem 0;
    min-width: 170px;
}
.msg-filecard-name {
    flex: 1;
    min-width: 0;
    font-size: .82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.msg-filecard-acts { display: flex; gap: .3rem; }
.msg-file-btn {
    border: none;
    background: rgba(255,255,255,.25);
    color: inherit;
    border-radius: 6px;
    padding: .28rem .5rem;
    font-size: .78rem;
    cursor: pointer;
}
.msg-bubble.theirs .msg-file-btn { background: rgba(0,0,0,.08); }
.msg-file-btn:hover { background: rgba(255,255,255,.45); }
.msg-bubble.theirs .msg-file-btn:hover { background: rgba(0,0,0,.16); }

/* Camembert de vérification de présence */
.pie-spin {
    display: inline-block;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    animation: pie-rot .8s linear infinite;
    vertical-align: -2px;
    margin-right: 5px;
}
@keyframes pie-rot { to { transform: rotate(360deg); } }
.presence-dot.checking {
    background: transparent;
    border: 2px solid #e0e0e0;
    border-top-color: #667eea;
    animation: pie-rot .8s linear infinite;
    width: 8px;
    height: 8px;
}
.peer-check { color: #ffe9b3; }

/* ── Recherche de news ── */
#search-box { position: relative; }
#search-input {
    width: 170px;
    padding: .32rem .7rem;
    border: 1px solid rgba(255,255,255,.4);
    border-radius: 20px;
    background: rgba(255,255,255,.18);
    color: #fff;
    font-size: .85rem;
    outline: none;
    transition: width .2s;
}
#search-input:focus { width: 220px; background: rgba(255,255,255,.28); }
#search-input::placeholder { color: rgba(255,255,255,.65); }
#search-input::-webkit-search-cancel-button { -webkit-appearance: none; }

#search-results {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.22);
    z-index: 950;
}
#search-results:empty { display: none; }
.search-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .6rem .8rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: #f4f5fd; }
.search-badge { font-size: 1rem; flex-shrink: 0; }
.search-item-body { min-width: 0; }
.search-item-title {
    font-size: .85rem;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.search-item-meta { font-size: .72rem; color: #999; }
.search-loading { padding: .8rem; text-align: center; color: #888; font-size: .82rem; }

@media (max-width: 480px) {
    #search-input { width: 110px; }
    #search-input:focus { width: 140px; }
    #search-results { width: 260px; right: -40px; }
}
