/*
|--------------------------------------------------------------------------
| TCHAT
|--------------------------------------------------------------------------
*/

.tchat-page {
    width: 100%;
    max-width: 1500px;
    height: calc(100vh - 100px);
    min-height: 650px;
    margin: 20px auto;
    padding: 0 15px;
    box-sizing: border-box;

    display: grid;
    grid-template-columns: 250px minmax(0, 1fr) 240px;
    gap: 15px;
}


/*
|--------------------------------------------------------------------------
| SIDEBARS
|--------------------------------------------------------------------------
*/

.tchat-sidebar {
    background: #fff;
    border: 1px solid #e9e9ef;
    border-radius: 18px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.tchat-sidebar-header {
    min-height: 65px;
    padding: 15px;
    box-sizing: border-box;

    display: flex;
    align-items: center;
    justify-content: space-between;

    border-bottom: 1px solid #eee;
}

.tchat-sidebar-header strong {
    display: block;
    font-size: 15px;
}

.tchat-sidebar-header small {
    display: block;
    margin-top: 4px;
    color: #999;
    font-size: 12px;
}

.tchat-online-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #27ae60;
    box-shadow: 0 0 0 4px rgba(39,174,96,.12);
}


/*
|--------------------------------------------------------------------------
| CONNECTÉS
|--------------------------------------------------------------------------
*/

.tchat-users-list {
    padding: 10px;
    overflow-y: auto;
}

.tchat-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px;
    margin-bottom: 4px;
    border-radius: 11px;
}

.tchat-user:hover {
    background: #f7f7fa;
}

.tchat-user-avatar {
    position: relative;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
}

.tchat-user-avatar img {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
}

.user-online {
    position: absolute;
    width: 9px;
    height: 9px;
    right: 0;
    bottom: 1px;
    border-radius: 50%;
    background: #2ecc71;
    border: 2px solid #fff;
}

.tchat-user-info {
    min-width: 0;
}

.tchat-user-info strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tchat-user-info small {
    display: block;
    margin-top: 3px;
    font-size: 11px;
}

.user-femme .tchat-user-info strong {
    color: #e84393;
}

.user-homme .tchat-user-info strong {
    color: #2980d9;
}

.user-autre .tchat-user-info strong {
    color: #7f8c8d;
}

.user-femme .tchat-user-info small {
    color: #e84393;
}

.user-homme .tchat-user-info small {
    color: #2980d9;
}


/*
|--------------------------------------------------------------------------
| CENTRE
|--------------------------------------------------------------------------
*/

.tchat-main {
    min-width: 0;
    background: #fff;
    border: 1px solid #e9e9ef;
    border-radius: 18px;

    display: flex;
    flex-direction: column;

    overflow: hidden;
}

.tchat-header {
    min-height: 72px;
    padding: 14px 20px;
    box-sizing: border-box;

    display: flex;
    align-items: center;
    justify-content: space-between;

    border-bottom: 1px solid #eee;
}

.tchat-header h1 {
    margin: 0;
    font-size: 20px;
}

.tchat-header p {
    margin: 5px 0 0;
    color: #888;
    font-size: 13px;
}

.tchat-member-count {
    padding: 7px 12px;
    border-radius: 20px;
    background: #f3f1ff;
    color: #6447b5;
    font-size: 12px;
    font-weight: 700;
}


/*
|--------------------------------------------------------------------------
| MESSAGES
|--------------------------------------------------------------------------
*/

.tchat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 20px;
    background: #fafafd;
}

.tchat-welcome {
    max-width: 500px;
    margin: 50px auto;
    text-align: center;
    color: #777;
}

.tchat-welcome-icon {
    width: 65px;
    height: 65px;
    margin: 0 auto 15px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 20px;
    background: #eeeaff;

    font-size: 30px;
}

.tchat-welcome h2 {
    margin: 0 0 8px;
    color: #333;
    font-size: 20px;
}

.tchat-welcome p {
    margin: 0;
    font-size: 14px;
}


/*
|--------------------------------------------------------------------------
| FORMULAIRE
|--------------------------------------------------------------------------
*/

.tchat-form {
    display: flex;
    gap: 10px;
    padding: 14px;
    border-top: 1px solid #eee;
    background: #fff;
}

.tchat-form input[type="text"] {
    flex: 1;
    min-width: 0;
    height: 48px;
    padding: 0 15px;
    border: 1px solid #ddd;
    border-radius: 12px;
    outline: none;
}

.tchat-form input[type="text"]:focus {
    border-color: #7054c5;
}

.tchat-form button {
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 12px;
    background: #6c4fc1;
    color: #fff;
    cursor: pointer;
    font-size: 20px;
}


/*
|--------------------------------------------------------------------------
| SALONS
|--------------------------------------------------------------------------
*/

.tchat-room-list {
    padding: 10px;
    overflow-y: auto;
}

.tchat-room {
    display: flex;
    align-items: center;
    gap: 10px;

    padding: 11px;
    margin-bottom: 5px;

    border-radius: 12px;
    text-decoration: none;
    color: #333;
}

.tchat-room:hover {
    background: #f7f7fa;
}

.tchat-room.active {
    background: #eeeaff;
    color: #5d43ad;
}

.tchat-room-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 10px;
    background: #f4f4f7;
}

.tchat-room strong {
    display: block;
    font-size: 14px;
}

.tchat-room small {
    display: block;
    margin-top: 3px;
    color: #999;
    font-size: 11px;
}

/* Messages */

.tchat-message {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    max-width: 90%;
}

.tchat-message-avatar {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
}

.tchat-message-avatar img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
}

.tchat-message-content {
    min-width: 0;
}

.tchat-message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.tchat-message-meta strong {
    font-size: 13px;
}

.tchat-message-meta span {
    color: #aaa;
    font-size: 11px;
}

.tchat-message-text {
    display: inline-block;
    padding: 9px 13px;
    border-radius: 5px 14px 14px 14px;
    background: #f0f0f5;
    color: #333;
    line-height: 1.45;
    word-break: break-word;
}


/* Femme */

.tchat-message-femme .tchat-message-meta strong {
    color: #e84393;
}

.tchat-message-femme .tchat-message-text {
    background: #fff0f7;
}


/* Homme */

.tchat-message-homme .tchat-message-meta strong {
    color: #2980d9;
}

.tchat-message-homme .tchat-message-text {
    background: #eef6ff;
}


/* Autre */

.tchat-message-autre .tchat-message-meta strong {
    color: #7f8c8d;
}

.tchat-users-list .tchat-user {
    text-decoration: none;
    color: inherit;
}

.tchat-users-list a.tchat-user {
    color: inherit;
}

.tchat-users-list a.tchat-user:hover {
    text-decoration: none;
}

/* =========================================================
   POPUP PROFIL TCHAT
   ========================================================= */

.tchat-profile-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;

    display: none;
    align-items: center;
    justify-content: center;

    padding: 20px;

    background: rgba(0, 0, 0, 0.65);
}

.tchat-profile-overlay.active {
    display: flex;
}


.tchat-profile-popup {
    position: relative;

    width: 100%;
    max-width: 340px;

    padding: 30px 25px;

    background: #fff;

    border-radius: 18px;

    text-align: center;

    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.30);

    animation: tchatProfilePopupIn 0.18s ease-out;
}


@keyframes tchatProfilePopupIn {

    from {
        opacity: 0;
        transform: scale(0.92) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}


/* Bouton fermer */

.tchat-profile-close {
    position: absolute;

    top: 10px;
    right: 12px;

    width: 34px;
    height: 34px;

    border: 0;
    border-radius: 50%;

    background: #f1f1f1;

    color: #555;

    font-size: 24px;
    line-height: 1;

    cursor: pointer;
}

.tchat-profile-close:hover {
    background: #e5e5e5;
}


/* Avatar */

.tchat-profile-avatar {
    position: relative;

    width: 100px;
    height: 100px;

    margin: 5px auto 15px;
}


.tchat-profile-avatar img {
    width: 100%;
    height: 100%;

    object-fit: cover;

    border-radius: 50%;

    border: 4px solid #fff;

    box-shadow:
        0 5px 20px rgba(0, 0, 0, 0.15);
}


.tchat-profile-online {
    position: absolute;

    right: 4px;
    bottom: 6px;

    width: 18px;
    height: 18px;

    border-radius: 50%;

    background: #35c759;

    border: 3px solid #fff;
}


/* Pseudo */

.tchat-profile-popup h3 {
    margin: 0;

    font-size: 22px;
}


/* Sexe */

.tchat-profile-popup p {
    margin: 6px 0 20px;

    color: #777;

    font-size: 14px;
}


/* Bouton privé */

.tchat-profile-private {
    width: 100%;

    padding: 12px 18px;

    border: 0;
    border-radius: 10px;

    background: #222;
    color: #fff;

    font-size: 15px;
    font-weight: 600;

    cursor: pointer;

    transition:
        transform 0.15s ease,
        opacity 0.15s ease;
}


.tchat-profile-private:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}




.tchat-profile-profile {
    width: 100%;

    padding: 12px 18px;

    border: 0;
    border-radius: 10px;
	margin-top: 15px;

    background: #444;
    color: #fff;

    font-size: 15px;
    font-weight: 600;

    cursor: pointer;

    transition:
        transform 0.15s ease,
        opacity 0.15s ease;
}


.tchat-profile-profile:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}





/* Les membres deviennent des boutons */

.tchat-users-list button.tchat-user {
    width: 100%;

    border: 0;

    font: inherit;

    text-align: left;

    color: inherit;

    cursor: pointer;
}


.tchat-users-list button.tchat-user:hover {
    background: rgba(0, 0, 0, 0.04);
}


.tchat-message-systeme {
    justify-content: center;
    margin: 12px 0;
}

.tchat-system-message {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 14px;
    border-radius: 20px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 13px;
    font-style: italic;
}

/* ==========================================================
   RÈGLES DU SALON
   ========================================================== */

.tchat-regles {
    display: flex;
    align-items: flex-start;
    gap: 12px;

    margin: 10px 15px;

    padding: 12px 15px;

    background: #fff8e7;

    border: 1px solid #f1dfad;

    border-radius: 12px;

    color: #66552a;
}


.tchat-regles-icon {
    flex: 0 0 auto;

    font-size: 22px;

    line-height: 1;
}


.tchat-regles-content {
    min-width: 0;
}


.tchat-regles-content strong {
    display: block;

    margin-bottom: 4px;

    font-size: 14px;

    color: #4d3d15;
}


.tchat-regles-content p {
    margin: 0;

    font-size: 13px;

    line-height: 1.5;

    white-space: normal;

    overflow-wrap: anywhere;
}


/* ==========================================================
   MOBILE
   ========================================================== */

@media (max-width: 700px) {

    .tchat-regles {
        margin: 8px 0;

        padding: 10px 12px;
    }

    .tchat-regles-icon {
        font-size: 20px;
    }

    .tchat-regles-content strong {
        font-size: 13px;
    }

    .tchat-regles-content p {
        font-size: 12px;
    }

}

/*
|--------------------------------------------------------------------------
| MOBILE
|--------------------------------------------------------------------------
*/

@media (max-width: 1000px) {

    .tchat-page {
        grid-template-columns: 210px minmax(0, 1fr);
    }

    .tchat-rooms {
        display: none;
    }

}

/* =========================================================
   MOBILE PAYSAGE
   On garde exactement le même ordre :
   Membres → Salons → Tchat
   ========================================================= */

@media (max-width: 900px) and (orientation: landscape) {

    .tchat-page {
        display: flex;
        flex-direction: column;
        gap: 8px;

        width: 100%;
        height: auto;

        padding: 8px;
        box-sizing: border-box;
    }

    .tchat-users {
        display: block;
        width: 100%;
        order: 1;
    }

    .tchat-users-list {
        display: flex;
        gap: 8px;

        width: 100%;
        overflow-x: auto;
        overflow-y: hidden;

        padding: 6px 2px;
        box-sizing: border-box;
    }

    .tchat-users-list .tchat-user {
        flex: 0 0 auto;
        min-width: 90px;
    }

    .tchat-rooms {
        display: block;
        width: 100%;
        order: 2;
    }

    .tchat-room-list {
        display: flex;
        gap: 8px;

        width: 100%;
        overflow-x: auto;
        overflow-y: hidden;

        padding: 6px 2px;
        box-sizing: border-box;
    }

    .tchat-room {
        flex: 0 0 auto;
        min-width: 140px;
    }

    .tchat-main {
        display: flex;
        flex-direction: column;

        width: 100%;
        order: 3;

        height: calc(100vh - 250px);
        min-height: 350px;

        box-sizing: border-box;
    }
	
.tchat-form input[type="text"] {
    flex: 1;
    min-width: 0;
    height: 48px;
    padding: 0 15px;
    border: 1px solid #ddd;
    border-radius: 12px;
    outline: none;
    font-size: 16px;
}	
	
}

@media (max-width: 700px) {

    .tchat-page {
        display: flex;
        flex-direction: column;
        gap: 10px;

        height: auto;
        min-height: calc(100vh - 100px);

        padding: 10px;
    }


    /* ==========================================================
       MEMBRES CONNECTÉS
       ========================================================== */

    .tchat-users {
        display: block;

        width: 100%;

        order: 1;
    }


    .tchat-users-list {
        display: flex;

        gap: 8px;

        overflow-x: auto;
        overflow-y: hidden;

        padding: 8px 2px;

        scrollbar-width: thin;
    }


    .tchat-users-list .tchat-user {
        flex: 0 0 auto;

        min-width: 100px;
    }


    /* ==========================================================
       SALONS
       ========================================================== */

    .tchat-rooms {
        display: block;

        width: 100%;

        order: 2;
    }


    .tchat-room-list {
        display: flex;

        gap: 8px;

        overflow-x: auto;
        overflow-y: hidden;

        padding: 8px 2px;

        scrollbar-width: thin;
    }


    .tchat-room {
        flex: 0 0 auto;

        min-width: 150px;
    }


    /* ==========================================================
       CHAT
       ========================================================== */

    .tchat-main {
        width: 100%;

        order: 3;

        height: calc(100vh - 260px);

        min-height: 500px;
    }

}


/* =========================================================
   CORRECTION DÉBORDEMENT HORIZONTAL — MOBILE
   ========================================================= */

@media (max-width: 700px) {

    html,
    body {
        max-width: 100%;
        overflow-x: hidden;
    }

    .tchat-page {
        width: 100%;
        max-width: 100%;

        box-sizing: border-box;

        padding-left: 10px;
        padding-right: 10px;

        overflow-x: hidden;
    }

    .tchat-main,
    .tchat-users,
    .tchat-rooms {
        width: 100%;
        max-width: 100%;

        min-width: 0;

        box-sizing: border-box;
    }

    .tchat-header,
    .tchat-regles,
    .tchat-messages,
    .tchat-form {
        max-width: 100%;
        box-sizing: border-box;
    }

    .tchat-users-list,
    .tchat-room-list {
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    .tchat-message {
        min-width: 0;
        max-width: 100%;
    }

    .tchat-message-content {
        min-width: 0;
        max-width: 100%;
    }

    .tchat-message-text {
        max-width: 100%;
        box-sizing: border-box;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

}


/* =========================================================
   IPHONE — CLAVIER VIRTUEL
   ========================================================= */

@media (max-width: 700px) {

    html,
    body {
        overflow-x: hidden;
    }

    .tchat-page {
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    .tchat-main {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
        overflow: hidden;
    }

    .tchat-form {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

.tchat-form input[type="text"] {
    flex: 1;
    min-width: 0;
    height: 48px;
    padding: 0 15px;
    border: 1px solid #ddd;
    border-radius: 12px;
    outline: none;
    font-size: 16px;
}

}

.tchat-user-room {
    display: block;
    margin-top: 3px;
    font-size: 11px;
    opacity: 0.65;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tchat-reply-target {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    background: rgba(24, 119, 242, 0.10);
    color: #1877f2;
    font-size: 13px;
}

.tchat-reply-target[hidden] {
    display: none;
}

.tchat-reply-target button {
    border: 0;
    background: transparent;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    color: inherit;
    padding: 0 4px;
}

.tchat-destinataire-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    margin-bottom: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.035);
}

.tchat-destinataire-wrap[hidden] {
    display: none !important;
}

/*
|--------------------------------------------------------------------------
| RÈGLES MOBILE
|--------------------------------------------------------------------------
*/

.tchat-regles-mobile {
    display: none;
}


/*
|--------------------------------------------------------------------------
| POPUP RÈGLES
|--------------------------------------------------------------------------
*/

.tchat-regles-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;

    display: none;
    align-items: center;
    justify-content: center;

    padding: 20px;

    background: rgba(0, 0, 0, 0.55);
}

.tchat-regles-overlay.active {
    display: flex;
}

.tchat-regles-popup {
    position: relative;

    width: 100%;
    max-width: 520px;
    max-height: 80vh;

    background: #ffffff;
    border-radius: 18px;

    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);

    overflow: hidden;
}

.tchat-regles-popup-header {
    display: flex;
    align-items: center;
    gap: 10px;

    padding: 18px 20px;

    border-bottom: 1px solid #eeeeee;
}

.tchat-regles-popup-header span {
    font-size: 22px;
}

.tchat-regles-popup-header h2 {
    margin: 0;
    font-size: 18px;
}

.tchat-regles-popup-content {
    padding: 20px;

    max-height: calc(80vh - 80px);

    overflow-y: auto;

    font-size: 14px;
    line-height: 1.6;
    color: #444444;
}

.tchat-regles-close {
    position: absolute;

    top: 10px;
    right: 12px;

    width: 34px;
    height: 34px;

    border: 0;
    border-radius: 50%;

    background: #f1f1f1;

    font-size: 24px;
    line-height: 1;

    cursor: pointer;

    z-index: 2;
}

.tchat-regles-close:hover {
    background: #e5e5e5;
}


/*
|--------------------------------------------------------------------------
| MOBILE
|--------------------------------------------------------------------------
*/

@media (max-width: 650px) {

    .tchat-regles-desktop {
        display: none;
    }

    .tchat-regles-mobile {
        display: block;

        width: 100%;

        margin: 8px 0 10px;
        padding: 10px 14px;

        border: 1px solid #e1e1e1;
        border-radius: 10px;

        background: #ffffff;

        font-size: 13px;
        font-weight: 600;

        text-align: left;

        cursor: pointer;
    }

    .tchat-regles-mobile:active {
        transform: scale(0.99);
    }

}