/* ========================================
   ! CHAT FEATURES — append to style.css
   ======================================== */

/* ========== EMOJI REACTION PICKER ========== */
.reaction-picker {
    display: flex;
    gap: 4px;
    padding: 8px 10px;
    background: var(--m-surface);
    border: 3px solid var(--m-dark);
    border-radius: 50px;
    box-shadow: 6px 6px 0 var(--m-dark);
    animation: ctx-pop .12s ease-out;
    z-index: 9999;
}

.reaction-picker-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 2px 3px;
    border-radius: 8px;
    transition: transform .1s, background .1s;
    line-height: 1;
}
.reaction-picker-btn:hover  { transform: scale(1.35); background: var(--m-surface2); }
.reaction-picker-btn:active { transform: scale(1.1); }

/* ========== REACTION CHIPS on messages ========== */
.msg-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 5px;
}

.msg-reaction-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px 2px 5px;
    border: 2px solid var(--m-dark);
    border-radius: 50px;
    background: var(--m-surface);
    font-size: 14px;
    cursor: pointer;
    transition: background .1s, transform .1s;
    font-family: inherit;
    line-height: 1.3;
}
.msg-reaction-chip span {
    font-size: 11px;
    font-weight: 900;
    color: var(--m-dark);
}
.msg-reaction-chip.mine {
    background: var(--m-yellow);
    border-color: var(--m-dark);
}
.msg-reaction-chip:hover  { transform: scale(1.08); }
.msg-reaction-chip:active { transform: scale(.97); }

/* ========== REPLY BAR ========== */
.reply-bar {
    border-top: 3px solid var(--m-teal);
    background: var(--m-surface);
    flex-shrink: 0;
}

.reply-bar-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
}

.reply-bar-icon { font-size: 18px; flex-shrink: 0; }

.reply-bar-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
    border-left: 3px solid var(--m-teal);
    padding-left: 8px;
}

.reply-bar-name {
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--m-teal);
}

.reply-bar-text {
    font-size: 12px;
    font-weight: 600;
    color: var(--m-dark);
    opacity: .65;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-bar-close {
    background: none;
    border: 2px solid #bbb;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    font-weight: 900;
    flex-shrink: 0;
    transition: background .1s, color .1s;
}
.reply-bar-close:hover { background: var(--m-pink); color: #fff; border-color: var(--m-pink); }

/* ========== QUOTED MESSAGE in bubble ========== */
.msg-quote {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 5px 10px;
    margin-bottom: 6px;
    border-left: 3px solid var(--m-teal);
    border-radius: 4px;
    background: rgba(0,0,0,0.06);
    cursor: pointer;
    transition: background .1s;
}
.message.own .msg-quote { border-left-color: rgba(0,0,0,0.3); }
.msg-quote:hover        { background: rgba(0,0,0,0.10); }

.msg-quote-name {
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--m-teal);
}
.message.own .msg-quote-name { color: rgba(0,0,0,0.5); }

.msg-quote-text {
    font-size: 12px;
    font-weight: 600;
    opacity: .7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Flash highlight when jumping */
@keyframes highlight-flash {
    0%   { box-shadow: 0 0 0 4px var(--m-teal); }
    60%  { box-shadow: 0 0 0 4px var(--m-teal); }
    100% { box-shadow: none; }
}
.message.highlight-flash {
    animation: highlight-flash 1.2s ease-out;
}

/* ========== EDIT BAR ========== */
.edit-bar {
    border-top: 3px solid var(--m-orange);
    background: var(--m-surface);
    flex-shrink: 0;
}

.edit-bar-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
}

.edit-bar-icon  { font-size: 18px; flex-shrink: 0; }

.edit-bar-label {
    flex: 1;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--m-orange);
}

.edit-bar-close {
    background: none;
    border: 2px solid #bbb;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    font-weight: 900;
    flex-shrink: 0;
    transition: background .1s, color .1s;
}
.edit-bar-close:hover { background: var(--m-orange); color: #fff; border-color: var(--m-orange); }

/* Edited marker */
.msg-edited {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    opacity: .5;
    margin-right: 4px;
}

/* ========== READ RECEIPTS ========== */
.msg-read-status {
    font-size: 11px;
    font-weight: 900;
    opacity: .45;
    margin-right: 3px;
    transition: color .2s, opacity .2s;
    letter-spacing: -1px;
}

.msg-read-status.read {
    color: var(--m-teal);
    opacity: 1;
}

/* ========== TYPING INDICATOR ========== */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    align-self: flex-start;
    padding: 8px 14px;
    background: var(--m-surface);
    border: 3px solid var(--m-dark);
    border-radius: 20px;
    border-bottom-left-radius: 6px;
    max-width: 100px;
    animation: ctx-pop .15s ease-out;
}

.typing-avatar {
    width: 24px;
    height: 24px;
    min-width: 24px;
    border-radius: 50%;
    background: var(--m-teal);
    color: var(--m-dark);
    font-size: 12px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--m-dark);
}

.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--m-dark);
    opacity: .4;
    animation: typing-bounce .9s infinite;
    display: block;
}
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .30s; }

@keyframes typing-bounce {
    0%, 80%, 100% { transform: translateY(0);    opacity: .4; }
    40%            { transform: translateY(-5px); opacity: 1;  }
}

/* ========== VOICE BUTTON ========== */
/* Styles now live in style.css under .chat-circle-btn.voice-btn */

@keyframes pulse-record {
    0%, 100% { opacity: 1; }
    50%       { opacity: .65; }
}

/* ========== RECORDING BAR ========== */
.recording-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--m-surface);
    border-top: 3px solid var(--m-pink);
    flex-shrink: 0;
    animation: ctx-pop .15s ease-out;
}

.recording-cancel {
    background: none;
    border: 2px solid #bbb;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .1s;
}
.recording-cancel:hover { background: #ffeaea; }

.recording-status {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.recording-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--m-pink);
    animation: pulse-record .8s infinite;
    flex-shrink: 0;
}

#recordingTime {
    font-size: 15px;
    font-weight: 900;
    font-family: 'Inter Tight', monospace;
    color: var(--m-pink);
    letter-spacing: 1px;
}

.recording-hint {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #aaa;
    flex-shrink: 0;
}

/* ========== VOICE MESSAGE BUBBLE ========== */
.msg-voice {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 180px;
    max-width: 260px;
}

.voice-play-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 50%;
    border: 3px solid var(--m-dark);
    background: var(--m-dark);
    color: var(--m-yellow);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, transform .1s;
    flex-shrink: 0;
}
.voice-play-btn:hover   { background: var(--m-teal); color: var(--m-dark); }
.voice-play-btn:active  { transform: scale(.93); }
.voice-play-btn.playing { background: var(--m-pink); color: #fff; }

.voice-waveform {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.voice-progress-bar {
    height: 4px;
    background: rgba(0,0,0,0.12);
    border-radius: 2px;
    overflow: hidden;
}

.voice-progress-fill {
    height: 100%;
    background: var(--m-dark);
    border-radius: 2px;
    width: 0%;
    transition: width .1s linear;
}

.message.own .voice-progress-fill { background: rgba(0,0,0,0.4); }

.voice-duration {
    font-size: 11px;
    font-weight: 900;
    opacity: .55;
    text-transform: uppercase;
    letter-spacing: .5px;
    flex-shrink: 0;
    font-family: 'Inter Tight', monospace;
}

.voice-audio { display: none; }

/* ========== DYNAMIC INPUT (wrap-based, no per-element radius needed) ========== */
/*
 * .chat-input-wrap has border + border-radius + overflow:hidden.
 * All children are flat — wrap handles the shape.
 * JS classes no-left-neighbour / no-right-neighbour no longer needed.
 */

/* ========== MOBILE adjustments ========== */
@media (max-width: 768px) {
    .reply-bar-inner  { padding: 8px 12px; }
    .edit-bar-inner   { padding: 8px 12px; }
    .recording-bar    { padding: 8px 12px; }

    .voice-btn {
        padding: 12px 12px;
        font-size: 16px;
    }
}
/* ========== IMAGE PREVIEW MODAL ========== */
.img-preview-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: ctx-pop .15s ease-out;
}

.img-preview-dialog {
    background: var(--m-surface);
    border: 3px solid var(--m-dark);
    border-radius: 20px;
    box-shadow: 8px 8px 0 var(--m-dark);
    display: flex;
    flex-direction: column;
    max-width: min(480px, 96vw);
    width: 100%;
    overflow: hidden;
    animation: ctx-pop .15s ease-out;
}

.img-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 10px;
    border-bottom: 2px solid var(--m-dark);
    background: var(--m-yellow);
}

.img-preview-title {
    font-size: 14px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--m-dark);
}

.img-preview-close {
    background: none;
    border: 2px solid var(--m-dark);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 12px;
    font-weight: 900;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--m-dark);
    transition: background .1s, color .1s;
    flex-shrink: 0;
}
.img-preview-close:hover { background: var(--m-pink); color: #fff; border-color: var(--m-pink); }

.img-preview-body {
    background: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: 55vh;
    overflow: hidden;
}

.img-preview-img {
    max-width: 100%;
    max-height: 55vh;
    object-fit: contain;
    display: block;
}

.img-preview-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 2px solid var(--m-dark);
    background: var(--m-surface);
}

.img-preview-caption {
    flex: 1;
    border: 2px solid var(--m-dark);
    border-radius: 50px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    background: var(--m-surface2, #f5f5f5);
    color: var(--m-dark);
    outline: none;
    transition: border-color .15s;
    min-width: 0;
}
.img-preview-caption:focus { border-color: var(--m-teal); }
.img-preview-caption::placeholder { opacity: .5; }

.img-preview-send {
    flex-shrink: 0;
    background: var(--m-dark);
    color: var(--m-yellow);
    border: 2px solid var(--m-dark);
    border-radius: 50px;
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .5px;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s, color .15s, transform .1s;
    white-space: nowrap;
}
.img-preview-send:hover  { background: var(--m-teal); color: var(--m-dark); border-color: var(--m-teal); }
.img-preview-send:active { transform: scale(.95); }

@media (max-width: 480px) {
    .img-preview-footer { flex-direction: column; gap: 8px; }
    .img-preview-caption { width: 100%; border-radius: 12px; }
    .img-preview-send    { width: 100%; border-radius: 12px; }
}
/* ========== IMAGE DOWNLOAD BUTTON (on image bubble) ========== */
.msg-image-wrap { position: relative; }

.msg-image-download {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 30px;
    height: 30px;
    background: rgba(0,0,0,0.52);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    text-decoration: none;
    opacity: 0;
    transition: opacity .15s, background .15s;
    z-index: 2;
    backdrop-filter: blur(4px);
    line-height: 1;
}
.msg-image-wrap:hover .msg-image-download { opacity: 1; }
.msg-image-download:hover { background: rgba(0,0,0,0.78); }

/* ========== CONTACT CARD — remove friend button ========== */
.contact-time-wrap {
    position: relative;
    flex-shrink: 0;
}

.contact-delete-btn {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    width: 20px;
    height: 20px;
    min-width: 20px;
    border-radius: 50%;
    border: 2px solid var(--m-dark);
    background: var(--m-surface);
    color: var(--m-pink);
    font-size: 10px;
    font-weight: 900;
    padding: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transform: scale(.8);
    transition: opacity .12s, transform .12s, background .12s, color .12s, border-color .12s;
    z-index: 2;
}

/* Show on card hover (desktop) and always show on touch devices, since
   there's no hover state to reveal it on mobile. */
.contact-card:hover .contact-delete-btn { opacity: 1; transform: scale(1); }
@media (hover: none) {
    .contact-delete-btn { opacity: .55; transform: scale(1); }
}

.contact-delete-btn:hover {
    background: var(--m-pink);
    color: #fff;
    border-color: var(--m-pink);
}
.contact-delete-btn:active { transform: scale(.9); }
/* ========== DRAFT PREVIEW in contact list ========== */
.contact-draft-label {
    color: var(--m-orange);
    font-weight: 900;
}
.contact-draft-text {
    color: #888;
    font-style: italic;
}