/* ============================================
   CHATRENCONTRE - Chat CSS
   Styles pour la messagerie privée
   ============================================ */

/* Chat Fullscreen Mode */
.chat-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: #0a0a0a;
    padding: 0 !important;
}

.chat-fullscreen .chat-window {
    height: 100vh;
    height: 100dvh;
    max-height: none;
}

/* Chat Container */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: calc(100vh - 120px);
    max-height: calc(100dvh - 120px);
}

/* Conversations List */
.conversations-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    background: transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.conversation-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.conversation-item.active {
    background: rgba(230, 57, 70, 0.1);
}

.conversation-item.unread::after {
    content: '';
    position: absolute;
    right: 1rem;
    width: 8px;
    height: 8px;
    background: #e63946;
    border-radius: 50%;
}

.conversation-avatar {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(135deg, #252525, #1a1a1a);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.125rem;
    color: rgba(255, 255, 255, 0.8);
    flex-shrink: 0;
    overflow: hidden;
}

.conversation-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.conversation-avatar.online::before {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border: 2px solid #0f0f0f;
    border-radius: 50%;
}

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

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

.conversation-name {
    font-weight: 600;
    font-size: 0.9375rem;
    color: #fff;
}

.conversation-time {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
}

.conversation-preview {
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
}

.conversation-preview.unread {
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

/* Chat Window */
.chat-window {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    background: #0a0a0a;
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    padding-top: max(0.875rem, env(safe-area-inset-top));
    background: rgba(10, 10, 10, 0.98);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.chat-back-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: 12px;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-back-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.chat-back-btn:active {
    transform: scale(0.95);
}

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

.chat-user-name {
    font-weight: 600;
    font-size: 1rem;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-user-status {
    font-size: 0.75rem;
    color: #22c55e;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.chat-user-status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #22c55e;
    border-radius: 50%;
    animation: pulse-online 2s ease-in-out infinite;
}

@keyframes pulse-online {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-user-status.offline {
    color: rgba(255, 255, 255, 0.4);
}

.chat-user-status.offline::before {
    background: rgba(255, 255, 255, 0.3);
    animation: none;
}

.chat-header-actions {
    display: flex;
    gap: 0.5rem;
}

.chat-action-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-action-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.chat-action-btn.danger:hover {
    background: rgba(230, 57, 70, 0.1);
    color: #e63946;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: linear-gradient(180deg, #0a0a0a 0%, #0f0f0f 100%);
    -webkit-overflow-scrolling: touch;
}

/* Message Bubble */
.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: message-appear 0.2s ease-out;
}

@keyframes message-appear {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.sent {
    align-self: flex-end;
}

.message.received {
    align-self: flex-start;
}

.message-bubble {
    padding: 0.625rem 0.875rem;
    border-radius: 18px;
    font-size: 0.9375rem;
    line-height: 1.45;
    word-wrap: break-word;
}

.message.sent .message-bubble {
    background: linear-gradient(135deg, #e63946 0%, #c62828 100%);
    color: #fff;
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 8px -2px rgba(230, 57, 70, 0.3);
}

.message.received .message-bubble {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-bottom-left-radius: 6px;
}

.message-time {
    font-size: 0.6875rem;
    color: rgba(255, 255, 255, 0.35);
    margin-top: 0.25rem;
    padding: 0 0.125rem;
}

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

.message.received .message-time {
    text-align: left;
}

.message-status {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 0.25rem;
}

.message-status.read {
    color: #22c55e;
}

/* Date Separator */
.chat-date-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 0;
    margin: 0.5rem 0;
}

.chat-date-separator span {
    padding: 0.375rem 0.75rem;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    font-size: 0.6875rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.45);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Chat Input */
.chat-input-container {
    padding: 0.75rem 1rem;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    background: rgba(10, 10, 10, 0.98);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 0.375rem 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    transition: border-color 0.2s ease;
}

.chat-input-wrapper:focus-within {
    border-color: rgba(230, 57, 70, 0.4);
}

.chat-input-actions {
    display: flex;
    gap: 0.25rem;
}

.chat-input-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-input-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.7);
}

.chat-input {
    flex: 1;
    min-height: 40px;
    max-height: 120px;
    padding: 0.625rem 0.25rem;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1rem;
    line-height: 1.4;
    resize: none;
}

.chat-input::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.chat-input:focus {
    outline: none;
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e63946 0%, #c62828 100%);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
    margin: -0.125rem -0.125rem -0.125rem 0;
}

.chat-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 20px -4px rgba(230, 57, 70, 0.6);
}

.chat-send-btn:active:not(:disabled) {
    transform: scale(0.92);
}

.chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.1);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.5);
}

.typing-dots {
    display: flex;
    gap: 3px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

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

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

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* Anonymous Chat Badge */
.anonymous-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 6px;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #a78bfa;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Empty Chat State */
.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
}

.chat-empty-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: 0.2;
}

.chat-empty-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 0.5rem;
}

.chat-empty-text {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.4);
    max-width: 250px;
}

/* Mobile Layout */
@media (max-width: 767px) {
    .chat-messages {
        padding: 0.75rem 0.625rem;
    }
    
    .message {
        max-width: 88%;
    }
    
    .chat-header {
        padding: 0.75rem;
        padding-top: max(0.75rem, env(safe-area-inset-top));
    }
    
    .chat-input-container {
        padding: 0.625rem 0.75rem;
        padding-bottom: max(0.625rem, env(safe-area-inset-bottom));
    }

    .chat-input-actions {
        display: none;
    }
    
    .chat-action-btn:not(.chat-back-btn) {
        display: none;
    }
}

/* ============================================
   Social Links Badges in Messages
   ============================================ */

/* Snapchat Badge */
.social-badge-snapchat {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    margin: 0.25rem 0.125rem;
    background: #FFFC00;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #000;
    text-decoration: none;
    transition: all 0.2s ease;
    vertical-align: middle;
}

.social-badge-snapchat:hover {
    background: #e6e300;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px -2px rgba(255, 252, 0, 0.4);
}

.social-badge-snapchat svg {
    width: 16px;
    height: 16px;
}

/* Telegram Badge */
.social-badge-telegram {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    margin: 0.25rem 0.125rem;
    background: #0088cc;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #fff;
    text-decoration: none;
    transition: all 0.2s ease;
    vertical-align: middle;
}

.social-badge-telegram:hover {
    background: #0077b3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px -2px rgba(0, 136, 204, 0.4);
}

.social-badge-telegram svg {
    width: 16px;
    height: 16px;
}

/* External link icon in badges */
.social-badge-external {
    opacity: 0.7;
    margin-left: 0.125rem;
}

/* Message bubble with social links */
.message-bubble a {
    text-decoration: none;
}

.message-bubble a:hover {
    text-decoration: none;
}

/* Wrap social badges nicely */
.message-bubble {
    word-break: break-word;
}

/* Make badges stand out in sent messages too */
.message.sent .message-bubble a {
    box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.3);
}

/* ============================================
   Media in Messages (Images & Videos)
   ============================================ */

/* Media dans les bulles de message */
.message-media {
    margin: -0.375rem -0.5rem 0.5rem;
    border-radius: 14px 14px 4px 4px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
}

.message.sent .message-media {
    border-radius: 14px 14px 4px 14px;
}

.message.received .message-media {
    border-radius: 14px 14px 14px 4px;
}

/* Si le message n'a pas de texte */
.message-bubble:has(.message-media):not(:has(span:not(:empty))) .message-media {
    margin-bottom: -0.25rem;
}

.message-media-content {
    width: 100%;
    max-width: 280px;
    max-height: 360px;
    object-fit: cover;
    display: block;
    transition: transform 0.2s ease;
}

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

/* Container vidéo avec overlay de lecture */
.message-video-container {
    position: relative;
    display: inline-block;
}

.video-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    transition: background 0.2s ease;
}

.message-media:hover .video-play-overlay {
    background: rgba(0, 0, 0, 0.5);
}

.video-play-overlay svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* ============================================
   Media Preview (avant envoi)
   ============================================ */

.media-preview-container {
    padding: 0.75rem 1rem;
    background: rgba(10, 10, 10, 0.98);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
}

.media-preview-content {
    position: relative;
    display: inline-block;
    max-width: 200px;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(230, 57, 70, 0.4);
    box-shadow: 0 4px 20px -4px rgba(230, 57, 70, 0.3);
}

.media-preview-content img,
.media-preview-content video {
    max-width: 200px;
    max-height: 200px;
    display: block;
    object-fit: cover;
}

.media-preview-remove {
    position: absolute;
    top: 0.375rem;
    right: 0.375rem;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
}

.media-preview-remove:hover {
    background: rgba(230, 57, 70, 0.8);
    transform: scale(1.1);
}

.media-preview-name {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   Media Fullscreen Viewer
   ============================================ */

.media-fullscreen-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.media-fullscreen-close {
    position: absolute;
    top: max(1rem, env(safe-area-inset-top));
    right: 1rem;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}

.media-fullscreen-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.media-fullscreen-content {
    max-width: 95vw;
    max-height: 90vh;
    animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.media-fullscreen-content img {
    max-width: 95vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 40px -8px rgba(0, 0, 0, 0.6);
}

.media-fullscreen-content video {
    max-width: 95vw;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 8px 40px -8px rgba(0, 0, 0, 0.6);
}

/* ============================================
   Mobile Adjustments for Media
   ============================================ */

@media (max-width: 767px) {
    .message-media-content {
        max-width: 240px;
        max-height: 300px;
    }
    
    .media-preview-content img,
    .media-preview-content video {
        max-width: 150px;
        max-height: 150px;
    }
    
    .media-preview-content {
        max-width: 150px;
    }
    
    .media-preview-name {
        max-width: 150px;
    }
    
    /* Afficher le bouton média sur mobile */
    .chat-input-actions {
        display: flex !important;
    }
    
    .chat-input-actions .chat-input-btn:first-child {
        display: flex !important;
    }
    
    /* Cacher le bouton album sur mobile si nécessaire */
    .chat-input-actions .chat-input-btn:nth-child(2) {
        display: none;
    }
}

