/* ── Chat ── */
.cht-wrap { background: var(--bg-color, #f8f9fa); min-height: calc(100vh - 80px); }

.cht-card {
    background: var(--card-color, #fff); border-radius: 14px;
    border: 1px solid var(--border-color, #e5e7eb);
    display: flex; flex-direction: column;
    height: calc(100vh - 160px); min-height: 460px;
    position: relative;
}

/* Card header */
.cht-card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: .65rem 1rem;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    flex-shrink: 0;
}

.cht-live-dot {
    display: flex; align-items: center; gap: .45rem;
    font-size: .78rem; font-weight: 600; color: var(--text-muted, #6b7280);
}
.cht-live-dot span {
    width: 8px; height: 8px; background: #22c55e; border-radius: 50%;
    flex-shrink: 0; animation: cht-pulse 1.5s ease-in-out infinite;
}
@keyframes cht-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: .3; }
}

/* Sound toggle */
.cht-sound-btn {
    background: none; border: 1px solid var(--border-color, #e5e7eb);
    color: var(--text-muted, #9ca3af); border-radius: 8px; width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: .78rem; transition: border-color .15s, color .15s, opacity .15s;
    flex-shrink: 0;
}
.cht-sound-btn:hover   { border-color: var(--underline-color); color: var(--underline-color); }
.cht-sound-btn.cht-muted { opacity: .4; }

/* Feed */
.cht-feed {
    flex: 1; overflow-y: auto; padding: 1.25rem;
    display: flex; flex-direction: column; gap: 0;
    scroll-behavior: smooth;
}
.cht-empty {
    text-align: center; color: var(--text-muted, #9ca3af);
    font-size: .9rem; margin: auto;
}

/* Date separator */
.cht-date-sep {
    display: flex; align-items: center; gap: 10px;
    margin: .9rem 0 .5rem; color: var(--text-muted, #9ca3af);
    font-size: .7rem; font-weight: 600; letter-spacing: .02em;
}
.cht-date-sep::before,
.cht-date-sep::after { content: ''; flex: 1; height: 1px; background: var(--border-color, #e5e7eb); }
.cht-date-sep span { white-space: nowrap; }

/* Messages */
.cht-msg { display: flex; align-items: flex-end; gap: .6rem; max-width: 72%; margin-top: .6rem; }
.cht-msg.cht-grouped { margin-top: .1rem; }
.cht-mine   { flex-direction: row-reverse; margin-left: auto; }
.cht-theirs { flex-direction: row; margin-right: auto; }

/* Hide avatar on grouped messages (keep space for alignment) */
.cht-grouped .cht-av { visibility: hidden; }

.cht-av {
    width: 32px; height: 32px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
    background: var(--underline-color, #6366f1);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: .85rem; text-decoration: none;
}
.cht-av img { width: 100%; height: 100%; object-fit: cover; }

.cht-bubble-wrap { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.cht-mine  .cht-bubble-wrap { align-items: flex-end; }
.cht-theirs .cht-bubble-wrap { align-items: flex-start; }

.cht-name { font-size: .72rem; font-weight: 600; color: var(--text-muted, #6b7280); text-decoration: none; margin-bottom: .1rem; }
.cht-name:hover { color: var(--underline-color, #6366f1); }

.cht-bubble {
    padding: .55rem .85rem; border-radius: 14px; font-size: .875rem;
    word-break: break-word; white-space: pre-wrap; line-height: 1.5;
    max-width: 100%;
}
.cht-mine   .cht-bubble { background: var(--underline-color, #6366f1); color: #fff; border-bottom-right-radius: 4px; }
.cht-theirs .cht-bubble { background: var(--hover-color, #f3f4f6); color: var(--text-color, #111); border-bottom-left-radius: 4px; }

.cht-time { font-size: .68rem; color: var(--text-muted, #9ca3af); padding: 0 .25rem; }

/* Message meta row (time + delete) */
.cht-msg-meta { display: flex; align-items: center; gap: 2px; margin-top: 2px; }

/* Scroll-to-bottom button */
.cht-scroll-btn {
    position: absolute; bottom: 72px; right: 14px;
    background: var(--underline-color, #6366f1); color: #fff;
    border: none; border-radius: 50%; width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,.22);
    z-index: 10; font-size: .85rem; transition: filter .15s;
}
.cht-scroll-btn:hover { filter: brightness(.88); }
.cht-scroll-count {
    position: absolute; top: -5px; right: -5px;
    background: #ef4444; color: #fff; border-radius: 20px;
    padding: 0 5px; font-size: .6rem; font-weight: 700;
    min-width: 17px; height: 17px; display: flex; align-items: center; justify-content: center;
    line-height: 1;
}

/* Input bar */
.cht-input-bar {
    border-top: 1px solid var(--border-color, #e5e7eb);
    padding: .8rem 1rem;
    position: relative;
}
.cht-form { display: flex; align-items: flex-end; gap: .6rem; }

/* Emoji picker — floating card */
.cht-emoji-picker {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    width: 300px;
    max-width: calc(100vw - 24px);
    background: var(--card-color, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,.14), 0 2px 8px rgba(0,0,0,.06);
    z-index: 30;
    animation: cht-picker-in .15s ease;
}
@keyframes cht-picker-in {
    from { opacity: 0; transform: translateY(6px) scale(.97); }
    to   { opacity: 1; transform: translateY(0)   scale(1);   }
}
.cht-emoji-head {
    display: flex; align-items: center; gap: 6px;
    padding: 9px 13px 8px;
    font-size: .67rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
    color: var(--text-muted, #9ca3af);
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    background: rgba(0,0,0,.015);
}
.cht-emoji-head i { font-size: .75rem; }
.cht-emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    padding: 6px 5px 8px;
    max-height: 190px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color, #e5e7eb) transparent;
}
.cht-emoji-grid::-webkit-scrollbar { width: 5px; }
.cht-emoji-grid::-webkit-scrollbar-track { background: transparent; }
.cht-emoji-grid::-webkit-scrollbar-thumb { background: var(--border-color, #e5e7eb); border-radius: 99px; }
.cht-emoji-item {
    display: flex; align-items: center; justify-content: center;
    width: 100%; aspect-ratio: 1;
    background: none; border: none; cursor: pointer;
    font-size: 1.25rem; border-radius: 8px; line-height: 1;
    transition: background .1s, transform .12s;
}
.cht-emoji-item:hover {
    background: var(--hover-color, #f3f4f6);
    transform: scale(1.25);
}

/* Emoji toggle button */
.cht-emoji-btn {
    background: none; border: 1px solid var(--border-color, #e5e7eb); border-radius: 8px;
    width: 36px; height: 36px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; cursor: pointer; transition: border-color .15s;
}
.cht-emoji-btn:hover { border-color: #059669; }

/* Input wrap + counter */
.cht-input-wrap { flex: 1; position: relative; }
.cht-input {
    width: 100%; border: 1px solid var(--border-color, #e5e7eb); border-radius: 10px;
    padding: .55rem 2.6rem .55rem .85rem; font-size: .9rem; resize: none; overflow: hidden;
    background: var(--bg-color, #f9fafb); color: var(--text-color, #111);
    font-family: inherit; max-height: 120px; transition: border-color .15s;
    display: block;
}
.cht-input:focus { outline: none; border-color: #059669; }

.cht-char-counter {
    position: absolute; right: 8px; bottom: 7px;
    font-size: .62rem; color: var(--text-muted, #9ca3af);
    pointer-events: none; line-height: 1;
}
.cht-char-counter.cht-warn   { color: #f59e0b; }
.cht-char-counter.cht-danger { color: #ef4444; font-weight: 700; }

.cht-send-btn {
    background: #059669; color: #fff; border: none; border-radius: 10px;
    width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 1rem; flex-shrink: 0; transition: background .15s;
}
.cht-send-btn:hover { background: #047857; }

/* Delete button — appears on hover */
.cht-del {
    background: none; border: none; cursor: pointer; line-height: 1;
    font-size: .65rem; color: var(--text-muted, #9ca3af);
    padding: 2px 4px; border-radius: 4px;
    opacity: 0; transition: opacity .15s, color .15s;
}
.cht-msg:hover .cht-del { opacity: 1; }
.cht-del:hover { color: #ef4444; }

.cht-login-notice {
    border-top: 1px solid var(--border-color, #e5e7eb);
    padding: 1rem 1.25rem; text-align: center;
    font-size: .875rem; color: var(--text-muted, #6b7280);
}
.cht-login-notice a { color: var(--underline-color, #6366f1); font-weight: 600; }

/* Mobile */
@media (max-width: 640px) {
    .cht-card         { height: calc(100vh - 120px); }
    .cht-msg          { max-width: 88%; }
    .cht-emoji-picker { width: 260px; }
    .cht-emoji-grid   { max-height: 160px; grid-template-columns: repeat(7, 1fr); }
    .cht-scroll-btn   { bottom: 68px; }
}

/* ── Pièce jointe chat ──────────────────────────────────────────────────── */
.chat-att-card {
    display: flex; align-items: center; gap: 10px;
    background: var(--card-color); border: 1.5px solid var(--border-color);
    border-radius: 12px; padding: 10px 12px; text-decoration: none;
    margin-top: 6px; max-width: 300px; transition: border-color .15s, box-shadow .15s;
}
.chat-att-card:hover { border-color: var(--underline-color); box-shadow: 0 2px 12px rgba(0,0,0,.08); }
.chat-att-thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.chat-att-icon-wrap {
    width: 40px; height: 40px; border-radius: 8px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.chat-att-info { flex: 1; min-width: 0; }
.chat-att-type { font-size: .68rem; font-weight: 700; color: var(--text-muted-input); text-transform: uppercase; letter-spacing: .04em; }
.chat-att-title { font-size: .82rem; font-weight: 600; color: var(--title-color); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-att-arrow { font-size: .7rem; color: var(--text-muted-input); flex-shrink: 0; }
.chat-att-pending { padding: 6px 12px 0; }
.chat-att-pending-inner {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg-input); border: 1px dashed var(--border-color);
    border-radius: 10px; padding: 7px 10px;
}
.chat-att-pending-icon { font-size: .9rem; flex-shrink: 0; }
.chat-att-pending-text { flex: 1; min-width: 0; }
.chat-att-pending-label { font-size: .65rem; font-weight: 700; color: var(--text-muted-input); text-transform: uppercase; }
.chat-att-pending-title { font-size: .8rem; font-weight: 600; color: var(--title-color); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-att-pending-clear {
    background: none; border: none; color: var(--text-muted-input); cursor: pointer;
    padding: 2px 4px; border-radius: 4px; font-size: .75rem; flex-shrink: 0;
    transition: color .15s;
}
.chat-att-pending-clear:hover { color: #ef4444; }
.chat-att-chips { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 12px 0; }
.chat-att-chip {
    display: inline-flex; align-items: center; gap: 5px;
    background: var(--bg-input); border: 1px dashed var(--border-color);
    border-radius: 20px; padding: 3px 6px 3px 10px;
    font-size: .75rem; font-weight: 600; color: var(--title-color); max-width: 180px;
}
.chat-att-chip-lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-att-chip-rm {
    background: none; border: none; color: var(--text-muted-input); cursor: pointer;
    padding: 0 2px; font-size: .65rem; flex-shrink: 0; transition: color .15s;
}
.chat-att-chip-rm:hover { color: #ef4444; }
.chat-att-sel-count { font-size: .78rem; font-weight: 700; color: var(--underline-color); }
.chat-att-picker-tabs { display: flex; gap: 4px; padding: 12px 12px 0; flex-wrap: wrap; }
.chat-att-picker-tab {
    padding: 5px 10px; border-radius: 8px; border: 1px solid var(--border-color);
    background: var(--bg-input); color: var(--text-muted-input);
    font-size: .75rem; font-weight: 700; cursor: pointer; transition: all .15s;
}
.chat-att-picker-tab.active { background: var(--underline-color); color: #fff; border-color: var(--underline-color); }
.chat-att-picker-tab:hover:not(.active) { border-color: var(--underline-color); color: var(--underline-color); }
.chat-att-private-toggle { display: flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--text-muted-input); padding: 6px 2px 0; cursor: pointer; }
.chat-att-results { max-height: 240px; overflow-y: auto; padding: 4px 0 8px; }
.chat-att-hint { padding: 16px; font-size: .82rem; color: var(--text-muted-input); text-align: center; }
.chat-att-section-label { padding: 8px 12px 4px; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted-input); }
.chat-att-result-row {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 8px 12px; border: none; background: transparent; cursor: pointer;
    text-align: left; transition: background .12s;
}
.chat-att-result-row:hover { background: rgba(var(--rgb-title-color),.04); }
.chat-att-result-row.selected { background: rgba(var(--rgb-underline-color),.08); }
.chat-att-result-icon {
    width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: .9rem;
}
.chat-att-result-info { flex: 1; min-width: 0; text-align: left; }
.chat-att-result-title { font-size: .82rem; font-weight: 600; color: var(--title-color); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-att-result-sub { font-size: .7rem; color: var(--text-muted-input); }
.chat-att-result-check { font-size: .75rem; color: var(--underline-color); opacity: 0; transition: opacity .15s; flex-shrink: 0; }
.chat-att-result-row.selected .chat-att-result-check { opacity: 1; }
.cht-attach-btn {
    background: none; border: 1px solid var(--border-color); border-radius: 8px;
    width: 36px; height: 36px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted-input); cursor: pointer; font-size: .88rem;
    transition: border-color .15s, color .15s;
}
.cht-attach-btn:hover { border-color: var(--underline-color); color: var(--underline-color); }

/* Attachment picker modal */
.chat-att-modal-content {
    background-color: var(--card-color) !important;
    border: 1.5px solid var(--border-color);
    border-radius: 20px !important;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,.22);
}
.chat-att-modal-content .modal-header {
    background: rgba(var(--rgb-underline-color),.04);
    border-bottom: 1.5px solid var(--border-color);
    padding: 14px 18px 12px;
}
.chat-att-modal-content .modal-body { background-color: var(--card-color) !important; padding: 0; }
.chat-att-modal-content .modal-footer {
    background-color: var(--card-color) !important;
    border-top: 1.5px solid var(--border-color);
    padding: 10px 18px;
}
.chat-att-modal-content .form-control {
    background-color: var(--bg-input) !important;
    border: 1.5px solid var(--border-color) !important;
    color: var(--title-color) !important;
    border-radius: 10px;
}
.chat-att-modal-content .form-control:focus {
    border-color: var(--underline-color) !important;
    box-shadow: 0 0 0 3px rgba(var(--rgb-underline-color),.13);
}
