/* ==========================================================================
   GLOBAL RESET SYSTEM & TYPOGRAPHY FIX
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Reddit Sans', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background: #f8f9fd;
    overflow: hidden; /* Pinipigilan ang double scrolling bars ng browser */
    height: 100vh;
}

/* ==========================================================================
   SIDEBAR LAYOUT COMPONENT BLOCK (STRICT ALIGNMENT WITH SETTINGS)
   ========================================================================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 92px;
    background-color: #5848CB;
    padding: .4rem .8rem;
    transition: all 0.5s ease;
    z-index: 999;
}

.sidebar.active {
    width: 250px;
}

/* ==========================================================================
   MAIN DASHBOARD WINDOW
   ========================================================================== */
.main-content {
    position: relative;
    left: 92px;
    width: calc(100% - 92px);
    height: 100vh;
    padding: 2.5rem 3rem;
    transition: all 0.5s ease;
    display: flex;
    flex-direction: column;
}

.sidebar.active ~ .main-content {
    left: 250px;
    width: calc(100% - 250px);
}

/* ==========================================================================
   SIDEBAR CORE INTERNALS
   ========================================================================== */
.sidebar #btn {
    position: absolute;
    color: #fff;
    top: 0.8rem;
    left: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    transform: translateX(-50%);
    cursor: pointer;
    transition: all 0.4s ease;
}

.sidebar .top .logo {
    width: 100%;
    margin-top: 70px;
    margin-bottom: 35px;
    display: flex;
    justify-content: center;
}

.logo-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-decoration: none;
    color: #fff;
}

.logo-link img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    transition: all 0.4s ease;
}

.sidebar.active .logo-link img {
    width: 65px;
    height: 65px;
}

.logo-link span {
    font-size: 1.4rem;
    font-weight: 700;
    white-space: nowrap;
    transition: all 0.3s ease;
}

.sidebar:not(.active) .logo-link span {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar.active .logo-link span {
    opacity: 1;
    width: auto;
}

.nav-list {
    margin-top: 35px;
}

.sidebar ul li {
    position: relative;
    list-style-type: none;
    margin: 12px 0;
    line-height: 50px;
    display: flex;
    justify-content: center;
}

.sidebar ul li a {
    color: #fff;
    display: flex;
    align-items: center;
    width: 100%;
    text-decoration: none;
    border-radius: 0.8rem;
    padding-left: 10px;
    height: 50px;
}

.sidebar ul li a:hover {
    background-color: #fff;
    color: #5848CB;
}

.sidebar ul li a i {
    min-width: 50px;
    text-align: center;
    font-size: 1.4rem;
}

.nav-item {
    opacity: 0;
    margin-left: 10px;
    transition: all 0.3s ease;
}

.sidebar.active .nav-item {
    opacity: 1;
}

.sidebar ul li .tooltip {
    position: absolute;
    left: 125px;
    top: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0.5rem 1rem rgba(88, 72, 203, 0.15);
    border-radius: .6rem;
    padding: .4rem 1.2rem;
    line-height: 1.8rem;
    z-index: 20;
    opacity: 0;
    background: white;
    color: #5848CB;
    font-weight: 600;
    pointer-events: none;
    transition: all 0.2s ease;
}

.sidebar:not(.active) ul li:hover .tooltip {
    opacity: 1;
}

.sidebar.active ul li .tooltip {
    display: none;
}

/* ==========================================================================
   CLEAN APP HEADER INTERFACES
   ========================================================================== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 30px;
    flex-shrink: 0;
}

.header h1 {
    color: #1e1b3d;
    font-size: 2.4rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.tabs {
    display: flex;
    gap: 28px;
    margin-top: 16px;
}

.tab {
    color: #787f95;
    cursor: pointer;
    position: relative;
    font-size: 0.95rem;
    font-weight: 700;
    padding-bottom: 6px;
    transition: color 0.2s ease;
}

.tab:hover {
    color: #5848CB;
}

.tab.active-tab {
    color: #5848CB;
}

.active-tab::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 100%;
    height: 3px;
    background: #5848CB;
    border-radius: 10px;
}

.new-btn {
    background: #5848CB;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(88, 72, 203, 0.2);
    transition: all 0.2s ease;
}

.new-btn:hover {
    background: #4536b3;
    box-shadow: 0 6px 15px rgba(88, 72, 203, 0.3);
}

/* ==========================================================================
   FLEX COMPARTMENT LAYOUT BOX ENGINE
   ========================================================================== */
.chat-layout {
    display: flex;
    gap: 30px;
    width: 100%;
    flex: 1;
    min-height: 0; /* Iniiwasan ang page height overflow */
    margin-bottom: 10px;
}

/* ==========================================================================
   LEFT SIDEBAR: CHAT ROSTER SYSTEM
   ========================================================================== */
.chat-list {
    width: 380px;
    min-width: 380px;
    background: white;
    border-radius: 20px;
    border: 1px solid rgba(235, 237, 247, 0.8);
    box-shadow: 0 10px 30px rgba(165, 173, 201, 0.06);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    border-bottom: 1px solid #f5f6fa;
    cursor: pointer;
    position: relative;
    transition: background 0.2s ease;
}

.chat-item:hover {
    background: #fbfbfe;
}

.chat-item.active-chat {
    background: #f4f3ff;
}

.avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
    background-color: #f4f5fa;
}

.avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.online {
    width: 14px;
    height: 14px;
    background: #62c462;
    border-radius: 50%;
    position: absolute;
    bottom: 0px;
    right: 0px;
    border: 2.5px solid white;
    z-index: 5;
}

.chat-info {
    flex: 1;
    min-width: 0; /* Pinipigilan ang pagkasira ng text overflow sa flex child */
}

.chat-info h3 {
    color: #1e1b3d;
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-info p {
    font-size: 0.9rem;
    color: #787f95;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Live Dynamic Draft Indicators */
.draft-indicator {
    color: #a855f7;
    font-weight: 700;
}

/* Unread Notifications Real-time Tracker CSS rule */
.chat-item.unread .chat-info h3 {
    font-weight: 800;
}

.chat-item.unread .chat-info p {
    font-weight: 700;
    color: #1e1b3d;
}

.chat-item.unread::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #5848CB;
    border-radius: 50%;
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
}

.time {
    font-size: 0.75rem;
    color: #9299b8;
    font-weight: 600;
    margin-left: 8px;
    flex-shrink: 0;
}

/* ==========================================================================
   RIGHT SIDEBAR: LIVE CONVERSATION TIMELINE
   ========================================================================== */
.chat-area {
    flex: 1;
    background: white;
    border-radius: 20px;
    border: 1px solid rgba(235, 237, 247, 0.8);
    box-shadow: 0 10px 30px rgba(165, 173, 201, 0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.chat-top {
    padding: 20px 24px;
    border-bottom: 1px solid #ebeef5;
    display: flex;
    align-items: center;
    gap: 16px;
    background: #ffffff;
    flex-shrink: 0;
}

.chat-active-profile h3 {
    color: #1e1b3d;
    font-size: 1.2rem;
    font-weight: 800;
}

.chat-active-profile span {
    color: #62c462;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Message Node Bubble Styling */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #fafbfe;
}

.message {
    max-width: 65%;
    padding: 14px 18px;
    border-radius: 18px;
    line-height: 1.5;
    font-size: 0.95rem;
    font-weight: 500;
    word-wrap: break-word;
}

.received {
    background: white;
    color: #33334f;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(165, 173, 201, 0.08);
    border: 1px solid #f0f2f9;
}

.sent {
    background: #5848CB;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(88, 72, 203, 0.15);
}

/* ==========================================================================
   BOTTOM PANEL CHAT CONTROL MECHANICS
   ========================================================================== */
.chat-input {
    padding: 20px 24px;
    border-top: 1px solid #ebeef5;
    display: flex;
    gap: 16px;
    background: white;
    align-items: center;
    flex-shrink: 0;
}

.chat-input input {
    flex: 1;
    border: 1.5px solid #e1e4ed;
    border-radius: 14px;
    padding: 14px 20px;
    outline: none;
    font-size: 0.95rem;
    font-weight: 500;
    color: #1e1b3d;
    transition: border-color 0.2s ease;
}

.chat-input input:focus {
    border-color: #5848CB;
}

.chat-input input::placeholder {
    color: #a0a6c0;
}

.send-btn {
    background: #5848CB;
    color: white;
    border: none;
    border-radius: 14px;
    padding: 14px 28px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 700;
    transition: background 0.2s ease;
}

.send-btn:hover {
    background: #4536b3;
}

/* ==========================================================================
   UI UTILITY SCROLLBAR SYSTEM
   ========================================================================== */
.chat-list::-webkit-scrollbar,
.messages::-webkit-scrollbar {
    width: 6px;
}

.chat-list::-webkit-scrollbar-thumb,
.messages::-webkit-scrollbar-thumb {
    background: #e1e4ed;
    border-radius: 20px;
}

.chat-list::-webkit-scrollbar-track,
.messages::-webkit-scrollbar-track {
    background: transparent;
}