/* ═══════════════════════════════════════════════════════════════
   TRADES — Système d'échanges acheteur-vendeur
   ═══════════════════════════════════════════════════════════════ */

/* Sections */
.trade-section {
    margin-bottom: 24px;
}

.trade-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #e2e8f0;
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.trade-count {
    background: rgba(102, 126, 234, 0.2);
    color: #667eea;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 10px;
}

/* ── Demandes ────────────────────────────────────────────── */

.trade-requests-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.trade-request-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    transition: background 0.15s;
}

.trade-request-card:hover {
    background: rgba(255, 255, 255, 0.06);
}

.trade-request-info {
    flex: 1;
    min-width: 0;
}

.trade-request-card-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #e2e8f0;
}

.trade-request-meta {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.45);
    margin-top: 2px;
}

.trade-request-message {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
    margin-top: 4px;
}

.trade-request-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.trade-request-status {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Boutons */
.trade-btn {
    padding: 7px 14px;
    border-radius: 8px;
    border: none;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.trade-btn-accept {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.3);
}
.trade-btn-accept:hover { background: rgba(34, 197, 94, 0.25); }

.trade-btn-reject {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.trade-btn-reject:hover { background: rgba(239, 68, 68, 0.2); }

.trade-btn-sold {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
    border: 1px solid rgba(234, 179, 8, 0.3);
}
.trade-btn-sold:hover { background: rgba(234, 179, 8, 0.25); }

.trade-btn-send {
    background: rgba(102, 126, 234, 0.2);
    color: #667eea;
    border: 1px solid rgba(102, 126, 234, 0.3);
}
.trade-btn-send:hover { background: rgba(102, 126, 234, 0.3); }

.trade-btn-sm {
    padding: 4px 10px;
    border-radius: 6px;
    border: none;
    font-size: 0.75rem;
    cursor: pointer;
}

.trade-btn-cancel {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.trade-btn-cancel:hover { color: #ef4444; border-color: rgba(239, 68, 68, 0.3); }

/* Statuts */
.trade-status { font-size: 0.8rem; font-weight: 600; }
.trade-status-pending { color: #eab308; }
.trade-status-accepted { color: #22c55e; }
.trade-status-rejected { color: #ef4444; }
.trade-status-cancelled { color: rgba(255,255,255,0.4); }
.trade-status-expired { color: rgba(255,255,255,0.3); }

/* ── Conversations liste ─────────────────────────────────── */

.trade-conversations-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.trade-conversation-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
}

.trade-conversation-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(102, 126, 234, 0.2);
}

.trade-conversation-item.unread {
    background: rgba(102, 126, 234, 0.06);
    border-left: 3px solid #667eea;
}

.trade-conv-info {
    flex: 1;
    min-width: 0;
}

.trade-conv-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.trade-conv-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #e2e8f0;
}

.trade-unread-badge {
    background: #667eea;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 9px;
    padding: 0 5px;
}

.trade-conv-other {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 2px;
}

.trade-conv-last {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.55);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 4px;
}

.trade-conv-time {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

/* ── Chat ────────────────────────────────────────────────── */

.trade-chat {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 280px);
    min-height: 400px;
}

.trade-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.trade-chat-back {
    background: none;
    border: none;
    color: #667eea;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    flex-shrink: 0;
}
.trade-chat-back:hover { background: rgba(102, 126, 234, 0.1); }

.trade-chat-card-info {
    flex: 1;
    min-width: 0;
}
.trade-chat-card-info strong {
    display: block;
    font-size: 0.9rem;
    color: #e2e8f0;
}
.trade-chat-card-info span {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.45);
}

.trade-chat-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.trade-chat-status {
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    flex-shrink: 0;
}

/* Messages zone */
.trade-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.trade-msg {
    max-width: 75%;
}

.trade-msg-mine {
    align-self: flex-end;
    text-align: right;
}

.trade-msg-other {
    align-self: flex-start;
}

.trade-msg-system {
    align-self: center;
    max-width: 90%;
    text-align: center;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.35);
    font-style: italic;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
}

.trade-msg-sender {
    font-size: 0.7rem;
    color: #667eea;
    font-weight: 600;
    margin-bottom: 2px;
}

.trade-msg-bubble {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 14px;
    font-size: 0.85rem;
    line-height: 1.4;
    word-break: break-word;
}

.trade-msg-mine .trade-msg-bubble {
    background: rgba(102, 126, 234, 0.2);
    color: #c7d2fe;
    border-bottom-right-radius: 4px;
}

.trade-msg-other .trade-msg-bubble {
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    border-bottom-left-radius: 4px;
}

.trade-msg-time {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.25);
    margin-top: 2px;
}

/* Input zone */
.trade-chat-input {
    display: flex;
    gap: 8px;
    padding: 12px 0 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.trade-chat-input input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
    font-size: 0.85rem;
    outline: none;
}
.trade-chat-input input:focus {
    border-color: rgba(102, 126, 234, 0.4);
}

/* Badge onglet */
#tradesBadge {
    background: #667eea;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 8px;
    padding: 0 4px;
    display: none;
    margin-left: 6px;
}

/* Bouton "Je suis intéressé" dans card-detail */
.cdm-btn-interest {
    border-color: rgba(34, 197, 94, 0.5) !important;
    color: #22c55e !important;
}
.cdm-btn-interest:hover {
    background: rgba(34, 197, 94, 0.1) !important;
}

/* Mobile */
@media (max-width: 640px) {
    .trade-chat {
        height: calc(100vh - 200px);
    }
    .trade-request-card {
        flex-direction: column;
        align-items: flex-start;
    }
    .trade-request-actions {
        width: 100%;
    }
    .trade-request-actions .trade-btn {
        flex: 1;
    }
    .trade-chat-header {
        flex-wrap: wrap;
    }
}
