.chat-page-modern {
    height: calc(100vh - 130px);
    padding: 16px;
    background: #f0f2f5;
}
.chat-layout {
    display: flex;
    height: 100%;
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,.08);
}
.chat-sidebar-modern {
    width: 340px;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    background: #fff;
    flex-shrink: 0;
}
.chat-sidebar-top {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
}
.chat-section-label {
    padding: 8px 16px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    background: #f8fafc;
}
.friend-req-item {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid #f1f5f9;
}
.friend-req-item:hover {
    background: #f8fafc;
}
.chat-room-list-modern {
    flex: 1;
    overflow-y: auto;
}

/* Room item — default (read) */
.chat-room-item-modern {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s;
    background: #fff;
}

.chat-room-item-modern:hover {
    background: #f8fafc;
    color: inherit;
}

.chat-room-item-modern.active {
    background: #eef4ff;
}

/* ✅ UNREAD — kontras tinggi */
.chat-room-item-modern.unread {
    background: #eff6ff;
    font-weight: 600;
}

.chat-room-item-modern.unread:hover {
    background: #dbeafe;
}

.chat-room-item-modern.unread .room-name-modern {
    color: #0f2345;
    font-weight: 700;
}

.chat-room-item-modern.unread .room-preview-modern {
    color: #1e40af;
    font-weight: 500;
}

.chat-room-item-modern.unread .room-time-modern {
    color: #1e4fa3;
    font-weight: 700;
}

/* ✅ READ — lebih redup */
.chat-room-item-modern:not(.unread) .room-preview-modern {
    color: #94a3b8;
}

.chat-room-item-modern:not(.unread) .room-time-modern {
    color: #cbd5e1;
}

/* Badge unread lebih tegas */
.unread-badge-modern {
    background: #dc3545;
    color: #fff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(220, 53, 69, 0.3);
}

/* Dot indicator */
.room-unread-dot {
    width: 10px;
    height: 10px;
    background: #1e4fa3;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 4px;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.85); }
}

/* Dark mode */
[data-bs-theme="dark"] .chat-room-item-modern {
    background: #111827;
    border-color: #374151;
}

[data-bs-theme="dark"] .chat-room-item-modern.unread {
    background: rgba(30, 79, 163, 0.25);
}

[data-bs-theme="dark"] .chat-room-item-modern.unread:hover {
    background: rgba(30, 79, 163, 0.35);
}

[data-bs-theme="dark"] .chat-room-item-modern.unread .room-name-modern {
    color: #f8fafc;
}

[data-bs-theme="dark"] .chat-room-item-modern.unread .room-preview-modern {
    color: #93c5fd;
}

[data-bs-theme="dark"] .chat-room-item-modern:not(.unread) .room-preview-modern {
    color: #64748b;
}

.room-avatar-modern {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e4fa3, #13a8d8);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.room-info-modern {
    flex: 1;
    min-width: 0;
}
.room-name-modern {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 2px;
}
.room-preview-modern {
    font-size: 12px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.room-time-modern {
    font-size: 11px;
    color: #94a3b8;
}
.unread-badge-modern {
    background: #1e4fa3;
    color: #fff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 700;
}

/* Chat main */
.chat-main-modern {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.chat-header-modern {
    padding: 14px 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.chat-body-modern {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
}
.chat-msg-modern {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    max-width: 75%;
}
.chat-msg-modern.mine {
    margin-left: auto;
    flex-direction: row-reverse;
}
.chat-msg-avatar-modern {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.chat-msg-bubble-modern {
    background: #fff;
    padding: 8px 14px;
    border-radius: 16px;
    box-shadow: 0 1px 2px rgba(0,0,0,.05);
    max-width: 100%;
}
.chat-msg-modern.mine .chat-msg-bubble-modern {
    background: linear-gradient(135deg, #1e4fa3, #13a8d8);
    color: #fff;
}
.chat-msg-name-modern {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 2px;
}
.chat-msg-time-modern {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}
.chat-msg-sticker-modern {
    font-size: 48px;
    line-height: 1;
    padding: 4px 0;
}
.chat-input-area-modern {
    padding: 12px 20px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
    position: relative;
}
.chat-toolbar-modern {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}
.chat-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.chat-input-modern {
    border-radius: 20px;
    resize: none;
    max-height: 100px;
}
.chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    flex-shrink: 0;
}
.emoji-picker-modern {
    position: absolute;
    bottom: 100%;
    left: 20px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,.15);
    padding: 12px;
    width: 340px;
    max-height: 280px;
    overflow-y: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    z-index: 100;
}
.emoji-item-modern {
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    user-select: none;
    transition: background 0.15s;
}
.emoji-item-modern:hover {
    background: #f1f5f9;
    transform: scale(1.15);
}
.sticker-picker-modern {
    position: absolute;
    bottom: 100%;
    left: 20px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,.15);
    padding: 12px;
    width: 340px;
    max-height: 280px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    z-index: 100;
}
.sticker-item-modern {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    padding: 8px;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.sticker-item-modern:hover {
    background: #eef4ff;
    border-color: #1e4fa3;
    transform: scale(1.08);
}

[data-bs-theme="dark"] .chat-page-modern {
    background: #0f172a;
}
[data-bs-theme="dark"] .chat-layout,
[data-bs-theme="dark"] .chat-sidebar-modern,
[data-bs-theme="dark"] .chat-header-modern,
[data-bs-theme="dark"] .chat-input-area-modern {
    background: #111827;
    border-color: #374151;
}
[data-bs-theme="dark"] .chat-body-modern {
    background: #0f172a;
}
[data-bs-theme="dark"] .chat-msg-bubble-modern {
    background: #1f2937;
    color: #e5e7eb;
}
[data-bs-theme="dark"] .emoji-picker-modern,
[data-bs-theme="dark"] .sticker-picker-modern {
    background: #1f2937;
}
[data-bs-theme="dark"] .emoji-item-modern:hover {
    background: #374151;
}
[data-bs-theme="dark"] .sticker-item-modern {
    background: #374151;
    border-color: #4b5563;
}

/* Date divider */
.chat-date-divider {
    text-align: center;
    margin: 16px 0 12px;
    position: relative;
}
.chat-date-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #e2e8f0;
    z-index: 0;
}
.chat-date-divider span {
    position: relative;
    background: #f8fafc;
    padding: 4px 14px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 1;
}

/* Deleted message */
.chat-msg-deleted {
    background: #f1f5f9 !important;
    color: #94a3b8 !important;
    font-style: italic;
}

/* Edited mark */
.chat-msg-edited {
    font-size: 10px;
    opacity: 0.7;
}

/* Action menu */
.chat-msg-actions {
    position: relative;
    align-self: flex-start;
    margin-top: 4px;
}
.chat-msg-modern.mine .chat-msg-actions {
    align-self: flex-end;
}

.btn-action-menu {
    background: transparent;
    border: 0;
    color: #94a3b8;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s;
}
.btn-action-menu:hover {
    background: #f1f5f9;
    color: #0f2345;
}

.chat-action-dropdown {
    position: absolute;
    right: 0;
    top: 100%;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    padding: 4px;
    z-index: 50;
    min-width: 140px;
}
.chat-msg-modern.mine .chat-action-dropdown {
    right: auto;
    left: 0;
}

.chat-action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border: 0;
    background: transparent;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    color: #0f2345;
    transition: background 0.15s;
}
.chat-action-btn:hover {
    background: #f8fafc;
}
.chat-action-btn small {
    font-size: 10px;
    color: #94a3b8;
    margin-left: auto;
}

/* Edit mode label */
.edit-mode-label {
    font-size: 12px;
    color: #1e4fa3;
    padding: 4px 8px;
    background: #eef4ff;
    border-radius: 8px;
    margin-bottom: 6px;
    display: inline-block;
}
.edit-mode-label a {
    color: #dc3545;
    text-decoration: none;
    font-weight: 700;
}

/* Date filter */
.chat-date-filter {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

/* Dark mode */
[data-bs-theme="dark"] .chat-date-divider span {
    background: #0f172a;
    color: #94a3b8;
}
[data-bs-theme="dark"] .chat-date-divider::before {
    background: #374151;
}
[data-bs-theme="dark"] .chat-msg-deleted {
    background: #1f2937 !important;
    color: #64748b !important;
}
[data-bs-theme="dark"] .chat-action-dropdown {
    background: #1f2937;
}
[data-bs-theme="dark"] .chat-action-btn {
    color: #e5e7eb;
}
[data-bs-theme="dark"] .chat-action-btn:hover {
    background: #374151;
}
[data-bs-theme="dark"] .btn-action-menu:hover {
    background: #374151;
    color: #f8fafc;
}

/* Read receipt */
.chat-msg-time-modern i.fa-check,
.chat-msg-time-modern i.fa-check-double {
    font-size: 11px;
    margin-left: 4px;
    vertical-align: middle;
}

.chat-msg-time-modern i.fa-check-double.text-primary {
    color: #13a8d8 !important;
}

/* Edited mark */
.chat-msg-edited {
    font-size: 10px;
    opacity: 0.7;
    font-style: italic;
}

/* Delete mark */
.chat-msg-deleted em {
    font-style: italic;
    opacity: 0.7;
    font-size: 13px;
}