/* css/messenger.css — MiChat Application Layout and Interactive Chat Styling */

.messenger-container {
    display: flex;
    width: 100%;
    height: 100%;
    background: #0f172a;
}

/* --- CONTACTS SIDEBAR --- */
.messenger-sidebar {
    width: 250px;
    background: #131b2e;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.messenger-sidebar-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #38bdf8;
    letter-spacing: 1px;
    font-family: var(--font-retro);
}

.contact-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    transition: background 0.15s, transform 0.1s;
    position: relative;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

.contact-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.contact-item:active {
    background: rgba(56, 189, 248, 0.18);
    transform: scale(0.98);
}

.contact-item.active {
    background: rgba(56, 189, 248, 0.12);
    border-left: 3px solid #38bdf8;
}

.contact-avatar-wrapper {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.contact-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    image-rendering: pixelated;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid #131b2e;
}

.status-dot.online {
    background-color: var(--accent-green);
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
}

.status-dot.away {
    background-color: #64748b;
}

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

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

.contact-title {
    font-size: 0.75rem;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-badge {
    background: var(--accent-red);
    color: #fff;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 2px 7px;
    border-radius: 10px;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
}

/* --- CHAT MAIN COLUMN --- */
.messenger-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0b1120;
}

.chat-header {
    height: 58px;
    padding: 0 18px;
    border-bottom: 1px solid var(--border-color);
    background: #111a2e;
    display: flex;
    align-items: center;
    gap: 14px;
}

.header-avatar-wrap {
    position: relative;
    width: 38px;
    height: 38px;
}

.header-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    image-rendering: pixelated;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.header-details {
    display: flex;
    flex-direction: column;
}

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

.header-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- MESSAGE BUBBLES --- */
.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.chat-bubble-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    max-width: 80%;
    animation: bubbleSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.chat-bubble-row.received {
    align-self: flex-start;
}

.chat-bubble-row.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.bubble-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    image-rendering: pixelated;
}

.chat-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-bubble-row.received .chat-bubble {
    background: #1e293b;
    border: 1px solid var(--border-color);
    color: #f1f5f9;
    border-bottom-left-radius: 3px;
}

.chat-bubble-row.sent .chat-bubble {
    background: linear-gradient(135deg, #0284c7, #0369a1);
    color: #fff;
    border-bottom-right-radius: 3px;
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.25);
}

.bubble-text {
    font-size: 0.9rem;
    line-height: 1.4;
    word-break: break-word;
}

.bubble-time {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.5);
    align-self: flex-end;
    font-family: var(--font-retro);
}

/* --- ATTACHMENT CARD --- */
.chat-attachment-card {
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border: 2px solid #38bdf8;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5), 0 0 10px rgba(56, 189, 248, 0.25);
    border-radius: 10px;
    padding: 16px;
    width: 270px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.attachment-badge {
    font-size: 0.75rem;
    font-weight: 700;
    color: #38bdf8;
    letter-spacing: 1px;
}

.attachment-title {
    font-size: 0.95rem;
    font-weight: bold;
    color: #f8fafc;
    font-family: var(--font-retro);
}

.attachment-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.attachment-btn {
    background: linear-gradient(135deg, #0284c7, #0ea5e9);
    color: #fff;
    font-weight: 800;
    border: none;
    border-radius: 6px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 0.85rem;
    letter-spacing: 1px;
    transition: transform 0.15s, box-shadow 0.2s;
    margin-top: 4px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.attachment-btn:hover {
    transform: scale(1.03);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.6);
}

.attachment-btn:active, .attachment-btn.touch-active {
    transform: scale(0.95);
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
    background: linear-gradient(135deg, #0369a1, #0284c7);
}

/* --- VOICE MESSAGE BUBBLE --- */
.voice-message-bubble {
    background: linear-gradient(135deg, #1e293b, #0f172a) !important;
    border: 1.5px solid rgba(56, 189, 248, 0.45) !important;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45), 0 0 10px rgba(56, 189, 248, 0.2);
    padding: 12px 14px !important;
    min-width: 250px;
    max-width: 320px;
}

.voice-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 8px;
}

.voice-badge {
    font-size: 0.72rem;
    font-weight: 800;
    color: #38bdf8;
    letter-spacing: 0.5px;
    font-family: var(--font-retro);
}

.voice-file-pill {
    font-size: 0.68rem;
    color: #94a3b8;
    background: rgba(15, 23, 42, 0.6);
    padding: 2px 7px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.voice-msg-player {
    display: flex;
    align-items: center;
    gap: 10px;
}

.voice-play-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0284c7, #38bdf8);
    border: none;
    color: #fff;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.4);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.12s, box-shadow 0.15s, background 0.15s;
}

.voice-play-btn:active, .voice-play-btn.touch-active {
    transform: scale(0.92);
    box-shadow: 0 2px 6px rgba(56, 189, 248, 0.6);
    background: linear-gradient(135deg, #0369a1, #0284c7);
}

.voice-waveform-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    cursor: pointer;
    padding: 2px 0;
}

.voice-waveform-bars {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 24px;
}

.v-bar {
    flex: 1;
    background: rgba(56, 189, 248, 0.45);
    border-radius: 2px;
    min-width: 3px;
    transition: height 0.15s ease, background 0.2s ease;
}

.voice-waveform-wrap.playing .v-bar {
    background: #38bdf8;
    animation: wavePulse 0.5s ease-in-out infinite alternate;
}

.voice-waveform-wrap.playing .v-bar:nth-child(2n) {
    animation-delay: 0.1s;
    animation-duration: 0.4s;
}
.voice-waveform-wrap.playing .v-bar:nth-child(3n) {
    animation-delay: 0.2s;
    animation-duration: 0.6s;
}
.voice-waveform-wrap.playing .v-bar:nth-child(4n) {
    animation-delay: 0.15s;
    animation-duration: 0.45s;
}

@keyframes wavePulse {
    from { transform: scaleY(0.6); }
    to { transform: scaleY(1.3); }
}

.voice-progress-track {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.voice-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #0284c7, #38bdf8);
    border-radius: 2px;
    transition: width 0.08s linear;
}

.voice-duration {
    font-size: 0.72rem;
    font-family: var(--font-retro);
    color: #e2e8f0;
    font-weight: 600;
    min-width: 32px;
    text-align: right;
}

/* --- TYPING INDICATOR --- */
.chat-typing-indicator {
    padding: 8px 20px;
    display: none;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

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

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingBounce 1.2s infinite ease-in-out;
}

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

@keyframes typingBounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-5px); background: var(--accent-blue); }
}

/* --- PLAYER REPLY CHOICES --- */
.chat-choices-area {
    padding: 14px 20px;
    border-top: 1px solid var(--border-color);
    background: #111a2e;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 65px;
    align-items: center;
}

.choice-btn {
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid var(--accent-blue);
    color: var(--text-primary);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

.choice-btn:hover {
    background: var(--accent-blue);
    color: #000;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
    transform: translateY(-2px);
}

.choice-btn:active, .choice-btn.touch-active {
    transform: scale(0.95);
    background: rgba(56, 189, 248, 0.3);
    border-color: #38bdf8;
    color: #fff;
}

/* Mobile Back Button */
.chat-mobile-back-btn {
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid var(--border-color);
    color: #38bdf8;
    border-radius: 6px;
    padding: 6px 12px;
    min-height: 34px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    margin-right: 6px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s, background 0.1s;
}

.chat-mobile-back-btn:active {
    transform: scale(0.94);
    background: rgba(56, 189, 248, 0.25);
}
    flex-shrink: 0;
    transition: background 0.15s;
}

.chat-mobile-back-btn:hover {
    background: rgba(56, 189, 248, 0.2);
}

/* ============================================================ */
/* MOBILE PHONE OPTIMIZATION (@media max-width: 768px)          */
/* ============================================================ */
@media (max-width: 768px) {
    .messenger-container {
        position: relative;
        overflow: hidden;
    }

    /* By default on mobile, show contacts list full width */
    .messenger-sidebar {
        width: 100% !important;
        border-right: none;
        display: flex !important;
    }

    .messenger-main {
        display: none !important;
        width: 100% !important;
    }

    /* When mobile-show-chat is active, hide sidebar and show chat full width */
    .messenger-container.mobile-show-chat .messenger-sidebar {
        display: none !important;
    }

    .messenger-container.mobile-show-chat .messenger-main {
        display: flex !important;
        width: 100% !important;
    }

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

    .chat-header {
        height: 52px;
        padding: 0 10px;
        gap: 8px;
    }

    .header-name {
        font-size: 0.9rem;
    }

    .header-sub {
        font-size: 0.7rem;
    }

    .chat-messages-container {
        padding: 12px 10px;
        gap: 12px;
    }

    .chat-bubble {
        max-width: 84%;
        padding: 10px 12px;
    }

    .bubble-text {
        font-size: 0.86rem;
    }

    .chat-choices-area {
        padding: 10px 12px;
        gap: 8px;
        min-height: 52px;
    }

    .choice-btn {
        padding: 8px 14px;
        font-size: 0.82rem;
    }

    .chat-attachment-card {
        max-width: 86%;
        padding: 12px 14px;
    }

    .voice-message-bubble {
        min-width: 220px !important;
        max-width: 88% !important;
        padding: 10px 12px !important;
    }

    .voice-play-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
        font-size: 1.05rem;
    }

    .voice-waveform-bars {
        height: 20px;
    }
}
