
.chat-page {
    height: 100dvh;
    display: flex;
    align-items: stretch;
    padding: 0;
    overflow: hidden;
    background: var(--bg-color);
}

.chat-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    width: 100%;
    height: 100%;
    gap: 0;
}
.quick-messages{
    display: grid;
    gap: 8px;
    padding: 2.7rem 0;
    width: fit-content;
    margin: 0 auto;
    text-align: center;
}



.quick-btn{
    background:#f1f5f9;
    border-radius:20px;
    padding:0.6rem 1.1rem;
    font-size: 0.99rem;
    white-space:nowrap;
    border:none;
    cursor:pointer;
}

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

/* =================== SIDEBAR =================== */
.sidebar-panel {
    background: var(--sidebar-bg);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1.25rem 1rem 1rem;
    flex-shrink: 0;
}

.sidebar-back-btn {
    color: var(--text-secondary) !important;
    flex-shrink: 0;
}

.sidebar-back-btn:hover {
    color: var(--primary-color) !important;
}

.sidebar-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
}

.title-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
}

.sidebar-title h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.search-wrapper {
    padding: 0 1rem 0.75rem;
    flex-shrink: 0;
}

.search-wrapper :deep(.p-iconfield) {
    width: 100%;
}

.search-input {
    width: 100% !important;
    background: var(--bg-color) !important;
    border-color: transparent !important;
    border-radius: 14px !important;
    font-size: 0.875rem !important;
    padding: 0.6rem 2.5rem 0.6rem 0.875rem !important;
    transition: var(--transition) !important;
}

.search-input:focus {
    border-color: var(--primary-color) !important;
    background: white !important;
}

.rooms-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 0 0.5rem 1rem;
}

.rooms-scroll::-webkit-scrollbar { width: 3px; }
.rooms-scroll::-webkit-scrollbar-track { background: transparent; }
.rooms-scroll::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }

.rooms-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.room-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.75rem;
    border-radius: 14px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.room-card:hover {
    background: var(--bg-color);
}

.room-card--active {
    background: rgba(37, 99, 235, 0.07) !important;
}

.room-card--active .room-name {
    color: var(--primary-color);
}

.room-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.room-avatar-img {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    object-fit: cover;
}

.room-avatar-placeholder {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
}

.online-dot {
    position: absolute;
    bottom: 2px;
    left: 2px;
    width: 10px;
    height: 10px;
    background: var(--success-color);
    border: 2px solid white;
    border-radius: 50%;
}

.room-details {
    flex: 1;
    min-width: 0;
}

.room-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

.room-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.room-time {
    font-size: 0.72rem;
    color: var(--text-secondary);
    flex-shrink: 0;
    margin-right: 0.25rem;
}

.room-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.room-preview {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.unread-badge {
    background: var(--primary-color) !important;
    min-width: 20px !important;
    height: 20px !important;
    font-size: 0.7rem !important;
    border-radius: 10px !important;
}

.empty-rooms {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-icon {
    width: 56px;
    height: 56px;
    background: var(--bg-color);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.empty-rooms p {
    font-size: 0.875rem;
}

/* =================== CHAT PANEL =================== */
.chat-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background: var(--bg-color);
    position: relative;
}

.chat-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* ---- Topbar ---- */
.chat-topbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.back-btn {
    display: none;
    color: var(--text-secondary) !important;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.topbar-avatar-wrap {
    position: relative;
}

.topbar-avatar-img {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    object-fit: cover;
}

.topbar-avatar-placeholder {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.875rem;
}

.topbar-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.topbar-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-status {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.topbar-status.online {
    color: var(--success-color);
}

.status-pulse {
    width: 6px;
    height: 6px;
    background: var(--success-color);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

.more-btn {
    color: var(--text-secondary) !important;
}

/* ---- Messages ---- */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-x: hidden;
}

.messages-area::-webkit-scrollbar { width: 4px; }
.messages-area::-webkit-scrollbar-track { background: transparent; }
.messages-area::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }

.messages-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}
.reply-action-btn .pi-reply {
    transform: rotateY(180deg);
}

.messages-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.msg-row {
    display: flex;
    justify-content: flex-end;
}

.msg-row--own {
    justify-content: flex-start;
}

.msg-bubble {
    max-width: 68%;
    background: var(--sidebar-bg);
    border-radius: 18px 18px 18px 4px;
    padding: 0.65rem 0.9rem;
    box-shadow: var(--shadow-sm);
    position: relative;
}

.msg-bubble--own {
    background: var(--primary-color);
    border-radius: 18px 18px 4px 18px;
    color: white;
}

.msg-text {
    font-size: 0.9rem;
    line-height: 1.6;
    word-break: break-word;
    color: inherit;
}

.msg-bubble:not(.msg-bubble--own) .msg-text {
    color: var(--text-primary);
}

.msg-foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.3rem;
    margin-top: 0.3rem;
}

.msg-time {
    font-size: 0.68rem;
    opacity: 0.65;
}

.tick-icon {
    font-size: 0.75rem;
    opacity: 0.7;
}

.tick-read {
    opacity: 1;
    color: #93c5fd;
}

/* ---- Typing ---- */
.typing-row {
    display: flex;
    justify-content: flex-start;
    padding: 0.25rem 0;
}

.typing-bubble {
    background: var(--sidebar-bg);
    border-radius: 18px 18px 18px 4px;
    padding: 0.7rem 1rem;
    display: flex;
    gap: 5px;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.typing-bubble span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-6px); opacity: 1; }
}

/* ---- Input Bar ---- */
.input-bar {
    padding: 0.75rem 1rem;
    background: var(--sidebar-bg);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    position: relative;
}

.emoji-panel {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 1rem;
    background: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 0.75rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    width: 220px;
    z-index: 10;
}

.emoji-btn-item {
    font-size: 1.3rem;
    padding: 4px;
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition);
    line-height: 1;
}

.emoji-btn-item:hover {
    background: var(--bg-color);
    transform: scale(1.15);
}

.input-row {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

.emoji-toggle {
    color: var(--text-secondary) !important;
    flex-shrink: 0;
}

.emoji-toggle.active {
    color: var(--primary-color) !important;
}

.msg-input {
    flex: 1;
    resize: none !important;
    border-radius: 14px !important;
    border-color: var(--border-color) !important;
    background: var(--bg-color) !important;
    font-size: 0.9rem !important;
    max-height: 120px;
    line-height: 1.5 !important;
    transition: var(--transition) !important;
}

.msg-input:focus {
    border-color: var(--primary-color) !important;
    background: white !important;
}

.send-btn {
    width: 42px !important;
    height: 42px !important;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark)) !important;
    border: none !important;
    flex-shrink: 0;
    transition: all 0.25s ease !important;
}

.send-btn:not(:disabled):hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35) !important;
}

.send-btn:disabled {
    opacity: 0.45 !important;
}

/* ---- Empty state ---- */
.chat-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.empty-chat-visual {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    text-align: center;
}

.empty-chat-icon {
    width: 72px;
    height: 72px;
    background: var(--sidebar-bg);
    border: 2px solid var(--border-color);
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--primary-light);
    box-shadow: var(--shadow-sm);
}

.empty-chat-visual h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.empty-chat-visual p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* =================== TRANSITIONS =================== */
.room-list-enter-active,
.room-list-leave-active { transition: all 0.25s ease; }
.room-list-enter-from { opacity: 0; transform: translateX(10px); }
.room-list-leave-to { opacity: 0; transform: translateX(-10px); }

.message-enter-active { transition: all 0.25s ease; }
.message-enter-from { opacity: 0; transform: translateY(10px); }

.fade-enter-active, .fade-leave-active { transition: opacity 0.2s ease; }
.fade-enter-from, .fade-leave-to { opacity: 0; }

.emoji-panel-enter-active, .emoji-panel-leave-active { transition: all 0.2s ease; }
.emoji-panel-enter-from, .emoji-panel-leave-to { opacity: 0; transform: translateY(8px) scale(0.96); }

.chat-enter-enter-active, .chat-enter-leave-active { transition: all 0.25s ease; }
.chat-enter-enter-from { opacity: 0; transform: scale(0.99); }
.chat-enter-leave-to { opacity: 0; }

/* =================== RESPONSIVE =================== */
@media (max-width: 1000px) {
    .chat-page {
        padding-bottom: 1rem;
    }

    .chat-layout {
        grid-template-columns: 1fr;
        position: relative;
    }

    .sidebar-panel {
        position: absolute;
        inset: 0;
        z-index: 2;
        border-left: none;
        transform: translateX(0);
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .sidebar-panel.slide-out {
        transform: translateX(100%);
        pointer-events: none;
    }

    .chat-panel {
        position: absolute;
        inset: 0;
        z-index: 3;
        transform: translateX(-100%);
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .chat-panel.slide-in {
        transform: translateX(0);
    }

    .back-btn {
        display: flex !important;
    }

    .msg-bubble {
        max-width: 82%;
    }
}

@media (max-width: 640px) {
    .chat-topbar {
        padding: 0.75rem;
    }

    .messages-area {
        padding: 1rem 0.75rem;
    }

    .input-bar {
        padding: 0.6rem 0.75rem;
    }

    .emoji-panel {
        right: 0.75rem;
        width: 200px;
    }
}

/* ===== REPLY ===== */
.msg-bubble {
    position: relative;
}

.reply-preview-bubble {
    background: rgba(0, 0, 0, 0.06);
    border-right: 3px solid var(--primary-light);
    border-radius: 8px;
    padding: 0.4rem 0.6rem;
    margin-bottom: 0.4rem;
}

.msg-bubble--own .reply-preview-bubble {
    background: rgba(255, 255, 255, 0.15);
    border-right-color: rgba(255, 255, 255, 0.6);

}

.reply-preview-name {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--primary-color);
    display: block;
    margin-bottom: 0.15rem;
}

.msg-bubble--own .reply-preview-name {
    color: #bfdbfe;
}

.reply-preview-text {
    font-size: 0.78rem;
    opacity: 0.75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.reply-action-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    color: var(--text-secondary);
    font-size: 0.75rem;
    transition: var(--transition);
    z-index: 5;
}

.msg-row--own .reply-action-btn {
    left: calc(100% + 8px);
    right: auto;
}

.msg-row:not(.msg-row--own) .reply-action-btn {
    left: calc(100% + 8px);
    right: auto;
}
.msg-bubble {
    position: relative;
    user-select: none;
}

.msg-bubble--swiping {
    cursor: grabbing;
}

.swipe-reply-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    color: var(--primary-color);
    pointer-events: none;
}

.msg-row--own .swipe-reply-icon {
    right: calc(100% + 10px);
}

.msg-row:not(.msg-row--own) .swipe-reply-icon {
    left: calc(100% + 10px);
}

.reply-icon-enter-active,
.reply-icon-leave-active {
    transition: opacity 0.2s ease;
}

.reply-icon-enter-from,
.reply-icon-leave-to {
    opacity: 0;
}

.reply-action-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.replying-to-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-color);
    border-radius: 12px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    border-right: 3px solid var(--primary-color);
    gap: 0.5rem;
}

.replying-to-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.replying-icon {
    color: var(--primary-color);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.replying-to-text {
    min-width: 0;
}

.replying-to-name {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--primary-color);
    display: block;
}

.replying-to-text p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cancel-reply-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 6px;
    font-size: 0.8rem;
    flex-shrink: 0;
    transition: var(--transition);
}

.cancel-reply-btn:hover {
    color: var(--error-color);
    background: var(--error-bg);
}

/* Transitions */
.reply-btn-enter-active, .reply-btn-leave-active { transition: all 0.15s ease; }
.reply-btn-enter-from, .reply-btn-leave-to { opacity: 0; transform: translateY(-50%) scale(0.8); }

.reply-bar-enter-active, .reply-bar-leave-active { transition: all 0.2s ease; }
.reply-bar-enter-from, .reply-bar-leave-to { opacity: 0; transform: translateY(6px); max-height: 0; }
.scroll-to-bottom-btn {
    position: absolute;
    bottom: 5rem;
    left: 3rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.3s ease;
}

.scroll-to-bottom-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.scroll-to-bottom-btn i {
    font-size: 20px;
}
.msg-bubble {
    min-width: 120px;
}
@keyframes highlight-flash-received {
    0% { background-color: #ffffff; }
    20% { background-color: #dbeafe; }
    80% { background-color: #dbeafe; }
    100% { background-color: #ffffff; }
}

@keyframes highlight-flash-own {
    0% { background-color: #2563eb; }
    20% { background-color: #1d4ed8; }
    80% { background-color: #1d4ed8; }
    100% { background-color: #2563eb; }
}

.msg-highlight .msg-bubble:not(.msg-bubble--own) {
    animation: highlight-flash-received 1.5s ease;
}

.msg-highlight .msg-bubble--own {
    animation: highlight-flash-own 1.5s ease;
}

.msg-highlight .msg-bubble--own {
    animation: highlight-flash-own 1.5s ease;
}
