/* ============================================================
   ZETBOO — Salons publics (MUC)
   ============================================================ */

/* .page (défini dans style.css) porte une grille pensée pour la home
   page (intro/hero/cards/cta/footer) — inadaptée ici, donc on repasse
   en layout vertical simple pour .salon-page tout en gardant .header,
   .logo, .header-label déjà stylés. */
.page.salon-page {
    display: block;
    width: min(720px, calc(100% - 40px));
    margin: 0 auto;
    padding: 24px 0 40px;
}

.salon-page .header {
    border-bottom: 1px solid var(--line);
    margin-bottom: 24px;
}

/* ---------- Liste des salons ---------- */
.salon-list-section {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: clamp(20px, 4vw, 32px);
}

.salon-list-section h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 18px;
    color: var(--ink);
}

.loading-msg,
.empty-msg {
    padding: 20px 0;
    text-align: center;
    color: var(--muted);
    font-size: 0.92rem;
}

.error-box {
    margin-bottom: 16px;
    padding: 10px 14px;
    border-radius: 8px;
    background: rgba(220, 38, 38, 0.08);
    border: 1px solid rgba(220, 38, 38, 0.25);
    color: #b91c1c;
    font-size: 0.88rem;
    text-align: center;
}

.salon-list {
    list-style: none;
}

.salon-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 4px;
    border-bottom: 1px solid var(--line);
}

.salon-item:last-child {
    border-bottom: none;
}

.salon-name {
    font-weight: 700;
    color: var(--ink);
    flex-shrink: 0;
}

.salon-desc {
    flex: 1;
    min-width: 0;
    color: var(--muted);
    font-size: 0.88rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-join {
    flex-shrink: 0;
    padding: 8px 18px;
    border: none;
    border-radius: 999px;
    background: var(--orange);
    color: var(--white);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.btn-join:hover:not(:disabled) {
    background: var(--orange-dark);
}

.btn-join:active:not(:disabled) {
    transform: scale(0.96);
}

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

/* ---------- Conversation dans un salon ----------
   Classes partagées avec messenger.php (room-header, messages-container,
   room-input, message-row, message-sender, message-text) : les styler
   ici les rend cohérentes partout où elles apparaissent dans la SPA. */
.salon-chat-section {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: min(70vh, 640px);
}

.room-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}

/* Corps de la conversation : messages+saisie à gauche, participants à droite */
.salon-chat-body {
    flex: 1;
    display: flex;
    min-height: 0;
}

.salon-chat-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ---------- Panneau participants (colonne de droite) ---------- */
.participants-panel {
    flex-shrink: 0;
    width: 200px;
    border-left: 1px solid var(--line);
    background: var(--paper);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.participants-title {
    flex-shrink: 0;
    padding: 14px 16px 10px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.participants-list {
    list-style: none;
    padding: 0 8px 12px;
}

.participant-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
}

.participant-item:hover {
    background: var(--bg-hover-item);
}

.participant-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.participant-name {
    font-size: 0.85rem;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .salon-chat-body {
        flex-direction: column;
    }

    .participants-panel {
        width: auto;
        max-height: 140px;
        border-left: none;
        border-top: 1px solid var(--line);
    }

    .participants-list {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        padding: 8px;
    }

    .participant-item {
        width: auto;
    }
}

.room-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-leave {
    flex-shrink: 0;
    padding: 8px 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--white);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.btn-leave:hover {
    border-color: var(--orange);
    color: var(--orange-dark);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.messages-container .message-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
    line-height: 1.5;
}

.messages-container .message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    margin-top: 2px;
}

.messages-container .message-content {
    min-width: 0;
}

.messages-container .message-sender {
    display: block;
    color: var(--orange-dark);
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 2px;
}

.messages-container .message-text {
    color: var(--ink);
    word-break: break-word;
}

.room-input {
    display: flex;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--line);
    flex-shrink: 0;
}

.room-input input {
    flex: 1;
    padding: 11px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.92rem;
    color: var(--ink);
    background: var(--paper);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.room-input input:focus {
    outline: none;
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(243, 107, 33, 0.15);
    background: var(--white);
}

.room-input button {
    flex-shrink: 0;
    padding: 0 22px;
    border: none;
    border-radius: 999px;
    background: var(--orange);
    color: var(--white);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.room-input button:hover {
    background: var(--orange-dark);
}

@media (max-width: 480px) {
    .salon-chat-section {
        height: min(75vh, 560px);
        border-radius: 12px;
    }

    .room-header,
    .room-input {
        padding: 12px 14px;
    }

    .messages-container {
        padding: 12px 14px;
    }
}

/* ============================================================
   Page "Messages privés" — même carte/mise en page que les salons
   (.room-header, .messages-container, .message-row, .room-input
   sont déjà stylés ci-dessus et partagés avec messenger.php).
   ============================================================ */
.page.messenger-page {
    display: block;
    width: min(720px, calc(100% - 40px));
    margin: 0 auto;
    padding: 24px 0 40px;
}

.messenger-page .header {
    border-bottom: 1px solid var(--line);
    margin-bottom: 24px;
}

.thread-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.thread-tabs button {
    padding: 6px 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--white);
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.thread-tabs button:hover {
    border-color: var(--orange);
    color: var(--orange-dark);
}

.thread-tabs button.active {
    background: var(--orange);
    border-color: var(--orange);
    color: var(--white);
}

.thread-section {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: min(70vh, 640px);
}

.thread-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.conversation-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

/* Input d'envoi de message plus haut, spécifique à cette page (le salon
   garde sa hauteur d'origine, .room-input étant une classe partagée). */
.thread-section .room-input input {
    height: 48px;
}

@media (max-width: 480px) {
    .thread-section {
        height: min(75vh, 560px);
        border-radius: 12px;
    }
}

/* ============================================================
   Modale de création de salon (XEP-0045, formulaire muc#owner)
   ============================================================ */
.room-create-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    z-index: 1100;
}

.room-create-modal {
    position: relative;
    background: var(--white);
    border-radius: 16px;
    padding: 28px 24px 24px;
    width: min(480px, 100%);
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}

.room-create-modal .btn-close-popup {
    position: absolute;
    top: 12px;
    right: 12px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--muted);
    line-height: 1;
}

.room-create-modal .btn-close-popup:hover {
    color: var(--ink);
}

.room-create-step h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 18px;
}

.rc-section {
    margin-bottom: 20px;
}

.rc-section h4 {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--line);
}

.rc-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.rc-field:last-child {
    margin-bottom: 0;
}

.rc-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--ink);
}

.rc-hint {
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.4;
}

.rc-field input[type="text"],
.rc-field input[type="password"],
.rc-field input[type="number"],
.rc-field select {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--ink);
    background: var(--paper);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.rc-field input[type="text"]:focus,
.rc-field input[type="password"]:focus,
.rc-field input[type="number"]:focus,
.rc-field select:focus {
    outline: none;
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(243, 107, 33, 0.15);
    background: var(--white);
}

.rc-input-short {
    max-width: 140px;
}

.rc-password-wrapper {
    position: relative;
    display: flex;
}

.rc-password-wrapper input {
    flex: 1;
    padding-right: 40px !important;
}

.rc-password-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--muted);
    border-radius: 50%;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.rc-password-toggle:hover {
    background: var(--bg-hover-item);
    color: var(--orange-dark);
}

.rc-toggle {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
    cursor: pointer;
}

.rc-toggle:last-child {
    margin-bottom: 0;
}

.rc-toggle input[type="checkbox"] {
    margin-top: 3px;
    width: 16px;
    height: 16px;
    accent-color: var(--orange);
    flex-shrink: 0;
    cursor: pointer;
}

.rc-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

@media (max-width: 480px) {
    .room-create-modal {
        padding: 22px 16px 18px;
        border-radius: 12px;
    }
}
