﻿:root {
    --primary-color: #336699;
    --background-color: #f4f7f9;
    --container-bg: #ffffff;
    --border-color: #e0e0e0;
    --text-color: #333;
    --text-light: #777;
    --accent-color: #007bff;
    --hover-bg: rgba(0,0,0,0.03);
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    /* Couleurs des départements */
    --dept-comptabilite-bg: #d1e7fd;
    --dept-site_web-bg: #d1f2e1;
    --dept-reseaux_sociaux-bg: #e9d8fd;
    --dept-contenus-bg: #fff3cd;
    --dept-devis-bg: #ffeedd; /* Orange Pastel */
    --dept-general-bg: #f0f2f5;
}
* { box-sizing: border-box; }
html { height: 100%; }
body {
    font-family: var(--font-family);
    margin: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    height: 100%;
    overflow: hidden;
}

/* ================================================ */
/* STYLES DE BASE (Login, Modals...)                */
/* ================================================ */
.login-container {
    background-color: var(--container-bg);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    width: 100%;
    max-width: 400px;
    text-align: center;
    margin: auto;
}
.login-container img { max-width: 150px; margin-bottom: 20px; }
.form-group { margin-bottom: 15px; text-align: left; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 600; font-size: 14px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 12px; border: 1px solid var(--border-color); border-radius: 8px; font-size: 16px; font-family: var(--font-family); }
.btn { width: 100%; padding: 12px; border: none; border-radius: 8px; background-color: var(--primary-color); color: white; font-size: 16px; font-weight: 600; cursor: pointer; transition: background-color 0.2s; }
.btn:hover { opacity: 0.9; }
.btn-sm { padding: 5px 12px; font-size: 13px; width: auto; }
.alert { padding: 15px; margin-bottom: 20px; border-radius: 8px; text-align: left; }
.alert-danger { background-color: #f8d7da; color: #721c24; }
.alert-success { background-color: #d4edda; color: #155724; }
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: none; justify-content: center; align-items: center; z-index: 1000; }
.modal-content { background: white; padding: 30px; border-radius: 12px; width: 90%; max-width: 500px; max-height: 90vh; overflow-y: auto;}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h2 { margin: 0; font-size: 20px; }
.close-modal { font-size: 24px; cursor: pointer; border: none; background: none; }
.empty-list-message, .no-conversation-message { text-align:center; color: #777; padding: 20px; font-style: italic; font-size: 14px; }

/* Styles pour le formulaire de devis */
.modal-content.devis-mode { background-color: var(--dept-devis-bg); }
#admin-upload-options { display: flex; gap: 20px; margin-bottom: 15px; padding-bottom: 15px; border-bottom: 1px solid #eee; }
#admin-upload-options label { font-weight: 500; cursor: pointer; }

/* --- DEBUT MODIFICATION 2FA --- */
#tfa_code {
    text-align: center;
    font-size: 24px;
    letter-spacing: 10px;
    padding-left: 20px; /* Compense le letter-spacing */
}
/* --- FIN MODIFICATION 2FA --- */


/* ================================================ */
/* STRUCTURE GLOBALE & VUE DESKTOP                  */
/* ================================================ */
.app-container { display: flex; width: 100vw; height: 100vh; background-color: var(--container-bg); }

.app-column {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
    overflow: hidden;
}

.app-column.sidebar { width: 340px; min-width: 260px; max-width: 600px; border-right: 1px solid var(--border-color); flex-shrink: 0; }
.app-column.middle-column {
    flex: 1 1 50%;
    min-width: 300px;
}
.app-column.right-column {
    flex: 1 1 50%;
    min-width: 300px;
}


#resizer-v, #resizer-h { width: 5px; cursor: col-resize; background: #e0e0e0; flex-shrink: 0; user-select: none; z-index: 10; }
#resizer-h { border-left: 1px solid var(--border-color); border-right: 1px solid var(--border-color); }

#welcome-message { flex-grow: 1; display: flex; justify-content: center; align-items: center; text-align: center; color: var(--text-light); font-size: 18px; }
.main-content-wrapper { display: none; flex-grow: 1; flex-direction: column; min-height: 0; }
.main-content-wrapper-placeholder { flex-grow: 1; background-color: #f8f9fa; }

.announcement-container-top { height: 160px; min-height: 80px; max-height: 50vh; border-bottom: 1px solid var(--border-color); flex-shrink: 0; overflow: auto;}
.resizer-h-announcement { height: 5px; cursor: row-resize; background: #e0e0e0; user-select: none; flex-shrink: 0;}
.announcements-container { display: flex; gap: 20px; width: 100%; height: 100%; padding: 15px; box-sizing: border-box; }
.announcement-card { display: flex; flex: 1; border: 1px solid #ddd; border-radius: 8px; overflow: hidden; background: #fff; min-width: 0; }
.announcement-thumb img { height: 100%; width: auto; object-fit: contain; display: block; }
.announcement-content { padding: 15px; font-size: 14px; }
.announcement-placeholder { width: 100%; height: 100%; background-color: #f8f9fa; }


/* ================================================ */
/* COMPOSANTS INTERNES (Sidebar, Chat, etc.)        */
/* ================================================ */
.sidebar-header { padding: 15px 20px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.logo-container { display: flex; align-items: center; gap: 10px; }
.logo { width: 90px !important; height: auto !important; }
.app-title { font-size: 24px; font-weight: bold; color: #333; }
a.logout-link { color: var(--text-light); text-decoration: none; font-size: 14px; }

.nav-tabs { display: flex; border-bottom: 1px solid var(--border-color); padding: 0 20px; }
.nav-tab { padding: 15px 20px; cursor: pointer; color: var(--text-light); font-weight: 500; display: flex; align-items: center; }
.nav-tab .icon { margin-right: 8px; }
.nav-tab.active { color: var(--primary-color); border-bottom: 2px solid var(--primary-color); }

.tab-content { display: none; flex-grow: 1; overflow-y: auto; flex-direction: column;}
.tab-content.active { display: flex; }
#announcements-settings-container { padding: 20px; overflow-y: auto; }

#department-legend { padding: 8px 20px; font-size: 11px; border-bottom: 1px solid var(--border-color); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; background-color: #f8f9fa;}
#department-legend b { margin-right: 5px; }
.legend-item { padding: 2px 6px; border-radius: 4px; }

.top-action-container {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
}

.conversations-list { flex-grow: 1; overflow-y: auto; }
.client-group-header { padding: 15px 20px; cursor: pointer; font-weight: bold; background-color: #f0f2f5; border-bottom: 1px solid var(--border-color); display: flex; align-items: center;}
.client-group-header:hover { background-color: #e9ecef; }
.client-icon { margin-right: 10px; }
.client-conversations { display: none; padding-left: 15px; border-bottom: 1px solid var(--border-color); }

.conversation-item { padding: 15px 20px; cursor: pointer; border-bottom: 1px solid var(--border-color); transition: background-color 0.2s; }
.conversation-item:last-child { border-bottom: none; }
.conversation-item-inner { display: flex; justify-content: space-between; align-items: center; width: 100%;}
.conversation-details { flex-grow: 1; overflow: hidden; display: flex; align-items: center; }
.subject { font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-footer {
    padding: 10px 20px;
    border-top: 1px solid var(--border-color);
    background-color: #f8f9fa;
}

.new-item-btn {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 8px;
    background-color: var(--primary-color);
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    text-align: center;
}
.new-item-btn:hover {
    opacity: 0.9;
}

#global-payment-request-btn {
    margin-top: 10px;
    background-color: #f48c06;
}

.install-app-btn {
    display: none;
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    background-color: #28a745;
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}
.install-app-btn:hover { opacity: 0.9; }

.conversation-icon { flex-shrink: 0; margin-right: 12px; color: var(--text-light); }

.conversation-item.dept-comptabilite { background-color: var(--dept-comptabilite-bg); }
.conversation-item.dept-site_web { background-color: var(--dept-site_web-bg); }
.conversation-item.dept-reseaux_sociaux { background-color: var(--dept-reseaux_sociaux-bg); }
.conversation-item.dept-contenus { background-color: var(--dept-contenus-bg); }
.conversation-item.dept-devis { background-color: var(--dept-devis-bg); }
.conversation-item.dept-general { background-color: #fff; }

.conversation-item.active {
    box-shadow: inset 4px 0 0 0 var(--primary-color);
    filter: brightness(95%);
}
.conversation-item:hover { filter: brightness(97%); }
.conversation-item.active:hover { filter: brightness(95%); }


#chat-wrapper { flex-grow: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-header { padding: 15px 20px; border-bottom: 1px solid var(--border-color); font-weight: 600; flex-shrink: 0; }
.messages-container { flex-grow: 1; padding: 20px; overflow-y: auto; }
.message { margin-bottom: 15px; max-width: 80%; padding: 10px 15px; border-radius: 18px; line-height: 1.4; word-wrap: break-word; }
.message p { margin: 0; }
.message-meta { font-size: 12px; color: var(--text-light); margin-top: 5px; }
.message.sent { background-color: var(--primary-color); color: white; margin-left: auto; border-bottom-right-radius: 4px; }
.message.sent .message-meta { color: #555 ; }
.message.received { background-color: #e9ecef; color: var(--text-color); margin-right: auto; border-bottom-left-radius: 4px; }
.message .attachment-link { display: block; margin-top: 8px; padding: 8px 12px; background-color: rgba(0,0,0,0.05); border-radius: 8px; text-decoration: none; color: inherit; }
.message.sent .attachment-link { background-color: rgba(255,255,255,0.1); }
.attachment-image { max-width: 200px; border-radius: 8px; margin-top: 5px; }

.message-form-container { display: flex; align-items: flex-end; gap: 10px; padding: 10px 15px; border-top: 1px solid var(--border-color); background-color: #f8f9fa; flex-shrink: 0; }
#message-form { flex-grow: 1; display: flex; border: 1px solid #ddd; border-radius: 22px; padding: 0; background-color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
#attachment-btn { align-self: center; padding: 8px; font-size: 20px; background: none; border: none; cursor: pointer; color: var(--text-light); }
#message-input { border: none; outline: none; resize: none; background: transparent; padding: 10px 15px; font-size: 16px; line-height: 1.4; width: 100%; box-sizing: border-box; }
#send-btn-container { padding: 0; }
#send-btn { width: auto; padding: 8px 15px; }
#attachment-preview { display: none; align-items: center; gap: 8px; font-size: 13px; margin: -5px 15px 8px 15px; }
#preview-cancel-btn { background: none; border: none; cursor: pointer; font-size: 16px; }

#client-space-wrapper { flex-grow: 1; display: flex; flex-direction: column; background-color: #f8f9fa; }
.client-space-header { padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); background: #fff; flex-shrink: 0; }
#client-payment-requests { padding: 20px; overflow-y: auto; flex-grow: 1; }
.payment-request-card { border-radius: 12px; padding: 15px; margin-bottom: 15px; border: 1px solid rgba(0,0,0,0.08); display: flex; gap: 15px; overflow: hidden; }
.payment-request-card.status-pending { background-color: #fff3cd; border-left: 5px solid #ffc107; }
.payment-request-card.status-processing { background-color: #ffedd5; border-left: 5px solid #fd7e14; }
.payment-request-card.status-paid { background-color: #d1f2e1; border-left: 5px solid #28a745; }
.pr-image { flex-shrink: 0; width: 120px; }
.pr-image img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.pr-content { flex-grow: 1; display: flex; flex-direction: column; justify-content: space-between; min-width: 0; }
.pr-header { display: flex; justify-content: space-between; align-items: flex-start; }
.pr-title { font-weight: bold; margin: 0 0 5px 0; font-size: 1.1em; }
.pr-date { font-size: 0.8em; color: #666; }
.pr-status { font-size: 12px; font-weight: 500; padding: 4px 10px; border-radius: 20px; color: #333; text-transform: uppercase; flex-shrink: 0; }
.status-pending .pr-status { background-color: #ffc107; }
.status-processing .pr-status { background-color: #fd7e14; color: white; }
.status-paid .pr-status { background-color: #28a745; color: white; }
.pr-description { font-size: 14px; margin: 5px 0; -webkit-box-orient: vertical; display: -webkit-box; -webkit-line-clamp: 2; overflow: hidden; text-overflow: ellipsis; }
.pr-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.invoice-link { display: inline-flex; align-items: center; gap: 5px; text-decoration: none; color: #0056b3; font-weight: 500; }
.admin-controls { display: flex; gap: 10px; align-items: center; }

.table-container { padding: 20px; flex-grow: 1; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
th { font-size: 14px; color: var(--text-light); }
.action-btn { background: none; border: none; cursor: pointer; font-size: 18px; padding: 5px; opacity: 0.7; }
.action-btn:hover { opacity: 1; }
.btn-danger { color: #dc3545; }
.action-icon { opacity: 0; transition: opacity 0.2s; flex-shrink: 0; }
.conversation-item:hover .action-icon { opacity: 0.7; }
@keyframes pulse-animation { 0% { transform: scale(1); opacity: 0.7; } 50% { transform: scale(1.2); opacity: 1; } 100% { transform: scale(1); opacity: 0.7; } }
.unread-client-icon { display: inline-block; animation: pulse-animation 1.5s infinite; color: #28a745; margin-left: 8px; font-size: 16px; vertical-align: middle; }
.unread-badge { font-size: 12px; color: var(--primary-color); margin-left: 8px; }
.conversation-item.unread .subject { font-weight: bold; color: var(--primary-color); }
.announcement-form-wrapper { display: flex; gap: 20px; margin-bottom: 20px; }
.announcement-form { flex: 1; border: 1px solid #ccc; padding: 15px; border-radius: 8px; min-width: 250px; }
.current-announcement-img { display: block; width: 100%; max-width: 100%; height: auto; max-height: 150px; margin-bottom: 10px; border-radius: 4px; object-fit: contain; border: 1px solid #ddd; background-color: #f9f9f9; }

.mobile-nav-btn {
    display: none;
}

#mockup-zone-container {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0,0,0,0.02);
}
.mockup-item {
    flex: 1;
    max-width: 200px;
    text-align: center;
    position: relative;
}
.mockup-item img {
    width: 100%;
    height: 150px;
    object-fit: contain;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #fff;
}
.mockup-label {
    font-size: 12px;
    font-weight: 500;
    color: #555;
    margin-top: 5px;
}
.mockup-item.mockup-validated a {
    cursor: default;
}
.mockup-item.mockup-validated img {
    filter: grayscale(80%) opacity(50%);
}
.mockup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    font-weight: bold;
    font-size: 18px;
    text-transform: uppercase;
    transform: rotate(-15deg);
    opacity: 0.8;
    pointer-events: none;
}

.devis-attachment-zone {
    padding: 15px;
    margin: 10px 20px;
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    background-color: rgba(0,0,0,0.02);
}
.devis-attachment-zone h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 14px;
    color: var(--text-light);
}
.attachments-grid {
    justify-content: flex-start;
}
.attachment-item, .attachment-item-placeholder {
    width: 100px;
    text-align: center;
    text-decoration: none;
    color: var(--text-color);
}
.attachment-item img, .attachment-item-placeholder img, .attachment-item .file-icon {
    width: 100px;
    height: 80px;
    object-fit: cover;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
}
.attachment-item-placeholder img {
    object-fit: contain;
    filter: grayscale(50%) opacity(60%);
}
.attachment-item span {
    font-size: 11px;
    display: block;
    margin-top: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ================================================ */
/* SECTION RESPONSIVE AVEC MEDIA QUERIES            */
/* ================================================ */

@media (max-width: 1024px) {
    .app-column.sidebar {
        width: 280px;
        min-width: 240px;
    }
    .announcement-form-wrapper {
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    body {
        overflow: auto;
    }
    .app-container {
        flex-direction: column;
        height: auto;
        width: 100%;
    }

    .app-column {
        width: 100% !important;
        height: auto;
        min-width: 0 !important;
        border: none !important;
        overflow: visible;
    }
    
    .app-column.sidebar {
        height: 100vh;
        max-width: 100%;
    }

    .app-column.middle-column,
    .app-column.right-column {
        display: none;
    }

    .app-container.show-chat .sidebar { display: none; }
    .app-container.show-chat .middle-column { display: flex; height: 100vh; }
    .app-container.show-chat .right-column { display: none; }

    .app-container.show-client-space .sidebar { display: none; }
    .app-container.show-client-space .middle-column { display: none; }
    .app-container.show-client-space .right-column { display: flex; height: 100vh; }

    #resizer-v, #resizer-h, .resizer-h-announcement {
        display: none;
    }

    .login-container {
        padding: 20px;
        box-shadow: none;
        max-width: 100%;
        margin: 0;
        border-radius: 0;
        height: 100vh;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .nav-tabs {
        justify-content: space-around;
        padding: 0;
    }
    .nav-tab {
        flex-grow: 1;
        justify-content: center;
        padding: 15px 10px;
    }
    .tab-text {
        display: none;
    }
    .icon {
        margin-right: 0;
    }

    .main-content-wrapper { display: flex; }
    .main-content-wrapper-placeholder, #welcome-message { display: none; }

    .modal-content {
        width: 95%;
        margin: auto;
    }
    
    .payment-request-card {
        flex-direction: column;
    }
    .pr-image {
        width: 100%;
        height: 150px;
    }
    
    .mobile-nav-btn {
        display: inline-flex;
        background: none;
        border: 2px solid #333;
        color: #333;
        cursor: pointer;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        align-items: center;
        justify-content: center;
        transition: background-color 0.2s, color 0.2s;
    }
    .mobile-nav-btn:hover, .mobile-nav-btn:active {
        background-color: #333;
        color: #fff;
    }
    .mobile-nav-btn svg {
        width: 22px;
        height: 22px;
    }

    .chat-header, .client-space-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 10px;
    }
    
    #chat-header-title, #client-space-header-title {
        flex-grow: 1;
        text-align: center;
        padding: 0 10px;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mockup-zone {
        flex-direction: column;
    }
    .mockup-item {
        max-width: 100%;
    }
    
    .attachments-grid {
        gap: 10px;
        flex-wrap: wrap;
    }
    .attachment-item, .attachment-item-placeholder {
        width: calc(33.33% - 10px);
        min-width: 80px;
    }
     .attachment-item img, .attachment-item-placeholder img, .attachment-item .file-icon {
        height: 60px;
    }
}

