/* ==============================================
   MESSAGERIE - STYLE UNIFIÉ
   Desktop épuré, Mobile minimaliste comme WhatsApp
   ============================================== */

/* --- Conteneur principal --- */
.messagerie-container {
    display: flex;
    height: calc(100vh - 180px);
    background: var(--clr-bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--clr-shadow);
    border: 1px solid var(--clr-border);
}

/* ========== VERSION DESKTOP (par défaut) ========== */
.conversations-view {
    width: 350px;
    border-right: 1px solid var(--clr-border);
    display: flex;
    flex-direction: column;
    background: var(--clr-bg-secondary);
}

.chat-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--clr-bg-secondary);
}

/* En-tête de la liste */
.conversations-header {
    padding: 1rem;
    border-bottom: 1px solid var(--clr-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-title h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.total-unread {
    background: var(--clr-red);
    color: white;
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
    margin-left: 0.5rem;
}

.header-actions {
    display: flex;
    gap: 0.3rem;
}

/* Recherche */
.conversations-search {
    padding: 0.8rem;
    border-bottom: 1px solid var(--clr-border);
}

.search-box {
    position: relative;
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--clr-text-secondary);
    font-size: 0.9rem;
}

.search-box input {
    width: 100%;
    padding: 0.6rem 1rem 0.6rem 2.5rem;
    border: 1px solid var(--clr-border);
    border-radius: 30px;
    background: var(--clr-bg-primary);
    color: var(--clr-text-primary);
    font-size: 0.9rem;
}

/* Filtres */
.conversations-filters {
    display: flex;
    gap: 0.3rem;
    padding: 0.5rem 0.8rem;
    border-bottom: 1px solid var(--clr-border);
    flex-wrap: wrap;
}

.filter-pill {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    background: var(--clr-bg-primary);
    color: var(--clr-text-secondary);
    font-size: 0.8rem;
    border: 1px solid var(--clr-border);
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-pill:hover,
.filter-pill.active {
    background: var(--clr-blue);
    color: white;
    border-color: var(--clr-blue);
}

/* Liste des conversations */
.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
    margin-bottom: 0.2rem;
}

.conversation-item:hover,
.conversation-item.active {
    background: var(--clr-bg-primary);
}

.conversation-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--clr-bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: white;
    position: relative;
    flex-shrink: 0;
}

.conversation-avatar.etablissement { background: linear-gradient(135deg, #0284c7, #38bdf8); }
.conversation-avatar.classe { background: linear-gradient(135deg, #10b981, #34d399); }
.conversation-avatar.groupe { background: linear-gradient(135deg, #8b5cf6, #a78bfa); }
.conversation-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.online-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #94a3b8;
    border: 2px solid var(--clr-bg-secondary);
}

.online-indicator.active { background: #10b981; }

.conversation-info {
    flex: 1;
    min-width: 0;
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.2rem;
}

.conversation-header h4 {
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-time {
    font-size: 0.7rem;
    color: var(--clr-text-secondary);
}

.conversation-last {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.last-message {
    font-size: 0.8rem;
    color: var(--clr-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.last-message i {
    margin-right: 0.2rem;
    font-size: 0.7rem;
}

.last-message i.read { color: var(--clr-blue); }

.unread-badge {
    background: var(--clr-red);
    color: white;
    font-size: 0.7rem;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.3rem;
}

/* Pied utilisateur */
.conversations-footer {
    padding: 0.8rem;
    border-top: 1px solid var(--clr-border);
}

.user-info-compact {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.user-avatar {
    position: relative;
}

.user-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.user-details {
    flex: 1;
}

.user-name {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
}

.user-status {
    display: block;
    font-size: 0.75rem;
    color: var(--clr-text-secondary);
}

/* ========== ZONE DE CHAT ========== */
.chat-header {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--clr-border);
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.back-button {
    display: none; /* Caché sur desktop */
}

.chat-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    cursor: pointer;
}

.chat-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #0284c7, #38bdf8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
}

.chat-details h2 {
    font-size: 1rem;
    margin-bottom: 0.2rem;
}

.chat-details p {
    font-size: 0.8rem;
    color: var(--clr-text-secondary);
}

.chat-actions {
    display: flex;
    gap: 0.3rem;
}

/* Messages */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message-date-separator {
    text-align: center;
    margin: 0.5rem 0;
}

.message-date-separator span {
    background: var(--clr-bg-primary);
    padding: 0.2rem 1rem;
    color: var(--clr-text-secondary);
    font-size: 0.75rem;
    border-radius: 20px;
}

.message {
    display: flex;
    gap: 0.5rem;
    max-width: 70%;
}

.message.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.message-content-wrapper {
    max-width: 100%;
}

.message-sender-info {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.1rem;
    margin-left: 0.3rem;
}

.message-bubble {
    background: var(--clr-bg-primary);
    padding: 0.5rem 1rem;
    border-radius: 16px;
    word-wrap: break-word;
}

.message.sent .message-bubble {
    background: var(--clr-blue);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.received .message-bubble {
    border-bottom-left-radius: 4px;
}

.message-bubble p {
    font-size: 0.9rem;
    line-height: 1.4;
    margin: 0;
}

.message-time {
    font-size: 0.65rem;
    color: var(--clr-text-secondary);
    margin-top: 0.1rem;
    display: block;
    text-align: right;
}

.message.sent .message-time {
    color: rgba(255,255,255,0.7);
}

.message-status {
    text-align: right;
    margin-top: 0.1rem;
}

.message-status i {
    font-size: 0.7rem;
    color: var(--clr-text-secondary);
}

.message-status i.read {
    color: var(--clr-blue);
}

.message.sent .message-status i {
    color: rgba(255,255,255,0.7);
}

/* Pièces jointes */
.message-attachment {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem;
    background: var(--clr-bg-secondary);
    border-radius: 8px;
    margin-top: 0.3rem;
}

.message.sent .message-attachment {
    background: rgba(255,255,255,0.1);
}

.message-attachment i {
    font-size: 1.2rem;
}

.attachment-info {
    flex: 1;
}

.attachment-name {
    font-size: 0.8rem;
    font-weight: 500;
}

.attachment-size {
    font-size: 0.65rem;
    color: var(--clr-text-secondary);
}

/* Images */
.message-image {
    position: relative;
    margin-top: 0.3rem;
    border-radius: 8px;
    overflow: hidden;
    max-width: 200px;
}

.message-image img {
    width: 100%;
    height: auto;
    display: block;
}

.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.message-image:hover .image-overlay {
    opacity: 1;
}

/* Message audio */
.message-audio {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem;
    background: var(--clr-bg-primary);
    border-radius: 30px;
    min-width: 160px;
}

.play-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--clr-blue);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
}

.audio-wave {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    height: 24px;
}

.audio-wave span {
    width: 3px;
    height: 100%;
    background: var(--clr-text-secondary);
    border-radius: 3px;
    animation: wave 1s infinite;
}

.audio-wave span:nth-child(2) { animation-delay: 0.1s; }
.audio-wave span:nth-child(3) { animation-delay: 0.2s; }

@keyframes wave {
    0%, 100% { height: 30%; }
    50% { height: 100%; }
}

.audio-duration {
    font-size: 0.7rem;
    color: var(--clr-text-secondary);
}

/* Réactions */
.message-reactions {
    display: flex;
    gap: 0.2rem;
    margin-top: 0.2rem;
}

.reaction-btn {
    padding: 0.1rem 0.3rem;
    border-radius: 12px;
    background: var(--clr-bg-primary);
    border: 1px solid var(--clr-border);
    font-size: 0.7rem;
    cursor: pointer;
}

/* Indicateur de frappe */
.typing-indicator {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.8rem;
    background: var(--clr-bg-primary);
    border-radius: 30px;
    align-self: flex-start;
    max-width: 150px;
}

.typing-avatars img {
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

.typing-text {
    font-size: 0.75rem;
    color: var(--clr-text-secondary);
}

/* Zone de saisie */
.chat-input-area {
    padding: 0.8rem;
    border-top: 1px solid var(--clr-border);
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

.attach-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--clr-bg-primary);
    color: var(--clr-text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--clr-border);
    cursor: pointer;
    flex-shrink: 0;
}

.input-wrapper {
    flex: 1;
    display: flex;
    align-items: flex-end;
    gap: 0.3rem;
    background: var(--clr-bg-primary);
    border-radius: 24px;
    padding: 0.2rem 0.2rem 0.2rem 1rem;
}

.input-wrapper textarea {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.5rem 0;
    font-size: 0.9rem;
    color: var(--clr-text-primary);
    resize: none;
    max-height: 80px;
    outline: none;
}

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--clr-blue);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
}

/* ========== VERSION MOBILE (comme WhatsApp) ========== */
@media (max-width: 768px) {
    /* Reset du conteneur */
    .messagerie-container {
        height: calc(100vh - 120px);
        border-radius: 0;
        border: none;
    }

    /* Une seule vue à la fois */
    .conversations-view,
    .chat-view {
        width: 100%;
        height: 100%;
        display: none;
    }

    .conversations-view.active {
        display: flex;
        flex-direction: column;
    }

    .chat-view.active {
        display: flex;
        flex-direction: column;
    }

    /* Bouton retour visible */
    .back-button {
        display: flex;
        width: 40px;
        height: 40px;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        color: var(--clr-text-primary);
        font-size: 1.2rem;
        cursor: pointer;
    }

    /* En-tête plus compact */
    .conversations-header {
        padding: 0.8rem;
    }

    .header-title h2 {
        font-size: 1.3rem;
    }

    /* Liste des conversations optimisée */
    .conversation-item {
        padding: 0.6rem;
    }

    .conversation-avatar {
        width: 52px;
        height: 52px;
        font-size: 1.3rem;
    }

    .conversation-header h4 {
        font-size: 1rem;
    }

    .last-message {
        max-width: 200px;
    }

    /* Chat en plein écran */
    .chat-view {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1000;
        background: var(--clr-bg-secondary);
    }

    .chat-header {
        padding: 0.6rem 0.8rem;
    }

    .chat-details h2 {
        font-size: 1rem;
        max-width: 180px;
    }

    /* Messages plus larges sur mobile */
    .message {
        max-width: 85%;
    }

    .message-bubble p {
        font-size: 0.95rem;
    }

    /* Zone de saisie fixe en bas */
    .chat-input-area {
        padding: 0.6rem;
        background: var(--clr-bg-primary);
    }

    /* Modales plein écran */
    .modal .modal-content {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        margin: 0;
        border-radius: 0;
        transform: none;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        overflow-y: auto;
    }

    .modal.open .modal-content {
        transform: none;
    }

    .modal-header {
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--clr-bg-secondary);
        padding: 1rem;
    }

    .modal-footer {
        position: sticky;
        bottom: 0;
        background: var(--clr-bg-secondary);
        padding: 1rem;
        flex-direction: column;
        gap: 0.5rem;
    }

     

    /* Menu utilisateur */
    .menu-content {
        padding: 1rem;
    }

    .menu-item {
        padding: 0.8rem;
    }
}

/* ========== TRÈS PETITS ÉCRANS ========== */
@media (max-width: 480px) {
    .conversation-avatar {
        width: 48px;
        height: 48px;
    }

    .conversation-header h4 {
        font-size: 0.95rem;
        max-width: 150px;
    }

    .last-message {
        max-width: 150px;
    }

    .message {
        max-width: 90%;
    }

    .message-image {
        max-width: 180px;
    }

    .chat-details h2 {
        max-width: 140px;
    }

    .chat-actions {
        gap: 0.2rem;
    }

    .chat-actions .btn-icon {
        width: 36px;
        height: 36px;
    }
}

/* ========== STYLES COMMUNS ========== */
.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--clr-text-secondary);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: var(--clr-bg-primary);
    color: var(--clr-blue);
}

.btn-small {
    padding: 0.3rem 0.8rem;
    font-size: 0.8rem;
    border-radius: 4px;
    cursor: pointer;
}

/* Scrollbar */
.conversations-list::-webkit-scrollbar,
.messages-container::-webkit-scrollbar {
    width: 4px;
}

.conversations-list::-webkit-scrollbar-thumb,
.messages-container::-webkit-scrollbar-thumb {
    background: var(--clr-blue);
    border-radius: 2px;
}

/* Modales */
.modal {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
}

.modal.open {
    opacity: 1;
    visibility: visible;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
}

.modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    background: var(--clr-bg-secondary);
    border-radius: 12px;
    overflow: hidden;
}

.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--clr-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--clr-bg-primary);
    color: var(--clr-text-secondary);
    border: none;
    cursor: pointer;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(80vh - 120px);
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--clr-border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Menu utilisateur mobile */
.user-menu-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    display: none;
}

.user-menu-modal.open {
    display: block;
}

.menu-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
}

.menu-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--clr-bg-secondary);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    padding: 1.5rem;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.user-info-large {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.user-info-large img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
}

.menu-items {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem;
    border-radius: 8px;
    background: var(--clr-bg-primary);
    border: none;
    color: var(--clr-text-primary);
    cursor: pointer;
    width: 100%;
    text-align: left;
}

.menu-item.danger {
    color: var(--clr-red);
}

.menu-item i {
    width: 20px;
}


/* ================================================================================ */

/* ==============================================
   MESSAGERIE - VERSION CORRIGÉE
   ============================================== */

/* --- Conteneur principal --- */
.messagerie-container {
    display: flex;
    height: calc(100vh - 180px);
    background: var(--clr-bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--clr-shadow);
    border: 1px solid var(--clr-border);
}

/* ========== VERSION DESKTOP (par défaut) ========== */
.conversations-view {
    width: 350px;
    border-right: 1px solid var(--clr-border);
    display: flex;
    flex-direction: column;
    background: var(--clr-bg-secondary);
}

.chat-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--clr-bg-secondary);
}

/* En-tête de la liste */
.conversations-header {
    padding: 1rem;
    border-bottom: 1px solid var(--clr-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-title h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.total-unread {
    background: var(--clr-red);
    color: white;
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
    margin-left: 0.5rem;
}

.header-actions {
    display: flex;
    gap: 0.3rem;
}

/* Recherche */
.conversations-search {
    padding: 0.8rem;
    border-bottom: 1px solid var(--clr-border);
}

.search-box {
    position: relative;
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--clr-text-secondary);
    font-size: 0.9rem;
}

.search-box input {
    width: 100%;
    padding: 0.6rem 1rem 0.6rem 2.5rem;
    border: 1px solid var(--clr-border);
    border-radius: 30px;
    background: var(--clr-bg-primary);
    color: var(--clr-text-primary);
    font-size: 0.9rem;
}

/* Filtres */
.conversations-filters {
    display: flex;
    gap: 0.3rem;
    padding: 0.5rem 0.8rem;
    border-bottom: 1px solid var(--clr-border);
    flex-wrap: wrap;
}

.filter-pill {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    background: var(--clr-bg-primary);
    color: var(--clr-text-secondary);
    font-size: 0.8rem;
    border: 1px solid var(--clr-border);
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-pill:hover,
.filter-pill.active {
    background: var(--clr-blue);
    color: white;
    border-color: var(--clr-blue);
}

/* Liste des conversations */
.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
    margin-bottom: 0.2rem;
}

.conversation-item:hover,
.conversation-item.active {
    background: var(--clr-bg-primary);
}

.conversation-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--clr-bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: white;
    position: relative;
    flex-shrink: 0;
}

.conversation-avatar.etablissement { background: linear-gradient(135deg, #0284c7, #38bdf8); }
.conversation-avatar.classe { background: linear-gradient(135deg, #10b981, #34d399); }
.conversation-avatar.groupe { background: linear-gradient(135deg, #8b5cf6, #a78bfa); }
.conversation-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.online-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #94a3b8;
    border: 2px solid var(--clr-bg-secondary);
}

.online-indicator.active { background: #10b981; }

.conversation-info {
    flex: 1;
    min-width: 0;
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.2rem;
}

.conversation-header h4 {
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-time {
    font-size: 0.7rem;
    color: var(--clr-text-secondary);
}

.conversation-last {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.last-message {
    font-size: 0.8rem;
    color: var(--clr-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.last-message i {
    margin-right: 0.2rem;
    font-size: 0.7rem;
}

.last-message i.read { color: var(--clr-blue); }

.unread-badge {
    background: var(--clr-red);
    color: white;
    font-size: 0.7rem;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.3rem;
}

/* Pied utilisateur */
.conversations-footer {
    padding: 0.8rem;
    border-top: 1px solid var(--clr-border);
}

.user-info-compact {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.user-avatar {
    position: relative;
}

.user-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.user-details {
    flex: 1;
}

.user-name {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
}

.user-status {
    display: block;
    font-size: 0.75rem;
    color: var(--clr-text-secondary);
}

/* ========== ZONE DE CHAT ========== */
.chat-header {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--clr-border);
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.back-button {
    display: none; /* Caché sur desktop */
}

.chat-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    cursor: pointer;
}

.chat-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #0284c7, #38bdf8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
}

.chat-details h2 {
    font-size: 1rem;
    margin-bottom: 0.2rem;
}

.chat-details p {
    font-size: 0.8rem;
    color: var(--clr-text-secondary);
}

.chat-actions {
    display: flex;
    gap: 0.3rem;
}

/* Messages */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message-date-separator {
    text-align: center;
    margin: 0.5rem 0;
}

.message-date-separator span {
    background: var(--clr-bg-primary);
    padding: 0.2rem 1rem;
    color: var(--clr-text-secondary);
    font-size: 0.75rem;
    border-radius: 20px;
}

.message {
    display: flex;
    gap: 0.5rem;
    max-width: 70%;
}

.message.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.message-content-wrapper {
    max-width: 100%;
}

.message-sender-info {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.1rem;
    margin-left: 0.3rem;
}

.message-bubble {
    background: var(--clr-bg-primary);
    padding: 0.5rem 1rem;
    border-radius: 16px;
    word-wrap: break-word;
}

.message.sent .message-bubble {
    background: var(--clr-blue);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.received .message-bubble {
    border-bottom-left-radius: 4px;
}

.message-bubble p {
    font-size: 0.9rem;
    line-height: 1.4;
    margin: 0;
}

.message-time {
    font-size: 0.65rem;
    color: var(--clr-text-secondary);
    margin-top: 0.1rem;
    display: block;
    text-align: right;
}

.message.sent .message-time {
    color: rgba(255,255,255,0.7);
}

.message-status {
    text-align: right;
    margin-top: 0.1rem;
}

.message-status i {
    font-size: 0.7rem;
    color: var(--clr-text-secondary);
}

.message-status i.read {
    color: var(--clr-blue);
}

.message.sent .message-status i {
    color: rgba(255,255,255,0.7);
}

/* ========== VERSION MOBILE - SUPERPOSITION ========== */
@media (max-width: 768px) {
    /* Le conteneur principal prend toute la hauteur disponible */
    .messagerie-container {
        height: calc(100vh - 60px); /* 60px = hauteur de la topbar mobile */
        border-radius: 0;
        border: none;
        position: relative;
    }

    /* Vue des conversations - visible par défaut */
    .conversations-view {
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        position: relative;
        z-index: 1;
    }

    /* Vue du chat - superposée et cachée par défaut */
    .chat-view {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 2000; /* Au-dessus de tout (topbar, sidebar, etc.) */
        background: var(--clr-bg-secondary);
        display: none;
    }

    .chat-view.active {
        display: flex;
        flex-direction: column;
    }

    /* Bouton retour visible dans le chat */
    .back-button {
        display: flex;
        width: 40px;
        height: 40px;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        color: var(--clr-text-primary);
        font-size: 1.2rem;
        cursor: pointer;
    }

    /* En-tête du chat avec fond pour meilleure lisibilité */
    .chat-header {
        background: var(--clr-bg-primary);
        border-bottom: 1px solid var(--clr-border);
        padding: 0.6rem 0.8rem;
    }

    /* Ajustements pour la liste des conversations */
    .conversations-header {
        padding: 0.8rem;
    }

    .conversation-item {
        padding: 0.8rem;
    }

    .conversation-avatar {
        width: 52px;
        height: 52px;
    }

    .last-message {
        max-width: 200px;
    }

    /* Messages plus larges sur mobile */
    .message {
        max-width: 85%;
    }

    /* Zone de saisie fixe en bas */
    .chat-input-area {
        background: var(--clr-bg-primary);
        border-top: 1px solid var(--clr-border);
    }

    /* Empêcher le scroll du body quand le chat est ouvert */
    body.chat-open {
        overflow: hidden;
    }
}

/* ========== TRÈS PETITS ÉCRANS ========== */
@media (max-width: 480px) {
    .conversation-avatar {
        width: 48px;
        height: 48px;
    }

    .last-message {
        max-width: 150px;
    }

    .message {
        max-width: 90%;
    }

    .chat-details h2 {
        font-size: 0.95rem;
        max-width: 140px;
    }
}

/* ========== TABLETTE ========== */
@media (min-width: 769px) and (max-width: 1024px) {
    .conversations-view {
        width: 300px;
    }

    .last-message {
        max-width: 150px;
    }
}

/* ========== STYLES COMMUNS ========== */
.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--clr-text-secondary);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: var(--clr-bg-primary);
    color: var(--clr-blue);
}

/* Scrollbar */
.conversations-list::-webkit-scrollbar,
.messages-container::-webkit-scrollbar {
    width: 4px;
}

.conversations-list::-webkit-scrollbar-thumb,
.messages-container::-webkit-scrollbar-thumb {
    background: var(--clr-blue);
    border-radius: 2px;
}




/* ===================================================================== */


/* ==============================================
   STYLES SPÉCIFIQUES AUX ANNONCES
   ============================================== */

/* --- Onglets de navigation --- */
.annonces-tabs {
    display: flex;
    gap: 0.5rem;
    margin: 1.5rem 0;
    border-bottom: 1px solid var(--clr-border);
    padding-bottom: 0.5rem;
    flex-wrap: wrap;
}

.annonces-tab {
    padding: 0.7rem 1.5rem;
    border-radius: 30px;
    background: transparent;
    color: var(--clr-text-secondary);
    font-weight: 500;
    transition: all 0.3s ease;
    border: 1px solid transparent;
    cursor: pointer;
}

.annonces-tab:hover {
    background: var(--clr-bg-primary);
    color: var(--clr-text-primary);
}

.annonces-tab.active {
    background: var(--clr-blue);
    color: white;
}

.annonces-view {
    display: none;
}

.annonces-view.active {
    display: block;
}

/* --- Liste des annonces --- */
.annonces-liste {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.annonce-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.2rem;
    background: var(--clr-bg-secondary);
    border-radius: 12px;
    box-shadow: var(--clr-shadow);
    border: 1px solid var(--clr-border);
    position: relative;
    transition: all 0.3s ease;
}

.annonce-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-color: var(--clr-blue);
}

.annonce-item.urgent {
    border-left: 4px solid var(--clr-red);
}

.annonce-item.programmee {
    border-left: 4px solid var(--clr-yellow);
}

.annonce-item.brouillon {
    border-left: 4px solid var(--clr-text-secondary);
    opacity: 0.8;
}

.annonce-checkbox {
    padding-top: 0.3rem;
}

.annonce-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.annonce-priority {
    min-width: 100px;
}

.priority-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.priority-badge.urgent {
    background: rgba(239, 68, 68, 0.1);
    color: var(--clr-red);
}

.priority-badge.programmee {
    background: rgba(245, 158, 11, 0.1);
    color: var(--clr-yellow);
}

.priority-badge.brouillon {
    background: rgba(100, 116, 139, 0.1);
    color: var(--clr-text-secondary);
}

.priority-badge i {
    font-size: 0.7rem;
}

.annonce-content {
    flex: 1;
}

.annonce-header {
    margin-bottom: 0.5rem;
}

.annonce-header h3 {
    font-size: 1.1rem;
    margin-bottom: 0.3rem;
    color: var(--clr-text-primary);
}

.annonce-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--clr-text-secondary);
    flex-wrap: wrap;
}

.annonce-meta span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.annonce-categorie {
    padding: 0.1rem 0.5rem;
    border-radius: 12px;
}

.annonce-categorie.info {
    background: rgba(2, 132, 199, 0.1);
    color: var(--clr-blue);
}

.annonce-categorie.evenement {
    background: rgba(16, 185, 129, 0.1);
    color: var(--clr-green);
}

.annonce-categorie.administratif {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}

.annonce-excerpt {
    font-size: 0.9rem;
    color: var(--clr-text-secondary);
    margin-bottom: 0.8rem;
    line-height: 1.5;
}

.annonce-audience {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.audience-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.8rem;
    background: var(--clr-bg-primary);
    color: var(--clr-text-secondary);
}

.audience-tag.tous {
    background: rgba(2, 132, 199, 0.1);
    color: var(--clr-blue);
}

.audience-tag.enseignants {
    background: rgba(16, 185, 129, 0.1);
    color: var(--clr-green);
}

.audience-tag.eleves {
    background: rgba(245, 158, 11, 0.1);
    color: var(--clr-yellow);
}

.audience-tag.parents {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}

.audience-tag.personnel {
    background: rgba(239, 68, 68, 0.1);
    color: var(--clr-red);
}

.annonce-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--clr-text-secondary);
}

.annonce-stats span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.annonce-actions {
    display: flex;
    gap: 0.3rem;
    flex-shrink: 0;
}

/* --- Cartes d'annonces --- */
.cartes-filters {
    margin-bottom: 1.5rem;
}

.cartes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.2rem;
    margin-bottom: 1.5rem;
}

.annonce-card {
    background: var(--clr-bg-secondary);
    border-radius: 12px;
    padding: 1.2rem;
    box-shadow: var(--clr-shadow);
    border: 1px solid var(--clr-border);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.annonce-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    border-color: var(--clr-blue);
}

.annonce-card.urgent {
    border-top: 4px solid var(--clr-red);
}

.annonce-card.evenement {
    border-top: 4px solid var(--clr-green);
}

.annonce-card.info {
    border-top: 4px solid var(--clr-blue);
}

.annonce-card.brouillon {
    border-top: 4px solid var(--clr-text-secondary);
    opacity: 0.8;
}

.card-badge {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
}

.card-badge.urgent {
    background: rgba(239, 68, 68, 0.1);
    color: var(--clr-red);
}

.card-badge.programmee {
    background: rgba(245, 158, 11, 0.1);
    color: var(--clr-yellow);
}

.card-badge.brouillon {
    background: rgba(100, 116, 139, 0.1);
    color: var(--clr-text-secondary);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.card-icon.evenement {
    background: linear-gradient(135deg, #10b981, #34d399);
}

.card-icon.info {
    background: linear-gradient(135deg, #0284c7, #38bdf8);
}

.card-icon.administratif {
    background: linear-gradient(135deg, #8b5cf6, #a78bfa);
}

.card-title {
    flex: 1;
}

.card-title h3 {
    font-size: 1rem;
    margin-bottom: 0.2rem;
}

.card-date {
    font-size: 0.75rem;
    color: var(--clr-text-secondary);
}

.card-body {
    margin-bottom: 1rem;
}

.card-body p {
    font-size: 0.9rem;
    color: var(--clr-text-secondary);
    margin-bottom: 0.8rem;
    line-height: 1.4;
}

.card-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--clr-text-secondary);
}

.card-meta span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.card-footer {
    display: flex;
    gap: 0.5rem;
    padding-top: 0.8rem;
    border-top: 1px solid var(--clr-border);
}

.btn-icon-small {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--clr-text-secondary);
    border: 1px solid var(--clr-border);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon-small:hover {
    background: var(--clr-bg-primary);
    color: var(--clr-blue);
}

/* --- Calendrier --- */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.calendar-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.calendar-nav h3 {
    font-size: 1.2rem;
    min-width: 150px;
    text-align: center;
}

.calendar-legend {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.calendar-legend span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.legend-dot.urgent { background: var(--clr-red); }
.legend-dot.evenement { background: var(--clr-green); }
.legend-dot.info { background: var(--clr-blue); }
.legend-dot.administratif { background: #8b5cf6; }

.calendar-grid {
    background: var(--clr-bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--clr-shadow);
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--clr-bg-primary);
    border-bottom: 2px solid var(--clr-border);
}

.calendar-weekdays div {
    padding: 1rem;
    text-align: center;
    font-weight: 600;
    color: var(--clr-text-secondary);
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--clr-border);
}

.calendar-day {
    background: var(--clr-bg-secondary);
    min-height: 100px;
    padding: 0.5rem;
    position: relative;
}

.calendar-day.other-month {
    background: var(--clr-bg-primary);
    opacity: 0.5;
}

.day-number {
    position: absolute;
    top: 0.3rem;
    right: 0.5rem;
    font-size: 0.8rem;
    color: var(--clr-text-secondary);
}

.day-events {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.event-item {
    padding: 0.2rem 0.3rem;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: white;
}

.event-item.urgent { background: var(--clr-red); }
.event-item.evenement { background: var(--clr-green); }
.event-item.info { background: var(--clr-blue); }
.event-item.administratif { background: #8b5cf6; }

/* --- Modal visualisation --- */
.annonce-view-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--clr-border);
}

.annonce-view-header h2 {
    font-size: 1.3rem;
    margin: 0.8rem 0;
}

.annonce-view-meta {
    display: flex;
    gap: 1.5rem;
    font-size: 0.9rem;
    color: var(--clr-text-secondary);
    flex-wrap: wrap;
}

.annonce-view-meta span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.annonce-view-audience {
    margin-bottom: 1.5rem;
}

.annonce-view-audience h4 {
    margin-bottom: 0.8rem;
    font-size: 0.95rem;
    color: var(--clr-text-secondary);
}

.annonce-view-content {
    margin-bottom: 1.5rem;
}

.annonce-view-content h4 {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    color: var(--clr-text-secondary);
}

.annonce-resume {
    background: var(--clr-bg-primary);
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    font-style: italic;
}

.annonce-contenu {
    line-height: 1.6;
}

.annonce-contenu ul {
    padding-left: 1.5rem;
    margin: 0.5rem 0;
}

.annonce-view-attachments {
    margin-bottom: 1.5rem;
}

.annonce-view-attachments h4 {
    margin-bottom: 0.8rem;
    font-size: 0.95rem;
    color: var(--clr-text-secondary);
}

.attachments-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.5rem;
    background: var(--clr-bg-primary);
    border-radius: 6px;
}

.attachment-item i {
    font-size: 1.2rem;
}

.attachment-item span {
    flex: 1;
}

.annonce-view-stats {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--clr-border);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

.stat-box {
    text-align: center;
    padding: 1rem;
    background: var(--clr-bg-primary);
    border-radius: 8px;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--clr-blue);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--clr-text-secondary);
}

/* --- Modal archives --- */
.archive-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.archive-filters .search-box {
    flex: 1;
    min-width: 250px;
}

.archive-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    max-height: 400px;
    overflow-y: auto;
}

.archive-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem;
    background: var(--clr-bg-primary);
    border-radius: 8px;
}

.archive-date {
    min-width: 80px;
    font-weight: 600;
    color: var(--clr-blue);
}

.archive-content {
    flex: 1;
}

.archive-content h4 {
    font-size: 0.95rem;
    margin-bottom: 0.2rem;
}

.archive-content p {
    font-size: 0.8rem;
    color: var(--clr-text-secondary);
}

/* --- Audience checkboxes --- */
.audience-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.5rem;
}

.audience-checkboxes .checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
}

.audience-checkboxes input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* --- Fichiers preview --- */
.files-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.file-preview {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.6rem;
    background: var(--clr-bg-primary);
    border-radius: 20px;
    font-size: 0.8rem;
}

.file-preview i {
    font-size: 1rem;
}

.file-preview .file-size {
    color: var(--clr-text-secondary);
    font-size: 0.7rem;
}

.file-preview .btn-icon {
    width: 24px;
    height: 24px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .annonce-item {
        flex-direction: column;
        align-items: stretch;
    }
    
    .annonce-priority {
        margin-left: 2rem;
    }
    
    .annonce-actions {
        justify-content: flex-end;
        margin-top: 0.5rem;
    }
    
    .cartes-grid {
        grid-template-columns: 1fr;
    }
    
    .calendar-weekdays div {
        padding: 0.5rem;
        font-size: 0.8rem;
    }
    
    .calendar-day {
        min-height: 60px;
    }
    
    .day-number {
        font-size: 0.7rem;
    }
    
    .event-item {
        font-size: 0.6rem;
        padding: 0.1rem 0.2rem;
    }
    
    .archive-filters {
        flex-direction: column;
    }
    
    .archive-item {
        flex-wrap: wrap;
    }
    
    .archive-date {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .annonce-meta {
        flex-direction: column;
        gap: 0.3rem;
    }
    
    .annonce-audience {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .annonce-stats {
        width: 100%;
        justify-content: space-between;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .calendar-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .calendar-nav {
        width: 100%;
        justify-content: space-between;
    }
}


/* ==============================================
   STYLES SPÉCIFIQUES À L'ASSISTANT IA
   ============================================== */

/* --- Conteneur principal --- */
.assistant-container {
    display: flex;
    height: calc(100vh - 180px);
    background: var(--clr-bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--clr-shadow);
    border: 1px solid var(--clr-border);
}

/* --- Colonne gauche : Historique --- */
.conversations-history {
    width: 280px;
    border-right: 1px solid var(--clr-border);
    display: flex;
    flex-direction: column;
    background: var(--clr-bg-secondary);
}

.history-header {
    padding: 1rem;
    border-bottom: 1px solid var(--clr-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-header h3 {
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.history-header h3 i {
    color: var(--clr-blue);
}

.history-search {
    padding: 0.8rem;
    border-bottom: 1px solid var(--clr-border);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 0.2rem;
}

.history-item:hover {
    background: var(--clr-bg-primary);
}

.history-item.active {
    background: var(--clr-bg-primary);
    border-left: 3px solid var(--clr-blue);
}

.history-item-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: linear-gradient(135deg, #0284c7, #38bdf8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
}

.history-item-content {
    flex: 1;
    min-width: 0;
}

.history-item-content h4 {
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
}

.history-item-content p {
    font-size: 0.75rem;
    color: var(--clr-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-time {
    font-size: 0.65rem;
    color: var(--clr-text-secondary);
}

.history-footer {
    padding: 0.8rem;
    border-top: 1px solid var(--clr-border);
    text-align: center;
}

/* --- Colonne centrale : Chat --- */
.assistant-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--clr-bg-secondary);
}

.assistant-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.assistant-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #0284c7, #38bdf8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
}

.assistant-details h2 {
    font-size: 1rem;
    margin-bottom: 0.2rem;
}

.assistant-details p {
    font-size: 0.75rem;
    color: var(--clr-text-secondary);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.online {
    background: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

/* Messages spécifiques à l'assistant */
.message.assistant .message-avatar {
    background: linear-gradient(135deg, #0284c7, #38bdf8);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.message.assistant .message-bubble {
    background: var(--clr-bg-primary);
    border-bottom-left-radius: 4px;
}

.message.user .message-bubble {
    background: var(--clr-blue);
    color: white;
}

/* Suggestions */
.suggestions-container {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--clr-border);
}

.suggestions-container p {
    font-size: 0.8rem;
    color: var(--clr-text-secondary);
    margin-bottom: 0.5rem;
}

.suggestions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.suggestion-chip {
    padding: 0.3rem 0.8rem;
    background: var(--clr-bg-primary);
    border: 1px solid var(--clr-border);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--clr-text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.suggestion-chip:hover {
    background: var(--clr-blue);
    color: white;
    border-color: var(--clr-blue);
}

.suggestion-chip.small {
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
}

/* Actions dans les messages */
.message-actions {
    display: flex;
    gap: 0.5rem;
    margin: 0.5rem 0;
    flex-wrap: wrap;
}

.action-link {
    background: transparent;
    border: none;
    color: var(--clr-blue);
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.action-link:hover {
    background: var(--clr-bg-primary);
}

/* Feedback sur les messages */
.message-feedback {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.3rem;
    padding: 0.3rem;
    background: var(--clr-bg-primary);
    border-radius: 20px;
    font-size: 0.75rem;
}

.feedback-btn {
    background: transparent;
    border: none;
    color: var(--clr-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.2rem 0.4rem;
    border-radius: 12px;
}

.feedback-btn:hover {
    background: var(--clr-bg-secondary);
}

/* Indicateur de frappe */
.typing-indicator {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
}

.typing-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0284c7, #38bdf8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
}

.typing-dots {
    display: flex;
    gap: 0.2rem;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--clr-blue);
    animation: typing 1.4s infinite;
    opacity: 0.3;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-5px); }
}

/* Suggestions en temps réel */
.input-suggestions {
    display: flex;
    gap: 0.3rem;
    padding: 0.3rem 0.5rem;
    flex-wrap: wrap;
}

/* --- Colonne droite : Sidebar --- */
.assistant-sidebar {
    width: 280px;
    border-left: 1px solid var(--clr-border);
    overflow-y: auto;
    background: var(--clr-bg-secondary);
}

.sidebar-section {
    padding: 1rem;
    border-bottom: 1px solid var(--clr-border);
}

.sidebar-section h3 {
    font-size: 0.95rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--clr-blue);
}

/* Réponses prédéfinies */
.predefined-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.predefined-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.5rem;
    background: var(--clr-bg-primary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.predefined-item:hover {
    background: var(--clr-bg-secondary);
    transform: translateX(5px);
}

.predefined-item i {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: linear-gradient(135deg, #0284c7, #38bdf8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
}

.predefined-content {
    flex: 1;
}

.predefined-content h4 {
    font-size: 0.9rem;
    margin-bottom: 0.1rem;
}

.predefined-content p {
    font-size: 0.7rem;
    color: var(--clr-text-secondary);
}

/* Automatisations */
.automation-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.automation-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.5rem;
    background: var(--clr-bg-primary);
    border-radius: 6px;
}

.automation-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: var(--clr-bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--clr-blue);
    font-size: 1rem;
}

.automation-content {
    flex: 1;
}

.automation-content h4 {
    font-size: 0.9rem;
    margin-bottom: 0.1rem;
}

.automation-content p {
    font-size: 0.7rem;
    color: var(--clr-text-secondary);
}

.automation-status {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    font-size: 0.6rem;
    font-weight: 600;
}

.automation-status.active {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.automation-status.paused {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

/* Statistiques mini */
.stats-mini {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
}

.stat-item {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.7rem;
    color: var(--clr-text-secondary);
    margin-bottom: 0.2rem;
}

.stat-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--clr-blue);
}

.stat-value.success {
    color: #10b981;
}

/* --- Modale automatisations --- */
.automation-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--clr-border);
    padding-bottom: 0.5rem;
    flex-wrap: wrap;
}

.automation-tab {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    background: transparent;
    color: var(--clr-text-secondary);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
}

.automation-tab:hover {
    background: var(--clr-bg-primary);
    color: var(--clr-text-primary);
}

.automation-tab.active {
    background: var(--clr-blue);
    color: white;
}

.automation-tab-content {
    display: none;
}

.automation-tab-content.active {
    display: block;
}

.automation-list-detailed {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
    max-height: 400px;
    overflow-y: auto;
}

.automation-card {
    background: var(--clr-bg-primary);
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid var(--clr-border);
}

.automation-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.automation-card-header h4 {
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.automation-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

/* Auto-réponses */
.auto-responses-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-bottom: 1rem;
    max-height: 400px;
    overflow-y: auto;
}

.auto-response-card {
    background: var(--clr-bg-primary);
    border-radius: 6px;
    padding: 0.8rem;
}

.auto-response-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.auto-response-header h4 {
    font-size: 0.9rem;
}

.auto-response-content {
    font-size: 0.8rem;
    color: var(--clr-text-secondary);
}

.auto-response-content p {
    margin: 0.2rem 0;
}

/* Notifications */
.notifications-config {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.config-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--clr-border);
}

.config-info h5 {
    font-size: 0.9rem;
    margin-bottom: 0.1rem;
}

.config-info p {
    font-size: 0.7rem;
    color: var(--clr-text-secondary);
}

/* Workflows */
.workflows-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.workflow-card {
    background: var(--clr-bg-primary);
    border-radius: 8px;
    padding: 1rem;
}

.workflow-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.workflow-icon {
    color: var(--clr-blue);
    font-size: 1.2rem;
}

.workflow-conditions {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
    margin: 0.5rem 0;
    font-size: 0.8rem;
}

.condition {
    padding: 0.2rem 0.5rem;
    background: var(--clr-bg-secondary);
    border-radius: 4px;
}

.condition.result {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.workflow-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
}

/* --- Modale statistiques --- */
.stat-card-large {
    grid-column: 1 / -1;
    background: var(--clr-bg-primary);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.stats-cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card-mini {
    background: var(--clr-bg-primary);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
}

.top-questions {
    background: var(--clr-bg-primary);
    border-radius: 8px;
    padding: 1rem;
}

.questions-list {
    margin-top: 0.5rem;
}

.question-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--clr-border);
}

.question-item:last-child {
    border-bottom: none;
}

.question {
    font-size: 0.9rem;
}

.count {
    font-size: 0.8rem;
    color: var(--clr-blue);
    font-weight: 600;
}

/* --- Modale menu --- */
.menu-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem;
    background: var(--clr-bg-primary);
    border: none;
    border-radius: 6px;
    color: var(--clr-text-primary);
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: all 0.3s ease;
}

.menu-item:hover {
    background: var(--clr-bg-secondary);
}

.menu-item i {
    width: 20px;
    color: var(--clr-blue);
}

.menu-item.danger {
    color: var(--clr-red);
}

.menu-item.danger i {
    color: var(--clr-red);
}

.divider {
    margin: 0.3rem 0;
    border: none;
    border-top: 1px solid var(--clr-border);
}

/* --- Switch toggle --- */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--clr-border);
    transition: .3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #10b981;
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* --- Responsive --- */
@media (max-width: 1200px) {
    .conversations-history {
        width: 240px;
    }
    
    .assistant-sidebar {
        width: 240px;
    }
}

@media (max-width: 992px) {
    .assistant-container {
        height: calc(100vh - 200px);
    }
    
    .assistant-sidebar {
        display: none;
    }
}

@media (max-width: 768px) {
    .assistant-container {
        flex-direction: column;
        height: calc(100vh - 160px);
    }
    
    .conversations-history {
        width: 100%;
        height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--clr-border);
    }
    
    .history-list {
        display: flex;
        overflow-x: auto;
        padding: 0.5rem;
    }
    
    .history-item {
        min-width: 200px;
        flex-shrink: 0;
    }
    
    .assistant-chat {
        height: calc(100vh - 360px);
    }
    
    .assistant-sidebar {
        display: none;
    }
}

@media (max-width: 480px) {
    .suggestions-list {
        flex-direction: column;
    }
    
    .suggestion-chip {
        width: 100%;
        text-align: center;
    }
    
    .message-actions {
        flex-direction: column;
    }
    
    .action-link {
        width: 100%;
        justify-content: center;
    }
    
    .message-feedback {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .stats-cards-grid {
        grid-template-columns: 1fr;
    }
}





/* ==============================================
   AMÉLIORATIONS MOBILE POUR L'ASSISTANT
   ============================================== */

@media (max-width: 768px) {
    /* Conteneur principal */
    .assistant-container {
        flex-direction: column;
        height: calc(100vh - 120px);
        position: relative;
    }
    
    /* Historique en overlay mobile */
    .conversations-history {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: auto;
        z-index: 100;
        background: var(--clr-bg-secondary);
        display: none;
    }
    
    .conversations-history.mobile-open {
        display: flex;
    }
    
    /* Chat en plein écran */
    .assistant-chat {
        width: 100%;
        height: 100%;
        display: flex;
    }
    
    /* Bouton menu mobile */
    .mobile-menu-btn {
        display: flex !important;
        margin-right: 0.5rem;
    }
    
    /* En-tête du chat */
    .chat-header {
        padding: 0.6rem;
    }
    
    .assistant-avatar {
        width: 36px;
        height: 36px;
        font-size: 1.2rem;
    }
    
    .assistant-details h2 {
        font-size: 0.9rem;
    }
    
    /* Messages */
    .message {
        max-width: 90%;
    }
    
    .message-bubble {
        font-size: 0.9rem;
    }
    
    /* Suggestions */
    .suggestions-list {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }
    
    .suggestion-chip {
        flex-shrink: 0;
    }
    
    /* Zone de saisie */
    .chat-input-area {
        padding: 0.5rem;
    }
    
    .input-wrapper textarea {
        font-size: 0.9rem;
        padding: 0.5rem;
    }
    
    .send-btn {
        width: 40px;
        height: 40px;
    }
    
    /* Historique en liste horizontale */
    .history-list {
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        padding: 0.5rem;
    }
    
    .history-item {
        min-width: auto;
        width: 100%;
    }
    
    /* Message feedback */
    .message-feedback {
        flex-wrap: wrap;
    }
    
    .feedback-btn {
        padding: 0.4rem 0.8rem;
    }
    
    /* Modales en plein écran */
    .modal .modal-content {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        margin: 0;
        border-radius: 0;
        transform: none;
        top: 0;
        left: 0;
        overflow-y: auto;
    }
    
    .modal-header {
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--clr-bg-secondary);
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
        overflow-y: auto;
    }
    
    .modal-footer {
        position: sticky;
        bottom: 0;
        background: var(--clr-bg-secondary);
        padding: 1rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .modal-footer button {
        width: 100%;
    }
    
    /* Historique complet */
    .history-full-item {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .history-date {
        width: 100%;
        padding: 0.5rem;
        background: var(--clr-bg-primary);
        border-radius: 4px;
    }
    
    .history-mini-item {
        padding: 0.8rem;
        border-left: 3px solid transparent;
    }
    
    .history-mini-item:active {
        background: var(--clr-bg-primary);
        border-left-color: var(--clr-blue);
    }
    
    /* Réponses prédéfinies */
    .predefined-card {
        padding: 0.8rem;
    }
    
    .predefined-card-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    /* Workflow builder */
    .workflow-builder {
        gap: 1rem;
    }
    
    .workflow-condition,
    .workflow-action {
        width: 100%;
    }
    
    .workflow-operator {
        text-align: center;
        padding: 0.5rem;
    }
}

/* Animation d'entrée pour le menu mobile */
@keyframes slideIn {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

.conversations-history.mobile-open {
    animation: slideIn 0.3s ease;
}

/* Bouton menu mobile */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--clr-text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.3rem;
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: 50%;
    }
    
    .mobile-menu-btn:active {
        background: var(--clr-bg-primary);
    }
}

/* Historique en colonne sur mobile */
@media (max-width: 768px) {
    .history-list {
        height: 100%;
        overflow-y: auto;
    }
    
    .history-item {
        margin-bottom: 0.5rem;
        border-bottom: 1px solid var(--clr-border);
        padding-bottom: 0.8rem;
    }
    
    .history-item:last-child {
        border-bottom: none;
    }
}

/* Amélioration de la zone de suggestions */
.input-suggestions {
    display: flex;
    gap: 0.3rem;
    padding: 0.5rem;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

.input-suggestions .suggestion-chip {
    flex-shrink: 0;
}

/* Indicateur de chargement pour les réponses */
.typing-indicator {
    padding: 0.8rem;
}

.typing-dots span {
    background: var(--clr-blue);
}


