/* ========================================
   PREMIUM MESSAGES/DM INTERFACE REDESIGN
   ======================================== */

/* ========================================
   ANIMATIONS
   ======================================== */

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

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes typingBubble {
    0%, 60%, 100% {
        opacity: 0.5;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-10px);
    }
}

/* ========================================
   MESSAGES CONTAINER
   ======================================== */

.messages-container {
    display: flex;
    gap: 0;
    flex: 1;
    height: 100%;
    background: var(--bg-primary);
}

/* ========================================
   CONVERSATIONS PANEL
   ======================================== */

.conversations-panel {
    width: 320px;
    background: linear-gradient(180deg, rgba(26, 13, 46, 0.6), rgba(15, 1, 24, 0.8));
    border-right: 1px solid rgba(139, 92, 246, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.conversations-header {
    padding: 24px;
    border-bottom: 1px solid rgba(139, 92, 246, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.conversations-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.conversations-header .btn-icon {
    background: linear-gradient(135deg, #a78bfa, #ec4899);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-size: 20px;
}

.conversations-header .btn-icon:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.3);
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
}

.conversations-list::-webkit-scrollbar {
    width: 8px;
}

.conversations-list::-webkit-scrollbar-track {
    background: rgba(139, 92, 246, 0.05);
    border-radius: 10px;
}

.conversations-list::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.4);
    border-radius: 10px;
    border: 2px solid rgba(139, 92, 246, 0.05);
}

.conversations-list::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.6);
}

.conversations-list {
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 92, 246, 0.4) rgba(139, 92, 246, 0.05);
}

.conversation-item {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(139, 92, 246, 0.05);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: fadeInBottom 0.5s ease forwards;
    opacity: 0;
}

.conversation-item:nth-child(1) { animation-delay: 0.05s; }
.conversation-item:nth-child(2) { animation-delay: 0.1s; }
.conversation-item:nth-child(3) { animation-delay: 0.15s; }
.conversation-item:nth-child(4) { animation-delay: 0.2s; }
.conversation-item:nth-child(5) { animation-delay: 0.25s; }

.conversation-item:hover {
    background: rgba(139, 92, 246, 0.1);
    border-left: 3px solid var(--primary-color);
    padding-left: 17px;
}

.conversation-item.active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(236, 72, 153, 0.1));
    border-left: 3px solid var(--primary-color);
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
    padding-left: 17px;
}

.conversation-user {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.conversation-user img {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid rgba(139, 92, 246, 0.2);
}

.conversation-info {
    flex: 1;
    min-width: 0;
}

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

.conversation-time {
    font-size: 11px;
    color: var(--text-tertiary);
    margin: 4px 0 0 0;
}

.conversation-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 20px;
    height: 20px;
    background: var(--danger-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: white;
}

/* ========================================
   CHAT PANEL
   ======================================== */

.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

.chat-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-content::-webkit-scrollbar {
    width: 8px;
}

.chat-content::-webkit-scrollbar-track {
    background: rgba(139, 92, 246, 0.05);
    border-radius: 10px;
}

.chat-content::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.4);
    border-radius: 10px;
    border: 2px solid rgba(139, 92, 246, 0.05);
}

.chat-content::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.6);
}

.chat-content {
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 92, 246, 0.4) rgba(139, 92, 246, 0.05);
}

.no-chat-selected {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 16px;
    text-align: center;
}

.no-chat-selected p {
    margin: 0;
}

.message-group {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    animation: messageSlide 0.4s ease;
}

.message-group.own {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 60%;
}

.message-group.own .message-content {
    align-items: flex-end;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.5;
    transition: all 0.3s ease;
}

.message-bubble:hover {
    transform: translateY(-2px);
}

.message-group:not(.own) .message-bubble {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(236, 72, 153, 0.1));
    color: var(--text-primary);
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.message-group.own .message-bubble {
    background: linear-gradient(135deg, #a78bfa, #ec4899);
    color: white;
}

.message-time {
    font-size: 12px;
    color: var(--text-tertiary);
    padding: 0 4px;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(236, 72, 153, 0.1));
    border-radius: 16px;
    width: fit-content;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(139, 92, 246, 0.6);
    animation: typingBubble 1.4s infinite;
}

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

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

/* ========================================
   CHAT INPUT
   ======================================== */

.chat-input {
    padding: 20px;
    border-top: 1px solid rgba(139, 92, 246, 0.1);
    background: var(--bg-primary);
}

.chat-input.hidden {
    display: none;
}

.message-form {
    display: flex;
    gap: 12px;
    align-items: center;
}

.message-form input {
    flex: 1;
    padding: 12px 16px;
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 24px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.3s ease;
}

.message-form input::placeholder {
    color: var(--text-tertiary);
}

.message-form input:focus {
    outline: none;
    border-color: rgba(139, 92, 246, 0.4);
    background: rgba(139, 92, 246, 0.12);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.message-form .btn-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #a78bfa, #ec4899);
    border: none;
    color: white;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-size: 18px;
}

.message-form .btn-icon:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.3);
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 1024px) {
    .conversations-panel {
        width: 280px;
    }

    .message-content {
        max-width: 70%;
    }
}

@media (max-width: 768px) {
    .messages-container {
        flex-direction: column;
    }

    .conversations-panel {
        width: 100%;
        height: auto;
        max-height: 40%;
        border-right: none;
        border-bottom: 1px solid rgba(139, 92, 246, 0.1);
    }

    .conversations-list {
        max-height: 200px;
    }

    .chat-panel {
        flex: 1;
    }

    .message-content {
        max-width: 85%;
    }
}

@media (max-width: 480px) {
    .conversations-panel {
        max-height: 30%;
    }

    .conversations-list {
        max-height: 150px;
    }

    .message-content {
        max-width: 90%;
    }

    .chat-content {
        padding: 16px;
    }

    .chat-input {
        padding: 16px;
    }

    .conversations-header {
        padding: 16px;
    }

    .message-form input {
        font-size: 16px;
    }
}

/* ========================================
   MOBILE RESPONSIVE IMPROVEMENTS
   ======================================== */

@media (max-width: 768px) {
    .messages-container {
        flex-direction: column;
    }

    .conversations-panel {
        width: 100%;
        height: 200px;
        border-right: none;
        border-bottom: 1px solid rgba(139, 92, 246, 0.1);
        max-height: 200px;
    }

    .conversations-list {
        max-height: 150px;
    }

    .chat-panel {
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    .chat-content {
        max-height: calc(100vh - 300px);
        overflow-y: auto;
    }

    .message-form {
        flex-wrap: wrap;
    }

    .message-bubble {
        max-width: 85%;
        font-size: 13px;
        padding: 10px 12px;
    }

    .chat-user-name {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .conversations-panel {
        height: 160px;
    }

    .conversations-list {
        max-height: 110px;
    }

    .chat-header {
        padding: 12px;
    }

    .chat-user-pic {
        width: 32px;
        height: 32px;
    }

    .chat-content {
        max-height: calc(100vh - 260px);
        padding: 12px;
    }

    .chat-message {
        margin-bottom: 8px;
    }

    .message-sender {
        font-size: 11px;
        padding: 0 2px;
    }

    .message-bubble {
        max-width: 90%;
        font-size: 12px;
        padding: 8px 10px;
        border-radius: 12px;
    }

    .chat-input {
        padding: 12px;
    }

    .message-form {
        gap: 8px;
    }

    .message-form input {
        font-size: 14px;
        padding: 10px;
    }

    .btn-icon {
        width: 32px;
        height: 32px;
        min-width: 32px;
    }

    .emoji-btn {
        width: 32px;
        height: 32px;
    }

    .conversation-item {
        padding: 12px;
    }

    .conversation-avatar {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }

    .conversation-info h4 {
        font-size: 12px;
    }

    .conversation-info p {
        font-size: 11px;
    }
}
