/* Instagram Direct — visual fiel ao app */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --ig-blue: #0095f6;
    --ig-blue-dark: #00376b;
    --ig-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.ig-chat-light {
    --chat-bg: #ffffff;
    --chat-header-bg: #ffffff;
    --chat-border: #dbdbdb;
    --chat-text: #262626;
    --chat-text-secondary: #737373;
    --chat-bubble-in: #efefef;
    --chat-bubble-out: #0095f6;
    --chat-bubble-out-text: #ffffff;
    --chat-input-bg: #efefef;
    --chat-input-placeholder: #737373;
    --chat-icon: #262626;
    --chat-active: #0095f6;
    --chat-btn-border: #dbdbdb;
    --chat-btn-text: #0095f6;
    --chat-composer-bg: #ffffff;
}

.ig-chat-dark {
    --chat-bg: #000000;
    --chat-header-bg: #000000;
    --chat-border: #262626;
    --chat-text: #f5f5f5;
    --chat-text-secondary: #a8a8a8;
    --chat-bubble-in: #262626;
    --chat-bubble-out: #3797f0;
    --chat-bubble-out-text: #ffffff;
    --chat-input-bg: #262626;
    --chat-input-placeholder: #a8a8a8;
    --chat-icon: #f5f5f5;
    --chat-active: #3797f0;
    --chat-btn-border: #363636;
    --chat-btn-text: #3797f0;
    --chat-composer-bg: #000000;
}

html, body {
    height: 100%;
    overflow: hidden;
}

.chat-page {
    background: #000;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    font-family: var(--ig-font);
    -webkit-font-smoothing: antialiased;
}

.chat-app {
    width: 100%;
    max-width: 430px;
    height: 100vh;
    height: 100dvh;
    background: var(--chat-bg);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* ===== Header ===== */
.chat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 8px 8px 4px;
    border-bottom: 1px solid var(--chat-border);
    background: var(--chat-header-bg);
    flex-shrink: 0;
    min-height: 44px;
}

.chat-header-back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    background: none;
    color: var(--chat-icon);
    cursor: default;
    flex-shrink: 0;
    text-decoration: none;
}

.chat-header-back.is-linked {
    cursor: pointer;
}

.chat-header-back.is-linked:active {
    opacity: 0.65;
}

.chat-header-back svg { width: 24px; height: 24px; }

.chat-header-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.chat-header-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.chat-header-avatar-ring {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    padding: 2px;
    background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-header-avatar-ring .chat-header-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--chat-header-bg);
    margin: 0;
}

.chat-header-avatar-wrap > .chat-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.chat-avatar-ph {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.chat-header-info { min-width: 0; }

.chat-header-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--chat-text);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-header-status {
    font-size: 12px;
    color: var(--chat-text-secondary);
    line-height: 1.3;
}

.chat-header-status.is-active {
    color: var(--chat-active);
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
}

.chat-header-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    background: none;
    color: var(--chat-icon);
    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: 24px; height: 24px; }

/* ===== Messages ===== */
.chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    -webkit-overflow-scrolling: touch;
}

.chat-date-divider {
    text-align: center;
    margin: 16px 0 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--chat-text-secondary);
}

.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    margin-bottom: 2px;
    animation: chatFadeIn 0.25s ease;
}

.chat-msg-in { align-self: flex-start; }
.chat-msg-out { align-self: flex-end; }

@keyframes chatFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-bubble {
    background: var(--chat-bubble-in);
    padding: 8px 12px;
    border-radius: 22px;
    border-bottom-left-radius: 4px;
    font-size: 15px;
    line-height: 1.35;
    color: var(--chat-text);
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chat-msg-out .chat-bubble {
    background: var(--chat-bubble-out);
    color: var(--chat-bubble-out-text);
    border-bottom-left-radius: 22px;
    border-bottom-right-radius: 4px;
}

.chat-media {
    max-width: 240px;
    max-height: 320px;
    border-radius: 16px;
    margin-bottom: 4px;
    object-fit: cover;
    display: block;
}

.chat-media-video {
    width: 240px;
    border-radius: 16px;
}

.chat-media-audio {
    width: 100%;
    max-width: 280px;
    min-width: 200px;
}

.chat-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
    width: 100%;
    min-width: 200px;
}

.chat-btn {
    background: var(--chat-bg);
    border: 1px solid var(--chat-btn-border);
    padding: 10px 16px;
    border-radius: 22px;
    font-family: var(--ig-font);
    font-size: 14px;
    font-weight: 600;
    color: var(--chat-btn-text);
    cursor: pointer;
    text-align: center;
    transition: opacity 0.15s, background 0.15s;
    width: 100%;
}

.chat-btn:hover:not(:disabled) { opacity: 0.85; }
.chat-btn:disabled {
    opacity: 0.45;
    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: 12px 16px;
    border-radius: 22px;
    border-bottom-left-radius: 4px;
}

.typing-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.typing-dots span {
    width: 7px;
    height: 7px;
    background: var(--chat-text-secondary);
    border-radius: 50%;
    animation: chatBounce 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 chatBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ===== Composer (visual) ===== */
.chat-composer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 12px;
    border-top: 1px solid var(--chat-border);
    background: var(--chat-composer-bg);
    flex-shrink: 0;
}

.chat-composer-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    color: var(--chat-icon);
    flex-shrink: 0;
}

.chat-composer-icon svg { width: 24px; height: 24px; }

.chat-composer-input {
    flex: 1;
    background: var(--chat-input-bg);
    border: none;
    border-radius: 22px;
    padding: 10px 16px;
    font-family: var(--ig-font);
    font-size: 15px;
    color: var(--chat-text);
    outline: none;
}

.chat-composer-input::placeholder {
    color: var(--chat-input-placeholder);
}

.chat-brand {
    text-align: center;
    padding: 4px 8px 8px;
    font-size: 11px;
    background: var(--chat-composer-bg);
}

.chat-brand a { color: var(--chat-text-secondary); text-decoration: none; }

@media (max-width: 430px) {
    .chat-page { background: var(--chat-bg); }
}
