/* ==========================================================================
   VARIABLES & BASE STYLES
   ========================================================================== */
:root { 
    --yt-bg: #0f172a; 
    --card-bg: #1e293b; 
    --text: #f8fafc; 
    --dim: #94a3b8; 
    --hover-bg: #334155; 
    --accent: #38bdf8; 
    --accent-strong: #0ea5e9;
    --border: rgba(148, 163, 184, 0.35);
}

body {
    margin: 0;
    padding: 0;
    background: var(--yt-bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden; /* Prevent body scroll for app-like feel */
}

/* ==========================================================================
   MAIN LAYOUT (Desktop Base)
   ========================================================================== */
.yt-main { 
    margin-left: 300px !important; 
    padding: 20px 30px !important; 
    max-width: none !important; 
    width: calc(100% - 300px) !important; 
    box-sizing: border-box; 
    height: 100vh;
    display: flex;
}

/* ==========================================================================
   SIDEBAR & HEADER FIXES
   ========================================================================== */
.yt-sidebar {
    width: 300px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background-color: #000000;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #2f3336;
    z-index: 1000;
    padding: 0; 
    margin: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 15px 20px; 
    background: transparent;
}

.logo-circle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 0%, #38bdf8, transparent 55%),
        radial-gradient(circle at 70% 100%, #0ea5e9, transparent 55%),
        linear-gradient(145deg, #020617, #0b1120);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 0 0 1px rgba(148, 163, 184, 0.6), 0 18px 45px rgba(15, 23, 42, 0.95);
}

.logo-circle span {
    font-size: 0.9rem;
    font-weight: 700;
    color: #e5f2ff;
}

.brand-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.brand-title {
    font-weight: 800;
    font-size: 1rem;
    color: #fff;
    line-height: 1.2;
}

.brand-subtitle {
    font-size: 0.75rem;
    color: #536471;
    margin-top: 2px;
}

.sidebar-search {
    padding: 0 20px 15px 20px;
    border-bottom: 1px solid #2f3336;
}

.yt-search { margin: 0; display: block; }

.yt-search-input {
    width: 100%;
    border-radius: 999px;
    padding: 10px 15px;
    background: #202327;
    color: white;
    border: none;
    box-sizing: border-box;
    font-size: 0.9rem;
}

.yt-search-input:focus { outline: none; background: #2b2f33; }

.sidebar-main-nav {
    padding: 15px 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    overflow-y: auto;
    flex-grow: 1;
}

.sidebar-main-nav a, #moreBtn {
    padding: 12px 15px;
    text-decoration: none;
    color: #e7e9ea;
    display: flex;
    align-items: center;
    gap: 15px;
    border-radius: 999px;
    font-size: 1.05rem;
    transition: background-color 0.2s;
    background: none;
    border: none;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}

.sidebar-main-nav a:hover, #moreBtn:hover { background-color: rgba(255, 255, 255, 0.1); }
.sidebar-main-nav a.active { font-weight: 700; background-color: rgba(255, 255, 255, 0.05); }
.login-link { color: #1d9bf0 !important; font-weight: 700; }

/* ==========================================================================
   RIGHT ACTION MENU & MODALS
   ========================================================================== */
.right-static-menu {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(20, 25, 30, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1); 
    border-right: none;
    border-radius: 15px 0 0 15px;
    padding: 15px 10px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 1000;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3); 
}

.right-static-menu a {
    color: #f7f9f9; 
    text-decoration: none;
    font-weight: 600;
    font-size: 0.8em;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    transition: transform 0.2s ease, color 0.2s ease;
}

.right-static-menu a:hover { transform: scale(1.1); color: #1d9bf0; }

#moreModal {
    position: fixed;
    background-color: #ffffff;
    border-radius: 16px;
    box-shadow: rgba(101, 119, 134, 0.2) 0px 0px 15px, rgba(101, 119, 134, 0.15) 0px 0px 3px 1px;
    width: 260px;
    max-height: 85vh;
    overflow-y: auto;
    z-index: 9999;
    display: none;
    flex-direction: column;
    padding: 8px 0;
    left: 15px;
}

#moreModal.active { display: flex; }

#moreModal a, #moreModal .auth-link {
    padding: 16px 20px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f1419;
    text-decoration: none;
    transition: background-color 0.2s;
    display: block;
}

#moreModal a:hover { background-color: rgba(15, 20, 25, 0.1); }

@media (prefers-color-scheme: dark) {
    #moreModal {
        background-color: #000000;
        border: 1px solid #2f3336;
        box-shadow: rgba(255, 255, 255, 0.1) 0px 0px 15px;
    }
    #moreModal a, #moreModal .auth-link { color: #e7e9ea; }
    #moreModal a:hover { background-color: rgba(255, 255, 255, 0.1); }
}

/* ==========================================================================
   CHAT LAYOUT & UI
   ========================================================================== */
.chat-main-container {
    display: flex;
    gap: 20px;
    background: var(--yt-bg);
}

.contacts-pane {
    width: 350px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.chat-pane {
    flex-grow: 1;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.pane-header, .chat-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.5);
}

.pane-header h3 { margin: 0; font-size: 1.2rem; }

.icon-btn, .mobile-back-btn {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.2s;
}
.icon-btn:hover { color: var(--accent); }

.mobile-back-btn { display: none; margin-right: 15px; }

.contacts-list { flex-grow: 1; overflow-y: auto; padding: 10px; }

.contact-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}
.contact-item:hover { background: var(--hover-bg); }

.contact-item img, .chat-user-info img {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    object-fit: cover;
    background: #000;
}

.contact-details h4 { margin: 0 0 5px 0; font-size: 1rem; }
.contact-preview { font-size: 0.85rem; color: var(--dim); }

.chat-interface { display: flex; flex-direction: column; height: 100%; }

.chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--dim);
    text-align: center;
}
.chat-empty-state i { margin-bottom: 20px; opacity: 0.5; }

.chat-user-info { display: flex; align-items: center; gap: 15px; flex-grow: 1; }
.chat-user-info h3 { margin: 0; }

.messages-area {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message-bubble {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.4;
    word-wrap: break-word;
}
.message-bubble.received {
    align-self: flex-start;
    background: var(--hover-bg);
    border-bottom-left-radius: 4px;
}
.message-bubble.sent {
    align-self: flex-end;
    background: var(--accent-strong);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-input-area {
    padding: 15px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(15, 23, 42, 0.5);
}

.chat-input-area input {
    flex-grow: 1;
    background: var(--yt-bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 20px;
    border-radius: 999px;
    font-size: 1rem;
}
.chat-input-area input:focus { outline: none; border-color: var(--accent); }

.attach-btn, .send-btn {
    background: transparent;
    border: none;
    color: var(--dim);
    font-size: 1.4rem;
    cursor: pointer;
    transition: color 0.2s;
}
.send-btn { color: var(--accent); }
.send-btn:hover { color: var(--accent-strong); }

.loading-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid var(--hover-bg);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

/* ==========================================================================
   MOBILE & MODAL UI (Base Styles)
   ========================================================================== */
.mobile-header {
    display: none;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #000000;
    border-bottom: 1px solid #2f3336;
    position: sticky;
    top: 0;
    z-index: 999;
}
.mobile-menu-btn { background: transparent; border: none; color: #fff; font-size: 24px; cursor: pointer; }

.mobile-menu-modal {
    display: none; position: fixed; inset: 0; background: rgba(10, 15, 20, 0.98); z-index: 100000; padding: 30px; overflow-y: auto; flex-direction: column;
}
.mobile-menu-modal.active { display: flex; }
.mobile-menu-close { align-self: flex-end; background: transparent; border: none; color: #fff; font-size: 28px; cursor: pointer; margin-bottom: 20px; }
.mobile-menu-title { font-size: 24px; font-weight: 800; color: #fff; }
.mobile-menu-subtitle { font-size: 14px; color: #1d9bf0; margin-bottom: 20px; }
.mobile-menu-link { display: block; color: #e7e9ea; text-decoration: none; padding: 15px 0; border-bottom: 1px solid #2f3336; font-size: 18px; font-weight: 600; }
.mobile-menu-link i { margin-right: 10px; width: 24px; text-align: center; }
.mobile-menu-footer-title { font-size: 14px; color: #71767b; margin-top: 20px; margin-bottom: 10px; text-transform: uppercase; }

/* ==========================================================================
   MOBILE RESPONSIVENESS (Media Queries)
   ========================================================================== */
/* ==========================================================================
   MOBILE HAMBURGER MENU ICON
   ========================================================================== */
.mobile-menu-toggle {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 26px;
    height: 18px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.mobile-menu-toggle span {
    width: 100%;
    height: 2px;
    background-color: #f8fafc; /* Color of the bars */
    border-radius: 4px;
    transition: all 0.3s ease-in-out;
    transform-origin: left center;
}

/* Optional: Animates the hamburger into an 'X' when clicked */
.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg);
    top: -1px;
    position: relative;
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
    width: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg);
    top: 1px;
    position: relative;
}



@media (max-width: 768px) {
    /* Global Overrides */
    .right-static-menu { display: none; }
    .yt-sidebar { display: none !important; }
    .mobile-header { display: flex !important; }
    
    .yt-main { 
        margin-left: 0 !important; 
        width: 100% !important; 
        padding: 0 !important;
        height: calc(100vh - 65px); /* Account for mobile header */
    } 

    /* Chat Layout Overrides */
    .chat-main-container { gap: 0; }
    .contacts-pane { width: 100%; border: none; border-radius: 0; }
    
    .chat-pane {
        display: none; /* Handled by JS on click */
        width: 100%;
        border: none;
        border-radius: 0;
        position: absolute;
        top: 0; left: 0; right: 0; bottom: 0;
        z-index: 100;
    }
    
    .mobile-back-btn { display: block; }
}