:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #e0e7ff;
    --bg-color: #f8fafc;
    --sidebar-bg: #ffffff;
    --nav-bg: #1e293b;
    --chat-bg: #f8fafc;
    --hover-bg: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --message-own-bg: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    --message-own-text: #ffffff;
    --message-other-bg: #f1f5f9;
    --message-other-text: #0f172a;
    --card-bg: #ffffff;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* --- Messenger Layout --- */
.messenger-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    background-color: var(--bg-color);
}

/* Main Navigation (Narrow) */
.main-nav {
    width: 72px;
    background-color: var(--nav-bg);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 24px 0;
    z-index: 100;
}

.nav-logo {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 22px;
    margin-bottom: 32px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    align-items: center;
}

.nav-links li {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
    transition: var(--transition);
}

.nav-links li:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-links li.active {
    background-color: rgba(99, 102, 241, 0.2);
    color: #818cf8;
}

.nav-bottom {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.nav-profile-dropdown-wrapper {
    position: relative;
}

.profile-dropdown {
    position: absolute;
    left: 60px;
    bottom: 0;
    width: 320px;
    background-color: var(--sidebar-bg);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.4);
    z-index: 999;
    overflow: hidden;
}

.profile-dropdown-header {
    padding: 16px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.06), rgba(99, 102, 241, 0));
}

.profile-info-item {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.avatar-md {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background-color: var(--primary-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}

.profile-name {
    font-weight: 800;
    color: var(--text-primary);
}

.btn-view-profile {
    display: block;
    width: 100%;
    text-align: center;
    padding: 10px 12px;
    border-radius: 12px;
    background-color: var(--hover-bg);
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 700;
}

.btn-view-profile:hover {
    background-color: var(--border-color);
}

.profile-dropdown-section {
    padding: 10px;
}

.profile-dropdown-menu {
    list-style: none;
}

.profile-dropdown-menu li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 12px;
    border-radius: 12px;
    cursor: pointer;
    color: var(--text-primary);
    transition: var(--transition);
}

.profile-dropdown-menu li:hover {
    background-color: var(--hover-bg);
}

.profile-dropdown-menu li i {
    color: var(--text-secondary);
}

.profile-dropdown-menu li span {
    flex: 1;
    color: var(--text-primary);
    font-weight: 600;
}

.profile-dropdown-footer {
    padding: 12px 16px 16px;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.profile-dropdown-footer a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
}

.profile-dropdown-footer a:hover {
    color: var(--text-primary);
}

.nav-item {
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
    transition: var(--transition);
}

.nav-item:hover {
    color: white;
}

.nav-profile {
    cursor: pointer;
}

.avatar-sm {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    position: relative;
    overflow: hidden;
}

/* Sidebar (Contacts) */
.sidebar {
    width: 320px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.02);
}

.sidebar-header {
    padding: 24px 20px;
}

.sidebar-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.brand-logo-main {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-v-container {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 16px -2px rgba(99, 102, 241, 0.3);
    transition: var(--transition);
}

.logo-v-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 20px -2px rgba(99, 102, 241, 0.4);
}

.logo-v-svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: white;
    stroke-width: 12;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.brand-icon-v-premium {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-icon-v-premium .logo-v-svg {
    width: 28px;
    height: 28px;
    stroke: url(#vibeGradient);
    stroke-width: 14;
}

.sidebar-title-row h1 {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.sidebar-search {
    margin-bottom: 8px;
}

.search-box {
    display: flex;
    align-items: center;
    background-color: var(--hover-bg);
    border-radius: 10px;
    padding: 10px 14px;
    border: 1px solid transparent;
    transition: var(--transition);
}

.search-box:focus-within {
    border-color: var(--primary-color);
    background-color: white;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.search-box i {
    color: var(--text-secondary);
    margin-right: 10px;
}

.search-box input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    font-size: 14px;
    color: var(--text-primary);
}

.contacts-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px;
}

.section-title {
    padding: 12px 12px 8px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

#contactsList li {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    gap: 12px;
    margin-bottom: 4px;
}

#contactsList li:hover {
    background-color: var(--hover-bg);
}

#contactsList li.active {
    background-color: var(--primary-light);
}

#contactsList li.active .contact-name {
    color: var(--primary-color);
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    font-size: 18px;
    position: relative;
    flex-shrink: 0;
}

.avatar-loading::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: rgba(15, 23, 42, 0.28);
    z-index: 8;
    pointer-events: none;
}

.avatar-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin-left: -8px;
    margin-top: -8px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: #ffffff;
    animation: avatarSpin 0.8s linear infinite;
    z-index: 9;
    pointer-events: none;
}

@keyframes avatarSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.avatar-status-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--sidebar-bg);
    z-index: 5;
}

.avatar-status-badge.online {
    background-color: #10b981;
}

.avatar-status-badge.just-offline {
    background-color: #94a3b8;
}

.avatar-status-badge.offline {
    background-color: #94a3b8;
    color: white;
    font-size: 8px;
    padding: 2px 4px;
    width: auto;
    height: auto;
    border-radius: 6px;
    bottom: -4px;
    right: -4px;
}

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

.contact-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

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

.contact-preview.unread {
    color: var(--primary-color);
    font-weight: 700;
}

.unread-badge {
    background-color: var(--primary-color);
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--chat-bg);
}

.chat-header {
    padding: 16px 24px;
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-details h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.chat-status {
    font-size: 12px;
    color: var(--text-secondary);
}

.chat-status.online {
    color: #10b981;
    font-weight: 600;
}

.message-area {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background-color: transparent;
}

.chat-message {
    max-width: 75%;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
    position: relative;
}

.chat-message.own {
    align-self: flex-end;
}

.message-content {
    display: flex;
    flex-direction: column;
    width: fit-content;
}

.chat-message.own .message-content {
    align-items: flex-end;
    margin-left: auto;
}

.message-content p {
    padding: 12px 18px;
    border-radius: 20px;
    font-size: 15px;
    line-height: 1.5;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    word-break: break-word;
    width: fit-content;
    max-width: 100%;
}

.message-content img {
    display: block;
    width: auto;
    max-width: min(320px, 62vw);
    max-height: 360px;
    border-radius: 20px;
    object-fit: cover;
    box-shadow: 0 2px 5px rgba(0,0,0,0.08);
    cursor: pointer;
}

.chat-message.own .message-content p {
    background: var(--message-own-bg);
    color: var(--message-own-text);
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
    border: none;
}

.chat-message.own .message-content img {
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.chat-message:not(.own) .message-content p {
    background-color: var(--message-other-bg);
    color: var(--message-other-text);
    border-bottom-left-radius: 4px;
    border: 1px solid #e2e8f0;
}

.chat-message:not(.own) .message-content img {
    border-bottom-left-radius: 4px;
}

/* Bubble grouping: only run boundaries keep prominent outer rounding */
.chat-message.own.bubble-single .message-content p {
    border-top-right-radius: 20px;
    border-bottom-right-radius: 4px;
}

.chat-message.own.bubble-start .message-content p {
    border-top-right-radius: 20px;
    border-bottom-right-radius: 8px;
}

.chat-message.own.bubble-middle .message-content p {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

.chat-message.own.bubble-end .message-content p {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 4px;
}

.chat-message:not(.own).bubble-single .message-content p {
    border-top-left-radius: 20px;
    border-bottom-left-radius: 4px;
}

.chat-message:not(.own).bubble-start .message-content p {
    border-top-left-radius: 20px;
    border-bottom-left-radius: 8px;
}

.chat-message:not(.own).bubble-middle .message-content p {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.chat-message:not(.own).bubble-end .message-content p {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 4px;
}

.chat-message.own.bubble-single .message-content img {
    border-top-right-radius: 20px;
    border-bottom-right-radius: 4px;
}

.chat-message.own.bubble-start .message-content img {
    border-top-right-radius: 20px;
    border-bottom-right-radius: 8px;
}

.chat-message.own.bubble-middle .message-content img {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

.chat-message.own.bubble-end .message-content img {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 4px;
}

.chat-message:not(.own).bubble-single .message-content img {
    border-top-left-radius: 20px;
    border-bottom-left-radius: 4px;
}

.chat-message:not(.own).bubble-start .message-content img {
    border-top-left-radius: 20px;
    border-bottom-left-radius: 8px;
}

.chat-message:not(.own).bubble-middle .message-content img {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.chat-message:not(.own).bubble-end .message-content img {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 4px;
}

/* Message Status Styling */
.chat-message.own .message-content {
    position: relative;
    align-items: flex-end;
    margin-left: auto;
}

.message-status-container {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 0;
    min-height: 0;
}

.chat-message.own .message-status-container {
    justify-content: flex-end;
    padding-right: 2px;
}

.chat-message:not(.own) .message-status-container {
    justify-content: flex-start;
    padding-left: 2px;
}

.message-time {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 500;
    position: absolute;
    top: calc(100% + 2px);
    right: 2px;
    z-index: 2;
    background: rgba(248, 250, 252, 0.95);
    padding: 1px 4px;
    border-radius: 6px;
    opacity: 0;
    white-space: nowrap;
    transition: var(--transition);
}

.chat-message:not(.own) .message-time {
    left: 2px;
    right: auto;
}

.chat-message:hover .message-time {
    opacity: 1;
}

.message-status {
    font-size: 11px;
    color: #3b82f6;
    display: flex;
    align-items: center;
    transition: var(--transition);
}

/* Divider cho tin nhắn chưa đọc */
.unread-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
    width: 100%;
    position: relative;
}

.unread-divider::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    background-color: #fee2e2;
    z-index: 1;
}

.unread-divider span {
    background-color: #fef2f2;
    color: #ef4444;
    padding: 4px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    z-index: 2;
    border: 1px solid #fee2e2;
}

.message-status.sent {
    color: #94a3b8;
}

.message-status.delivered {
    color: #3b82f6;
}

.message-status.seen {
    color: #3b82f6;
}

/* Seen Avatar Style (Modern) */
.message-status.seen-avatar {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    border: 1px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Inbox Status (Right side) */
.contact-item-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
    margin-left: 12px;
    min-width: 55px;
    flex-shrink: 0;
}

.contact-item-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    min-height: 16px;
}

.contact-time {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    white-space: nowrap;
}

.contact-message-status {
    font-size: 11px;
    display: flex;
    align-items: center;
}

.contact-message-status.sent { color: #94a3b8; }
.contact-message-status.delivered { color: #3b82f6; }
.contact-message-status.seen { color: #3b82f6; }

.unread-badge {
    background-color: var(--primary-color);
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.chat-input-area {
    padding: 16px 24px 24px;
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-color);
}

.input-wrapper {
    background-color: white;
    border-radius: 12px;
    padding: 6px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.input-wrapper input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px;
    font-size: 15px;
    outline: none;
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: var(--transition);
}

.icon-btn:hover {
    background-color: var(--hover-bg);
    color: var(--primary-color);
}

.send-btn {
    color: var(--primary-color);
}

.send-btn:hover {
    background-color: var(--primary-light);
}

/* Chat Placeholder */
.chat-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
    background-color: var(--chat-bg);
}

.placeholder-icon {
    width: 120px;
    height: 120px;
    background-color: white;
    border-radius: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-size: 50px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
}

.chat-placeholder h2 {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 12px;
    max-width: 450px;
}

.chat-placeholder p {
    color: var(--text-secondary);
    font-size: 16px;
    max-width: 400px;
}

/* Full Contacts View */
.contacts-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
    padding: 40px;
    overflow-y: auto;
}

.contacts-view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.contacts-view-header h1 {
    font-size: 32px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.contacts-view-header p {
    color: var(--text-secondary);
    font-size: 16px;
}

.header-right {
    display: flex;
    gap: 16px;
}

.search-box-lg {
    display: flex;
    align-items: center;
    background-color: white;
    border-radius: 14px;
    padding: 12px 20px;
    border: 1px solid var(--border-color);
    width: 350px;
    box-shadow: var(--shadow-sm);
}

.search-box-lg input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    margin-left: 12px;
    font-size: 15px;
}

.contacts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.contact-card {
    background-color: white;
    border-radius: 20px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border: 1px solid var(--border-color);
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.contact-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.card-avatar-lg {
    width: 80px;
    height: 80px;
    border-radius: 24px;
    font-size: 32px;
    font-weight: 800;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    position: relative;
}

.card-status-dot {
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 4px solid white;
}

.card-status-dot.online { background-color: #10b981; }
.card-status-dot.offline { background-color: #94a3b8; }

.contact-card h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.contact-card p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.card-actions {
    display: flex;
    gap: 12px;
    width: 100%;
}

.btn-card-action {
    flex: 1;
    padding: 10px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-chat {
    background-color: var(--primary-color);
    color: white;
}

.btn-chat:hover {
    background-color: var(--primary-hover);
}

.btn-profile {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

.btn-profile:hover {
    background-color: var(--border-color);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    transition: var(--transition);
}

.modal.hidden {
    display: none !important;
}

.modal-content {
    background-color: white;
    width: 100%;
    max-width: 450px;
    border-radius: 20px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    animation: modalSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#friendModal .modal-content {
    max-width: 560px;
}

#friendModal .modal-body {
    padding-top: 18px;
}

#friendModal .modal-section + .modal-section {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border-color);
}

@keyframes modalSlideIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

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

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.close-btn {
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-section h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}

.friend-section-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.friend-search-box {
    display: flex;
    gap: 10px;
    align-items: center;
}

.friend-input-wrap {
    position: relative;
    flex: 1;
}

.friend-input-wrap i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 14px;
    pointer-events: none;
}

.friend-input-wrap .form-control {
    padding-left: 38px;
    min-height: 44px;
}

.friend-search-btn {
    min-height: 44px;
    white-space: nowrap;
}

.friend-action-status {
    margin-top: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid transparent;
}

.friend-action-status.success {
    color: #047857;
    background: #ecfdf5;
    border-color: #a7f3d0;
}

.friend-action-status.error {
    color: #b91c1c;
    background: #fef2f2;
    border-color: #fecaca;
}

.friend-action-status.info {
    color: #1d4ed8;
    background: #eff6ff;
    border-color: #bfdbfe;
}

.friend-requests-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.friend-requests-header h3 {
    margin-bottom: 0;
}

.pending-count-badge {
    background: var(--primary-light);
    color: var(--primary-color);
    border: 1px solid #c7d2fe;
    min-width: 26px;
    height: 26px;
    padding: 0 8px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 12px;
}

.friend-requests-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    max-height: 310px;
    overflow-y: auto;
    padding-right: 4px;
}

.friend-request-card {
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--border-color);
    background: #fff;
    border-radius: 14px;
    padding: 12px;
    transition: var(--transition);
}

.friend-request-card:hover {
    border-color: #c7d2fe;
    box-shadow: 0 8px 18px rgba(99, 102, 241, 0.12);
    transform: translateY(-1px);
}

.friend-request-card .card-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    color: #fff;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.friend-request-card .card-info {
    flex: 1;
    min-width: 0;
}

.friend-request-card .card-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.friend-request-card .card-mutual {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.friend-request-card .card-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.btn-card {
    border: none;
    border-radius: 10px;
    height: 34px;
    padding: 0 12px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.btn-confirm {
    background: var(--primary-color);
    color: #fff;
}

.btn-confirm:hover {
    background: var(--primary-hover);
}

.btn-delete {
    background: #f1f5f9;
    color: #334155;
}

.btn-delete:hover {
    background: #e2e8f0;
}

.btn-card:disabled,
.friend-search-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.friend-empty-state {
    border: 1px dashed #cbd5e1;
    background: #f8fafc;
    border-radius: 14px;
    padding: 22px 14px;
    text-align: center;
}

.friend-empty-state i {
    font-size: 22px;
    color: #94a3b8;
    margin-bottom: 8px;
}

.friend-empty-state p {
    font-size: 13px;
    color: #64748b;
    font-weight: 600;
}

.form-group {
    margin-bottom: 16px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background-color: var(--hover-bg);
    font-size: 14px;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: white;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.btn {
    padding: 12px 20px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn.primary {
    background-color: var(--primary-color);
    color: white;
}

.btn.primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn.secondary {
    background-color: var(--hover-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn.secondary:hover {
    background-color: var(--border-color);
    transform: translateY(-1px);
}

.btn.danger {
    background-color: #fee2e2;
    color: #ef4444;
}

.btn.danger:hover {
    background-color: #fecaca;
}

/* Profile Settings */
.profile-info-display {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.profile-name-row {
}

body.profile-page-body {
    background-color: var(--bg-color);
    overflow: auto;
}

.profile-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 16px 60px;
}

.back-btn-profile {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 700;
    padding: 10px 12px;
    border-radius: 12px;
    background-color: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
}

.back-btn-profile:hover {
    background-color: #fff;
}

.profile-cover {
    position: relative;
    margin-top: 16px;
    height: 260px;
    border-radius: 20px;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.9), rgba(168, 85, 247, 0.9));
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.14);
}

.cover-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.18), transparent 55%),
    radial-gradient(circle at 80% 30%, rgba(255, 255, 255, 0.12), transparent 55%),
    radial-gradient(circle at 50% 90%, rgba(0, 0, 0, 0.15), transparent 55%);
}

.edit-cover-btn {
    position: absolute;
    right: 16px;
    bottom: 16px;
    border: 0;
    border-radius: 12px;
    padding: 10px 12px;
    font-weight: 700;
    background-color: rgba(255, 255, 255, 0.9);
    color: var(--text-primary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.edit-cover-btn:hover {
    background-color: #fff;
}

.profile-header-info {
    display: grid;
    grid-template-columns: 180px 1fr auto;
    gap: 18px;
    align-items: end;
    background-color: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 18px;
    margin-top: -70px;
    position: relative;
    backdrop-filter: blur(14px);
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.08);
}

.profile-avatar-wrapper {
    position: relative;
    width: 168px;
    height: 168px;
}

.avatar-xl {
    width: 168px;
    height: 168px;
    border-radius: 32px;
    background-color: var(--primary-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 56px;
    font-weight: 900;
    border: 6px solid #fff;
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.14);
    overflow: hidden;
    position: relative;
}

.edit-avatar-btn {
    position: absolute;
    right: 10px;
    bottom: 10px;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    background-color: rgba(255, 255, 255, 0.95);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.12);
}

.edit-avatar-btn:hover {
    background-color: #fff;
}

.profile-text-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.profile-name-large {
    font-size: 30px;
    line-height: 1.1;
    font-weight: 900;
    color: var(--text-primary);
    margin: 0;
}

.profile-bio {
    color: var(--text-secondary);
    font-weight: 600;
    margin: 0;
}

.profile-stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.profile-stats span {
    display: inline-flex;
    gap: 6px;
    align-items: baseline;
    padding: 8px 10px;
    border-radius: 14px;
    background-color: var(--hover-bg);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 13px;
}

.profile-stats strong {
    color: var(--text-primary);
    font-size: 14px;
}

.profile-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.profile-nav-tabs {
    margin-top: 16px;
    background-color: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 6px;
    position: sticky;
    top: 12px;
    z-index: 50;
    backdrop-filter: blur(14px);
}

.profile-nav-tabs ul {
    list-style: none;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding: 0;
    margin: 0;
}

.profile-nav-tabs li {
    padding: 10px 12px;
    border-radius: 14px;
    font-weight: 800;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.profile-nav-tabs li:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

.profile-nav-tabs li.active {
    background-color: var(--primary-light);
    color: var(--primary-color);
}

.profile-content-grid {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 16px;
    margin-top: 16px;
}

.info-card {
    background-color: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 16px;
    box-shadow: 0 16px 28px rgba(15, 23, 42, 0.06);
    backdrop-filter: blur(14px);
}

.info-card h3 {
    margin: 0 0 14px;
    font-size: 14px;
    font-weight: 900;
    color: var(--text-primary);
}

.info-card ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: var(--text-secondary);
    font-weight: 600;
}

.info-card li {
    display: flex;
    align-items: center;
    gap: 10px;
}

.info-card li i {
    width: 18px;
    color: var(--text-secondary);
}

.btn-full-width {
    width: 100%;
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background-color: var(--hover-bg);
    font-weight: 800;
    cursor: pointer;
    color: var(--text-primary);
}

.btn-full-width:hover {
    background-color: var(--border-color);
}

.post-composer {
    background-color: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 16px;
    box-shadow: 0 16px 28px rgba(15, 23, 42, 0.06);
    backdrop-filter: blur(14px);
}

.composer-header {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 14px;
}

.composer-placeholder {
    flex: 1;
    text-align: left;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    background-color: var(--hover-bg);
    color: var(--text-secondary);
    font-weight: 700;
    cursor: pointer;
}

.composer-placeholder:hover {
    background-color: var(--border-color);
}

.composer-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.composer-actions button {
    border: 1px solid var(--border-color);
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 14px;
    padding: 10px 12px;
    cursor: pointer;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.composer-actions button:hover {
    background-color: #fff;
}

@media (max-width: 980px) {
    .profile-header-info {
        grid-template-columns: 1fr;
        align-items: start;
        margin-top: -54px;
    }
    .profile-avatar-wrapper {
        width: 140px;
        height: 140px;
    }
    .avatar-xl {
        width: 140px;
        height: 140px;
        font-size: 48px;
        border-radius: 26px;
    }
    .profile-actions {
        justify-content: flex-start;
    }
    .profile-content-grid {
        grid-template-columns: 1fr;
    }
}

#contactsList li.unread .contact-name {
    font-weight: 800; /* In đậm tên người gửi khi có tin nhắn chưa đọc */
    color: var(--text-primary); /* Đảm bảo màu chữ không bị thay đổi bởi active state */
}

#contactsList li.unread .contact-preview span {
    font-weight: 700 !important; /* In đậm nội dung bên trong span của preview */
    color: var(--primary-color) !important;
}
