/* ═══════════════════════════════════════════════════════════════
   Selfa — پیوستِ فایل در جعبه‌ی گفتگو (chat-attach.js)
   ═══════════════════════════════════════════════════════════════ */

/* دکمه‌ی گیره — هم‌شکلِ دکمه‌ی میکروفون، ولی در موبایل پنهان نمی‌شود */
.btn-attach {
    width: 36px;
    height: 36px;
    border-radius: var(--r-sm, 8px);
    background: transparent;
    color: var(--ink-tertiary, rgba(244, 232, 200, 0.42));
    border: 1px solid var(--line-strong, rgba(201, 169, 97, 0.12));
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    padding: 0;
}
.btn-attach:hover,
.btn-attach.has-file {
    color: var(--gold-bright, #e8c878);
    border-color: var(--gold-soft, rgba(201, 169, 97, 0.45));
    background: var(--bg-hover, #1a1c25);
}
.btn-attach svg { width: 16px; height: 16px; }

/* ورودیِ فایل هرگز دیده نمی‌شود */
#chatFileInput {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* نوارِ فایلِ انتخاب‌شده — بالای جعبه‌ی نوشتن */
.chat-attach-bar {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: var(--s2, 8px);
}
.chat-attach-bar[hidden],
.chat-attach-chip[hidden] { display: none !important; }

.chat-attach-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    max-width: 100%;
    padding: 7px 8px 7px 12px;
    background: var(--bg-elevated, #14151c);
    border: 1px solid var(--gold-soft, rgba(201, 169, 97, 0.45));
    border-radius: var(--r-md, 12px);
    box-shadow: 0 0 0 1px var(--gold-faint, rgba(201, 169, 97, 0.08));
    animation: chatAttachIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
[dir="rtl"] .chat-attach-chip { padding: 7px 12px 7px 8px; }

.chat-attach-icon {
    position: relative;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-sm, 8px);
    background: var(--gold-faint, rgba(201, 169, 97, 0.08));
    color: var(--gold, #c9a961);
}
.chat-attach-icon svg { width: 16px; height: 16px; }
.chat-attach-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--gold-soft, rgba(201, 169, 97, 0.45));
    border-top-color: var(--gold-bright, #e8c878);
    border-radius: 50%;
    animation: chatAttachSpin 0.8s linear infinite;
}
.chat-attach-chip.is-busy .chat-attach-icon svg { display: none; }
.chat-attach-chip.is-busy .chat-attach-spinner { display: block; }

.chat-attach-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.35;
}
.chat-attach-name {
    font-size: 13px;
    font-weight: 400;
    color: var(--ink-primary, rgba(244, 232, 200, 0.95));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
    direction: ltr;
    unicode-bidi: plaintext;
    text-align: start;
}
.chat-attach-sub {
    font-size: 11px;
    font-weight: 300;
    color: var(--ink-tertiary, rgba(244, 232, 200, 0.42));
    white-space: nowrap;
}

.chat-attach-remove {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--ink-tertiary, rgba(244, 232, 200, 0.42));
    cursor: pointer;
    transition: all 0.2s;
}
.chat-attach-remove:hover {
    color: var(--ink-primary, rgba(244, 232, 200, 0.95));
    background: var(--bg-hover, #1a1c25);
}
.chat-attach-remove svg { width: 13px; height: 13px; }

.chat-attach-error {
    font-size: 12px;
    font-weight: 300;
    line-height: 1.6;
    color: #e08a6d;
}
.chat-attach-error:empty { display: none; }

/* برچسبِ فایل داخلِ حبابِ پیامِ کاربر */
.msg-attach {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--line-strong, rgba(201, 169, 97, 0.12));
    font-size: 12px;
    color: var(--gold, #c9a961);
}
.msg-attach svg { width: 14px; height: 14px; flex-shrink: 0; }
.msg-attach span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    unicode-bidi: plaintext;
}

/* کشیدن و رها کردن روی ستونِ گفتگو */
.panel-chat.attach-drop { position: relative; }
.panel-chat.attach-drop::after {
    content: attr(data-drop-label);
    position: absolute;
    inset: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px dashed var(--gold-soft, rgba(201, 169, 97, 0.45));
    border-radius: var(--r-md, 12px);
    background: rgba(8, 9, 13, 0.82);
    color: var(--gold-bright, #e8c878);
    font-size: 14px;
    z-index: 20;
    pointer-events: none;
}

@keyframes chatAttachIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: none; }
}
@keyframes chatAttachSpin { to { transform: rotate(360deg); } }

@media (max-width: 768px) {
    .chat-attach-name { max-width: 52vw; }
}
