/* ============================================================
   sms.css — Messagerie boutique ↔ clients Flutter
   Cadre 2 colonnes : liste des conversations | chat
   ============================================================ */

.sms-wrap {
    display: flex;
    gap: 14px;
    height: calc(100vh - 220px);
    min-height: 420px;
}

/* ── Colonne conversations ────────────────────────────────── */
.sms-convs {
    width: 320px;
    flex-shrink: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sms-convs-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .8rem 1rem;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: .9rem;
    color: var(--text);
}

.sms-conv-list {
    flex: 1;
    overflow-y: auto;
}

.sms-conv-item {
    display: flex;
    gap: .7rem;
    align-items: center;
    padding: .75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background .15s;
}

.sms-conv-item:hover { background: var(--bg); }
.sms-conv-item.active { background: var(--primary-light); }

.sms-conv-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
}

.sms-conv-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sms-conv-body { flex: 1; min-width: 0; }

.sms-conv-name {
    font-weight: 600;
    font-size: .85rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sms-conv-preview {
    font-size: .76rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sms-conv-badge {
    background: var(--danger);
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    border-radius: 999px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sms-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--muted);
    font-size: .85rem;
}

/* ── Colonne chat ─────────────────────────────────────────── */
.sms-chat {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sms-chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    color: var(--muted);
}

.sms-chat-empty i { font-size: 2.4rem; }

.sms-chat-pane {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.sms-chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .8rem 1rem;
    border-bottom: 1px solid var(--border);
}

.sms-peer {
    font-weight: 700;
    font-size: .95rem;
    color: var(--text);
}

.sms-msg-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.sms-msg {
    max-width: 72%;
    padding: .55rem .85rem;
    border-radius: 14px;
    font-size: .85rem;
    line-height: 1.4;
    word-break: break-word;
    cursor: grab;
    transition: transform .15s ease;
    user-select: none;
}
.sms-msg.dragging { cursor: grabbing; transition: none; }

/* ── Citation (réponse à un message) ──────────────────────── */
.sms-msg-quote {
    border-left: 3px solid rgba(46,125,98,.9);
    background: rgba(46,125,98,.10);
    border-radius: 8px;
    padding: .3rem .5rem;
    margin-bottom: .4rem;
    font-size: .72rem;
    display: block;
}
.sms-msg.out .sms-msg-quote {
    border-left-color: rgba(255,255,255,.7);
    background: rgba(255,255,255,.15);
}
.sms-msg-quote .quote-who { font-weight: 700; display: block; }
.sms-msg-quote .quote-txt {
    display: block; opacity: .85;
    overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; max-width: 220px;
}

/* ── Barre de réponse au-dessus du champ ──────────────────── */
.sms-reply-bar {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin: 0 1rem;
    padding: .5rem .8rem;
    background: var(--surface2, #f6f8f7);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: 10px;
    font-size: .78rem;
}
.sms-reply-bar .reply-ico { color: var(--primary); }
.sms-reply-bar .reply-who { font-weight: 700; color: var(--primary); }
.sms-reply-bar .reply-txt {
    flex: 1; opacity: .8;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sms-reply-bar .reply-x {
    border: none; background: none; cursor: pointer;
    color: var(--muted, #888); font-size: .9rem; padding: .2rem;
}
.sms-reply-bar .reply-x:hover { color: var(--text); }

/* ── Avatar dans l'en-tête du chat ────────────────────────── */
.sms-peer-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    overflow: hidden; flex-shrink: 0;
    background: var(--surface2, #eef0ee);
    color: var(--primary); font-weight: 800; font-size: .9rem;
    display: flex; align-items: center; justify-content: center;
}
.sms-peer-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ── Champ de saisie multiligne auto-resize ───────────────── */
textarea.sms-input {
    flex: 1; resize: none;
    min-height: 38px; max-height: 120px;
    overflow-y: auto; line-height: 1.35;
    padding-top: .55rem; padding-bottom: .55rem;
}

.sms-msg .sms-msg-meta {
    display: block;
    font-size: .65rem;
    opacity: .7;
    margin-top: .25rem;
}

/* acheteur (client) → bulle à gauche */
.sms-msg.in {
    align-self: flex-start;
    background: var(--bg);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

/* vendeur (moi) → bulle à droite */
.sms-msg.out {
    align-self: flex-end;
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.sms-input-row {
    display: flex;
    gap: .6rem;
    padding: .8rem 1rem;
    border-top: 1px solid var(--border);
}

.sms-input-row .form-control { flex: 1; }

/* ── Responsive : une colonne à la fois ───────────────────── */
@media (max-width: 768px) {
    .sms-wrap { flex-direction: column; height: auto; }
    .sms-convs { width: 100%; }
    .sms-chat { min-height: 60vh; }
}

/* ── Contexte produit ─────────────────────────────────────── */
#sms-product-card { padding: .6rem 1rem 0; }

.sms-product-card {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .55rem .8rem;
    background: var(--surface2, #f6f8f7);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.sms-product-img {
    width: 40px; height: 40px;
    border-radius: 8px;
    overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    background: #fff;
    color: var(--primary);
    flex-shrink: 0;
}
.sms-product-img img { width: 100%; height: 100%; object-fit: cover; }

.sms-product-label {
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted, #888);
}

.sms-product-nom { font-size: .85rem; font-weight: 700; }
.sms-product-prix { font-size: .78rem; font-weight: 700; color: var(--primary); }

/* Puce produit dans une bulle de message */
.sms-msg-product {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .35rem .5rem;
    margin-bottom: .45rem;
    border-radius: 8px;
    background: rgba(0,0,0,.05);
    font-size: .75rem;
    font-weight: 600;
}
.sms-msg-product img {
    width: 26px; height: 26px;
    border-radius: 6px;
    object-fit: cover;
}
.sms-msg-product i { font-size: .9rem; }
