/* =================================================_ */
/* 1. CONFIGURATION GLOBALE & VARIABLES               */
/* =================================================_ */
:root {
    --bg-color: #fafafa;
    --text-color: #000000;
    --text-muted: #737373;
    --border-color: #dbdbdb;
    --hover-bg: #f5f5f5;
    --primary-color: #0095f6;
    --heart-red: #ff3040;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
}

/* Structure principale de type Threads / App Layout */
.app-layout {
    display: flex;
    max-width: 950px;
    margin: 0 auto;
    min-height: 100vh;
    box-sizing: border-box;
}

/* =================================================_ */
/* 2. MENU LATÉRAL (SIDEBAR) - FIXE SUR PC            */
/* =================================================_ */
.sidebar {
    width: 240px;
    padding: 24px 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    position: sticky;
    top: 0;
    height: 100vh;
    box-sizing: border-box;
    border-right: 1px solid var(--border-color);
    background-color: #ffffff;
    z-index: 100;
}

.sidebar-logo {
    font-size: 1.6rem;
    font-weight: 700;
    text-decoration: none;
    color: inherit;
    padding-left: 12px;
    margin-bottom: 10px;
    letter-spacing: -0.5px;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: 12px;
    text-decoration: none;
    color: #262626;
    font-weight: 500;
    font-size: 0.95rem;
    transition: background-color 0.2s;
}

.sidebar-menu a:hover, .sidebar-menu a.active {
    background-color: #f0f0f0;
    font-weight: 600;
}

.sidebar-menu a i {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

/* =================================================_ */
/* 3. CONTENU PRINCIPAL                               */
/* =================================================_ */
.main-content {
    flex: 1;
    max-width: 620px;
    padding: 20px;
    box-sizing: border-box;
    margin: 0 auto;
    width: 100%;
}

.main-container {
    width: 100%;
    max-width: 600px;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    min-height: 100vh;
    box-sizing: border-box;
}

/* En-tête du fil */
.feed-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.feed-header h2 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
}

.btn-publish {
    background-color: var(--text-color);
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

/* =================================================_ */
/* 4. POSTS ET CARTES                                 */
/* =================================================_ */
.post-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
}

.post-author {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: #f0f0f0;
}

.post-date {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.post-content h3 {
    margin: 0 0 8px 0;
    font-size: 1rem;
    font-weight: 600;
}

.post-content p {
    margin: 0 0 12px 0;
    font-size: 0.95rem;
    line-height: 1.4;
}

.post-meta {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    align-items: center;
}

.badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-available { background-color: #e6f4ea; color: #137333; }
.status-reserved { background-color: #fef7e0; color: #b06000; }
.status-sold { background-color: #fce8e6; color: #c5221f; }
.status-rented { background-color: #e8f0fe; color: #1a73e8; }

.post-price {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-color);
}

/* Correction propre du conteneur du carrousel et des éléments multimédias/map */
.image-carousel {
    position: relative;
    width: 100%;
    background: #111;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.carousel-track {
    width: 100%;
    display: flex;
    transition: transform 0.3s ease-in-out;
}

/* S'assure que chaque image ou élément de la map s'affiche l'un après l'autre et non par-dessus */
.carousel-img {
    min-width: 100%;
    width: 100%;
    height: 400px;
    object-fit: contain;
    object-position: center;
    background-color: #111;
    display: none;
    border-radius: 8px;
}

.carousel-img.active {
    display: block;
}

/* Style spécifique pour le bloc de la carte intégrée pour éviter qu'il ne se décale */
.carousel-img iframe {
    width: 100%;
    height: 400px;
    border: 0;
    border-radius: 8px;
    display: block;
}
.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.prev-btn { left: 10px; }
.next-btn { right: 10px; }

/* Actions (J'aime / Commentaires) */
.post-actions {
    display: flex;
    gap: 20px;
    align-items: center;
    border-top: 1px solid #efefef;
    padding-top: 10px;
    margin-top: 12px;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0;
}

.action-btn i.liked {
    color: var(--heart-red);
}

/* Texte tronqué ("Voir plus") */
.clamp-text {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
}

.clamp-text.expanded {
    display: block;
    overflow: visible;
}

.see-more-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    font-size: 0.85rem;
    margin-top: 4px;
    font-weight: 600;
}

.see-more-btn:hover {
    color: #000;
}

/* =================================================_ */
/* 5. COMMENTAIRES & FORMULAIRES                      */
/* =================================================_ */
.comment-form {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
    width: 100%;
}

.comment-input {
    flex: 1;
    height: 38px;
    padding: 0 14px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.9rem;
    outline: none;
    box-sizing: border-box;
}

.comment-submit-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 50%;
    background-color: var(--text-color);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.comment-submit-btn:hover {
    opacity: 0.85;
}

/* Formulaires de création */
.container {
    max-width: 600px;
    margin: 40px auto;
    padding: 20px;
}

form div {
    margin-bottom: 15px;
}

form label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

form input[type="text"],
form input[type="number"],
form select,
form textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-sizing: border-box;
}

form textarea {
    height: 120px;
    resize: vertical;
}

form button[type="submit"] {
    background-color: var(--text-color);
    color: #fff;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
}

/* =================================================_ */
/* 6. MODALE DE COMMENTAIRES                          */
/* =================================================_ */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #fff;
    padding: 20px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.close-modal {
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 15px;
    max-height: 350px;
}

/* =================================================_ */
/* 7. AUTHENTIFICATION (LOGIN / REGISTER)             */
/* =================================================_ */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: var(--bg-color);
    padding: 20px;
}

.auth-box {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 40px 30px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    text-align: center;
}

.auth-logo {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

.auth-alert.error {
    background-color: #ffebe9;
    color: #d73a49;
    border: 1px solid rgba(215, 58, 73, 0.2);
    padding: 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 20px;
    text-align: left;
}

.auth-form { text-align: left; }
.auth-form .form-group { margin-bottom: 18px; }

.auth-form label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: #262626;
}

.auth-form input[type="text"],
.auth-form input[type="password"] {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    box-sizing: border-box;
    outline: none;
}

.auth-btn {
    width: 100%;
    height: 42px;
    background-color: #000000;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    margin-top: 10px;
}

/* =================================================_ */
/* 8. RESPONSIVE DESIGN (MOBILE)                      */
/* =================================================_ */
.mobile-top-bar { 
    display: none; 
}

/* --- CORRECTION RESPONSIVE MOBILE DÉFINITIVE --- */
@media (max-width: 768px) {
    /* On remet le body en défilement normal pour éliminer toute zone grise parasite */
    body {
        margin: 0;
        padding: 0;
        background-color: var(--bg-color, #fafafa);
        overflow-y: auto;
    }

    /* La barre du haut reste fixe par-dessus sans créer d'espace vide */
    .mobile-top-bar {
        display: flex;
        position: fixed;
        top: 0; 
        left: 0; 
        right: 0;
        height: 55px;
        background: #fff;
        border-bottom: none !important;
        align-items: center;
        justify-content: space-between;
        padding: 0 16px;
        z-index: 1000;
    }

    .app-layout {
        display: block;
        width: 100%;
        margin: 0;
        max-width: 100%;
        min-height: auto;
    }

    /* Le contenu principal défile naturellement avec un espace en haut pour la barre fixe et en bas pour le menu */
    .main-content {
        width: 100%;
        max-width: 100%;
        padding: 10px 10px 70px 10px;
        margin-top: 55px; /* Al juste la hauteur de la barre fixe pour ne pas cacher les premiers éléments */
        margin-bottom: 0;
        box-sizing: border-box;
    }

    /* Barre de navigation du bas fixe */
    .sidebar {
        position: fixed;
        bottom: 0; 
        left: 0;
        right: 0;
        top: auto; 
        width: 100%; 
        height: 55px; 
        flex-direction: row; 
        justify-content: space-around; 
        border-top: 1px solid var(--border-color, #dbdbdb); 
        border-right: none; 
        padding: 0; 
        z-index: 1000;
        background-color: #ffffff;
    }

    .sidebar-logo { 
        display: none; 
    }

    .sidebar-menu { 
        flex-direction: row; 
        width: 100%; 
        justify-content: space-around; 
        align-items: center; 
    }

    .sidebar-menu a span {
        display: none; /* Masque le texte sur mobile, garde uniquement les icônes */
    }
}

/* --- Formulaire de commentaire (Style Threads) --- */
.comment-form {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    width: 100% !important;
    margin-top: 10px !important;
    box-sizing: border-box;
}

/* Champ de saisie fluide à gauche */
.comment-input {
    flex: 1 !important;
    width: 100% !important;
    height: 38px !important;
    padding: 0 14px !important;
    border: 1px solid var(--border-color, #dbdbdb) !important;
    background-color: #ffffff !important;
    color: #000000 !important;
    border-radius: 20px !important;
    font-size: 0.9rem !important;
    outline: none !important;
    box-sizing: border-box !important;
    margin-bottom: 0 !important;
}

/* Bouton d'envoi rond et compact à droite */
.comment-submit-btn {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    border-radius: 50% !important;
    background-color: var(--text-color, #000000) !important;
    color: #ffffff !important;
    border: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin-bottom: 0 !important;
}

.comment-submit-btn:hover {
    opacity: 0.85;
}

.comment-submit-btn i {
    font-size: 0.9rem !important;
    color: #ffffff !important;
}


/* =========================================================
   9. AJUSTEMENT DE L'ESPACE SOUS LA BARRE MOBILE
   Réduction d'environ 70 % de l'espace supérieur
   ========================================================= */

@media (max-width: 768px) {
    .main-content .feed-header {
        margin-top: -60px !important;
    }
}
