/* ===================================================================
   CHAT REFERENCES — Chips, File Tiles, Composer Preview, Add Menu
   =================================================================== */

/* ------------------------------------------------------------------ */
/*  A) Reference chips (tasks · events · customers)                   */
/* ------------------------------------------------------------------ */
.chat-ref-chips {
    display: inline-flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 5px;
    margin-bottom: 6px;
    max-width: 85%;
}

/* When expanded after +N click, wrap — default left-align (received) */
.chat-ref-chips.expanded {
    flex-wrap: wrap;
    justify-content: flex-start;
}
/* Sent messages: expanded chips right-align */
.message.sent .chat-ref-chips.expanded {
    justify-content: flex-end;
}

.chat-ref-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px 4px 8px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 500;
    background: var(--accent-soft, rgba(0, 112, 243, 0.10));
    color: var(--text-main);
    cursor: pointer;
    border: 1px solid transparent;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    line-height: 1.35;
    flex-shrink: 0;
}

.chat-ref-chip > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* +N overflow badge */
.chat-ref-overflow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
    cursor: pointer;
    letter-spacing: 0.01em;
    transition: background 0.15s ease;
}
.chat-ref-overflow:hover {
    background: rgba(0, 0, 0, 0.10);
}

body.dark-mode .chat-ref-overflow {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-light);
}
body.dark-mode .chat-ref-overflow:hover {
    background: rgba(255, 255, 255, 0.14);
}

/* Hidden overflow chips — collapsed by default */
.chat-ref-chips-hidden {
    display: none;
}

/* Customer revenue value tag inside chip */
.chat-ref-chip-value {
    font-size: 10.5px;
    font-weight: 600;
    color: #22c55e;
    margin-left: 2px;
    flex-shrink: 0;
}

.chat-ref-chip:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}
/* Type-specific hover borders — lighter shade of each chip's color */
.chat-ref-chip[data-ref-type="task"]:hover     { border-color: rgba(0, 112, 243, 0.25); }
.chat-ref-chip[data-ref-type="event"]:hover    { border-color: rgba(142, 68, 230, 0.25); }
.chat-ref-chip[data-ref-type="customer"]:hover { border-color: rgba(230, 126, 34, 0.25); }

body.dark-mode .chat-ref-chip:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
body.dark-mode .chat-ref-chip[data-ref-type="task"]:hover     { border-color: rgba(0, 112, 243, 0.35); }
body.dark-mode .chat-ref-chip[data-ref-type="event"]:hover    { border-color: rgba(142, 68, 230, 0.35); }
body.dark-mode .chat-ref-chip[data-ref-type="customer"]:hover { border-color: rgba(230, 126, 34, 0.35); }

.chat-ref-chip-icon {
    font-size: 11px;
    color: var(--accent);
    flex-shrink: 0;
    width: 16px;
    text-align: center;
}

/* Type-specific chip tints */
.chat-ref-chip[data-ref-type="task"] { background: rgba(0, 112, 243, 0.10); }
.chat-ref-chip[data-ref-type="task"] .chat-ref-chip-icon { color: #0070f3; }

.chat-ref-chip[data-ref-type="event"] { background: rgba(142, 68, 230, 0.10); }
.chat-ref-chip[data-ref-type="event"] .chat-ref-chip-icon { color: #8e44e6; }

.chat-ref-chip[data-ref-type="customer"] { background: rgba(230, 126, 34, 0.10); }
.chat-ref-chip[data-ref-type="customer"] .chat-ref-chip-icon { color: #e67e22; }

/* Sent bubble — chips sit outside the blue bubble, keep readable tinted bg */
.message.sent .chat-ref-chips {
    align-self: flex-end;
}
.message.sent .chat-ref-files {
    align-self: flex-end;
}


/* ------------------------------------------------------------------ */
/*  B) File tiles (sheets · docs) — mini workspace card               */
/* ------------------------------------------------------------------ */
.chat-ref-files {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
    max-width: 85%;
    position: relative;
}

.chat-ref-file-tile {
    width: 140px;
    min-height: 100px;
    border-radius: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.15s ease;
    position: relative;
    overflow: hidden;
}

.chat-ref-file-tile:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
    border-color: var(--accent);
}

/* Only lift on hover for non-stacked single tiles */
.chat-ref-files:not(.stacked) .chat-ref-file-tile:hover {
    transform: translateY(-3px);
}

/* Single file tile — no tilt */
.chat-ref-files:not(.stacked):not(.multi) .chat-ref-file-tile {
    transform: none;
}

.chat-ref-file-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.chat-ref-file-icon svg {
    width: 20px;
    height: 20px;
}

.chat-ref-file-icon[data-ref-type="sheet"] {
    background: rgba(52, 199, 89, 0.12);
    color: #34c759;
}

.chat-ref-file-icon[data-ref-type="doc"] {
    background: rgba(0, 122, 255, 0.10);
    color: #007aff;
}

.chat-ref-file-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.3;
}

.chat-ref-file-meta {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =====  Stacked tile effect for exactly 2 files  ===== */
.chat-ref-files.stacked {
    padding: 20px 0 0 20px; /* room for the offset back tile */
}

.chat-ref-files.stacked .chat-ref-file-tile:first-child {
    z-index: 2;
    position: relative;
    transform: rotate(3deg);
    transition: transform 0.35s cubic-bezier(.4,0,.2,1);
}

.chat-ref-files.stacked .chat-ref-file-tile:nth-child(2) {
    position: absolute;
    z-index: 1;
    left: -14px;
    top: -14px;
    transform: rotate(-6deg);
    opacity: 0.92;
    transition: transform 0.35s cubic-bezier(.4,0,.2,1),
                left 0.35s cubic-bezier(.4,0,.2,1),
                top 0.35s cubic-bezier(.4,0,.2,1),
                opacity 0.35s ease;
}

/* On hover — back tile moves out, front tile shifts just slightly (sent = expand left) */
.chat-ref-files.stacked:hover .chat-ref-file-tile:first-child {
    transform: rotate(2deg) translate(5px, 3px);
}

.chat-ref-files.stacked:hover .chat-ref-file-tile:nth-child(2) {
    left: -32px;
    top: -24px;
    transform: rotate(-4deg);
    opacity: 1;
}

/* Received messages: back tile offset to the right so both file names are readable */
.message:not(.sent) .chat-ref-files.stacked {
    padding: 20px 40px 0 0;
}

.message:not(.sent) .chat-ref-files.stacked .chat-ref-file-tile:nth-child(2) {
    left: auto;
    right: -36px;
    top: -12px;
    transform: rotate(4deg);
    transition: transform 0.35s cubic-bezier(.4,0,.2,1),
                right 0.35s cubic-bezier(.4,0,.2,1),
                top 0.35s cubic-bezier(.4,0,.2,1),
                opacity 0.35s ease;
}

.message:not(.sent) .chat-ref-files.stacked:hover .chat-ref-file-tile:first-child {
    transform: rotate(-1deg) translate(-4px, 2px);
}

.message:not(.sent) .chat-ref-files.stacked:hover .chat-ref-file-tile:nth-child(2) {
    left: auto;
    right: -52px;
    top: -18px;
    transform: rotate(3deg);
    opacity: 1;
}

/* =====  Multi layout for 3+ files — horizontal with slight overlap  ===== */
.chat-ref-files.multi {
    gap: 0;
    padding: 6px 0 0;
}

.chat-ref-files.multi .chat-ref-file-tile {
    width: 120px;
    min-height: 88px;
    margin-left: -16px;
}

.chat-ref-files.multi .chat-ref-file-tile:first-child {
    margin-left: 0;
}

.chat-ref-files.multi .chat-ref-file-tile:nth-child(1) { transform: rotate(-2deg);  z-index: 4; }
.chat-ref-files.multi .chat-ref-file-tile:nth-child(2) { transform: rotate(2.5deg); z-index: 3; }
.chat-ref-files.multi .chat-ref-file-tile:nth-child(3) { transform: rotate(-1.5deg);z-index: 2; }
.chat-ref-files.multi .chat-ref-file-tile:nth-child(4) { transform: rotate(2deg);   z-index: 1; }

.chat-ref-files.multi .chat-ref-file-tile:hover {
    transform: translateY(-4px) rotate(0deg);
    z-index: 10;
}

/* Sent bubble — file tiles get a very subtle grey tint + thicker border to stand out on white */
.message.sent .chat-ref-file-tile {
    align-self: flex-end;
    background: #fafbfb;
    border: 1.5px solid #ededf0;
}

/* Received bubble — slight grey to differentiate from sent */
.message:not(.sent) .chat-ref-file-tile {
    background: #f4f5f6;
    border: 1.5px solid #e8e9ec;
}


/* ------------------------------------------------------------------ */
/*  C) Composer preview — staged references before send               */
/* ------------------------------------------------------------------ */

/* Chips container — sits above .chat-composer-inner */
.chat-composer-refs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 0 6px;
}
.chat-composer-refs:empty { display: none; }

/* Staged chips reuse .chat-ref-chip styles from section A.
   Only override for the inline remove button. */
.chat-composer-chip {
    position: relative;
    cursor: default;
    animation: refTagIn 0.15s ease-out;
}

@keyframes refTagIn {
    from { opacity: 0; transform: scale(0.9); }
    to   { opacity: 1; transform: scale(1); }
}

.chat-composer-chip-remove {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.08);
    color: var(--text-muted);
    font-size: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 2px;
    transition: background 0.12s ease, color 0.12s ease;
    padding: 0;
    line-height: 1;
}
.chat-composer-chip-remove:hover {
    background: rgba(255, 59, 48, 0.15);
    color: #ff3b30;
}

/* File tiles container */
.chat-composer-file-tiles {
    display: flex;
    gap: 8px;
    padding: 6px 6px 6px 0;
    position: relative;
    overflow: visible;
}
.chat-composer-file-tiles:empty { display: none; }

/* Mini version of the sent file tile — reuses .chat-ref-file-tile base */
.chat-composer-file-tile {
    /* Shrink from sent 140/100 to 100/70 */
    width: 100px !important;
    min-height: 70px !important;
    padding: 8px !important;
    gap: 5px !important;
    animation: refTagIn 0.15s ease-out;
    position: relative;
    background: var(--bg-body) !important;
    overflow: visible !important;
    transition: transform 0.25s cubic-bezier(.4,0,.2,1),
                box-shadow 0.15s ease,
                border-color 0.15s ease;
}

/* Tilts — reuse same pattern as sent file tiles */
.chat-composer-file-tile:nth-child(1) { transform: rotate(-1.5deg); }
.chat-composer-file-tile:nth-child(2) { transform: rotate(2.5deg);  }
.chat-composer-file-tile:nth-child(3) { transform: rotate(-2deg);   }
.chat-composer-file-tile:nth-child(4) { transform: rotate(1.5deg);  }

.chat-composer-file-tile:hover {
    transform: rotate(0deg) translateY(-2px) !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.10);
    border-color: var(--accent);
    z-index: 5;
}

.chat-composer-file-tile .chat-ref-file-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    font-size: 13px;
}
.chat-composer-file-tile .chat-ref-file-icon svg {
    width: 16px;
    height: 16px;
}

.chat-composer-file-tile .chat-ref-file-name {
    font-size: 10.5px;
}

.chat-composer-file-tile .chat-ref-file-meta {
    font-size: 9px;
}

/* Remove button on file tile — top-right X circle */
.chat-composer-tile-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1.5px solid var(--bg-surface);
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0;
    transform: scale(0.7);
    transition: opacity 0.15s ease, transform 0.15s ease, background 0.12s ease;
    padding: 0;
    line-height: 1;
    z-index: 10;
}
.chat-composer-file-tile:hover .chat-composer-tile-remove {
    opacity: 1;
    transform: scale(1);
}
.chat-composer-tile-remove:hover {
    background: #ff3b30;
}


/* ------------------------------------------------------------------ */
/*  D) "+" Add menu (settings-dropdown style)                         */
/* ------------------------------------------------------------------ */
.chat-add-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14), 0 2px 8px rgba(0, 0, 0, 0.06);
    min-width: 200px;
    padding: 6px;
    z-index: 10001;
    animation: chatAddMenuIn 0.14s ease-out;
    display: none;
}

.chat-add-menu.active { display: block; }

@keyframes chatAddMenuIn {
    from { opacity: 0; transform: translateY(6px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-add-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
    color: var(--text-main);
    font-size: 13px;
    font-weight: 500;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
}

.chat-add-menu-item:hover {
    background: var(--bg-hover, rgba(0, 0, 0, 0.04));
}

.chat-add-menu-item i {
    width: 18px;
    text-align: center;
    font-size: 14px;
}

.chat-add-menu-item i.fa-check-circle  { color: #0070f3; }
.chat-add-menu-item i.fa-calendar      { color: #8e44e6; }
.chat-add-menu-item i.fa-user-tie      { color: #e67e22; }
.chat-add-menu-item i.fa-table         { color: #34c759; }
.chat-add-menu-item i.fa-file-alt      { color: #ff3b30; }
.chat-add-menu-item i.fa-poll          { color: #5ac8fa; }

.chat-add-menu-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 4px 8px;
}

.chat-add-menu-coming-soon {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.04);
    border-radius: 999px;
    padding: 1px 7px;
    margin-left: auto;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}


/* ------------------------------------------------------------------ */
/*  E) Reference picker modal — redesigned with tabs + suggestions    */
/* ------------------------------------------------------------------ */
.chat-ref-picker {
    width: 480px;
    height: 560px;
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    overflow: hidden;
}

/* --- Header --- */
.chat-ref-picker-header {
    padding: 0;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.chat-ref-picker-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 8px;
}

.chat-ref-picker-title-row h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
}

/* --- Search (matches global .search-bar pill) --- */
.chat-ref-picker-search {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 16px 10px;
    background: var(--bg-surface);
    padding: 10px 18px;
    border-radius: 999px;
    border: 1.5px solid var(--border-subtle);
    transition: all var(--transition-fast);
}

.chat-ref-picker-search:focus-within {
    border-color: var(--accent);
}

.chat-ref-picker-search i {
    color: var(--text-muted);
    font-size: 14px;
    flex-shrink: 0;
}

.chat-ref-picker-search input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 14px;
    color: var(--text-main);
    font-family: var(--font-family);
}

.chat-ref-picker-search input::placeholder {
    color: var(--text-muted);
}

/* --- Tabs --- */
.chat-ref-picker-tabs {
    display: flex;
    gap: 0;
    padding: 0 16px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.chat-ref-picker-tabs::-webkit-scrollbar { display: none; }

.chat-ref-picker-tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: -1px;
}

.chat-ref-picker-tab i {
    font-size: 11px;
}

.chat-ref-picker-tab:hover {
    color: var(--text-main);
}

.chat-ref-picker-tab.active {
    color: var(--text-main);
    font-weight: 600;
    border-bottom-color: var(--text-main);
}

/* --- Body --- */
.chat-ref-picker-body {
    flex: 1;
    min-height: 0; /* ensures flex child overflow works in all browsers */
    overflow-y: auto;
    padding: 4px 0;
    overscroll-behavior: contain;
}

/* --- Section label --- */
.chat-ref-picker-section {
    padding: 0 8px;
}

.chat-ref-picker-section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 12px 10px 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-ref-picker-section-label i {
    font-size: 11px;
    color: var(--accent);
}

/* --- List rows --- */
.chat-ref-picker-list {
    padding: 0 2px;
}

.chat-ref-picker-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.12s ease;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    position: relative;
}

.chat-ref-picker-row:hover {
    background: var(--bg-hover, rgba(0, 0, 0, 0.04));
}

.chat-ref-picker-row.selected {
    background: rgba(0, 112, 243, 0.06);
}

.chat-ref-picker-row-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    -webkit-text-stroke: 0.4px;
}

.chat-ref-picker-row-icon svg {
    width: 15px;
    height: 15px;
    stroke-width: 1.5;
}

.chat-ref-picker-row-body {
    flex: 1;
    min-width: 0;
}

.chat-ref-picker-row-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-ref-picker-row-sub {
    font-size: 11.5px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.chat-ref-picker-row-check {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1.5px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: transparent;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.chat-ref-picker-row.selected .chat-ref-picker-row-check {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* --- Empty / Loading --- */
.chat-ref-picker-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 40px 16px;
    color: var(--text-muted);
    font-size: 13px;
}

.chat-ref-picker-empty i {
    font-size: 24px;
    opacity: 0.25;
}

.chat-ref-picker-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 32px 16px;
    color: var(--text-secondary);
    font-size: 13px;
}

.chat-ref-picker-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-subtle);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: refPickerSpin 0.6s linear infinite;
}

@keyframes refPickerSpin {
    to { transform: rotate(360deg); }
}

/* --- Footer (multi-select attach bar) --- */
.chat-ref-picker-footer {
    display: none; /* toggled via JS */
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    flex-shrink: 0;
    animation: refPickerFooterIn 0.15s ease;
}

@keyframes refPickerFooterIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chat-ref-picker-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.chat-ref-picker-attach-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 20px;
    border-radius: 999px;
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}

.chat-ref-picker-attach-btn:hover {
    filter: brightness(1.08);
}

.chat-ref-picker-attach-btn:active {
    transform: scale(0.97);
}

.chat-ref-picker-attach-btn i {
    font-size: 11px;
}


/* ------------------------------------------------------------------ */
/*  F) Reference tooltip (hover popover)                              */
/* ------------------------------------------------------------------ */
.chat-ref-tooltip {
    position: fixed;
    z-index: 10005;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
    padding: 12px 14px;
    max-width: 260px;
    pointer-events: none;
    animation: chatRefTipIn 0.12s ease-out;
}

@keyframes chatRefTipIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chat-ref-tooltip-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-ref-tooltip-meta {
    font-size: 11.5px;
    color: var(--text-muted);
    line-height: 1.4;
}

.chat-ref-tooltip-meta span {
    display: block;
}


/* ------------------------------------------------------------------ */
/*  G) Dark mode adjustments                                          */
/* ------------------------------------------------------------------ */
body.dark-mode .chat-ref-chip[data-ref-type="task"]     { background: rgba(0, 112, 243, 0.14); }
body.dark-mode .chat-ref-chip[data-ref-type="event"]    { background: rgba(142, 68, 230, 0.14); }
body.dark-mode .chat-ref-chip[data-ref-type="customer"] { background: rgba(230, 126, 34, 0.14); }
body.dark-mode .chat-ref-chip:hover { box-shadow: 0 2px 8px rgba(0, 112, 243, 0.2); }

body.dark-mode .chat-ref-file-tile {
    background: var(--bg-body);
    border-color: var(--border-medium);
}
body.dark-mode .chat-ref-file-tile:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
body.dark-mode .message.sent .chat-ref-file-tile {
    background: #1e1e1e;
    border-color: var(--border-medium);
}
body.dark-mode .message:not(.sent) .chat-ref-file-tile {
    background: #1a1a1a;
    border-color: var(--border-medium);
}

body.dark-mode .chat-add-menu {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.2);
}

body.dark-mode .chat-composer-chip-remove {
    background: rgba(255, 255, 255, 0.10);
}
body.dark-mode .chat-composer-tile-remove {
    background: rgba(255, 255, 255, 0.55);
    color: #000;
    border-color: var(--bg-body);
}

body.dark-mode .chat-ref-tooltip {
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
}

body.dark-mode .chat-ref-picker-row.selected {
    background: rgba(0, 112, 243, 0.10);
}
body.dark-mode .chat-ref-picker-row-check {
    border-color: var(--border-medium);
}
body.dark-mode .chat-ref-picker-search {
    background: transparent;
    border-color: var(--border-subtle);
}
body.dark-mode .chat-ref-picker-search:focus-within {
    background: transparent;
    border-color: var(--accent);
}
body.dark-mode .chat-ref-picker-attach-btn {
    background: var(--accent);
}

body.dark-mode .chat-add-menu-coming-soon {
    background: rgba(255, 255, 255, 0.06);
}


/* ------------------------------------------------------------------ */
/*  H) Mobile: smaller tiles and menu                                 */
/* ------------------------------------------------------------------ */
@media (max-width: 600px) {
    .chat-ref-file-tile { width: 110px; min-height: 80px; padding: 10px; }
    .chat-ref-file-icon { width: 28px; height: 28px; font-size: 13px; }
    .chat-ref-file-name { font-size: 11px; }

    .chat-ref-files.stacked { padding: 14px 0 0 14px; }
    .chat-ref-files.multi .chat-ref-file-tile { width: 100px; min-height: 72px; margin-left: -10px; }

    .chat-composer-file-tile { width: 85px !important; min-height: 60px !important; padding: 6px !important; }
    .chat-composer-file-tile .chat-ref-file-icon { width: 22px; height: 22px; font-size: 11px; }
    .chat-composer-file-tile .chat-ref-file-name { font-size: 9px; }
    .chat-composer-file-tile .chat-ref-file-meta { font-size: 8px; }

    .chat-add-menu { min-width: 180px; }

    .chat-ref-picker { width: calc(100vw - 32px); max-height: 70vh; }\n    .chat-ref-picker-tabs { gap: 0; }
    .chat-ref-picker-tab { padding: 8px 8px; font-size: 11px; }
}
