/* ============================================================
   Production Chat UI — ImpromptuIndian light + crimson brand
   ============================================================ */

.pm-chat-widget,
#supportChat {
    --chat-brand: #A52422;
    --chat-brand-mid: #c43a38;
    --chat-brand-hover: #8e1f1d;
    --chat-brand-soft: #7F3937;
    --chat-brand-light: #fecaca;
    --chat-on-brand: #ffffff;
    --chat-brand-a06: rgba(165, 36, 34, 0.06);
    --chat-brand-a08: rgba(165, 36, 34, 0.08);
    --chat-brand-a10: rgba(165, 36, 34, 0.10);
    --chat-brand-a12: rgba(165, 36, 34, 0.12);
    --chat-brand-a15: rgba(165, 36, 34, 0.15);
    --chat-brand-a18: rgba(165, 36, 34, 0.18);
    --chat-brand-a25: rgba(165, 36, 34, 0.25);
    --chat-brand-a35: rgba(165, 36, 34, 0.35);
    --chat-brand-a40: rgba(165, 36, 34, 0.40);
    --chat-brand-a55: rgba(165, 36, 34, 0.55);
    --chat-bg: #ffffff;
    --chat-bg-muted: #f9fafb;
    --chat-bg-subtle: #f3f4f6;
    --chat-border: #e5e7eb;
    --chat-border-strong: #d1d5db;
    --chat-text: #111827;
    --chat-text-secondary: #374151;
    --chat-text-muted: #6b7280;
    --chat-incoming-bg: #ffffff;
    --chat-incoming-text: #111827;
    --chat-shadow: 0 4px 24px rgba(17, 24, 39, 0.08), 0 0 0 1px rgba(17, 24, 39, 0.04);
    --chat-shadow-lg: 0 25px 80px rgba(17, 24, 39, 0.12), 0 0 0 1px rgba(17, 24, 39, 0.06);
}

.chat-brand-avatar {
    background: linear-gradient(to bottom right, var(--chat-brand-mid), var(--chat-brand));
    color: var(--chat-on-brand);
    box-shadow: 0 4px 14px var(--chat-brand-a25);
}

.chat-brand-avatar--sm {
    width: 2rem;
    height: 2rem;
    font-size: 0.75rem;
}

.pm-chat-widget {
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
    color: var(--chat-text);
    overflow: hidden;
    box-shadow: var(--chat-shadow-lg);
}

.pm-chat-header {
    flex-shrink: 0;
    padding: 0.875rem 1rem;
    min-height: 3.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.625rem;
    border-bottom: 1px solid var(--chat-border);
    background: var(--chat-bg);
}

.pm-chat-header__avatar {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    background: linear-gradient(to bottom right, var(--chat-brand-mid), var(--chat-brand));
    color: var(--chat-on-brand);
    box-shadow: 0 2px 8px var(--chat-brand-a25);
}

.pm-chat-header__title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--chat-text);
    margin: 0;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pm-chat-header__subtitle {
    font-size: 0.75rem;
    color: var(--chat-text-muted);
    margin: 0.125rem 0 0;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pm-chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    background: var(--chat-bg-muted);
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.pm-chat-messages::-webkit-scrollbar {
    display: none;
}

.pm-chat-footer {
    flex-shrink: 0;
    border-top: 1px solid var(--chat-border);
    background: var(--chat-bg);
    padding: 1rem;
    max-height: 44%;
    overflow-y: auto;
}

.pm-chat-footer__lead {
    font-size: 0.75rem;
    color: var(--chat-text-muted);
    margin: 0 0 0.75rem 0.25rem;
    line-height: 1.45;
}

/* Status banner */
.pm-chat-status {
    border-radius: 0.75rem;
    padding: 0.75rem 0.875rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--chat-brand-a35);
    background: var(--chat-brand-a08);
}

.pm-chat-status--review {
    border-color: rgba(37, 99, 235, 0.25);
    background: rgba(37, 99, 235, 0.06);
}

.pm-chat-status__row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.pm-chat-status__title {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--chat-brand);
    margin: 0 0 0.2rem;
}

.pm-chat-status--review .pm-chat-status__title {
    color: #2563eb;
}

.pm-chat-status__label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--chat-text);
    margin: 0;
}

.pm-chat-status__pill {
    font-size: 0.62rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    white-space: nowrap;
    background: var(--chat-brand-a15);
    color: var(--chat-brand);
    border: 1px solid var(--chat-brand-a35);
}

.pm-chat-status--review .pm-chat-status__pill {
    background: rgba(37, 99, 235, 0.1);
    color: #2563eb;
    border-color: rgba(37, 99, 235, 0.25);
}

.pm-chat-status__hint {
    font-size: 0.72rem;
    color: var(--chat-text-muted);
    margin: 0.5rem 0 0.65rem;
    line-height: 1.4;
}

.pm-chat-status__placements {
    font-size: 0.72rem;
    color: var(--chat-text-secondary);
    margin: 0.25rem 0 0;
}

/* Empty state */
.pm-chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem 1rem;
    color: var(--chat-text-muted);
    min-height: 8rem;
}

.pm-chat-empty__icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.7;
}

.pm-chat-empty__title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--chat-text-secondary);
    margin: 0 0 0.35rem;
}

.pm-chat-empty__text {
    font-size: 0.78rem;
    margin: 0;
    max-width: 16rem;
    line-height: 1.45;
    color: var(--chat-text-muted);
}

/* Message rows */
.pm-chat-msg {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    width: 100%;
    margin-bottom: 1rem;
    animation: pmChatIn 0.3s ease-out;
}

.pm-chat-msg--out {
    flex-direction: row-reverse;
}

.pm-chat-msg__avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 800;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(17, 24, 39, 0.08);
}

.pm-chat-msg__avatar--team {
    background: linear-gradient(to bottom right, var(--chat-brand-mid), var(--chat-brand));
    color: var(--chat-on-brand);
}

.pm-chat-msg__avatar--customer {
    background: var(--chat-bg-subtle);
    color: var(--chat-text-secondary);
    border: 1px solid var(--chat-border);
}

.pm-chat-msg__body {
    min-width: 0;
    max-width: 85%;
}

.pm-chat-msg__time {
    font-size: 0.65rem;
    color: var(--chat-text-muted);
    margin-top: 0.25rem;
}

.pm-chat-msg--out .pm-chat-msg__time {
    text-align: right;
}

/* Bubbles */
.pm-chat-bubble,
.pm-chat-widget .customer-message-bubble,
.pm-chat-widget .ai-message-bubble {
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.pm-chat-bubble--team,
.pm-chat-widget .customer-message-bubble {
    background: var(--chat-brand);
    color: var(--chat-on-brand);
    border-radius: 12px 12px 2px 12px;
    font-weight: 500;
    box-shadow: 0 2px 8px var(--chat-brand-a25);
}

.pm-chat-bubble--customer-in,
.pm-chat-widget .ai-message-bubble {
    background: var(--chat-incoming-bg);
    color: var(--chat-incoming-text);
    border: 1px solid var(--chat-border);
    box-shadow: 0 1px 3px rgba(17, 24, 39, 0.06);
    border-radius: 12px 12px 12px 2px;
}

.pm-chat-bubble--customer-out {
    background: var(--chat-brand);
    color: var(--chat-on-brand);
    border-radius: 12px 12px 2px 12px;
    font-weight: 500;
    box-shadow: 0 2px 8px var(--chat-brand-a25);
}

.pm-chat-bubble--request,
.pm-chat-widget .vendor-query-bubble {
    background: var(--chat-brand-a08);
    border: 1px solid var(--chat-brand-a35);
    color: var(--chat-text);
    border-radius: 14px 14px 14px 4px;
    box-shadow: 0 2px 8px rgba(17, 24, 39, 0.06);
}

/* Production team requests — light incoming bubble */
.ai-message-bubble.production-vendor-request,
.pm-chat-widget .ai-message-bubble.production-vendor-request {
    background: var(--chat-incoming-bg);
    color: var(--chat-incoming-text);
    border: 1px solid var(--chat-border);
    box-shadow: 0 1px 3px rgba(17, 24, 39, 0.06);
    border-radius: 12px 12px 12px 2px;
    max-width: 85%;
}

.ai-message-bubble.production-vendor-request .pm-chat-bubble__badge {
    color: var(--chat-brand);
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 4px;
}

.ai-message-bubble.production-vendor-request .pm-chat-bubble__type {
    color: var(--chat-brand-soft);
}

.ai-message-bubble.production-vendor-request .pm-chat-bubble__placements,
.ai-message-bubble.production-vendor-request .vendor-query-placements-list,
.ai-message-bubble.production-vendor-request .vendor-query-placements-list li {
    color: var(--chat-text-secondary);
}

.pm-chat-bubble__badge,
.pm-chat-widget .vendor-query-title {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 4px;
    color: var(--chat-brand);
}

.pm-chat-bubble__type,
.pm-chat-widget .production-workflow-card__label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--chat-brand-soft);
    margin: 0.15rem 0 0.35rem;
}

.pm-chat-bubble__placements,
.pm-chat-widget .vendor-query-placements-list {
    margin: 0.35rem 0 0.5rem;
    padding-left: 1.1rem;
    font-size: 0.78rem;
    color: var(--chat-text-secondary);
}

.pm-chat-bubble__reason {
    margin: 0.2rem 0 0.35rem;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--chat-brand);
}

.pm-chat-vendor-query__body {
    margin-top: 0.35rem;
    line-height: 1.45;
    white-space: pre-wrap;
}

.customer-message-bubble .pm-chat-bubble__badge,
.customer-message-bubble .pm-chat-bubble__type,
.customer-message-bubble .pm-chat-bubble__reason,
.customer-message-bubble .pm-chat-bubble__placements,
.customer-message-bubble .pm-chat-bubble__placements li {
    color: rgba(255, 255, 255, 0.92);
}

.pm-chat-system {
    align-self: center;
    font-size: 12px;
    color: var(--chat-text-muted);
    font-style: italic;
    text-align: center;
    padding: 6px 16px;
    border: 1px dashed var(--chat-border-strong);
    border-radius: 8px;
    background: var(--chat-bg-subtle);
    max-width: 90%;
    margin: 12px auto;
}

/* Vendor action panel */
.pm-chat-action-panel {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.pm-chat-step__head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.pm-chat-step__num {
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 999px;
    background: var(--chat-brand-a15);
    border: 1px solid var(--chat-brand-a35);
    color: var(--chat-brand);
    font-size: 0.7rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pm-chat-step__title {
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--chat-text-muted);
    margin: 0;
}

.pm-chat-step__tools {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.pm-chat-link-btn {
    border: none;
    background: none;
    color: var(--chat-brand);
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.pm-chat-link-btn:hover {
    color: var(--chat-brand-hover);
}

.pm-chat-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    max-height: 9rem;
    overflow-y: auto;
}

.pm-chat-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid var(--chat-border);
    background: var(--chat-bg);
    color: var(--chat-text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.pm-chat-chip.is-selected {
    border-color: var(--chat-brand-a55);
    background: var(--chat-brand-a12);
    color: var(--chat-brand);
}

.pm-chat-chip__tag {
    font-size: 0.62rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.pm-chat-chip__tag--ok {
    color: #16a34a;
}

.pm-chat-chip__tag--missing {
    color: #dc2626;
}

.pm-chat-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.pm-chat-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--chat-brand-a35);
    background: var(--chat-brand-a10);
    color: var(--chat-brand);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.pm-chat-action-btn:hover:not(:disabled) {
    background: var(--chat-brand-a18);
    transform: translateY(-1px);
}

.pm-chat-action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pm-chat-action-btn--warn {
    border-color: rgba(220, 38, 38, 0.25);
    background: rgba(220, 38, 38, 0.06);
    color: #b91c1c;
}

.pm-chat-action-btn--ok {
    border-color: rgba(22, 163, 74, 0.28);
    background: rgba(22, 163, 74, 0.08);
    color: #15803d;
}

.pm-chat-review-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    width: 100%;
    margin-top: 0.35rem;
}

.pm-chat-review-actions__single,
.pm-chat-review-actions .pm-chat-action-btn {
    width: 100%;
}

@media (max-width: 420px) {
    .pm-chat-review-actions {
        grid-template-columns: 1fr;
    }
}

.pm-chat-blocked {
    padding: 0.75rem;
    border-radius: 0.75rem;
    border: 1px dashed var(--chat-border-strong);
    background: var(--chat-bg-muted);
}

.pm-chat-blocked__text {
    font-size: 0.75rem;
    color: var(--chat-text-muted);
    margin: 0;
    line-height: 1.45;
}

/* Customer response panel */
.pm-chat-response-panel {
    border-radius: 0.75rem;
    border: 1px solid var(--chat-brand-a35);
    background: var(--chat-brand-a06);
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.pm-chat-response-panel__title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--chat-brand);
    margin: 0 0 0.35rem;
}

.pm-chat-response-panel__hint {
    font-size: 0.72rem;
    color: var(--chat-text-muted);
    margin: 0 0 0.65rem;
}

.pm-chat-response-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.pm-chat-response-btn {
    width: 100%;
    text-align: left;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--chat-brand-a35);
    background: var(--chat-bg);
    color: var(--chat-text);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.pm-chat-response-btn:hover {
    background: var(--chat-brand-a08);
    border-color: var(--chat-brand-a55);
}

.pm-chat-response-btn__sub {
    display: block;
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--chat-text-muted);
    margin-top: 0.15rem;
}

@keyframes pmChatIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 400px) {
    .pm-chat-actions {
        grid-template-columns: 1fr;
    }
}

/* Customer upload cards (outgoing design reference) */
.customer-message-bubble.pm-chat-customer-upload,
.ai-message-bubble.pm-chat-customer-upload {
    white-space: normal;
    padding: 0;
    overflow: hidden;
    max-width: min(300px, 92%);
    background: var(--chat-bg, #ffffff);
    border: 1px solid var(--chat-border, #e5e7eb);
}

.pm-chat-customer-upload-card {
    display: flex;
    flex-direction: column;
}

.pm-chat-upload-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 12px 8px;
    border-bottom: 1px solid var(--chat-border, #e5e7eb);
}

.pm-chat-upload-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--chat-text, #111827);
    line-height: 1.3;
}

.pm-chat-upload-zone-pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #ffffff;
    background: var(--chat-brand, #A52422);
    white-space: nowrap;
}

.pm-chat-upload-preview {
    display: block;
    line-height: 0;
    background: var(--chat-bg-muted, #f9fafb);
    border-bottom: 1px solid var(--chat-border, #e5e7eb);
}

.pm-chat-upload-preview img {
    width: 100%;
    max-height: 220px;
    min-height: 100px;
    object-fit: contain;
    object-position: center;
    display: block;
    background: var(--chat-bg-muted, #f9fafb);
}

.pm-chat-upload-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px 10px;
}

.pm-chat-upload-filename {
    font-size: 0.6875rem;
    color: var(--chat-text-muted, #6b7280);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
}

.pm-chat-upload-open {
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--chat-brand, #A52422);
    text-decoration: none;
    white-space: nowrap;
}

.pm-chat-upload-open:hover {
    text-decoration: underline;
}

.pm-chat-upload-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    text-decoration: none;
    color: inherit;
}

.pm-chat-upload-file__icon {
    font-size: 1.25rem;
    line-height: 1;
}

.pm-chat-upload-file__meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

/* Vendor production progress update (stage + photo) */
.ai-message-bubble.production-progress-update,
.pm-chat-widget .ai-message-bubble.production-progress-update,
.customer-message-bubble.production-progress-update {
    background: var(--chat-incoming-bg);
    color: var(--chat-incoming-text);
    border: 1px solid var(--chat-border);
    box-shadow: 0 1px 3px rgba(17, 24, 39, 0.06);
    border-radius: 12px 12px 12px 2px;
    max-width: 85%;
}

.production-progress-update .pm-chat-bubble__badge {
    color: var(--chat-brand);
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 4px;
}

.production-progress-update .pm-chat-progress-update__stage {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--chat-brand);
    margin: 0.2rem 0 0.45rem;
}

.production-progress-update .pm-chat-progress-update__text {
    margin: 0 0 0.65rem;
    font-size: 0.84rem;
    line-height: 1.45;
    color: var(--chat-text-secondary);
}

.pm-chat-progress-update__media {
    display: block;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--chat-border, rgba(255, 255, 255, 0.12));
    max-width: 260px;
}

.pm-chat-progress-update__media img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 220px;
    object-fit: cover;
}
