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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f2f5;
    color: #333;
    line-height: 1.6;
}

/* ========================================
   APP LAYOUT - Fullscreen
   ======================================== */

.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* HEADER FIXE en haut */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #2c3e50;
    color: #fff;
    padding: 10px 25px;
    flex-shrink: 0;
    z-index: 100;
}

.app-header h1 {
    font-size: 1.3rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
}

/* CORPS : sidebar + main */
.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ========================================
   BARRE DE FILTRES
   ======================================== */

.filter-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 8px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
}

/* Dropdown filtre */
.filter-dropdown {
    position: relative;
}

.filter-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.82rem;
    color: #444;
    user-select: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.filter-dropdown-btn:hover {
    border-color: #aaa;
}

.filter-dropdown-open .filter-dropdown-btn {
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52,152,219,0.15);
}

.filter-dropdown-icon {
    font-size: 0.85rem;
    color: #7f8c8d;
}

.filter-dropdown-arrow {
    font-size: 0.65rem;
    color: #95a5a6;
    margin-left: 2px;
}

.filter-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 220px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
    z-index: 500;
    overflow: hidden;
}

.filter-dropdown-open .filter-dropdown-menu {
    display: block;
}

.filter-dropdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 16px;
    font-size: 0.83rem;
    color: #333;
    cursor: pointer;
    transition: background 0.1s;
}

.filter-dropdown-item:hover {
    background: #f0f4f8;
}

.filter-dropdown-item-active {
    background: #f0f4f8;
    font-weight: 600;
    color: #2c3e50;
}

.filter-dropdown-count {
    background: #e8ecef;
    color: #555;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
    min-width: 28px;
    text-align: center;
}

.filter-dropdown-item-active .filter-dropdown-count {
    background: #3498db;
    color: #fff;
}

/* Recherche */
.filter-search {
    margin-left: auto;
}

.filter-search input {
    padding: 6px 14px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    font-size: 0.82rem;
    font-family: inherit;
    width: 220px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.filter-search input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52,152,219,0.15);
}

/* ========================================
   SIDEBAR
   ======================================== */

.sidebar {
    width: 320px;
    min-width: 320px;
    background: #fff;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-title {
    padding: 12px 16px;
    font-weight: 700;
    font-size: 0.9rem;
    color: #2c3e50;
    border-bottom: 1px solid #eee;
    background: #fafafa;
    flex-shrink: 0;
}

.sidebar-list {
    flex: 1;
    overflow-y: auto;
}

.sidebar-empty {
    padding: 30px 16px;
    text-align: center;
    color: #95a5a6;
}

.sidebar-item {
    display: block;
    padding: 10px 16px;
    border-bottom: 1px solid #f0f0f0;
    text-decoration: none;
    color: #333;
    transition: background 0.15s;
    border-left: 3px solid transparent;
    cursor: pointer;
}

.nav-link {
    cursor: pointer;
    user-select: none;
}

.sidebar-item:hover {
    background: #f5f7fa;
}

.sidebar-item-active {
    background: #e8f4fd;
    border-left-color: #3498db;
}

.sidebar-item-en_attente {
    border-left-color: #f39c12;
}

.sidebar-item-en_cours {
    border-left-color: #3498db;
}

.sidebar-item-termine {
    border-left-color: #27ae60;
}

.sidebar-item-active.sidebar-item-en_attente {
    background: #fef9e7;
    border-left-color: #f39c12;
}

.sidebar-item-active.sidebar-item-en_cours {
    background: #e8f4fd;
    border-left-color: #3498db;
}

.sidebar-item-active.sidebar-item-termine {
    background: #eafaf1;
    border-left-color: #27ae60;
}

.sidebar-item-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
}

.sidebar-item-who {
    font-size: 0.82rem;
    font-weight: 600;
    color: #2c3e50;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-item-date {
    font-size: 0.72rem;
    color: #95a5a6;
    white-space: nowrap;
    margin-left: 8px;
    flex-shrink: 0;
}

.sidebar-item-titre {
    font-size: 0.8rem;
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}

.sidebar-item-service {
    background: #ecf0f1;
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 0.68rem;
    margin-left: 5px;
    font-weight: normal;
    color: #7f8c8d;
}

.sidebar-item-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}

.sidebar-item-count {
    font-size: 0.7rem;
    color: #95a5a6;
}

.sidebar-item-vu {
    font-size: 0.7rem;
    color: #27ae60;
    font-weight: 600;
}

/* ========================================
   MAIN CONTENT
   ======================================== */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f0f2f5;
}

/* En-tête de la demande */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 14px 20px;
    background: #fff;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
}

.content-header-left h2 {
    font-size: 1.1rem;
    color: #2c3e50;
    margin-bottom: 2px;
}

.content-meta {
    display: flex;
    gap: 10px;
    align-items: center;
    font-size: 0.8rem;
    color: #7f8c8d;
}

.content-service {
    background: #ecf0f1;
    padding: 1px 8px;
    border-radius: 8px;
    font-size: 0.75rem;
}

.content-header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.content-vu {
    font-size: 0.75rem;
    color: #27ae60;
    font-style: italic;
}

/* Zone des messages - scrollable */
.content-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.content-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #95a5a6;
    font-size: 1.1rem;
}

/* Messages */
.msg {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 10px;
    max-width: 75%;
}

.msg-demandeur {
    background: #fff;
    border-left: 3px solid #3498db;
    margin-right: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.msg-technicien {
    background: #f0faf4;
    border-right: 3px solid #27ae60;
    border-left: none;
    margin-left: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.msg-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 0.78rem;
    color: #7f8c8d;
}

.msg-header strong {
    color: #2c3e50;
    font-size: 0.82rem;
}

.msg-date {
    margin-left: auto;
    font-size: 0.72rem;
}

.msg-body a {
    color: #2980b9;
    text-decoration: underline;
    word-break: break-all;
}

.msg-body a:hover {
    color: #1a5276;
}

.msg-body {
    color: #333;
    font-size: 0.9rem;
    line-height: 1.5;
}

.msg-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.msg-image-link img {
    max-width: 150px;
    max-height: 100px;
    border-radius: 4px;
    border: 1px solid #ddd;
    object-fit: cover;
    transition: transform 0.2s;
    cursor: pointer;
}

.msg-image-link img:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Zone de réponse fixée en bas */
.content-reply {
    padding: 10px 20px 14px;
    background: #fff;
    border-top: 1px solid #ddd;
    flex-shrink: 0;
}

.reply-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.reply-row textarea {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    resize: none;
}

.reply-row textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52,152,219,0.2);
}

.reply-options {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 6px;
    font-size: 0.8rem;
}

.reply-file-label {
    color: #3498db;
    cursor: pointer;
    font-size: 0.8rem;
}

.reply-file-label:hover {
    text-decoration: underline;
}

.reply-file-label input[type="file"] {
    display: none;
}

.reply-statut-select {
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.8rem;
    font-family: inherit;
}

.file-count {
    font-size: 0.75rem;
    color: #27ae60;
    font-weight: 600;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Prévisualisation des images avant envoi */
.reply-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 0 8px 0;
}

.reply-preview:empty {
    display: none;
}

.preview-thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 5px;
    border: 2px solid #3498db;
}

.content-termine {
    padding: 12px 20px;
    text-align: center;
    background: #eafaf1;
    color: #27ae60;
    font-weight: 700;
    border-top: 2px solid #27ae60;
    flex-shrink: 0;
}

/* Bouton Terminer */
.btn-terminer {
    background: #e74c3c;
    white-space: nowrap;
}

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

.btn-suppr {
    background: #95a5a6;
    font-size: 0.72rem;
    padding: 3px 10px;
    margin-top: 4px;
}

.btn-suppr:hover {
    background: #e74c3c;
}

/* ========================================
   MODALE CONFIRMATION
   ======================================== */

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-active {
    display: flex;
}

.modal-box {
    background: #fff;
    border-radius: 10px;
    padding: 30px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.modal-box h3 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1.15rem;
}

.modal-box p {
    color: #7f8c8d;
    font-size: 0.9rem;
    margin-bottom: 25px;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-modal-cancel {
    background: #95a5a6;
}

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

.btn-modal-confirm {
    background: #e74c3c;
}

.btn-modal-confirm:hover {
    background: #c0392b;
}

/* ========================================
   BADGES
   ======================================== */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-sm {
    padding: 2px 6px;
    font-size: 0.65rem;
}

.badge-en_attente {
    background: #f39c12;
    color: #fff;
}

.badge-en_cours {
    background: #3498db;
    color: #fff;
}

.badge-termine {
    background: #27ae60;
    color: #fff;
}

.badge-tech {
    background: #5963b6;
    color: #fff;
}

/* ========================================
   BOUTONS
   ======================================== */

.btn {
    display: inline-block;
    padding: 8px 18px;
    background: #3498db;
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.2s;
}

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

.btn-small {
    padding: 5px 12px;
    font-size: 0.8rem;
}

.btn-danger {
    background: #e74c3c;
}

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

/* ========================================
   PAGES FORMULAIRES (login, nouvelle demande)
   ======================================== */

.container {
    max-width: 700px;
    margin: 0 auto;
    padding: 20px;
}

.container header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #2c3e50;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 25px;
}

.container header h1 {
    font-size: 1.3rem;
}

.login-container {
    max-width: 400px;
    margin: 80px auto;
    background: #fff;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-align: center;
}

.login-container h1 {
    color: #2c3e50;
    margin-bottom: 5px;
}

.login-container h2 {
    color: #7f8c8d;
    font-size: 1rem;
    font-weight: normal;
    margin-bottom: 25px;
}

.form-group {
    margin-bottom: 18px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #2c3e50;
}

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

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52,152,219,0.2);
}

.erreur {
    background: #fdecea;
    color: #c0392b;
    padding: 10px 15px;
    border-radius: 5px;
    margin-bottom: 15px;
    border-left: 4px solid #e74c3c;
}

.date-info {
    color: #7f8c8d;
    margin-bottom: 20px;
}

.help-text {
    display: block;
    margin-top: 5px;
    color: #95a5a6;
    font-size: 0.8rem;
}

.actions {
    margin-bottom: 20px;
}

/* ========================================
   LIGHTBOX
   ======================================== */

.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.lightbox-active {
    display: flex;
}

.lightbox-img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 6px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 2.5rem;
    font-weight: 300;
    cursor: pointer;
    line-height: 1;
    transition: opacity 0.2s;
}

.lightbox-close:hover {
    opacity: 0.7;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .filter-bar {
        gap: 8px;
        padding: 6px 12px;
        flex-wrap: wrap;
    }
    .app-header {
        flex-direction: column;
        gap: 8px;
        text-align: center;
        padding: 8px 15px;
    }
    .header-right {
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px;
    }
    .app-body {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        min-width: 100%;
        max-height: 35vh;
        border-right: none;
        border-bottom: 1px solid #ddd;
    }
    .msg {
        max-width: 90%;
    }
    .reply-row {
        flex-direction: column;
    }
    .reply-row .btn {
        align-self: flex-end;
    }
    .content-header {
        flex-direction: column;
        gap: 8px;
    }
    .content-meta {
        flex-wrap: wrap;
    }
}
