/* =============================================================================
   Message Window v2 (msg-window.css)
   Sits on top of Bootstrap 5; only styles what Bootstrap doesn't already cover.
   BEM-ish naming under .msg-window so it doesn't leak into the rest of the app.
   ========================================================================== */

.msg-window {
    border: 0;
    border-radius: 0.75rem;
    overflow: hidden;
}

/* --- Tabs ---------------------------------------------------------------- */

/* Override legacy .tabs rule from msgV2.css that sets max-width:70% */
.msg-window .msg-window__tabs {
    background: #f1f3f5;
    border-bottom: 1px solid #dee2e6;
    padding: 0.5rem 0.5rem 0;
    flex-wrap: nowrap;
    width: 100%;
    max-width: none;
    margin: 0;
}

.msg-window .msg-window__tabs .nav-item {
    flex: 1 1 0;
}

/* The legacy stylesheet has .tab-button rules that don't target .nav-link,
   so these are safe — just ensure specificity beats anything generic. */
.msg-window .msg-window__tabs .nav-link {
    width: 100%;
    text-align: center;
    font-weight: 600;
    color: #495057;
    background: transparent;
    border: 1px solid transparent;
    border-bottom: 0;
    border-top-left-radius: 0.5rem;
    border-top-right-radius: 0.5rem;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.msg-window .msg-window__tabs .nav-link:hover {
    color: #212529;
    background-color: rgba(255, 255, 255, 0.6);
}

.msg-window .msg-window__tabs .nav-link.active {
    color: #212529;
    background-color: #fff;
    border-color: #dee2e6 #dee2e6 #fff;
}

/* Locked tab (entices upgrade) */
.msg-window__tab--locked {
    color: #6c757d;
    text-decoration: none;
    position: relative;
}

.msg-window__tab--locked:hover,
.msg-window__tab--locked:focus {
    color: #0d6efd;
    background-color: rgba(13, 110, 253, 0.08);
}

.msg-window__tab--locked .bi-lock-fill {
    margin-right: 0.35rem;
}

/* --- Content ------------------------------------------------------------- */

/* The parent wrapper. Override the legacy .tab-content rule from msgV2.css
   (which sets display:none on the wrapper itself) by being more specific. */
.msg-window .tab-content,
.msg-window__content {
    display: block;
    background: #fff;
    padding: 1.25rem;
    width: auto;
    max-width: none;
    margin: 0;
}

/* Self-contained tab visibility — doesn't depend on Bootstrap's JS-applied
   .fade.show.active classes, so panes work even if bootstrap.bundle.js is
   blocked by CSP, slow to load, or fails. Specificity is bumped with the
   .msg-window prefix to defeat any legacy .tab-* rules from msgV2.css. */
.msg-window .tab-pane {
    display: none;
}
.msg-window .tab-pane.active {
    display: block;
}

.msg-window__form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.msg-window__intro p {
    font-size: 1rem;
    line-height: 1.5;
}

.msg-window__custom-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.msg-window__custom-body {
    flex: 1 1 auto;
    min-width: 0;
}

.msg-window__avatar {
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.msg-window__textarea {
    resize: vertical;
    min-height: 5rem;
}

/* --- Drop zone / file uploader ------------------------------------------ */

.msg-window__dropzone {
    position: relative;
    border: 2px dashed #ced4da;
    border-radius: 0.5rem;
    padding: 1rem;
    background: #fbfbfc;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.msg-window__dropzone.is-dragover {
    border-color: #0d6efd;
    background: #eff6ff;
}

.msg-window__dropzone.is-invalid {
    border-color: #dc3545;
    background: #fff5f5;
}

.msg-window__file-input {
    /* Visually hidden but still focusable + clickable via the label. */
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.msg-window__file-input:focus-visible + .msg-window__file-label {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

.msg-window__file-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    text-align: center;
    color: #6c757d;
    margin: 0;
    pointer-events: none; /* let clicks fall through to the input */
}

.msg-window__file-label .bi {
    font-size: 1.5rem;
    color: #495057;
}

.msg-window__file-cta {
    font-weight: 500;
    color: #495057;
}

/* Preview tile */
.msg-window__preview {
    position: relative;
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.msg-window__preview img,
.msg-window__preview video {
    max-width: 96px;
    max-height: 96px;
    border-radius: 0.375rem;
    object-fit: cover;
}

.msg-window__preview-meta {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.875rem;
}

.msg-window__preview-name {
    display: block;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.msg-window__preview-remove {
    flex-shrink: 0;
}

/* --- Actions ------------------------------------------------------------- */

.msg-window__actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
}

.msg-window__upsell {
    font-size: 0.95rem;
}

/* --- Mobile -------------------------------------------------------------- */

@media (max-width: 575.98px) {
    .msg-window__content {
        padding: 1rem;
    }

    .msg-window__custom-row {
        gap: 0.5rem;
    }

    .msg-window__avatar {
        width: 48px;
        height: 48px;
    }

    .msg-window__tabs .nav-link {
        font-size: 0.95rem;
        padding: 0.5rem 0.4rem;
    }
}
