/* =====================================================
   LATINBOOK - MESSAGES MODERN CSS
   Modern Messenger/Instagram Style Chat Interface
   ===================================================== */

/* ===== MAIN CONTAINER ===== */
.messages-container-modern {
    display: flex;
    height: calc(100vh - 80px);
    max-height: 900px;
    background: var(--bg-secondary);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border-color);
}

/* ===== SIDEBAR (LEFT PANEL) ===== */
.messages-sidebar {
    width: 380px;
    min-width: 380px;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
}

/* Sidebar Header */
.messages-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.messages-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.messages-title i {
    font-size: 26px;
    animation: pulseIcon 2s ease-in-out infinite;
}

@keyframes pulseIcon {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.btn-new-message {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.btn-new-message:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.08) rotate(5deg);
    box-shadow: 0 4px 16px rgba(255, 255, 255, 0.3);
}

/* Search Bar */
.messages-search-container {
    position: relative;
    padding: 16px 20px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

.messages-search-icon {
    position: absolute;
    left: 34px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 15px;
    pointer-events: none;
}

.messages-search-input {
    width: 100%;
    padding: 12px 40px 12px 40px;
    border: 2px solid var(--border-color);
    border-radius: 24px;
    font-size: 14px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.messages-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-primary);
    box-shadow: 0 0 0 4px rgba(255, 73, 108, 0.1);
}

.messages-search-clear {
    position: absolute;
    right: 32px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--text-secondary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: all 0.2s ease;
}

.messages-search-clear:hover {
    background: var(--text-primary);
    transform: translateY(-50%) scale(1.1);
}

/* Filter Tabs */
.messages-filter-tabs {
    display: flex;
    gap: 8px;
    padding: 16px 20px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}

.messages-filter-tab {
    padding: 8px 16px;
    border-radius: 20px;
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    position: relative;
}

.messages-filter-tab i {
    font-size: 14px;
}

.messages-filter-tab.active {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(255, 73, 108, 0.25);
}

.messages-filter-tab:hover:not(.active) {
    border-color: var(--primary-color);
    background: var(--bg-primary);
    transform: translateY(-2px);
}

.filter-badge {
    background: white;
    color: var(--primary-color);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    margin-left: 4px;
}

.messages-filter-tab.active .filter-badge {
    background: rgba(255, 255, 255, 0.95);
    color: var(--primary-color);
}

/* Conversations List */
.messages-conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    background: var(--bg-primary);
}

.conversation-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    border-left: 3px solid transparent;
}

.conversation-item:hover {
    background: var(--bg-secondary);
}

.conversation-item.active {
    background: var(--bg-secondary);
    border-left-color: var(--primary-color);
}

.conversation-item.unread {
    background: var(--bg-hover);
}

.conversation-avatar-container {
    position: relative;
    margin-right: 14px;
    flex-shrink: 0;
}

.conversation-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--bg-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.conversation-item.unread .conversation-avatar {
    border-color: var(--primary-color);
}

.online-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #00D936;
    border: 3px solid var(--bg-primary);
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(0, 217, 54, 0.2);
    animation: onlinePulse 2s ease-in-out infinite;
}

@keyframes onlinePulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(0, 217, 54, 0.2); }
    50% { box-shadow: 0 0 0 4px rgba(0, 217, 54, 0.4); }
}

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

.conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.conversation-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.conversation-item.unread .conversation-name {
    color: var(--primary-color);
}

.verified-badge-small {
    font-size: 13px;
    color: var(--accent-color);
}

.conversation-time {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.conversation-item.unread .conversation-time {
    color: var(--primary-color);
    font-weight: 700;
}

.conversation-preview {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.conversation-item.unread .conversation-preview {
    color: var(--text-primary);
    font-weight: 600;
}

.unread-badge {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(255, 73, 108, 0.4);
    animation: bounce 0.5s ease infinite alternate;
}

@keyframes bounce {
    from { transform: translateY(calc(-50% - 2px)); }
    to { transform: translateY(calc(-50% + 2px)); }
}

.important-indicator {
    color: #FFD700;
    font-size: 14px;
    margin-left: 4px;
}

/* Empty State */
.messages-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    padding: 40px;
    text-align: center;
}

.messages-empty-state i {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.messages-empty-state p {
    font-size: 15px;
    margin: 0;
}

/* ===== CHAT PANEL (RIGHT PANEL) ===== */
.messages-chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    position: relative;
}

/* Welcome State */
.messages-welcome-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
}

.welcome-icon {
    width: 120px;
    height: 120px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    box-shadow: 0 12px 40px rgba(255, 73, 108, 0.3);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.welcome-icon i {
    font-size: 56px;
    color: white;
}

.messages-welcome-state h3 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 12px 0;
}

.messages-welcome-state p {
    font-size: 16px;
    color: var(--text-secondary);
    margin: 0 0 28px 0;
    max-width: 380px;
}

.btn-send-message-cta {
    padding: 14px 32px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    border: none;
    border-radius: 28px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 24px rgba(255, 73, 108, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-send-message-cta:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(255, 73, 108, 0.4);
}

/* Chat View */
.messages-chat-view {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Chat Header */
.messages-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    position: relative;
}

.chat-header-user {
    display: flex;
    align-items: center;
    gap: 14px;
}

.btn-back-mobile {
    display: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-back-mobile:hover {
    background: var(--bg-hover);
}

.chat-header-avatar-container {
    position: relative;
}

.chat-header-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.chat-header-info {
    display: flex;
    flex-direction: column;
}

.chat-header-name {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.chat-header-status {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.chat-action-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-action-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: scale(1.08);
}

/* Chat Messages */
.messages-chat-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message-group.received {
    align-items: flex-start;
}

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

.message-bubble {
    max-width: 65%;
    padding: 12px 16px;
    border-radius: 20px;
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
    animation: messageSlideIn 0.3s ease;
}

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

.message-group.received .message-bubble {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.message-group.sent .message-bubble {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(255, 73, 108, 0.25);
}

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

.message-group.sent .message-time {
    text-align: right;
}

.message-image {
    max-width: 300px;
    border-radius: 16px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.message-image:hover {
    transform: scale(1.02);
}

.date-separator {
    text-align: center;
    margin: 24px 0 16px 0;
    position: relative;
}

.date-separator span {
    background: var(--bg-primary);
    padding: 6px 16px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Chat Input */
.messages-chat-input {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 16px 24px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}

.chat-input-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-input-btn:hover {
    background: var(--bg-hover);
    color: var(--primary-color);
    transform: scale(1.08);
}

.chat-input-field-container {
    flex: 1;
    position: relative;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 24px;
    padding: 10px 48px 10px 16px;
    transition: all 0.3s ease;
}

.chat-input-field-container:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(255, 73, 108, 0.1);
}

.chat-input-field {
    width: 100%;
    max-height: 120px;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 15px;
    resize: none;
    font-family: inherit;
}

.chat-input-emoji {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.chat-input-emoji:hover {
    transform: translateY(-50%) scale(1.15);
}

.chat-send-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(255, 73, 108, 0.3);
}

.chat-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 16px rgba(255, 73, 108, 0.4);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: scale(1);
}

/* Emoji Picker */
.emoji-picker {
    position: absolute;
    bottom: 100%;
    right: 24px;
    width: 340px;
    height: 380px;
    background: var(--bg-primary);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    animation: emojiPickerSlideUp 0.3s ease;
}

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

.emoji-picker-header {
    display: flex;
    gap: 4px;
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}

.emoji-category {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.emoji-category:hover {
    background: var(--bg-secondary);
}

.emoji-category.active {
    background: var(--primary-color);
    color: white;
}

.emoji-picker-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    align-content: start;
}

.emoji-item {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.emoji-item:hover {
    background: var(--bg-secondary);
    transform: scale(1.2);
}

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

/* Tablet */
@media (max-width: 1024px) {
    .messages-container-modern {
        height: calc(100vh - 70px);
    }

    .messages-sidebar {
        width: 320px;
        min-width: 320px;
    }

    .conversation-avatar {
        width: 48px;
        height: 48px;
    }

    .emoji-picker {
        width: 300px;
        height: 340px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .messages-container-modern {
        height: calc(100vh - 60px);
        border-radius: 0;
    }

    .messages-sidebar {
        width: 100%;
        min-width: 100%;
    }

    .messages-sidebar.hidden-mobile {
        display: none;
    }

    .messages-chat-panel.hidden-mobile {
        display: none;
    }

    .btn-back-mobile {
        display: flex;
    }

    .chat-header-actions {
        gap: 4px;
    }

    .chat-action-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .message-bubble {
        max-width: 80%;
    }

    .emoji-picker {
        width: calc(100% - 48px);
        left: 24px;
        right: 24px;
    }

    .messages-chat-input {
        gap: 6px;
        padding: 12px 16px;
    }

    .chat-input-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .chat-send-btn {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .messages-sidebar-header {
        padding: 16px 18px;
    }

    .messages-title {
        font-size: 20px;
    }

    .messages-filter-tabs {
        padding: 12px 16px;
    }

    .conversation-item {
        padding: 12px 16px;
    }

    .conversation-avatar {
        width: 44px;
        height: 44px;
    }

    .conversation-name {
        font-size: 14px;
    }

    .conversation-preview {
        font-size: 13px;
    }

    .messages-chat-header {
        padding: 12px 16px;
    }

    .chat-header-avatar {
        width: 42px;
        height: 42px;
    }

    .chat-header-name {
        font-size: 16px;
    }

    .messages-chat-content {
        padding: 16px;
    }

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

/* Dark Mode Enhancements */
[data-theme="dark"] .messages-sidebar-header {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .conversation-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .message-group.received .message-bubble {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .emoji-picker {
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
}

/* Scrollbar Styling */
.messages-conversations-list::-webkit-scrollbar,
.messages-chat-content::-webkit-scrollbar,
.emoji-picker-body::-webkit-scrollbar {
    width: 6px;
}

.messages-conversations-list::-webkit-scrollbar-thumb,
.messages-chat-content::-webkit-scrollbar-thumb,
.emoji-picker-body::-webkit-scrollbar-thumb {
    background: var(--text-secondary);
    border-radius: 10px;
}

.messages-conversations-list::-webkit-scrollbar-thumb:hover,
.messages-chat-content::-webkit-scrollbar-thumb:hover,
.emoji-picker-body::-webkit-scrollbar-thumb:hover {
    background: var(--text-primary);
}
