/* ====================================
   ZIKA - MESSAGES (Style Instagram DM)
   ==================================== */

.messages-container {
    display: grid;
    grid-template-columns: 450px 1fr;
    height: calc(100vh - 140px);
    margin: 1rem auto;
    max-width: 1600px;
    background: var(--bg-card, #1a1a1a);
    border: 1px solid var(--border, #2a2a2a);
    border-radius: 16px;
    overflow: hidden;
}

/* Sidebar conversations */
.messages-sidebar {
    border-right: 1px solid var(--border, #2a2a2a);
    display: flex;
    flex-direction: column;
}

.messages-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border, #2a2a2a);
}

.messages-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
}

.empty-conversations {
    padding: 3rem 2rem;
    text-align: center;
    color: #808080;
}

.empty-conversations i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.conversation-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.conversation-item.active {
    background: rgba(0, 255, 0, 0.1);
    border-left: 3px solid #00ff00;
}

.conversation-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.conversation-info {
    flex: 1;
    min-width: 0;
}

.conversation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

.conversation-header h4 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-badge {
    background: #00ff00;
    color: #000;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.conversation-preview {
    margin: 0;
    font-size: 0.85rem;
    color: #808080;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Zone de chat */
.messages-chat-area {
    display: flex;
    flex-direction: column;
    position: relative;
}

.empty-chat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #808080;
}

.empty-chat i {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    opacity: 0.3;
}

.empty-chat h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.5rem;
    color: white;
}

/* Header du chat */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border, #2a2a2a);
}

.chat-back-btn {
    display: none;
    margin-right: 0.5rem;
}

.chat-header-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 8px;
    padding: 0.5rem;
    margin: -0.5rem;
}

.chat-header-user:hover {
    background: rgba(255, 255, 255, 0.05);
}

.chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
}

/* Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto !important;
    overflow-x: hidden;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    -webkit-overflow-scrolling: touch;
}

.empty-messages {
    text-align: center;
    padding: 3rem 2rem;
    color: #808080;
}

.message {
    display: flex;
    gap: 0.75rem;
    max-width: 70%;
}

.message-mine {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-theirs {
    align-self: flex-start;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.message-bubble {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.75rem 1rem;
    border-radius: 18px;
    word-wrap: break-word;
}

.message-mine .message-bubble {
    background: #00cc00;
    color: #000;
}

.message-mine .message-bubble p {
    color: #000 !important;
}

.message-bubble p {
    margin: 0;
    color: white;
    font-size: 0.95rem;
    line-height: 1.4;
}

.message-time {
    display: block;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 0.25rem;
}

/* Input zone */
.chat-input-area {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border, #2a2a2a);
    background: rgba(0, 0, 0, 0.2);
}

#message-form {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 0.85rem 1.25rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    color: white;
    font-size: 16px;
    font-family: inherit;
}

.chat-input:focus {
    outline: none;
    border-color: #00ff00;
    background: rgba(255, 255, 255, 0.08);
}

.chat-input::placeholder {
    color: #808080;
}

.btn-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Scrollbar */
.conversations-list::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.conversations-list::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.conversations-list::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

/* Responsive Mobile - Redesign complet */
@media (max-width: 768px) {
    .messages-container {
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        bottom: 70px;
        margin: 0;
        border-radius: 0;
        border: none;
        background: var(--bg-dark, #0a0a0a);
        display: block;
        height: auto;
        max-width: 100%;
    }
    
    /* Sidebar conversations mobile */
    .messages-sidebar {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        display: flex;
        flex-direction: column;
        background: var(--bg-dark, #0a0a0a);
        z-index: 10;
    }
    
    .messages-sidebar.hide {
        display: none;
    }
    
    .conversations-list {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Zone de chat mobile */
    .messages-chat-area {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        display: none;
        flex-direction: column;
        background: var(--bg-dark, #0a0a0a);
        z-index: 20;
    }
    
    .messages-chat-area.show {
        display: flex;
    }
    
    /* Header chat mobile */
    .chat-header {
        flex-shrink: 0;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--border, #2a2a2a);
        background: var(--bg-card, #1a1a1a);
    }
    
    .chat-back-btn {
        display: flex !important;
        width: 36px;
        height: 36px;
        margin-right: 0.5rem;
    }
    
    .chat-header-user {
        flex: 1;
        padding: 0;
        margin: 0;
        gap: 0.75rem;
    }
    
    .chat-avatar {
        width: 36px;
        height: 36px;
    }
    
    .chat-header h3 {
        font-size: 1rem;
    }
    
    /* Cacher le bouton fermer */
    .chat-header > .btn-icon:last-child {
        display: none !important;
    }
    
    /* Messages scrollables */
    .chat-messages {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 1rem;
        display: block;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    
    .message {
        max-width: 85%;
        margin-bottom: 1rem;
        display: flex;
        gap: 0.5rem;
    }
    
    .message-mine {
        margin-left: auto;
        flex-direction: row-reverse;
    }
    
    .message-theirs {
        margin-right: auto;
    }
    
    /* Input fixé en bas */
    .chat-input-area {
        flex-shrink: 0;
        padding: 0.75rem 1rem;
        background: var(--bg-card, #1a1a1a);
        border-top: 1px solid var(--border, #2a2a2a);
    }
    
    #message-form {
        display: flex;
        gap: 0.5rem;
    }
    
    .chat-input {
        flex: 1;
        padding: 0.75rem 1rem;
        font-size: 16px;
        border-radius: 20px;
    }
    
    .btn-send {
        width: 40px;
        height: 40px;
        flex-shrink: 0;
    }
}

@media (max-width: 480px) {
    .messages-container {
        top: 70px;
        bottom: 70px;
    }
    
    .conversation-avatar {
        width: 48px;
        height: 48px;
    }
    
    .chat-avatar {
        width: 32px;
        height: 32px;
    }
    
    .messages-header {
        padding: 1rem;
    }
    
    .messages-header h2 {
        font-size: 1.1rem;
    }
}

.text-small {
    font-size: 0.85rem;
    color: #808080;
    margin: 0;
}
