/* ╔═══════════════════════════════════════════════════════════╗
   ║  IMPERIAL CHAT V5.0 — Full-width Row + RTL (Discord)   ║
   ║  Approach: Each row = 100% width, justify-content       ║
   ║  pushes content to edges. No more centering bugs.       ║
   ╚═══════════════════════════════════════════════════════════╝ */

/* ══════════════════════════════════════
   1. CHAT BODY — Force RTL + Stretch
   ══════════════════════════════════════ */
.home-gc-body {
    flex: 1 !important;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.25rem 1rem !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0.35rem !important;
    direction: rtl !important;
    background: radial-gradient(circle at top right, rgba(139, 92, 246, 0.04), transparent 40%) !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    min-height: 400px;
}

/* ══════════════════════════════════════
   2. MESSAGE ROW — Full-width + Push to edges
   ══════════════════════════════════════ */
.gc-row {
    display: flex !important;
    align-items: flex-start !important;
    gap: 10px !important;
    width: 100% !important;
    max-width: 100% !important;
    animation: gcMsgIn 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
    margin: 0 !important;
    padding: 4px 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

@keyframes gcMsgIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ─── MY messages → push to RIGHT (flex-start in RTL) ─── */
.gc-me {
    justify-content: flex-start !important;
    flex-direction: row !important;
}

/* Spring: push gc-me content to the right edge */
.gc-me .gc-stack {
    margin-inline-end: auto !important;
}

/* ─── THEIR messages → push to LEFT (flex-end in RTL) ─── */
.gc-them {
    justify-content: flex-end !important;
    flex-direction: row !important;
}

/* Spring: push gc-them content to the left edge */
.gc-them .home-gc-avatar-slot {
    margin-inline-start: auto !important;
    order: -1 !important;
}

/* Ensure avatar is on the LEFT for their messages */
.gc-them .gc-stack {
    order: 0 !important;
}

/* ══════════════════════════════════════
   3. AVATAR — Fixed size, locked to bubble
   ══════════════════════════════════════ */
.home-gc-avatar-slot {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    cursor: pointer;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    display: block !important;
    width: 40px !important;
    height: 40px !important;
}

.home-gc-avatar-stack {
    width: 40px !important;
    height: 40px !important;
    position: relative;
    flex-shrink: 0 !important;
    display: inline-grid !important;
    place-items: center;
    isolation: isolate;
}

.home-gc-face {
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    border: 2px solid rgba(139, 92, 246, 0.25) !important;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.08) !important;
    transition: border-color 0.3s !important;
    position: relative;
    z-index: 1;
}

.gc-row:hover .home-gc-face {
    border-color: rgba(139, 92, 246, 0.5) !important;
}

.home-gc-frame {
    position: absolute;
    inset: -15%;
    z-index: 2;
    pointer-events: none;
}

.home-gc-frame-media {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ══════════════════════════════════════
   4. MESSAGE STACK (Name + Bubble) — Constrained width
   ══════════════════════════════════════ */
.gc-stack {
    display: flex !important;
    flex-direction: column !important;
    gap: 3px !important;
    min-width: 0 !important;
    max-width: 75% !important;
    flex-shrink: 1 !important;
    flex-grow: 0 !important;
    background: transparent !important;
}

.gc-me .gc-stack {
    align-items: flex-start !important;
}

.gc-them .gc-stack {
    align-items: flex-end !important;
}

/* Hide name for own messages */
.gc-me .gc-name {
    display: none !important;
}

.gc-name {
    font-size: 0.72rem;
    font-weight: 800;
    color: #a78bfa !important;
    padding: 0 6px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

/* ══════════════════════════════════════
   5. BUBBLE — Glassmorphism Effect
   ══════════════════════════════════════ */
.gc-bubble {
    padding: 0.7rem 1rem !important;
    border-radius: 18px !important;
    font-size: 0.9rem !important;
    line-height: 1.55 !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    position: relative;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: box-shadow 0.25s;
    max-width: 100% !important;
    width: fit-content !important;
}

.gc-row:hover .gc-bubble {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

/* My bubble → Purple glass */
.gc-me .gc-bubble {
    background: rgba(139, 92, 246, 0.12) !important;
    border: 1px solid rgba(139, 92, 246, 0.25) !important;
    border-top-right-radius: 4px !important;
    border-top-left-radius: 18px !important;
    color: #f1f5f9 !important;
    text-align: right;
}

/* Their bubble → Neutral glass */
.gc-them .gc-bubble {
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-top-left-radius: 4px !important;
    border-top-right-radius: 18px !important;
    color: #e2e8f0 !important;
    text-align: right;
}

/* ══════════════════════════════════════
   6. MESSAGE ACTIONS — Inside bubble, neon hover
   ══════════════════════════════════════ */
.gc-me-actions {
    display: flex !important;
    justify-content: flex-end !important;
    gap: 10px !important;
    margin-top: 6px !important;
    padding-top: 5px !important;
    border-top: 1px solid rgba(255, 255, 255, 0.05) !important;
    opacity: 0;
    transition: opacity 0.25s;
}

.gc-row:hover .gc-me-actions {
    opacity: 1;
}

.gc-del {
    background: none !important;
    border: none !important;
    padding: 3px 6px !important;
    cursor: pointer;
    font-size: 0.72rem !important;
    color: rgba(255, 255, 255, 0.3) !important;
    border-radius: 6px;
    transition: color 0.3s, text-shadow 0.3s, background 0.2s;
}

.gc-del:hover {
    color: #a78bfa !important;
    text-shadow: 0 0 8px rgba(139, 92, 246, 0.6);
    background: rgba(139, 92, 246, 0.08) !important;
}

/* Delete → red neon */
.gc-del[title="حذف"]:hover {
    color: #f43f5e !important;
    text-shadow: 0 0 8px rgba(244, 63, 94, 0.5);
    background: rgba(244, 63, 94, 0.08) !important;
}

/* ══════════════════════════════════════
   7. REPLY EMBED
   ══════════════════════════════════════ */
.chat-reply-embed {
    border-right: 3px solid rgba(139, 92, 246, 0.6) !important;
    border-left: none !important;
    background: rgba(139, 92, 246, 0.08) !important;
    padding: 0.45rem 0.65rem !important;
    border-radius: 10px !important;
    margin-bottom: 0.4rem !important;
    cursor: pointer;
    font-size: 0.75rem;
    transition: background 0.2s;
    max-width: 100%;
    overflow: hidden;
}

.chat-reply-embed:hover {
    background: rgba(139, 92, 246, 0.15) !important;
}

.chat-text {
    font-size: 0.88rem;
    line-height: 1.55;
    color: inherit;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ══════════════════════════════════════
   8. FOOTER / INPUT — Purple neon focus
   ══════════════════════════════════════ */
.home-gc-foot {
    position: relative;
    z-index: 10;
    padding: 1rem 1.25rem !important;
    border-top: 1px solid rgba(255, 255, 255, 0.06) !important;
    background: rgba(0, 0, 0, 0.35) !important;
    flex-shrink: 0 !important;
}

.home-gc-input-wrap {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

.home-gc-input {
    width: 100% !important;
    resize: none !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 14px !important;
    padding: 0.75rem 1rem !important;
    padding-left: 120px !important;
    font-size: 0.88rem !important;
    font-family: inherit;
    color: #f4f4f5 !important;
    background: rgba(255, 255, 255, 0.04) !important;
    outline: none !important;
    max-height: 120px;
    min-height: 48px;
    transition: border-color 0.25s, box-shadow 0.25s;
    direction: rtl !important;
}

.home-gc-input::placeholder {
    color: #52525b !important;
}

.home-gc-input:focus {
    border-color: rgba(139, 92, 246, 0.5) !important;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1), 0 0 18px rgba(139, 92, 246, 0.15) !important;
    background: rgba(255, 255, 255, 0.06) !important;
}

.home-gc-input-actions {
    position: absolute;
    left: 8px;
    bottom: 8px;
    display: flex;
    align-items: center;
    gap: 2px;
}

/* ══════════════════════════════════════
   9. RESPONSIVE — Mobile Breakpoints
   ══════════════════════════════════════ */
@media (max-width: 640px) {
    .home-gc-body {
        padding: 0.75rem 0.5rem !important;
        gap: 0.3rem !important;
        min-height: 280px;
    }

    .gc-row {
        gap: 7px !important;
        padding: 3px 0 !important;
    }

    .gc-stack {
        max-width: 80% !important;
    }

    .home-gc-avatar-slot,
    .home-gc-avatar-stack,
    .home-gc-face {
        width: 32px !important;
        height: 32px !important;
    }

    .gc-name {
        font-size: 0.65rem;
        max-width: 140px;
    }

    .gc-bubble {
        padding: 0.55rem 0.75rem !important;
        font-size: 0.82rem !important;
        border-radius: 14px !important;
    }

    .chat-text {
        font-size: 0.82rem;
    }

    .home-gc-foot {
        padding: 0.75rem !important;
    }

    .home-gc-input {
        padding-left: 95px !important;
        font-size: 0.82rem !important;
        min-height: 42px !important;
    }

    .gc-me-actions {
        opacity: 1 !important;
    }
}

@media (max-width: 400px) {
    .gc-row {
        gap: 5px !important;
    }

    .gc-stack {
        max-width: 85% !important;
    }

    .home-gc-avatar-slot,
    .home-gc-avatar-stack,
    .home-gc-face {
        width: 28px !important;
        height: 28px !important;
    }

    .gc-bubble {
        padding: 0.5rem 0.65rem !important;
        font-size: 0.78rem !important;
    }

    .home-gc-input {
        padding-left: 85px !important;
        font-size: 0.78rem !important;
    }
}
