/* ============================================================
   NextChat — Estilos responsivos (versão mobile)
   ============================================================ */

#shell-members { display: none; }

.touch-only { display: none; }

@media (max-width: 800px) {
    /* Alvos de toque maiores e sem zoom duplo */
    body {
        -webkit-tap-highlight-color: transparent;
        overscroll-behavior-y: none;
    }

    .shell-btn,
    .sap-btn,
    .sap-close-btn,
    .member-item,
    .room-card,
    .dm-search-hit,
    .dm-panel-item {
        touch-action: manipulation;
    }

    .sap-shell {
        position: sticky;
        top: 0;
        z-index: 990;
        display: flex;
        flex-wrap: nowrap;
        padding: 0 8px;
        font-size: 12px;
    }

    .shell-logo {
        white-space: nowrap;
        margin-right: 10px;
        font-size: 15px;
    }

    .shell-title {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        flex: 0 1 auto;
        min-width: 0;
    }

    .shell-username { display: none; }

    .shell-btn {
        width: 40px;
        height: 40px;
        margin-left: 2px;
        margin-right: 2px;
    }

    .chat-app {
        height: calc(var(--vvh, 100dvh) - var(--shell-height));
    }

    .chat-main { position: relative; }

    .chat-room-info {
        padding: 8px 12px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .chat-room-info h2 { font-size: 16px; }

    .room-actions { flex-wrap: wrap; }

    .room-btn { height: 32px; font-size: 12px; padding: 0 10px; }

    .chat-scroll { padding: 12px 8px; }

    .chat-input { padding: 8px 10px; }

    .chat-input .sap-textarea {
        min-height: 40px;
        max-height: 100px;
    }

    /* Sidebar de membros vira um drawer */
    #shell-members { display: inline-flex; }

    .member-sidebar {
        position: fixed;
        top: var(--shell-height);
        right: 0;
        bottom: 0;
        width: min(320px, 84vw);
        z-index: 960;
        transform: translateX(100%);
        transition: transform 0.24s ease;
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.2);
        margin: 0;
    }

    body.member-open .member-sidebar { transform: translateX(0); }

    body.member-open::after {
        content: '';
        position: fixed;
        inset: var(--shell-height) 0 0 0;
        background: rgba(0, 0, 0, 0.35);
        z-index: 950;
    }

    /* Ações de admin sempre visíveis no toque */
    .member-actions {
        display: flex;
        position: static;
        transform: none;
        border: none;
        box-shadow: none;
        background: none;
        padding: 0;
    }

    .member-action {
        padding: 6px 8px;
        font-size: 13px;
    }

    /* Inputs >= 16px para evitar zoom automático no iOS */
    .sap-input,
    .sap-textarea,
    .dm-input,
    .sap-switch + input,
    input, textarea, select {
        font-size: 16px;
    }

    /* Lobby */
    .lobby-page { padding: 14px; }

    .lobby-header { gap: 10px; }

    .lobby-header h1 { font-size: 17px; }

    .room-card { min-height: 120px; padding: 14px; }

    /* Janelas de DM em fullscreen */
    #mirc-windows {
        left: 0;
        right: 0;
        bottom: var(--kbd-offset, 0px);
        align-items: stretch;
    }

    .mirc-window {
        width: 100%;
        height: var(--vvh, 100vh);
        border-radius: 14px 14px 0 0;
        margin-bottom: 0;
    }

    .mirc-window--minimized { height: auto; border-radius: 0; }

    .mirc-window__bar { padding: 12px 10px; }
    .mirc-winwn { padding: 6px 10px; }

    /* Conversa privada — fullscreen (estilo WhatsApp) */
    .dm-mobile {
        position: fixed;
        inset: 0;
        z-index: 2000;
        height: var(--vvh, 100vh);
    }

    .dm-mobile__back { display: flex; }
    .dm-mobile__close { display: none; }

    /* Toasts e livedata */
    #toast-container,
    [class*="toast"] { left: 8px; right: 8px; }
}

@media (max-width: 600px) {
    /* Modais ocupam a tela inteira */
    .sap-modal-overlay { padding: 0; align-items: flex-end; }

    .sap-modal {
        max-width: none;
        max-height: 100vh;
        max-height: 100dvh;
        width: 100%;
        height: calc(var(--vvh, 100dvh) - 4vh);
        border-radius: 16px 16px 0 0;
        border-bottom: none;
        margin-bottom: var(--kbd-offset, 0px);
    }

    .sap-modal__header { padding: 16px 18px; }
    .sap-modal__body { padding: 18px; }
    .sap-modal__footer { padding: 12px 18px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }

    .sap-btn { min-height: 40px; }

    .invite-box { padding: 10px 12px; }
}

@media (max-width: 380px) {
    .shell-logo { font-size: 12px; }
    .chat-room-info h2 { font-size: 15px; }
    .room-topic { font-size: 11px; }
}

/* ============================================================
   Conversa privada — base (mobile fullscreen / web modal)
   ============================================================ */
.dm-mobile {
    display: none;
    flex-direction: column;
    background: var(--sap-bg);
}

.dm-mobile--open { display: flex; }

.dm-mobile__view {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    min-height: 0;
    background: var(--sap-bg);
}

.dm-mobile__bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--sap-brand);
    color: #fff;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.dm-mobile__back,
.dm-mobile__close {
    background: rgba(255, 255, 255, 0.18);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dm-mobile__avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 17px;
    flex-shrink: 0;
}

.dm-mobile__meta { flex: 1; min-width: 0; }

.dm-mobile__name {
    font-weight: 700;
    font-size: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dm-mobile__status { font-size: 12px; opacity: 0.92; }

.dm-mobile__status--on { opacity: 1; }

.dm-mobile__list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    -webkit-overflow-scrolling: touch;
}

.dm-mobile__row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 85%;
    -webkit-touch-callout: none;
}

.dm-mobile__row--mine { align-self: flex-end; align-items: flex-end; }

.dm-mobile__nick {
    font-size: 11px;
    color: var(--sap-text-muted);
    margin: 0 4px 2px;
}

.dm-mobile__bubble {
    padding: 8px 10px 5px;
    border-radius: 14px 14px 14px 4px;
    font-size: 14.5px;
    line-height: 1.4;
    background: var(--sap-surface);
    color: var(--sap-text);
    border: 1px solid var(--sap-border);
    word-break: break-word;
    box-shadow: var(--shadow-sm);
}

.dm-mobile__row--mine .dm-mobile__bubble {
    background: #d9fdd3;
    border-color: #c0e8b8;
    border-radius: 14px 14px 4px 14px;
}

.dm-mobile__text {
    display: block;
    white-space: pre-wrap;
}

.dm-mobile__time {
    display: block;
    text-align: right;
    font-size: 10px;
    color: var(--sap-text-muted);
    margin-top: 2px;
}

.dm-mobile__typing {
    min-height: 18px;
    padding: 2px 12px;
    font-style: italic;
    color: var(--sap-text-muted);
    font-size: 12px;
    flex-shrink: 0;
}

.dm-mobile__input {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 14px;
    background: var(--sap-surface);
    border-top: 1px solid var(--sap-border);
    flex-shrink: 0;
}

.dm-mobile__field {
    flex: 1;
    min-height: 40px;
    font-size: 15px;
    border-radius: 20px;
    padding: 8px 14px;
}

.dm-mobile__send {
    background: var(--sap-brand);
    border: none;
    color: #fff;
    width: 42px;
    height: 40px;
    border-radius: 50%;
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

/* Janela de chat em modal na versão web (desktop) */
@media (min-width: 801px) {
    .dm-mobile {
        position: fixed;
        inset: 0;
        z-index: 1200;
        background: rgba(0, 0, 0, 0.45);
        align-items: center;
        justify-content: center;
        padding: 20px;
    }

    .dm-mobile__view {
        width: min(460px, 92vw);
        height: min(640px, 82vh);
        border-radius: 14px;
        overflow: hidden;
        border: 1px solid var(--sap-border-strong);
        box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
    }

    .dm-mobile__bar { padding-top: 14px; padding-bottom: 14px; }
    .dm-mobile__input { padding-bottom: 12px; }

    .dm-mobile__back { display: none; }
    .dm-mobile__close { display: flex; }
}

/* Botão de apagar conversa — sempre visível (mesmo onde o × fica oculto) */
.dm-mobile__del { display: flex; }