/* Quote intake form — inline-expand panel below the order builder card. */

.ldi-quote-form { margin-top: 16px; }
.ldi-quote-form .ldi-card { position: relative; }

.ldi-quote-form .ldi-card__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ldi-quote-form__close {
    background: transparent;
    border: 0;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: var(--ldi-text-soft);
    padding: 4px 8px;
}
.ldi-quote-form__close:hover { color: var(--ldi-text); }

.ldi-quote-form__form {
    display: grid;
    gap: 14px;
    margin-top: 8px;
}
.ldi-quote-form__row { display: grid; gap: 4px; }
.ldi-quote-form__row label {
    font-size: 13px;
    color: var(--ldi-text);
    font-weight: 500;
}
.ldi-quote-form__row label span[aria-hidden="true"] { color: #c1393e; }

.ldi-quote-form__row .ldi-input { width: 100%; }
.ldi-quote-form__row textarea.ldi-input { resize: vertical; min-height: 88px; }

.ldi-quote-form__error {
    color: #c1393e;
    font-size: 12px;
    margin-top: 2px;
}
.ldi-input--error {
    border-color: #c1393e !important;
    box-shadow: 0 0 0 2px rgba(193, 57, 62, 0.12);
}

.ldi-quote-form__actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 8px;
}
.ldi-quote-form__actions .ldi-btn.ldi-loading { opacity: 0.7; pointer-events: none; }

/* On wider screens, two-column layout for the short fields */
@media (min-width: 720px) {
    .ldi-quote-form__form {
        grid-template-columns: 1fr 1fr;
    }
    .ldi-quote-form__row:nth-child(5),  /* message textarea */
    .ldi-quote-form__error,
    .ldi-quote-form__actions {
        grid-column: 1 / -1;
    }
}

/* ───── Negotiation page ───── */

.ldi-negotiation-page {
    max-width: 720px;
    margin: 32px auto;
    padding: 0 16px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #0f172a;
    line-height: 1.55;
}
.ldi-negotiation-page h1 {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0 0 24px;
}
.ldi-negotiation-page h2 {
    font-size: 16px;
    font-weight: 500;
    margin: 24px 0 12px;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.ldi-negotiation-status {
    border-radius: 8px;
    padding: 14px 18px;
    margin: 0 0 24px;
    border: 1px solid #e5e7eb;
    background: #f8fafc;
}
.ldi-negotiation-status strong { display: block; margin-bottom: 4px; font-size: 15px; }
.ldi-negotiation-status p      { margin: 0; font-size: 14px; color: #475569; }
.ldi-negotiation-status--success { background: #f0fdf4; border-color: #bbf7d0; }
.ldi-negotiation-status--info    { background: #eff6ff; border-color: #bfdbfe; }
.ldi-negotiation-status--neutral { background: #f8fafc; border-color: #e5e7eb; }

.ldi-negotiation-summary {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 18px 20px;
    margin: 0 0 24px;
}
.ldi-negotiation-summary__grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 8px 16px;
    margin: 0;
    font-size: 14px;
}
.ldi-negotiation-summary__grid dt {
    font-weight: 500;
    color: #475569;
    margin: 0;
}
.ldi-negotiation-summary__grid dd { margin: 0; }
.ldi-negotiation-summary__agreed  { color: #166534; font-weight: 600; }

.ldi-negotiation-actions {
    margin: 0 0 24px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.ldi-conversation { margin: 24px 0; }

.ldi-negotiation-thread {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.ldi-negotiation-thread__msg {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px 16px;
    max-width: 540px;
}
/* Chat-style alignment, matching the live negotiation window: the buyer (you)
   on the right, the advisor/admin on the left. */
.ldi-negotiation-thread__msg--buyer {
    align-self: flex-end;
    background: #4f46e5;
    border-color: #4f46e5;
    color: #ffffff;
}
.ldi-negotiation-thread__msg--buyer .ldi-negotiation-thread__meta,
.ldi-negotiation-thread__msg--buyer .ldi-negotiation-thread__price { color: #ffffff; }
.ldi-negotiation-thread__msg--admin,
.ldi-negotiation-thread__msg--llm      { align-self: flex-start; background: #f8fafc; border-color: #e5e7eb; }
.ldi-negotiation-thread__meta {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    font-size: 12px;
    color: #64748b;
    margin-bottom: 6px;
}
.ldi-negotiation-thread__body { margin: 0; font-size: 14px; }
.ldi-negotiation-thread__price {
    margin: 6px 0 0;
    font-weight: 600;
    color: #166534;
}

.ldi-negotiation-placeholder {
    margin-top: 24px;
    padding: 18px 20px;
    background: #fafafa;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    text-align: center;
}
.ldi-negotiation-placeholder strong { display: block; margin-bottom: 4px; }
.ldi-negotiation-placeholder p { margin: 0; color: #475569; font-size: 14px; }

/* ───── Live negotiation chat (module 06) ───── */

/* The whole chat is a bordered window: a scrollable thread above a pinned
   footer that holds the (always-visible) composer. */
.ldi-chat {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    border: 1px solid #d5d8de;
    border-radius: 12px;
    background: #ffffff;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.ldi-chat__thread {
    list-style: none;
    margin: 0;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 220px;
    max-height: 440px;
    overflow-y: auto;
}

.ldi-bubble {
    display: inline-flex;
    flex-direction: column;
    max-width: 80%;
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #ffffff;
}
.ldi-bubble--buyer {
    align-self: flex-end;
    background: #4f46e5;
    border-color: #4f46e5;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}
.ldi-bubble--llm,
.ldi-bubble--admin {
    align-self: flex-start;
    background: #f8fafc;
    border-bottom-left-radius: 4px;
}
.ldi-bubble__who {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.7;
    margin-bottom: 3px;
}
.ldi-bubble__body { font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.ldi-bubble__time {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 4px;
    align-self: flex-end;
}

/* typing indicator — the [hidden] attribute must win over this display rule,
   otherwise it shows permanently. */
.ldi-chat__typing {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 16px 10px;
    color: #64748b;
    font-size: 13px;
}
.ldi-chat__typing[hidden] { display: none; }
.ldi-chat__typing span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #cbd5e1;
    display: inline-block;
    animation: ldi-typing 1.2s infinite ease-in-out;
}
.ldi-chat__typing span:nth-child(2) { animation-delay: 0.15s; }
.ldi-chat__typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ldi-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* footer: Accept bar + always-visible composer, divided from the thread. */
.ldi-chat__footer {
    border-top: 1px solid #e5e7eb;
    background: #f8fafc;
    padding: 12px 16px;
}
.ldi-chat__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.ldi-chat__actions:not(:empty) { margin-bottom: 12px; }

/* Chat action buttons — self-contained: the negotiation page loads this file
   without the order-builder button base, so define sizing + colours here.
   Accept = solid primary; Request (below-minimum → review) = outlined, clearly
   distinct so a buyer can't mistake it for a confirmed price. */
.ldi-chat__actions .ldi-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: 8px;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
}
.ldi-chat__accept {
    background: #4f46e5;
    color: #ffffff;
    border-color: #4f46e5;
}
.ldi-chat__accept:hover,
.ldi-chat__accept:focus { background: #4338ca; border-color: #4338ca; color: #fff; }
.ldi-chat__request {
    background: #ffffff;
    color: #4f46e5;
    border-color: #c7d2fe;
}
.ldi-chat__request:hover,
.ldi-chat__request:focus { background: #eef2ff; border-color: #a5b4fc; color: #4f46e5; }
.ldi-chat__request-note {
    flex-basis: 100%;
    display: block;
    color: #64748b;
    font-size: 12px;
    margin-top: -2px;
}

.ldi-chat__composer { margin: 0; }
.ldi-chat__composer-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}
.ldi-chat__composer textarea {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 9px 12px;
    font: inherit;
    font-size: 14px;
    resize: vertical;
    min-height: 42px;
    max-height: 160px;
    background: #ffffff;
}
.ldi-chat__composer textarea:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.12);
}
.ldi-chat__composer textarea:disabled {
    background: #f1f5f9;
    color: #94a3b8;
    cursor: not-allowed;
}
.ldi-chat__composer #ldi-chat-send { white-space: nowrap; }
.ldi-chat__composer #ldi-chat-send:disabled { opacity: 0.55; cursor: not-allowed; }
.ldi-chat__error { display: block; color: #b32d2e; font-size: 13px; margin-top: 6px; }
.ldi-chat .ldi-btn.ldi-loading { opacity: 0.7; pointer-events: none; }

/* End-conversation button + redirect modal (shown on ended states). */
.ldi-end-conversation-wrap { margin: 28px 0 8px; text-align: center; }
.ldi-end-conversation {
	background: #6b7280;
	color: #fff;
	border: 0;
	border-radius: 8px;
	padding: 10px 22px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
}
.ldi-end-conversation:hover { background: #4b5563; }

.ldi-end-modal {
	position: fixed;
	inset: 0;
	background: rgba(15, 23, 42, 0.55);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 100000;
}
.ldi-end-modal__box {
	background: #fff;
	border-radius: 12px;
	padding: 28px 32px;
	max-width: 420px;
	width: calc(100% - 40px);
	text-align: center;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}
.ldi-end-modal__msg { margin: 0 0 18px; font-size: 16px; color: #0f172a; line-height: 1.5; }
.ldi-end-modal__btn {
	background: #4f46e5;
	color: #fff;
	border: 0;
	border-radius: 8px;
	padding: 10px 24px;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
}
.ldi-end-modal__btn:hover { background: #4338ca; }
