/* Facebook Messenger — visual mobile */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --fb-blue: #0084ff;
    --fb-blue-hover: #006fd6;
    --fb-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --chat-bg: #ffffff;
    --chat-header-bg: #ffffff;
    --chat-border: #e4e6eb;
    --chat-text: #050505;
    --chat-text-secondary: #65676b;
    --chat-bubble-in: #e4e6eb;
    --chat-bubble-out: #0084ff;
    --chat-bubble-out-text: #ffffff;
    --chat-input-bg: #f0f2f5;
    --chat-input-placeholder: #65676b;
    --chat-icon: #050505;
    --chat-active: #31a24c;
    --chat-btn-border: #ccd0d5;
    --chat-btn-text: #0084ff;
    --chat-composer-bg: #ffffff;
}

html, body {
    height: 100%;
    overflow: hidden;
}

.messenger-page {
    background: #f0f2f5;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    font-family: var(--fb-font);
    -webkit-font-smoothing: antialiased;
}

.messenger-app {
    width: 100%;
    max-width: 430px;
    height: 100vh;
    height: 100dvh;
    background: var(--chat-bg);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.08);
}

/* ===== Header ===== */
.messenger-header {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 4px 6px 0;
    border-bottom: 1px solid var(--chat-border);
    background: var(--chat-header-bg);
    flex-shrink: 0;
    min-height: 56px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.messenger-header-back {
    color: var(--fb-blue);
    width: 40px;
    height: 40px;
}

.messenger-header-back svg { width: 22px; height: 22px; }

.messenger-header-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.messenger-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.messenger-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.messenger-avatar-ph {
    background: linear-gradient(135deg, #0084ff, #44bec7);
}

.messenger-online-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 11px;
    height: 11px;
    background: #31a24c;
    border: 2px solid #fff;
    border-radius: 50%;
}

.chat-header-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--chat-text);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.messenger-status {
    font-size: 12px;
    color: var(--chat-text-secondary);
    line-height: 1.3;
}

.messenger-status.is-active {
    color: var(--chat-active);
}

.messenger-header-actions {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.chat-header-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    color: var(--fb-blue);
    cursor: default;
    text-decoration: none;
}

.chat-header-btn.is-linked { cursor: pointer; }
.chat-header-btn.is-linked:active { opacity: 0.65; }
.chat-header-btn svg { width: 22px; height: 22px; }

.chat-header-back {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    text-decoration: none;
    flex-shrink: 0;
}

.chat-header-back.is-linked { cursor: pointer; }

/* ===== Messages ===== */
.messenger-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    background: var(--chat-bg);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    -webkit-overflow-scrolling: touch;
}

.chat-date-divider {
    text-align: center;
    margin: 12px 0 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--chat-text-secondary);
}

.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 78%;
    margin-bottom: 3px;
    animation: messengerFadeIn 0.22s ease;
}

.chat-msg-in { align-self: flex-start; }
.chat-msg-out { align-self: flex-end; }

@keyframes messengerFadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-bubble {
    background: var(--chat-bubble-in);
    padding: 8px 12px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.34;
    color: var(--chat-text);
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chat-msg-in .chat-bubble {
    border-bottom-left-radius: 4px;
}

.chat-msg-out .chat-bubble {
    background: var(--chat-bubble-out);
    color: var(--chat-bubble-out-text);
    border-bottom-right-radius: 4px;
}

.chat-media {
    max-width: 240px;
    max-height: 320px;
    border-radius: 12px;
    margin-bottom: 4px;
    object-fit: cover;
    display: block;
}

.chat-media-video {
    width: 240px;
    border-radius: 12px;
}

.chat-media-audio {
    width: 100%;
    max-width: 280px;
}

.chat-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
    width: 100%;
    min-width: 180px;
}

.chat-btn {
    background: var(--chat-bg);
    border: 1px solid var(--chat-btn-border);
    padding: 9px 14px;
    border-radius: 18px;
    font-family: var(--fb-font);
    font-size: 14px;
    font-weight: 600;
    color: var(--chat-btn-text);
    cursor: pointer;
    text-align: center;
    transition: background 0.15s;
    width: 100%;
}

.chat-btn:hover:not(:disabled) { background: #f0f2f5; }
.chat-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.chat-typing-wrap {
    align-self: flex-start;
    padding: 4px 0;
}

.chat-typing {
    display: inline-flex;
    align-items: center;
    background: var(--chat-bubble-in);
    padding: 10px 14px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
}

.typing-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.typing-dots span {
    width: 7px;
    height: 7px;
    background: #90949c;
    border-radius: 50%;
    animation: messengerBounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes messengerBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ===== Composer ===== */
.messenger-composer {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px 10px;
    border-top: 1px solid var(--chat-border);
    background: var(--chat-composer-bg);
    flex-shrink: 0;
}

.messenger-composer-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    color: var(--fb-blue);
    flex-shrink: 0;
    padding: 0;
}

.messenger-composer-btn svg { width: 22px; height: 22px; }

.messenger-composer-camera svg { width: 24px; height: 24px; }

.messenger-composer-input {
    flex: 1;
    background: var(--chat-input-bg);
    border: none;
    border-radius: 20px;
    padding: 9px 14px;
    font-family: var(--fb-font);
    font-size: 15px;
    color: var(--chat-text);
    outline: none;
    min-width: 0;
}

.messenger-composer-input::placeholder {
    color: var(--chat-input-placeholder);
}

.messenger-composer-like {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    color: var(--fb-blue);
    flex-shrink: 0;
    padding: 0;
}

.messenger-composer-like svg {
    width: 22px;
    height: 22px;
}

.messenger-brand {
    text-align: center;
    padding: 4px 8px 8px;
    font-size: 11px;
    background: var(--chat-composer-bg);
}

.messenger-brand a {
    color: var(--chat-text-secondary);
    text-decoration: none;
}

@media (max-width: 430px) {
    .messenger-page { background: var(--chat-bg); }
    .messenger-app { box-shadow: none; }
}
