/* Premium Messages Interface Styles */

/* Main Messages Layout - Updated to work within positioned container */
.messages-premium-layout {
    height: calc(100vh - var(--header-offset, 6rem)); /* match Insights sidebar height */
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
    position: relative;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Premium Friends Interface Styles (match Messages layout) */
.friends-premium-layout {
    height: 100%; /* fit center column height between fixed sidebars */
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
    position: relative;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.friends-premium-header {
    background: linear-gradient(135deg, #48D1CC 0%, #40E0D0 50%, #AFEEEE 100%);
    padding: 1.25rem;
    color: white;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.friends-main-container {
    flex: 1;
    background: white;
    .mood-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: #fff8f2;
        border: 0.2px solid #fde1cc;
        color: #111827;
        cursor: pointer;
    }
    margin: 0;
    border-radius: 0;
    position: relative;
    display: grid;
    grid-template-columns: 300px minmax(0,1fr);
    gap: 16px;
    min-height: 0; /* allow inner scroller */
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}
.friends-main-container > * { min-width: 0; }

.friends-content-scroll {
    min-height: 0;
    overflow-y: auto;
    padding: 1rem;
    background: #f8fafc;
}

.messages-premium-header {
    background: linear-gradient(135deg, #48D1CC 0%, #40E0D0 50%, #AFEEEE 100%);
    padding: 1.25rem;
    color: white;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: none; /* Remove max-width constraint */
    margin: 0;
}

.messages-title {
    font-size: 2rem;
    font-weight: 900;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.messages-subtitle {
    font-size: 1rem;
    opacity: 0.9;
    margin-top: 0.5rem;
}

.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.premium-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}

.premium-btn.primary {
    background: rgba(255,255,255,0.2);
    color: white;
    backdrop-filter: blur(10px);
    border: 0.2px solid rgba(255,255,255,0.3);
}

.premium-btn.primary:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
}

.premium-btn.secondary {
    background: rgba(255,255,255,0.1);
    color: white;
    border: 0.2px solid rgba(255,255,255,0.2);
    padding: 0.75rem;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.premium-btn.large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

/* Main Container - Updated for constrained layout */
.messages-main-container {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: 280px minmax(0,1fr) 300px; /* conversations | chat | info */
    gap: 16px;
    background: white;
    margin: 0;
    border-radius: 0;
    overflow: hidden;
    min-height: 0; /* allow inner grid children to shrink and scroll */
    min-width: 0;
    box-shadow: none;
    position: relative; /* allow FAB positioning */
    max-width: 100%;
    box-sizing: border-box;
}
.messages-main-container.with-info { grid-template-columns: 280px minmax(0,1fr) 300px; }

.messages-main-container.with-info {
    grid-template-columns: 280px minmax(0,1fr) 300px; /* show info panel */
}

/* Conversations Panel */
.conversations-panel {
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 100%;
}
.chat-panel { min-width: 0; max-width: 100%; }
.conversations-controls {
    padding: 1rem;
    border-bottom: 1px solid #e2e8f0;
}
.chat-info-panel { min-width: 0; max-width: 100%; }
.search-wrapper {
    position: relative;
    margin-bottom: 1rem;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    z-index: 2;
}

.search-input {
    width: 100%;
    height: 38px;
    padding: 0.25rem 1rem 0.25rem 2.5rem;
    border: 0.2px solid #e2e8f0;
    border-radius: 25px;
    background: white;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: #48D1CC;
    box-shadow: 0 0 0 3px rgba(72, 209, 204, 0.1);
}

.filter-tabs {
    display: flex;
    gap: 0.5rem;
}

.filter-tab {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 0.2px solid #e2e8f0;
    border-radius: 20px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.85rem;
    font-weight: 500;
}

.filter-tab.active,
.filter-tab:hover {
    background: #48D1CC;
    color: white;
    border-color: #48D1CC;
}

/* Conversations List */
.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
}

.conversation-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 0.5rem;
    position: relative;
}

.conversation-item:hover {
    background: rgba(72, 209, 204, 0.1);
    transform: translateX(5px);
}

.conversation-item.active {
    background: linear-gradient(135deg, #48D1CC, #40E0D0);
    color: white;
}

.conversation-item.featured {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    margin-bottom: 1rem;
}

.conversation-avatar-stack {
    position: relative;
    margin-right: 1rem;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 0.2px solid rgba(255,255,255,0.3);
}

.status-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 0.2px solid white;
}

.status-indicator.online { background: #10b981; }
.status-indicator.away { background: #f59e0b; }
.status-indicator.offline { background: #6b7280; }

.conversation-content {
    flex: 1;
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.conversation-header h4 {
    font-weight: 600;
    font-size: 0.95rem;
    margin: 0;
}

.time {
    font-size: 0.7rem;
    opacity: 0.7;
}

.preview {
    font-size: 0.8rem;
    opacity: 0.8;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-badges {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.badge {
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

.badge.new { background: rgba(16, 185, 129, 0.2); color: #10b981; }
.badge.unread { background: rgba(239, 68, 68, 0.2); color: #ef4444; }
.badge.group { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }

/* Loading Animation */
.loading-conversations {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
}

.loading-animation {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.pulse-circle {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #48D1CC;
    animation: pulse 1.4s ease-in-out infinite both;
}

.pulse-circle:nth-child(1) { animation-delay: -0.32s; }
.pulse-circle:nth-child(2) { animation-delay: -0.16s; }

@keyframes pulse {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Chat Panel */
.chat-panel {
    display: grid;
    grid-template-rows: auto 1fr auto;
    background: white;
    min-height: 0; /* allow inner scroller */
    overflow: hidden; /* do not scroll entire panel; only messages list */
}

.chat-welcome-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
}

.welcome-content {
    max-width: 400px;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #48D1CC, #40E0D0);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 2rem;
    font-size: 2rem;
    color: white;
}

.welcome-content h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #1f2937;
}

.welcome-content p {
    font-size: 1.1rem;
    color: #6b7280;
    margin-bottom: 2rem;
}

.welcome-features {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 3rem;
}

.feature-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: #6b7280;
    font-size: 0.9rem;
}

.feature-item i {
    font-size: 1.5rem;
    color: #48D1CC;
}

/* Chat Interface */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.chat-participant-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.participant-avatar-small {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.participant-details h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    color: #1f2937;
}

.status {
    font-size: 0.85rem;
    color: #10b981;
}

.chat-header-actions {
    display: flex;
    gap: 0.5rem;
}

.chat-action-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(72, 209, 204, 0.1);
    color: #48D1CC;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-action-btn:hover,
.chat-action-btn.active {
    background: #48D1CC;
    color: white;
}

/* Messages Area */
.chat-messages-area {
    padding: 1rem;
    overflow-y: auto; /* the only scroller in chat panel */
    overflow-x: hidden;
    background: linear-gradient(to bottom, #f8fafc, #ffffff);
    /* keep last messages clear of the input bar */
    padding-bottom: calc(1rem + 110px);
    min-height: 0; /* allow scrolling within grid row */
}

.message-group {
    margin-bottom: 1.5rem;
}

.message {
    max-width: 70%;
    margin-bottom: 0.5rem;
    position: relative;
}

.message.sent {
    margin-left: auto;
}

.message.received {
    margin-right: auto;
}

.message-content {
    padding: 0; /* neutral container; bubble styling moved to .text-message */
    border-radius: 0;
    font-size: 0.9rem;
    line-height: 1.4;
    background: transparent;
    border: none;
}

/* Sent/received bubble styling applied to visible .text-message */
.message.sent .text-message {
    background: linear-gradient(135deg, #e8f3ff, #dfefff) !important;
    color: #0f172a !important;
    border: 0.2px solid #d6e8ff !important;
    border-bottom-right-radius: 8px !important;
    padding: 12px 16px !important;
}

.message.received .text-message {
    background: #f7fafc !important;
    color: #1f2937 !important;
    border: 0.2px solid #e5e7eb !important;
    border-bottom-left-radius: 8px !important;
    padding: 12px 16px !important;
}

.message-time {
    font-size: 0.65rem;
    color: #9aa3ae;
    margin-top: 0.25rem;
    text-align: right;
}

.message.received .message-time {
    text-align: left;
}

/* Chat Input */
.chat-input-area {
    padding: 1rem;
    border-top: 1px solid #e2e8f0;
    background: white;
}

/* On narrow/mobile screens, make input sticky to viewport bottom for better reachability */
@media (max-width: 767px) {
    #messages-section .chat-input-area {
        position: sticky;
        bottom: 0;
        z-index: 2;
    }
    /* Mobile: full-screen chat when active */
    .messages-main-container.mobile-chat-active {
        display: grid;
        grid-template-columns: 1fr;
    }
    .messages-main-container.mobile-chat-active .conversations-panel,
    .messages-main-container.mobile-chat-active .chat-info-panel {
        display: none;
    }
    .messages-main-container.mobile-chat-active #chat-main-area .chat-back-btn {
        display: inline-flex;
    }
}

/* Emphasize New Chat button in header */
#new-conversation-btn {
    background: #ffffff;
    color: #0e7490;
    border: 0.2px solid rgba(14, 116, 144, 0.25);
    box-shadow: 0 6px 18px rgba(14, 116, 144, 0.18);
}
#new-conversation-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(14, 116, 144, 0.24);
}

/* Floating Action Button for new chat */
.messages-fab {
    position: absolute;
    right: 20px;
    bottom: 112px; /* sit above the higher input area */
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #48D1CC, #40E0D0);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 24px rgba(64, 224, 208, 0.35);
    border: none;
    cursor: pointer;
    z-index: 10;
}
.messages-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 32px rgba(64, 224, 208, 0.45);
}

.chat-input-wrapper {
    display: flex;
    align-items: center; /* center vertically since no padding */
    gap: 10px;
    background: #f8fafc;
    border-radius: 18px;
    padding: 0; /* ensure no padding wins */
    height: 48px; /* fixed row height */
    border: 0.2px solid #e2e8f0;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.02);
}

.attach-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(72, 209, 204, 0.1);
    color: #48D1CC;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-input-container {
    flex: 1;
    position: relative;
}

.message-input {
    width: 100%;
    border: none;
    background: transparent;
    resize: none;
    overflow-y: auto;
    outline: none;
    font-size: 0.9rem;
    line-height: 1.2;
    height: 32px; /* practical height */
    min-height: 32px;
    max-height: 120px;
    padding: 0 10px; /* override any global padding */
}

.input-actions {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 0.25rem;
}

.emoji-btn,
.mood-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoji-btn:hover,
.mood-btn:hover {

/* Mood tag style (also receives inline color via JS) */
.mood-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-top: 0.25rem;
    margin-right: 0.25rem;
}

/* Modal overlay for mood picker */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.32);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-content {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    width: calc(100% - 2rem);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
}
.modal-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 0.2px solid #e5e7eb;
    background: #fff;
    cursor: pointer;
}
    background: rgba(72, 209, 204, 0.1);
    color: #48D1CC;
}

.send-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: #48D1CC;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover {
    background: #40E0D0;
    transform: scale(1.05);
}

/* Image message bubble */
.message-content.image-bubble {
    padding: 0;
    background: transparent;
    border: none;
    overflow: hidden;
    border-radius: 14px;
}
.message-image {
    display: block;
    max-width: min(420px, 70vw);
    height: auto;
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Visually indicate when an image is selected */
#chat-attach-btn.attached {
    background: rgba(72, 209, 204, 0.18);
    color: #0e7490;
    box-shadow: inset 0 0 0 2px rgba(14, 116, 144, 0.2);
}

/* Chat Info Panel */
.chat-info-panel {
    background: #f8fafc;
    border-left: 1px solid #e2e8f0;
    display: none; /* hidden by default */
    flex-direction: column;
}

/* Desktop draggable pop-out window */
.chat-popout-window {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 380px;
    height: 520px;
    background: #fff;
    border: 0.2px solid rgba(0,0,0,0.08);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
    z-index: 4000;
    overflow: hidden;
}
.chat-popout-window.minimized {
    height: auto;
    bottom: 16px;
}
.chat-popout-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .5rem .75rem;
    background: #0ea5e9;
    color: #fff;
    cursor: move;
    user-select: none;
}
.chat-popout-title { display: inline-flex; align-items: center; gap: .5rem; font-weight: 800; }
.chat-popout-actions { display: inline-flex; align-items: center; gap: .25rem; }
.chat-popout-btn { width: 28px; height: 28px; border-radius: 6px; border: 0.2px solid rgba(255,255,255,0.5); background: rgba(255,255,255,0.2); color:#fff; display:flex; align-items:center; justify-content:center; cursor:pointer; }
.chat-popout-btn:hover { background: rgba(255,255,255,0.3); }
.chat-popout-content { flex: 1; display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; }
.chat-popout-window.minimized .chat-popout-content { display: none; }
.chat-popout-resize { position: absolute; right: 0; bottom: 0; width: 16px; height: 16px; cursor: nwse-resize; }

.messages-main-container.with-info .chat-info-panel {
    display: flex; /* visible when container has with-info */
}

.chat-info-content {
    padding: 1rem;
    flex: 1;
    overflow-y: auto;
}

.chat-participant-info {
    text-align: center;
    margin-bottom: 2rem;
}

.participant-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 1rem;
    display: block;
}

.participant-name {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
    color: #1f2937;
}

.participant-status {
    color: #10b981;
    font-size: 0.9rem;
}

.chat-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.chat-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 0.2px solid #e2e8f0;
    border-radius: 12px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.8rem;
    color: #6b7280;
}

.chat-action-btn:hover {
    border-color: #48D1CC;
    color: #48D1CC;
    transform: translateY(-2px);
}

.shared-media h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #1f2937;
}

.no-media {
    text-align: center;
    padding: 2rem;
    color: #6b7280;
}

.no-media i {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: #d1d5db;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: #6b7280;
}

.empty-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #48D1CC, #40E0D0);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.5rem;
    color: white;
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #1f2937;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    border-radius: 20px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: #1f2937;
}

.modal-close-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(107, 114, 128, 0.1);
    color: #6b7280;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.recipient-input {
    width: 100%;
    padding: 0.75rem;
    border: 0.2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.suggested-contacts h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.contact-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-radius: 10px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.contact-item:hover {
    background: #f8fafc;
}

.contact-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 1rem;
}

.contact-info {
    flex: 1;
}

.contact-name {
    display: block;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.25rem;
}

.contact-status {
    font-size: 0.8rem;
    color: #6b7280;
}

.contact-select-btn {
    padding: 0.5rem 1rem;
    background: #48D1CC;
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.contact-select-btn:hover {
    background: #40E0D0;
    transform: translateY(-1px);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .messages-main-container {
        grid-template-columns: 300px 1fr;
    }
    .messages-main-container.with-info {
        grid-template-columns: 300px 1fr; /* collapse info panel on smaller screens */
    }
}

@media (max-width: 768px) {
    .messages-premium-header {
        padding: 1rem;
    }
    
    .messages-title {
        font-size: 1.8rem;
    }
    
    .messages-main-container { grid-template-columns: 1fr; }
    /* Show conversation list by default on mobile; chat view shown after selection via JS */
    .conversations-panel { display: flex; }
    
    .header-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    /* keep FAB above input on small screens */
    .messages-fab {
        bottom: 112px; /* match desktop gap */
        right: 16px;
    }
}

/* Prevent overflow beyond content column */
.friends-premium-layout,
.messages-premium-layout,
.friends-main-container,
.messages-main-container {
  min-width: 0; /* prevent overflow beyond content column */
  max-width: 100%;
}

/* Chat header back button (mobile) */
.chat-back-btn { display:inline-flex; }
.chat-header { position: sticky; top: 0; background: #f8fafc; z-index: 1; }

/* Ensure #chat-messages scrolls correctly within chat panel grid row */
#chat-messages { min-height: 0; max-height: none; }

/* Ensure search input doesn’t cause layout shift */
.messages-premium-header .header-content,
.friends-premium-header .header-content {
  max-width: 100%;
  overflow: hidden;
}

