/* =======================================================
 * LAYOUT PRINCIPAL (TRAVADO NA TELA)
 * ======================================================= */
html, body.chat-body-lock {
    height: 100%; width: 100%;
    margin: 0; padding: 0;
    overflow: hidden !important; /* Proíbe scroll global */
}

.main-layout.chat-layout { 
    display: flex; 
    flex-direction: row; 
    width: 100%; 
    height: 100vh; /* fallback */
    height: 100dvh; /* viewport dinâmica (mobile + teclado) */
    background: #fff; 
    overflow: hidden; /* Nada sai daqui */
}

/* =======================================================
 * SIDEBAR (Igual Comunidade)
 * ======================================================= */
.sidebar {
    width: 260px;
    background: #fff;
    border-right: 1px solid var(--border-light);
    display: flex; flex-direction: column;
    padding: 22px 16px;
    flex-shrink: 0;
    height: 100%; 
    z-index: 100;
}
.sidebar::-webkit-scrollbar { display: none; }

/* Elementos Visuais Sidebar */
.logo-area { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; padding-left: 4px; }
.sidebar-logo-img { width: 34px; height: auto; }
.brand-text { font-family: 'Montserrat', sans-serif; font-weight: 800; color: var(--primary-color); font-size: 1rem; }
.brand-text span { color: #6e513d; }
.nav-links { list-style: none; padding: 0; margin: 0; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.nav-links a { text-decoration: none; color: var(--text-secondary); display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; font-weight: 700; font-size: 0.9rem; transition: 0.2s; position: relative; }
.nav-links a:hover { background-color: #f7f9fa; color: var(--primary-color); }
.nav-links a.active { background-color: #e8f5e9; color: #53954a; font-weight: 700; }
.icon-container { position: relative; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; }
.nav-badge { position: absolute; top: -5px; right: -6px; background-color: #ff3b30; color: white; font-size: 0.6rem; font-weight: 800; min-width: 16px; height: 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; z-index: 10; }
.nav-footer { margin-top: auto; border-top: 1px solid var(--border-light); padding-top: 16px; }
.profile-pill-link { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #050505; padding: 8px; border-radius: 12px; }
.nav-avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; }

/* =======================================================
 * PAINÉIS DO CHAT (FLEXBOX CORRIGIDO)
 * ======================================================= */
.chat-sidebar-panel { 
    width: 360px; 
    background: #fff; 
    border-right: 1px solid var(--border-light); 
    display: flex; flex-direction: column; 
    height: 100%; 
    z-index: 90;
}

.chat-window-panel { 
    flex: 1; /* Ocupa o resto */
    display: flex; 
    flex-direction: column; 
    background: #fff; 
    height: 100%; 
    position: relative; 
    min-width: 0; /* Permite encolher */
}

/* =======================================================
 * MOBILE
 * ======================================================= */
.bottom-nav { display: none; position: fixed; left: 0; right: 0; bottom: 0; height: 68px; background: #fff; border-top: 1px solid var(--border-light); z-index: 140; padding: 8px 10px; gap: 6px; justify-content: space-between; }
.bottom-nav .bn-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: #777; font-weight: 700; font-size: 0.75rem; text-decoration: none; border-radius: 12px; padding: 6px 4px; }
.bottom-nav .bn-item.active { color: #53954a; background: #e8f5e9; }

@media (max-width: 992px) {
    .brand-text, .nav-links span, .profile-info-mini { display: none; }
    .sidebar { width: 80px; align-items: center; padding: 20px 10px; }
    .chat-sidebar-panel { width: 320px; }
}

@media (max-width: 700px) {
    .sidebar { display: none; }
    .chat-sidebar-panel {
        width: 100% !important;
        height: calc(100vh - 68px);
        height: calc(100dvh - 68px);
        border-right: none;
    }
    .chat-window-panel {
        display: none;
        width: 100% !important;
        height: calc(100vh - 68px);
        height: calc(100dvh - 68px);
        position: absolute;
        top: 0;
        left: 0;
        z-index: 100;
    }
    .chat-window-panel.active-mobile { display: flex; }
    .chat-sidebar-panel.active-mobile { display: none; }
    .bottom-nav { display: flex; }
}
/* =======================================================
 * OFF-CANVAS SEARCH DRAWER (PORTAL PATTERN) - GLOBAL
 * ======================================================= */
.insta-search-drawer {
    position: fixed; top: 0; left: 0; width: 100%; max-width: 350px; height: 100vh;
    background-color: #ffffff; box-shadow: 4px 0 15px rgba(0,0,0,0.1); z-index: 10000; 
    transform: translateX(-100%); transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    display: flex; flex-direction: column;
}
.insta-search-drawer.active { transform: translateX(0); }
.insta-drawer-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 15px 15px; }
.insta-drawer-header h2 { font-size: 1.2rem; font-weight: 800; color: #1a1a1a; margin: 0; }
.insta-close-btn { background: none; border: none; font-size: 1.2rem; color: #65676b; cursor: pointer; transition: color 0.2s ease; }
.insta-close-btn:hover { color: #e74c3c; }

/* Input Trapping Box */
.insta-drawer-search-container { padding: 0 15px 15px; border-bottom: 1px solid #eaeaea; }
.insta-input-wrapper { position: relative; width: 100%; }
.insta-input-wrapper i { position: absolute; top: 50%; left: 12px; transform: translateY(-50%); color: #8e8e8e; font-size: 0.9rem; pointer-events: none; }
.insta-drawer-input { width: 100%; padding: 10px 10px 10px 35px; background-color: #efefef; border: none; border-radius: 8px; font-size: 0.95rem; color: #1a1a1a; outline: none; transition: background-color 0.2s; }
.insta-drawer-input:focus { background-color: #e4e4e4; }

/* UX: Sidebar trigger read-only feel */
.sidebar-search input, .mobile-menu-search input { cursor: pointer; }

/* Content Rendering */
.insta-results-area { padding: 15px; overflow-y: auto; flex: 1; }
.insta-user-item { display: flex; align-items: center; padding: 10px; text-decoration: none; color: inherit; border-radius: 8px; transition: background-color 0.2s ease; cursor: pointer; }
.insta-user-item:hover { background-color: #f0f2f5; }
.insta-avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; margin-right: 12px; border: 1px solid #eaeaea; }
.insta-user-info { display: flex; flex-direction: column; overflow: hidden; }
.insta-username { font-weight: 700; font-size: 0.95rem; color: #1a1a1a; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.insta-name { font-size: 0.85rem; color: #65676b; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }

/* States */
.insta-state-msg { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px 10px; color: #65676b; }
.insta-state-title { font-weight: 700; color: #1a1a1a; margin-bottom: 5px; }
.insta-state-desc { font-size: 0.9rem; }
.insta-loader-container { display: flex; justify-content: center; padding: 30px 0; }
.insta-spinner { width: 30px; height: 30px; border: 3px solid #f3f3f3; border-top: 3px solid #53954a; border-radius: 50%; animation: insta-spin 1s linear infinite; }
@keyframes insta-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }