/* =========================================
   REDLINE Negotiation Chat Styles
   ========================================= */

/* ─── INBOX VIEW ─── */
.chat-inbox-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 32px 16px 80px;
}

.chat-inbox-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.chat-inbox-header h1 {
    font-family: var(--font-brand, 'Cinzel', serif);
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary, #fff);
    letter-spacing: 0.03em;
}

.chat-inbox-header .inbox-count {
    background: var(--accent-red, #e53935);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
}

.chat-inbox-empty {
    text-align: center;
    padding: 80px 32px;
    color: var(--text-muted, #777);
}

.chat-inbox-empty i {
    font-size: 3.5rem;
    margin-bottom: 18px;
    display: block;
    opacity: 0.3;
}

.chat-inbox-empty p {
    font-size: 1.05rem;
    margin-bottom: 20px;
}

.chat-inbox-empty a {
    color: var(--accent-red, #e53935);
    text-decoration: none;
    font-weight: 600;
}

/* Negotiation list items */
.neg-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.neg-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: var(--bg-surface, #1a1a2e);
    border: 1px solid var(--border-color, rgba(255,255,255,0.06));
    border-radius: 14px;
    text-decoration: none;
    transition: all 0.25s ease;
    position: relative;
    cursor: pointer;
}

.neg-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(229, 57, 53, 0.25);
    transform: translateY(-1px);
}

.neg-item.unread {
    border-color: rgba(229, 57, 53, 0.3);
    background: rgba(229, 57, 53, 0.04);
}

.neg-item-img {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    background: rgba(255,255,255,0.04);
}

.neg-item-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.neg-item-img .no-img {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--text-muted, #777);
    font-size: 1.2rem;
}

.neg-item-body {
    flex: 1;
    min-width: 0;
}

.neg-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.neg-item-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary, #fff);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.neg-item-time {
    font-size: 0.75rem;
    color: var(--text-muted, #777);
    flex-shrink: 0;
}

.neg-item-listing {
    font-size: 0.8rem;
    color: var(--text-secondary, #aaa);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}

.neg-item-preview {
    font-size: 0.82rem;
    color: var(--text-muted, #777);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.neg-item .unread-dot {
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    background: var(--accent-red, #e53935);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(229, 57, 53, 0.5);
}

.neg-item-status {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: 6px;
    display: inline-block;
}

.neg-item-status.status-active {
    background: rgba(76, 175, 80, 0.15);
    color: #81c784;
}

.neg-item-status.status-accepted {
    background: rgba(33, 150, 243, 0.15);
    color: #64b5f6;
}

.neg-item-status.status-rejected {
    background: rgba(229, 57, 53, 0.15);
    color: #ef5350;
}

.neg-item-status.status-expired {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted, #777);
}


/* ─── CHAT VIEW ─── */
.chat-page {
    max-width: 820px;
    margin: 0 auto;
    padding: 16px 16px 80px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 80px);
}

.chat-product-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: var(--bg-surface, #1a1a2e);
    border: 1px solid var(--border-color, rgba(255,255,255,0.06));
    border-radius: 14px;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.chat-product-header .back-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.05);
    color: var(--text-secondary, #aaa);
    text-decoration: none;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-product-header .back-btn:hover {
    background: var(--accent-red, #e53935);
    color: #fff;
}

.chat-product-img {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
}

.chat-product-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-product-info {
    flex: 1;
    min-width: 0;
}

.chat-product-info h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary, #fff);
    margin: 0 0 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-product-info .meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
}

.chat-product-info .meta .price {
    color: var(--accent-red, #e53935);
    font-weight: 700;
}

.chat-product-info .meta .partner {
    color: var(--text-muted, #777);
}

.chat-neg-status {
    padding: 5px 12px;
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.chat-neg-status.st-active { background: rgba(76,175,80,0.15); color: #81c784; }
.chat-neg-status.st-accepted { background: rgba(33,150,243,0.15); color: #64b5f6; }
.chat-neg-status.st-rejected { background: rgba(229,57,53,0.15); color: #ef5350; }


/* ─── MESSAGES AREA ─── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
}

/* Message Bubbles */
.msg-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 80%;
}

.msg-row.self {
    align-self: flex-end;
}

.msg-row.other {
    align-self: flex-start;
}

.msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg-surface, #1a1a2e);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary, #aaa);
    flex-shrink: 0;
    border: 1px solid var(--border-color, rgba(255,255,255,0.06));
    overflow: hidden;
}

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

.msg-bubble {
    padding: 10px 16px;
    border-radius: 18px;
    font-size: 0.9rem;
    line-height: 1.5;
    position: relative;
    word-break: break-word;
}

.msg-row.self .msg-bubble {
    background: linear-gradient(135deg, #e53935, #c62828);
    color: #fff;
    border-bottom-right-radius: 6px;
}

.msg-row.other .msg-bubble {
    background: var(--bg-surface, #1a1a2e);
    color: var(--text-primary, #fff);
    border: 1px solid var(--border-color, rgba(255,255,255,0.06));
    border-bottom-left-radius: 6px;
}

.msg-time {
    font-size: 0.65rem;
    color: rgba(255,255,255,0.4);
    margin-top: 4px;
    display: block;
}

.msg-row.other .msg-time {
    color: var(--text-muted, #777);
}


/* ─── OFFER CARDS ─── */
.msg-offer-card {
    padding: 16px 18px;
    border-radius: 16px;
    border: 1px solid var(--border-color, rgba(255,255,255,0.06));
    min-width: 220px;
}

.msg-row.self .msg-offer-card {
    background: linear-gradient(135deg, rgba(229,57,53,0.15), rgba(198,40,40,0.1));
    border-color: rgba(229,57,53,0.3);
}

.msg-row.other .msg-offer-card {
    background: var(--bg-surface, #1a1a2e);
}

.offer-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.offer-label i {
    font-size: 0.9rem;
}

.offer-label.type-offer { color: #ffb74d; }
.offer-label.type-counter { color: #64b5f6; }
.offer-label.type-accept { color: #81c784; }
.offer-label.type-reject { color: #ef5350; }

.offer-amount {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary, #fff);
    margin-bottom: 4px;
    font-family: var(--font-brand, 'Cinzel', serif);
}

.offer-msg {
    font-size: 0.82rem;
    color: var(--text-secondary, #aaa);
    margin-bottom: 10px;
}

.offer-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.offer-actions button {
    flex: 1;
    padding: 8px 14px;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.25s ease;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.offer-actions .btn-accept {
    background: #4caf50;
    color: #fff;
}
.offer-actions .btn-accept:hover {
    background: #43a047;
    transform: translateY(-1px);
}

.offer-actions .btn-reject {
    background: rgba(229, 57, 53, 0.15);
    color: #ef5350;
    border: 1px solid rgba(229,57,53,0.25);
}
.offer-actions .btn-reject:hover {
    background: rgba(229, 57, 53, 0.25);
    transform: translateY(-1px);
}

.offer-actions .btn-counter {
    background: rgba(33, 150, 243, 0.15);
    color: #64b5f6;
    border: 1px solid rgba(33,150,243,0.25);
}
.offer-actions .btn-counter:hover {
    background: rgba(33, 150, 243, 0.25);
    transform: translateY(-1px);
}


/* ─── SYSTEM MESSAGES ─── */
.msg-system {
    align-self: center;
    max-width: 90%;
    text-align: center;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 0.8rem;
    color: var(--text-muted, #777);
    background: rgba(255,255,255,0.03);
    border: 1px dashed rgba(255,255,255,0.08);
}

.msg-system.accepted {
    color: #81c784;
    border-color: rgba(76,175,80,0.2);
    background: rgba(76,175,80,0.05);
}

.msg-system.rejected {
    color: #ef5350;
    border-color: rgba(229,57,53,0.2);
    background: rgba(229,57,53,0.05);
}


/* ─── INPUT BAR ─── */
.chat-input-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--bg-surface, #1a1a2e);
    border: 1px solid var(--border-color, rgba(255,255,255,0.06));
    border-radius: 16px;
    flex-shrink: 0;
    backdrop-filter: blur(16px);
}

.chat-input-bar input[type="text"] {
    flex: 1;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px;
    padding: 10px 16px;
    color: var(--text-primary, #fff);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.3s;
}

.chat-input-bar input[type="text"]:focus {
    border-color: rgba(229,57,53,0.4);
}

.chat-input-bar input[type="text"]::placeholder {
    color: var(--text-muted, #777);
}

.chat-input-bar .btn-send {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #e53935, #c62828);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s;
    flex-shrink: 0;
}

.chat-input-bar .btn-send:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(229,57,53,0.35);
}

.chat-input-bar .btn-offer {
    padding: 10px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255,183,77,0.3);
    background: rgba(255,183,77,0.1);
    color: #ffb74d;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.25s;
    flex-shrink: 0;
    white-space: nowrap;
}

.chat-input-bar .btn-offer:hover {
    background: rgba(255,183,77,0.2);
    transform: translateY(-1px);
}

/* ─── QUICK REPLIES ─── */
.quick-replies-rack {
    display: flex;
    gap: 8px;
    padding: 0 16px 8px;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.quick-replies-rack::-webkit-scrollbar { height: 4px; }
.quick-replies-rack::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }

.quick-reply-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-secondary, #aaa);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.75rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}
.quick-reply-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-color: rgba(255,255,255,0.2);
}

.chat-closed-bar {
    padding: 16px 20px;
    text-align: center;
    background: var(--bg-surface, #1a1a2e);
    border: 1px solid var(--border-color, rgba(255,255,255,0.06));
    border-radius: 16px;
    color: var(--text-muted, #777);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.chat-closed-bar i {
    margin-right: 6px;
}


/* ─── OFFER MODAL ─── */
.offer-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.offer-modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.offer-modal {
    background: var(--bg-card, #16162a);
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
    border-radius: 20px;
    padding: 32px 28px;
    width: 92%;
    max-width: 380px;
    text-align: center;
    transform: translateY(20px) scale(0.95);
    transition: all 0.35s ease;
}

.offer-modal-overlay.show .offer-modal {
    transform: translateY(0) scale(1);
}

.offer-modal h3 {
    font-family: var(--font-brand, 'Cinzel', serif);
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--text-primary, #fff);
    margin-bottom: 6px;
}

.offer-modal .modal-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted, #777);
    margin-bottom: 20px;
}

.offer-modal .offer-input-group {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 16px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 14px;
    overflow: hidden;
    background: rgba(255,255,255,0.03);
}

.offer-modal .currency-label {
    padding: 12px 14px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-secondary, #aaa);
    background: rgba(255,255,255,0.04);
    border-right: 1px solid rgba(255,255,255,0.08);
}

.offer-modal .offer-amount-input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 12px 14px;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary, #fff);
    outline: none;
}

.offer-modal .offer-amount-input::placeholder {
    color: var(--text-muted, #777);
    font-weight: 400;
}

.offer-modal .offer-note {
    width: 100%;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 14px;
    padding: 10px 14px;
    font-size: 0.85rem;
    color: var(--text-primary, #fff);
    outline: none;
    margin-bottom: 20px;
    resize: none;
    min-height: 50px;
    font-family: inherit;
    transition: border-color 0.3s;
}

.offer-modal .offer-note:focus {
    border-color: rgba(229,57,53,0.4);
}

.offer-modal .offer-note::placeholder {
    color: var(--text-muted, #777);
}

.offer-modal-actions {
    display: flex;
    gap: 10px;
}

.offer-modal-actions button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.25s;
}

.offer-modal-actions .btn-cancel {
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary, #aaa);
}
.offer-modal-actions .btn-cancel:hover {
    background: rgba(255,255,255,0.1);
}

.offer-modal-actions .btn-submit-offer {
    background: linear-gradient(135deg, #ffb74d, #f57c00);
    color: #000;
    font-weight: 800;
}
.offer-modal-actions .btn-submit-offer:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(255,183,77,0.3);
}


/* ─── NEGOTIATE BUTTON on listing page ─── */
.btn-negotiate {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 13px 24px;
    border: 1px solid rgba(255,183,77,0.3);
    background: rgba(255,183,77,0.08);
    color: #ffb74d;
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 10px;
}

.btn-negotiate:hover {
    background: rgba(255,183,77,0.18);
    border-color: rgba(255,183,77,0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(255,183,77,0.15);
    color: #ffb74d;
    text-decoration: none;
}

.btn-negotiate i {
    font-size: 1rem;
}


/* ─── DATE SEPARATOR ─── */
.msg-date-sep {
    align-self: center;
    padding: 4px 16px;
    font-size: 0.7rem;
    color: var(--text-muted, #777);
    background: rgba(255,255,255,0.03);
    border-radius: 20px;
    margin: 8px 0;
    font-weight: 600;
    letter-spacing: 0.03em;
}


/* ─── TYPING INDICATOR (optional future use) ─── */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 16px;
    align-self: flex-start;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--text-muted, #777);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}


/* ─── NAV BADGE for Chat ─── */
.chat-nav-badge,
.chat-badge-count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--accent-red, #e53935);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(229,57,53,0.4);
}


/* ─── LEGACY ALIASES (kept for backward compatibility) ─── */
/* The negotiate.php page now uses .messenger-shell / .msg-sidebar / .msg-pane */
.seller-chat-container {
    display: flex;
    height: calc(100vh - 160px);
    background: var(--bg-card, #16162a);
    border-radius: 14px;
    border: 1px solid var(--border-color, rgba(255,255,255,0.06));
    overflow: hidden;
}

.seller-neg-list {
    width: 310px;
    border-right: 1px solid var(--border-color, rgba(255,255,255,0.06));
    overflow-y: auto;
    flex-shrink: 0;
}

.seller-chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.seller-chat-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted, #777);
}

.seller-chat-placeholder i {
    font-size: 3rem;
    margin-bottom: 14px;
    opacity: 0.2;
}


/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
    .chat-page {
        padding: 8px 8px 100px;
        height: calc(100vh - 60px);
    }

    .chat-product-header {
        padding: 10px 12px;
        border-radius: 12px;
        gap: 10px;
    }

    .chat-product-img {
        width: 40px;
        height: 40px;
    }

    .msg-row {
        max-width: 90%;
    }

    .chat-input-bar {
        border-radius: 12px;
        padding: 10px 12px;
        gap: 8px;
    }

    .chat-input-bar .btn-offer span {
        display: none;
    }

    .chat-inbox-page {
        padding: 16px 12px 100px;
    }

    .chat-inbox-header h1 {
        font-size: 1.4rem;
    }

    .seller-chat-container {
        flex-direction: column;
        height: auto;
    }

    .seller-neg-list {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.06));
        max-height: 280px;
    }

    /* Messenger shell responsive override */
    .messenger-shell {
        flex-direction: column !important;
        height: auto !important;
        min-height: unset !important;
        border-radius: 0 !important;
    }

    .msg-sidebar {
        width: 100% !important;
        height: 38vh !important;
        border-right: none !important;
        border-bottom: 2px solid var(--border-color, rgba(255,255,255,0.06)) !important;
    }

    .msg-pane {
        min-height: 55vh;
    }
}
