:root {
    --bg-main: #020617;
    --bg-side: #0f172a;
    --bg-chat: #0b141a;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --brand-color: #6366f1;
    --msg-me: #005c4b;
    --msg-other: #202c33;
    --border-color: rgba(255, 255, 255, 0.05);
    --header-bg: #111b21;
    --input-bg: #2a3942;
    /* Mobil klavye açılınca header/footer kaymasını engellemek için dinamik viewport yüksekliği */
    --app-height: 100dvh;
}

.theme-whatsapp {
    --bg-main: #111b21;
    --bg-side: #111b21;
    --bg-chat: #0b141a;
    --text-primary: #e9edef;
    --text-secondary: #8696a0;
    --brand-color: #00a884;
    --msg-me: #054740;
    --msg-other: #202c33;
    --border-color: rgba(255, 255, 255, 0.1);
    --header-bg: #202c33;
    --input-bg: #2a3942;
}

.theme-messenger {
    --bg-main: #ffffff;
    --bg-side: #ffffff;
    --bg-chat: #ffffff;
    --text-primary: #050505;
    --text-secondary: #65676b;
    --brand-color: #0084ff;
    --msg-me: #0084ff;
    --msg-other: #e4e6eb;
    --border-color: rgba(0, 0, 0, 0.1);
    --header-bg: #ffffff;
    --input-bg: #f0f2f5;
}

@keyframes shrink { from { width: 100%; } to { width: 0%; } }
.shrink-animation { animation-name: shrink; animation-timing-function: linear; animation-fill-mode: forwards; }
.scrollbar-hide::-webkit-scrollbar { display: none; }
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }

html, body {
    /* FIX: Sayfanın yukarı kaymasını önleyen kritik ayarlar */
    height: var(--app-height); /* JS ile güncellenen dinamik yükseklik */
    width: 100%;
    position: fixed; /* Sayfayı çiviler */
    inset: 0;
    overflow: hidden; /* Document scroll'u engeller */
    overscroll-behavior: none;
    background-color: var(--bg-main);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    transition: height 0.1s ease; /* Klavye açılışını yumuşat */
}

@media print { body { display: none; } }

/* FIX: App layout artık 100% yükseklikte ve flex/grid ile içeriği yönetiyor */
.app-layout {
    height: 100%;
    width: 100%;
    display: grid;
    grid-template-columns: 320px 1fr;
}

/* iOS safe-area (notch) uyumu */
#chat-header, #chat-footer {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
}

#chat-header {
    padding-top: max(0px, env(safe-area-inset-top));
}

#chat-footer {
    padding-bottom: max(0px, env(safe-area-inset-bottom));
}

@media (max-width: 768px) {
    .app-layout { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        width: 300px;
        z-index: 150;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 20px 0 50px rgba(0,0,0,0.5);
        background-color: var(--bg-side);
    }
    .sidebar.active { left: 0; }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.7);
        backdrop-filter: blur(4px);
        z-index: 140;
    }
    .sidebar-overlay.active { display: block; }

    /* FIX: Sticky kaldırıldı, grid/flex yapısı ile yönetiliyor */
    #chat-header { position: relative; }
    #chat-footer { position: relative; }
}

.chat-item-active {
    background: rgba(128, 128, 128, 0.1);
    border-left: 4px solid var(--brand-color);
}

.status-dot { width: 10px; height: 10px; border-radius: 9999px; display: inline-block; }
.status-online { background-color: #10b981; }
.status-offline { background-color: #64748b; }
.status-pending { background-color: #f59e0b; animation: pulse 1.5s infinite; }

@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.4; } 100% { opacity: 1; } }

.custom-alert {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem;
    border-radius: 0.75rem;
    z-index: 600;
    animation: slideIn 0.3s ease-out;
    background-color: var(--brand-color);
    color: white;
}

@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

input:disabled { opacity: 0.5; cursor: not-allowed; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

#messages-area {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background-color: var(--bg-chat);
    /* Scroll özelliği sadece burada aktif */
    overflow-y: auto;
}

/* Kamera Panelleri için Geçişler */
#camera-panel-desktop, #camera-panel-mobile {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Gelişmiş Medya Overlay */
.media-modal-backdrop {
    backdrop-filter: blur(15px);
    background: rgba(0, 0, 0, 0.95);
    transition: opacity 0.3s ease;
}

#display-room-code{
    font-size: 0.9em;
}