/* ---------------------------------------------------------
   UNIVERSAL CHAT WRAPPER
--------------------------------------------------------- */

.chat-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-height: 100vh;
    background: var(--chat-bg);
    border-radius: 12px;
    box-shadow: 0 0 20px rgba(0,0,0,0.04);
    position: relative;
    overflow: hidden;

    /* IMPORTANT: below header */
    z-index: 9000;
}

/* Hide scrollbars */
.chat-messages::-webkit-scrollbar {
    width: 0;
    height: 0;
}
.chat-messages {
    scrollbar-width: none;
}

/* ---------------------------------------------------------
   HEADER
--------------------------------------------------------- */

.chat-header {
    padding: 14px 18px;
    background: var(--chat-header-bg);
    border-bottom: 1px solid var(--chat-border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--chat-header-text);
}

.chat-header .chat-user {
    font-size: 14px;
    color: var(--chat-muted);
}

.chat-hamburger {
    margin-left: auto;
    display: none; /* shown in mobile */
    cursor: pointer;
    background: none;
    border: none;
}

/* ---------------------------------------------------------
   MESSAGES AREA
--------------------------------------------------------- */

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    padding-bottom: 160px; /* composer height + lift */
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: var(--chat-bg);
}

.chat-message {
    background: var(--chat-bubble-bg);
    padding: 12px 14px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    border: 1px solid var(--chat-border-soft, var(--chat-border));
    position: relative;
}

.chat-meta {
    font-size: 12px;
    font-weight: 600;
    color: var(--chat-muted-strong, var(--chat-muted));
    margin-bottom: 4px;
}

.chat-body {
    font-size: 15px;
    line-height: 1.45;
    color: var(--chat-text);
}

/* ---------------------------------------------------------
   MESSAGE ACTION BUTTONS
--------------------------------------------------------- */

.msg-actions {
    position: absolute;
    top: 6px;
    right: 8px;
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.chat-message:hover .msg-actions {
    opacity: 1;
}

.msg-action-btn {
    background: none;
    border: none;
    font-size: 15px;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.msg-action-btn:hover {
    background: rgba(0,0,0,0.08);
}

/* ---------------------------------------------------------
   MEDIA TYPES
--------------------------------------------------------- */

.chat-image,
.chat-message iframe {
    max-width: 100%;
    border-radius: 10px;
    margin-top: 6px;
    border: 1px solid var(--chat-border-soft, var(--chat-border));
}

/* ---------------------------------------------------------
   COMPOSER
--------------------------------------------------------- */

.chat-composer {
    position: relative;
    width: 100%;

    padding: 12px 16px; /* slight right breathing room */
    background: var(--chat-composer-bg);
    border-top: 1px solid var(--chat-border);

    display: flex;
    align-items: center;
    gap: 10px;
}

/* Text input flexes, button never shrinks */
.chat-input {
    flex: 1 1 auto;
    min-width: 0; /* critical for flex overflow safety */

    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--chat-border-input, var(--chat-border));
    font-size: 15px;
    resize: none;
    height: 48px;
    background: var(--chat-input-bg);
    color: var(--chat-text);
}

.chat-input:focus {
    outline: none;
    border-color: var(--chat-accent-soft);
    box-shadow: 0 0 0 2px var(--chat-accent-soft);
}

/* Send button is protected from clipping */
.chat-send-btn {
    flex-shrink: 0; /* 🔑 prevents cutoff */
    margin-right: 22px; /* Pulls it left*/
    background: var(--chat-accent);
    color: #fff;
    border: none;
    padding: 0 18px;
    height: 48px;
    border-radius: 10px;
    font-size: 15px;
    cursor: pointer;
    transition: 0.2s ease;
}

.chat-send-btn:hover {
    background: var(--chat-accent-strong);
}

/* ---------------------------------------------------------
   SLIDE-UP EDITOR PANEL
--------------------------------------------------------- */

.chat-editor {
    position: fixed;
    bottom: 110px;
    left: 10px;
    right: 10px;

    padding: 12px 14px;
    background: var(--chat-editor-bg);

    border-top: 1px solid rgba(0,0,0,0.08);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.06);

    transform: translateY(calc(100% + 120px));
    transition: transform 0.25s ease;

    /* BELOW HEADER, ABOVE COMPOSER */
    z-index: 9500;
    isolation: isolate;
}

.chat-editor.show {
    transform: translateY(0);
}

.chat-editor textarea {
    width: 100%;
    height: 70px;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.15);
    padding: 10px 12px;
    font-size: 15px;
    resize: none;
    background: white;
    box-sizing: border-box;
}

.editor-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}

.editor-actions button {
    padding: 6px 14px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    background: var(--chat-accent-soft);
    color: var(--chat-text);
}

/* ---------------------------------------------------------
   MOBILE MODE (max-width: 900px)
--------------------------------------------------------- */

@media (max-width: 900px) {

    .chat-wrapper {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;

        /* BELOW HEADER */
        z-index: 9000;

        background: var(--chat-bg);
    }

    .chat-header {
        padding: 14px 16px;
    }

    .chat-hamburger {
        display: flex;
    }

    .chat-messages {
        padding-bottom: 180px;
    }

    .chat-composer {
        bottom: 0;
        border-radius: 0;
        padding: 14px;
    }

    .chat-editor {
        bottom: 90px !important;
        left: 10px !important;
        right: 10px !important;
    }
    
}
