/* --- MINIMALIST MONOCHROME THEME --- */
:root {
    --bg-body: #ffffff;
    --bg-hover: #f7f7f7;
    --bg-active: #ebebeb;
    --text-main: #000000;
    --text-muted: #757575;
    --border-color: #e0e0e0;

    --radius-m: 12px;
    --radius-full: 999px;
    --font-stack: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
}

/* --- BASE --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    outline: none;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: var(--font-stack);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    font-weight: 600;
    color: inherit;
}

button:active {
    transform: scale(0.96);
    opacity: 0.8;
}

input,
textarea {
    font-family: inherit;
    border: none;
    background: transparent;
    color: var(--text-main);
    resize: none;
}

a {
    text-decoration: none;
    color: inherit;
}

/* --- LAYOUT --- */
.container {
    max-width: 1100px;
    margin: 0 auto;
    min-height: 100vh;
}

.app-layout {
    display: grid;
    grid-template-columns: 240px 1fr 300px;
    gap: 0;
    align-items: start;
}

/* --- SIDEBAR --- */
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 30px 20px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 15px;
}

.sidebar h2 {
    font-size: 20px;
    font-weight: 900;
    letter-spacing: -1px;
    margin-bottom: 20px;
    padding-left: 10px;
}

.sidebar button,
.sidebar a {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 15px;
    font-size: 18px;
    font-weight: 400;
    border-radius: var(--radius-full);
    color: var(--text-main);
}

.sidebar button:hover,
.sidebar a:hover,
.sidebar button.active {
    background: var(--bg-hover);
    font-weight: 700;
}

.sidebar ion-icon {
    font-size: 24px;
}

.logout-btn {
    opacity: 0.6;
}

/* --- MAIN FEED --- */
.main-feed {
    width: 100%;
    max-width: 600px;
    border-right: 1px solid var(--border-color);
    min-height: 100vh;
}

/* UPDATED HEADER STYLES */
.header-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#page-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

/* New Mobile Button (Hidden on Desktop) */
#mobile-suggestions-btn {
    display: none;
    font-size: 24px;
    padding: 5px;
    border-radius: 50%;
}

#mobile-suggestions-btn:hover {
    background: var(--bg-hover);
}

/* --- CREATE POST --- */
.post-box {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.post-box textarea {
    width: 100%;
    font-size: 18px;
    margin-bottom: 10px;
}

.post-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 10px;
}

.file-btn {
    cursor: pointer;
    padding: 8px 12px;
    border-radius: var(--radius-full);
}

.file-btn:hover {
    background: var(--bg-hover);
}

input[type="file"] {
    display: none;
}

.post-actions button {
    background: var(--text-main);
    color: #fff;
    padding: 8px 20px;
    border-radius: var(--radius-full);
    font-size: 14px;
}

#image-preview-container {
    margin-bottom: 15px;
    position: relative;
    display: inline-block;
}

#image-preview {
    max-height: 200px;
    border-radius: var(--radius-m);
    border: 1px solid var(--border-color);
}

#image-preview-container button {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

/* --- POST ITEM --- */
.post {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}

.post:hover {
    background: var(--bg-hover);
}

.post-header-flex {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
    align-items: flex-start;
}

.avatar-small {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.post-info {
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.post-info h4 {
    font-size: 15px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
}

.post-info span {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 14px;
}

.verified-badge {
    color: var(--text-main);
    font-size: 14px;
    margin-left: 4px;
}

.post-content {
    font-size: 16px;
    word-break: break-word;
    overflow-wrap: break-word;
    color: var(--text-main);
    
}

.post-img {
    width: 100%;
    border-radius: var(--radius-m);
    object-fit: contain;
    max-height: 500px;
    border: 1px solid var(--border-color);
    margin-top: 10px;
}

.shared-content {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-m);
    padding: 15px;
    margin-top: 10px;
    background: #fff;
    word-break: break-word;
}

.shared-content:hover {
    background: var(--bg-hover);
}

.actions {
    display: flex;
    justify-content: space-between;
    max-width: 80%;
    margin-top: 15px;
    color: var(--text-muted);
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 20px;
    font-weight: 500;
}

.action-btn:hover {
    color: var(--text-main);
}

.action-btn.liked {
    color: var(--text-main);
}

.action-btn.liked ion-icon {
    fill: currentColor;
}

.delete-btn {
    margin-left: auto;
    color: var(--text-muted);
}

/* --- COMMENTS --- */
.comments-section {
    display: none;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.comments-section.show {
    display: block;
}

.comment-input-area {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: flex-start;
}

.input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
}

.input-wrapper:focus-within {
    border-bottom: 1px solid var(--text-main);
}

.comment-input-area input {
    flex: 1;
    padding: 8px 0;
}

.send-btn {
    font-size: 24px;
    color: var(--text-main);
    padding: 0 5px;
}

.comment-item {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
}

.comment-body {
    flex: 1;
    min-width: 0;
}

.comment-bubble {
    padding-bottom: 4px;
    word-break: break-word;
    display: grid;
}

.comment-author-name {
    font-weight: 700;
    font-size: 14px;
    margin-right: 5px;
    display: flex;
    align-items: center;
}

.comment-actions {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    display: flex;
    gap: 16px;
    align-items: center;
}

.comment-action-btn {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

.comment-action-btn.liked {
    color: var(--text-main);
    font-weight: 600;
}

.comment-action-btn.liked ion-icon {
    color: #000;
}

/* --- COMMENT USERNAME --- */
.comment-username {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 400;
}

/* --- SIDEBAR & PROFILE --- */
.right-sidebar {
    padding: 30px 20px;
    position: sticky;
    top: 0;
}

.right-sidebar ul {
    list-style: none;
}

.right-sidebar li {
    margin-bottom: 20px;
}

.profile-info {
    padding: 30px 20px;
    border-bottom: 1px solid var(--border-color);
}

.profile-avatar-large {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 15px;
}

#profile-name {
    font-size: 24px;
    font-weight: 900;
    margin-bottom: 10px;
}

#profile-actions button {
    padding: 8px 24px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
}

/* --- MODALS & TOAST --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #fff;
    width: 100%;
    max-width: 600px;
    border-radius: var(--radius-m);
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    margin: 4px;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
    z-index: 10;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 50%;
}

.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-main);
    color: #fff;
    padding: 12px 24px;
    border-radius: var(--radius-full);
    opacity: 0;
    transition: 0.3s;
    z-index: 2000;
}

.toast.show {
    opacity: 1;
    bottom: 80px;
}

/* --- MOBILE RESPONSIVENESS --- */
@media (max-width: 768px) {
    .app-layout {
        display: grid;
        grid-template-columns: initial;
        width: 100%;
    }

    #chat-view {
        grid-template-columns: initial;
    }

    .right-sidebar {
        display: none;
    }

    .container {
        max-width: 100%;
        padding: 0;
        margin: 0;
    }

    .main-feed {
        width: 100%;
        max-width: 100%;
        border: none;
        padding-bottom: 80px;
    }

    .post {
        padding: 15px;
        border-radius: 0;
    }

    .post-box {
        padding: 15px;
    }

    /* Mobile Bottom Navigation */
    .sidebar {
        display: flex;
        position: fixed;
        bottom: 0;
        top: auto;
        width: 100%;
        height: 60px;
        border-right: none;
        border-top: 1px solid var(--border-color);
        background: #fff;
        flex-direction: row;
        justify-content: space-around;
        padding: 0;
        z-index: 900;
        gap: 0;
        /* Reset gap from desktop */
    }

    .sidebar h2 {
        display: none;
    }

    .sidebar button {
        flex-direction: column;
        font-size: 10px;
        gap: 4px;
        padding: 10px;
        width: auto;
    }

    .sidebar button.active {
        background: transparent;
        color: var(--text-main);
    }

    /* Hide the bottom divider/logout on mobile nav for space */
    .sidebar div[style*="margin-top: auto"] {
        display: none;
    }

    .logout-btn,
    .sidebar a {
        display: none;
    }

    /* Show Suggestions Button on Mobile */
    #mobile-suggestions-btn {
        display: block;
    }

    .modal-content {
        width: 100%;
        border-radius: 8px;
    }
}

/* --- NOTIFICATIONS PANEL --- */
.notification-panel {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    max-width: 500px;
    background: #fff;
    border-right: 1px solid var(--border-color);
    z-index: 100;
    overflow-y: auto;
    box-shadow: 5px 0 15px rgba(0, 0, 0, 0.05);
}

.notif-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.badge {
    background: var(--text-main);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    position: absolute;
    top: 10px;
    right: 10px;
}

.totalcount {
    font-size: 12px;
}

/* --- REPLY TOGGLE BUTTON --- */
.reply-toggle-btn {
    background: none;
    border: none;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px 0;
    margin-left: 52px;
    /* Align with comment text */
    display: flex;
    align-items: center;
    gap: 5px;
}

.reply-toggle-btn::before {
    content: '';
    display: inline-block;
    width: 30px;
    height: 1px;
    background: var(--border-color);
}

.reply-toggle-btn:hover {
    color: var(--text-main);
}

/* --- ANIMATIONS --- */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- MENTION DROPDOWN --- */
.mention-dropdown {
    position: absolute;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-m);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-height: 200px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    width: 250px;
    z-index: 99999;
    display: none;
}

.mention-item {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid var(--bg-hover);
    transition: background 0.2s;
}

.mention-item:hover {
    background: var(--bg-hover);
}

.mention-item:last-child {
    border-bottom: none;
}

.mention-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    margin-right: 10px;
    object-fit: cover;
}

.mention-info {
    display: flex;
    flex-direction: column;
}

.mention-username {
    font-weight: 700;
    font-size: 13px;
}

.mention-fullname {
    font-size: 12px;
    color: var(--text-muted);
}

/* --- LOADING SPINNER --- */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top: 4px solid #000;
    /* Black color */
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* --- GLOBAL FULL-SCREEN LOADER --- */
#global-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    z-index: 9999;
    /* On top of everything */
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease;
}

/* --- MENTION LINKS --- */
.mention-link {
    font-weight: 500;
    /* Bold */
    color: #000;
    /* Black (or your theme color) */
    cursor: pointer;
    transition: color 0.2s;
}

.mention-link:hover {
    text-decoration: underline;
    color: var(--text-muted);
}

/* --- PRIVACY BADGES --- */
.privacy-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid #eee;
    margin-left: 5px;
    color: #666;
    text-transform: uppercase;
}

/* --- HASHTAGS & LINKS --- */
.hashtag {
    color: #1d9bf0;
    font-weight: 500;
    cursor: pointer;
}

.hashtag:hover {
    text-decoration: underline;
}

.external-link {
    color: #1d9bf0;
    text-decoration: underline;
    cursor: pointer;
}

/* --- ACTIVE STATUS --- */
.active-dot {
    width: 8px;
    height: 8px;
    background: #4caf50;
    border-radius: 50%;
    display: inline-block;
    margin-right: 5px;
}

.last-seen {
    font-size: 11px;
    color: #888;
}

/* --- BUTTON LOADING STATE --- */
button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

/* --- BUTTON LOADING SPINNER --- */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.btn-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top: 2px solid #000;
    /* Black spinner */
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
    vertical-align: middle;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* --- MESSAGE META & TIME --- */
.msg-meta {
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    gap: 10px;
    transition: all 0.2s ease;
}

.msg-full-time {
    display: none;
    font-weight: 600;
}

.msg-meta.active .msg-full-time {
    display: inline;
}

.msg-meta.active .msg-time.hidden-time {
    display: none;
    /* Hide short time if full time is showing */
}

.msg-time.hidden-time {
    opacity: 0;
    pointer-events: none;
}

/* On hover of body, show the minute time if it was hidden */
.msg-body:hover .msg-time.hidden-time {
    opacity: 1;
}

/* --- ACTIVE STATUS --- */
.status-indicator {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.online-dot {
    width: 10px;
    height: 10px;
    background-color: #10b981;
    /* Green */
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 2px #fff;
}

.status-text {
    font-weight: 500;
}

/* --- SEARCH UI --- */
.search-bar-wrapper {
    padding: 15px 20px;
    position: relative;
    border-bottom: 1px solid var(--border-color);
}

.search-bar-wrapper input {
    width: 100%;
    padding: 12px 12px 12px 40px;
    background: var(--bg-hover);
    border-radius: var(--radius-full);
    font-size: 15px;
    color: var(--text-main);
}

.search-bar-wrapper ion-icon {
    position: absolute;
    left: 35px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: var(--text-muted);
}

.search-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
}

.search-tabs button {
    flex: 1;
    padding: 15px;
    font-weight: 600;
    color: var(--text-muted);
    position: relative;
    border-radius: 0;
}

.search-tabs button.active {
    color: var(--text-main);
}

.search-tabs button.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: var(--text-main);
    border-radius: 4px;
}

.search-user-item {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

.search-user-item:hover {
    background: var(--bg-hover);
}

.placeholder-msg {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 15px;
}

/* --- STATS BUTTONS --- */
.stat-btn {
    font-size: 15px;
    color: var(--text-muted);
    padding: 0;
    margin-right: 15px;
    cursor: pointer;
}

.stat-btn:hover {
    text-decoration: underline;
}

/* --- SOCIAL LIST MODAL ITEMS --- */
.social-list-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid var(--bg-hover);
}

.social-list-item:hover {
    background: var(--bg-hover);
}

.social-list-info {
    flex: 1;
    margin-left: 12px;
    cursor: pointer;
}

.follow-btn-small {
    padding: 6px 16px;
    font-size: 13px;
    border-radius: 99px;
    font-weight: 700;
    cursor: pointer;
}

/* State: Not Following */
.follow-btn-small.not-following {
    background: #000;
    color: #fff;
    border: 1px solid #000;
}

/* State: Following */
.follow-btn-small.following {
    background: transparent;
    color: #000;
    border: 1px solid #ddd;
}

.follow-btn-small.following:hover {
    border-color: #f4212e;
    color: #f4212e;
    background: rgba(244, 33, 46, 0.1);
}

.follow-btn-small.following:hover span {
    display: none;
}

.follow-btn-small.following:hover::after {
    content: 'Unfollow';
}

.view-original-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    /* space between text and icon */
}

/* --- CHAT HEADER WITH BACK BUTTON --- */
.chat-sidebar-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 15px;
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 10;
}

.chat-title {
    font-weight: 800;
    font-size: 20px;
}

.chat-back-home-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-hover);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    transition: background 0.2s;
    color: var(--text-main);
    font-size: 20px;
}

.chat-back-home-btn:hover {
    background: #e0e0e0;
}

/* --- CHAT SPECIFIC --- */

/* 1. Base Layout (Mobile First) */
#chat-view {
    width: 100%;
    height: 100vh;
    background: #fff;
    position: relative;
    overflow: hidden;
}

/* Sidebar is full width on mobile */
.chat-sidebar {
    width: 100%;
    height: 100%;
    background: #fff;
    overflow-y: auto;
    z-index: 1;
}

/* Chat Main Area (Hidden by default on mobile) */
.chat-main {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    z-index: 2000;
    /* Above sidebar and nav */
    display: flex;
    flex-direction: column;

    /* Animation: Slide out to right */
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
}

/* Class to Slide Chat In */
.chat-main.open {
    transform: translateX(0);
}

/* 2. Conversation Items */
.conv-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 20px;
    cursor: pointer;
    border-bottom: 1px solid var(--bg-hover);
    transition: background 0.2s;
}

.conv-item:hover,
.conv-item.active {
    background: var(--bg-hover);
}

.conv-info {
    flex: 1;
    overflow: hidden;
}

.conv-preview {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-meta {
    font-size: 11px;
    color: var(--text-muted);
    float: right;
}

.unread-badge {
    background: #f4212e;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
    margin-left: 5px;
}

/* 3. Messages */
.msg-row {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    margin-bottom: 5px;
}

.msg-row.sent {
    align-self: flex-end;
    align-items: flex-end;
}

.msg-row.received {
    align-self: flex-start;
    align-items: flex-start;
    flex-direction: row;
    gap: 8px;
    width: 100%;
}

.msg-partner-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 10px;
    /* Align near top of bubble */
}

.msg-body {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.msg-row.sent .msg-body {
    align-items: flex-end;
}

.msg-row.received .msg-body {
    align-items: flex-start;
}

.msg-bubble {
    padding: 10px 15px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.4;
    position: relative;
    z-index: 2;
}

.msg-text {
    word-wrap: break-word;
    white-space: pre-wrap;
}

/* Markdown Elements */
.msg-text code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
}

.msg-row.sent .msg-text code {
    background: rgba(255, 255, 255, 0.2);
}

.msg-text pre {
    background: rgba(0, 0, 0, 0.1);
    padding: 10px;
    border-radius: 8px;
    margin: 8px 0;
    overflow-x: auto;
    font-family: 'Courier New', Courier, monospace;
}

.msg-row.sent .msg-text pre {
    background: rgba(255, 255, 255, 0.15);
}

.msg-text blockquote {
    border-left: 3px solid rgba(0, 0, 0, 0.2);
    margin: 8px 0;
    padding-left: 10px;
    color: var(--text-muted);
    font-style: italic;
}

.msg-row.sent .msg-text blockquote {
    border-left-color: rgba(255, 255, 255, 0.5);
    color: rgba(255, 255, 255, 0.8);
}

.msg-row.sent .msg-bubble {
    background: #000;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.msg-row.received .msg-bubble {
    background: var(--bg-hover);
    color: #000;
    border-bottom-left-radius: 4px;
}

.msg-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
    display: flex;
    gap: 5px;
}

.seen-tick {
    color: var(--text-main);
    font-weight: bold;
}

/* 4. Desktop Overrides (Tablet & Up) */
@media (min-width: 769px) {
    #chat-view {
        display: grid;
        grid-template-columns: 350px 1fr;
        /* Split View */
    }

    .chat-sidebar {
        width: auto;
        border-right: 1px solid var(--border-color);
    }

    .chat-main {
        position: static;
        /* Not fixed anymore */
        transform: none;
        /* No sliding */
        z-index: 1;
        width: auto;
    }

    /* Hide Back Button on Desktop */
    .back-to-list-btn {
        display: none !important;
    }

    /* Hide Empty State if a chat is active */
    #active-chat-interface {
        display: flex;
    }
}

/* --- CHAT ANIMATIONS --- */

/* 1. Message Entry Animation */
@keyframes msgSlideUp {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.msg-row {
    /* Apply animation to all messages when they appear */
    animation: msgSlideUp 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    transform-origin: bottom left;
}

.msg-row.sent {
    transform-origin: bottom right;
}

/* 2. Typing Indicator Animation */
.typing-container {
    padding: 5px 20px;
    display: none;
    /* Hidden by default */
}

.typing-bubble {
    background: var(--bg-hover);
    padding: 8px 15px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    width: fit-content;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #888;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0s;
}

@keyframes typingBounce {

    0%,
    80%,
    100% {
        transform: scale(0);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.badge {
    background: #f4212e;
    /* Twitter/Youtube Red */
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    position: absolute;
    top: 8px;
    right: 10px;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* --- REPLY STYLES --- */

/* The quoted message inside a bubble */
.msg-reply-quote {
    background: rgba(0, 0, 0, 0.05);
    border-left: 3px solid #ccc;
    padding: 5px 8px;
    margin-bottom: 5px;
    border-radius: 4px;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    cursor: pointer;
}

/* Specific colors for sent messages */
.msg-row.sent .msg-reply-quote {
    background: rgba(255, 255, 255, 0.2);
    border-left-color: #fff;
    color: #f0f0f0;
}

.reply-sender {
    font-weight: 700;
    margin-bottom: 2px;
    font-size: 11px;
}

/* --- REPLY STYLES --- */

/* The quoted message inside a bubble */
.reply-quote {
    background: rgba(0, 0, 0, 0.05);
    border-left: 3px solid rgba(0, 0, 0, 0.2);
    padding: 6px 10px;
    border-radius: 4px;
    margin-bottom: 6px;
    font-size: 12px;
    display: flex;
    flex-direction: column;
}

.msg-row.sent .reply-quote {
    background: rgba(255, 255, 255, 0.2);
    border-left-color: rgba(255, 255, 255, 0.5);
}

.reply-sender {
    font-weight: 800;
    margin-bottom: 2px;
}

.reply-content {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.8;
}

/* Swipe Logic */
.msg-bubble {
    /* Enable hardware acceleration for smooth swipe */
    transition: transform 0.2s ease-out;
    touch-action: pan-y;
    /* Allow vertical scroll, handle horizontal in JS */
    position: relative;
    z-index: 2;
}

/* Swipe Indicator (shown behind the bubble when swiped) */
.swipe-indicator {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    z-index: 1;
}

.msg-row.received .swipe-indicator {
    left: -30px;
}

.msg-row.sent .swipe-indicator {
    right: -30px;
}

/* Reply Preview above Chat Input */
.chat-reply-preview {
    display: none;
    padding: 8px 15px;
    background: var(--bg-hover);
    border-top: 1px solid var(--border-color);
    border-left: 4px solid var(--text-main);
    justify-content: space-between;
    align-items: center;
}

.reply-preview-info {
    overflow: hidden;
}

.reply-preview-name {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-main);
    display: block;
}

.reply-preview-text {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cancel-reply-btn {
    cursor: pointer;
    font-size: 20px;
    color: var(--text-muted);
}

/* Emoji Picker Popover */
.emoji-picker-container {
    position: absolute;
    bottom: 100%;
    left: 10px;
    z-index: 1000;
    display: none;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    margin-bottom: 10px;
    animation: fadeInSlideUp 0.2s ease-out;
}

@keyframes fadeInSlideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

emoji-picker {
    --num-columns: 8;
    --category-emoji-size: 1.25rem;
    height: 350px;
    width: 320px;
}

.emoji-trigger {
    color: var(--text-muted);
    font-size: 24px;
    padding: 8px 0;
    transition: color 0.2s;
    background: none;
    border: none;
    cursor: pointer;
}

.emoji-trigger:hover {
    color: var(--text-main);
}