:root {
    --app-height: 100dvh;
}

@supports not (height: 100dvh) {
    :root {
        --app-height: 100vh;
    }
}

html {
    height: 100%;
    overflow: hidden;
}

body {
    min-height: var(--app-height, 100vh);
    margin: 0;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background-color: #FDFCFB;
    background-image:
        radial-gradient(at 0% 0%,    rgba(251, 191, 36, 0.06) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(251, 191, 36, 0.06) 0px, transparent 50%);
    color: #1f2937;
    overflow: hidden;
}

body.seller-chat-page {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 100%;
    min-height: var(--app-height, 100vh);
    height: var(--app-height, 100vh);
    max-height: var(--app-height, 100vh);
    align-items: stretch;
    overflow: hidden;
}

body.seller-chat-page > * {
    min-width: 0;
    min-height: 0;
}

.font-lora {
    font-family: Lora, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Message Bubbles */
/* Message Bubbles - Modern Refined (Option 4: Very Light Yellow) */
.msg-user {
    border-radius: 18px 18px 4px 18px;
    background: white;
    color: #374151;
    /* Gray-700 */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    border: 1px solid #f3f4f6;
}

.msg-seller {
    border-radius: 18px 18px 18px 4px;
    /* Very Light Yellow (Matches Chatroom List) */
    background: #fffbeb;
    /* Amber-50 */
    color: #111827;
    /* Gray-900 (Black) */
    border: none;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.15);
}

.msg-bot-sent {
    border-radius: 18px 18px 18px 4px;
    /* Match Seller Bubble (Very Light Yellow) */
    background: #fffbeb;
    /* Amber-50 */
    color: #111827;
    /* Gray-900 (Black) */
    border: none;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.15);
}

/* ── Suggestion Card ──────────────────────────────────────── */
.suggestion-card-shell {
    display: flex;
    justify-content: flex-end;
    width: 100%;
    margin-bottom: 0.5rem;
}
.suggestion-card-shell.hidden,
.suggestion-card .hidden {
    display: none;
}

.suggestion-card {
    --suggestion-card-surface: #ffffff;
    --suggestion-card-surface-soft: #fffdf7;
    --suggestion-card-tint: #fffbeb;
    --suggestion-card-tint-alt: #fef9ee;
    --suggestion-card-border: #fde68a;
    --suggestion-card-border-soft: #fef3c7;
    --suggestion-card-text: #1f2937;
    --suggestion-card-muted: #6b7280;
    --suggestion-card-accent: #f59e0b;
    --suggestion-card-accent-strong: #d97706;
    --suggestion-card-accent-text: #92400e;
    --suggestion-card-danger-text: #c2410c;
    --suggestion-card-danger-text-hover: #9a3412;
    --suggestion-card-danger-bg: #fff7ed;
    --suggestion-card-danger-bg-hover: #ffedd5;
    --suggestion-card-danger-border: #fed7aa;
    width: 100%;
    max-width: 85%;
    border-radius: 16px 4px 16px 16px;
    background: var(--suggestion-card-surface);
    border: 1px solid var(--suggestion-card-border);
    box-shadow: 0 4px 16px -2px rgba(245, 158, 11, 0.12), 0 1px 3px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

@media (min-width: 768px) {
    .suggestion-card {
        max-width: 65%;
    }
}

.suggestion-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem 0.5rem;
    background: linear-gradient(135deg, var(--suggestion-card-tint) 0%, var(--suggestion-card-tint-alt) 100%);
    border-bottom: 1px solid var(--suggestion-card-border-soft);
}

.suggestion-card__title-group,
.suggestion-card__meta {
    display: flex;
    align-items: center;
    min-width: 0;
}

.suggestion-card__title-group {
    gap: 0.375rem;
}

.suggestion-card__meta {
    gap: 0.375rem;
    justify-content: flex-end;
}

.suggestion-card__title-icon {
    color: var(--suggestion-card-accent);
    font-size: 0.875rem;
    flex-shrink: 0;
}

.suggestion-card__title {
    font-size: 0.75rem;
    line-height: 1;
    font-weight: 700;
    color: var(--suggestion-card-accent-strong);
}

.suggestion-card__status {
    font-size: 0.625rem;
    line-height: 1;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--suggestion-card-accent-text);
    white-space: nowrap;
    max-width: 10rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggestion-card__stream-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--suggestion-card-accent);
    flex-shrink: 0;
    animation: suggestion-pulse 1s ease-in-out infinite;
}

@keyframes suggestion-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.4; transform: scale(0.75); }
}

.suggestion-card__stop {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.2rem 0.5rem;
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--suggestion-card-danger-text);
    border: 1px solid var(--suggestion-card-danger-border);
    border-radius: 9999px;
    background: var(--suggestion-card-danger-bg);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.suggestion-card__stop:hover {
    background: var(--suggestion-card-danger-bg-hover);
    color: var(--suggestion-card-danger-text-hover);
}

.suggestion-card__stop-icon {
    font-size: 0.75rem;
}

.suggestion-card__thinking {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 0.875rem;
    min-height: 48px;
}

.suggestion-card__thinking-icon {
    color: #fbbf24;
    font-size: 1rem;
    opacity: 0.7;
}

.suggestion-card__typing-dots {
    display: flex;
    gap: 0.25rem;
}

.suggestion-card__body {
    padding: 0.625rem 0.875rem;
}

.suggestion-card__editor {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    font-size: 0.875rem;
    color: var(--suggestion-card-text);
    line-height: 1.6;
    resize: none;
    max-height: 10rem;
    overflow-y: auto;
    padding: 0.25rem 0;
}

.suggestion-card__editor:disabled {
    opacity: 0.6;
    cursor: default;
}

.suggestion-card__actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem 0.625rem;
    border-top: 1px solid var(--suggestion-card-border-soft);
    background: var(--suggestion-card-surface-soft);
}

.suggestion-card__spacer {
    flex: 1 1 auto;
}

.suggestion-card__button {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.65rem;
    font-size: 0.7rem;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}

.suggestion-card__button-icon {
    font-size: 0.75rem;
}

.suggestion-card__button--ghost {
    font-weight: 500;
    color: var(--suggestion-card-muted);
    border: 1px solid #e5e7eb;
    background: var(--suggestion-card-surface);
}

.suggestion-card__button--ghost:hover {
    background: #f9fafb;
    color: #374151;
    border-color: #d1d5db;
}

.suggestion-card__button--ghost:disabled,
.suggestion-card__button--primary:disabled {
    opacity: 0.45;
    cursor: default;
    pointer-events: none;
}

.suggestion-card__button--primary {
    padding: 0.4rem 0.85rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: #ffffff;
    background: var(--suggestion-card-accent);
    border: none;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.suggestion-card__button--primary:hover {
    background: var(--suggestion-card-accent-strong);
    box-shadow: 0 3px 10px rgba(245, 158, 11, 0.4);
}

.suggestion-card__button--primary:active {
    transform: scale(0.97);
}

.suggestion-card__button--primary:disabled {
    box-shadow: none;
}

.msg-code-inline {
    background-color: rgba(148, 163, 184, 0.2);
    border-radius: 6px;
    padding: 0 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.85em;
}

.msg-code-block {
    background-color: rgba(148, 163, 184, 0.18);
    border-radius: 10px;
    padding: 10px 12px;
    overflow-x: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.8em;
    line-height: 1.4;
}

.msg-code-block code {
    white-space: pre-wrap;
}

.chat-message-copy {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* Loading Dots Animation */
.typing-dot {
    width: 6px;
    height: 6px;
    background-color: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Mobile Responsive Utilities */
.chat-list-view {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

.chat-room-view {
    display: none;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    flex: 1 1 auto;
    height: 100%;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

/* Explicit grid row assignments so the in-chat search bar doesn't steal the 1fr row */
.chat-room-view > header          { grid-row: 1; }
.chat-room-view > #chat-in-search-bar { grid-row: 2; }
.chat-room-view > .chat-messages-shell { grid-row: 3; }
.chat-room-view > footer          { grid-row: 4; }

.chat-list-view > #chat-list {
    min-height: 0;
    overflow-y: auto;
}

.chat-room-view #chat-messages-container {
    min-height: 0;
}

@media (min-width: 768px) {
    body.seller-chat-page {
        grid-template-columns: 380px minmax(0, 1fr);
    }

    .chat-list-view {
        display: grid;
        width: 380px;
        max-width: 380px;
        flex: 0 0 380px;
        height: 100%;
        min-height: 0;
        max-height: 100%;
        overflow: hidden;
    }

    .chat-room-view {
        display: grid;
        flex-grow: 1;
        min-width: 0;
        min-height: 0;
        height: 100%;
        max-height: 100%;
        overflow: hidden;
    }
}

body.mobile-chat-active .chat-list-view {
    display: none;
}

body.mobile-chat-active .chat-room-view {
    display: grid;
    height: 100%;
}

#chat-list {
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.chat-list-row {
    backface-visibility: hidden;
}

@media (min-width: 1280px) {
    .chat-media-preview-shell,
    .chat-compose-shell,
    .chat-status-shell {
        width: min(100%, 1200px);
        max-width: none;
    }

    .chat-bubble-shell {
        max-width: min(72%, 980px) !important;
    }
}

@media (min-width: 1600px) {
    .chat-media-preview-shell,
    .chat-compose-shell,
    .chat-status-shell {
        width: min(100%, 1320px);
    }

    .chat-bubble-shell {
        max-width: min(70%, 1060px) !important;
    }
}

/* Modal & Dropdown Utilities */
.modal {
    transition: opacity 0.25s ease;
}

body.modal-active {
    overflow: hidden;
}

.media-preview-bar {
    max-height: 80px;
}

.media-preview-content {
    max-height: 64px;
}

.emoji-picker-anchor {
    left: 0;
    bottom: calc(100% + 0.5rem);
}

.emoji-suggestions-anchor {
    left: 0;
    bottom: calc(100% + 0.75rem);
}

/* Shared Input Styling (Matches Chat New) */
.input-box-glow {
    background: #f9fafb;
    /* Gray-50 */
    border: 1px solid #e5e7eb;
    /* Gray-200 */
    transition: all 0.2s ease;
}

.input-box-glow:hover {
    background: white;
    border-color: #fcd34d;
    /* Amber-300 */
    box-shadow: 0 4px 6px -1px rgba(245, 158, 11, 0.1), 0 2px 4px -1px rgba(245, 158, 11, 0.06);
}

.input-box-glow:focus-within {
    background: white;
    border-color: #f59e0b;
    /* Amber-500 */
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15), 0 4px 6px -1px rgba(245, 158, 11, 0.1);
}

.dropdown-menu {
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: top right;
}

.dropdown-left {
    transform-origin: top left;
}

.dropdown-menu.hidden {
    opacity: 0;
    transform: scale(0.95) translateY(-5px);
    pointer-events: none;
    display: block;
}

.dropdown-menu.visible {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
    display: block;
}

.chat-total-unread-badge {
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.375rem;
    border-radius: 9999px;
    background: #ef4444;
    color: #ffffff;
    font-size: 0.6875rem;
    line-height: 1;
    font-weight: 700;
    letter-spacing: 0.01em;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
    font-variant-numeric: tabular-nums;
}

.chat-total-unread-badge.is-visible {
    display: inline-flex;
}

.emoji-picker {
    position: absolute;
    bottom: 4.5rem;
    left: 0.75rem;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border-radius: 0.75rem;
    padding: 0.5rem;
    z-index: 30;
    width: 18rem;
    max-height: 16rem;
    overflow: hidden;
}

@media (min-width: 640px) {
    .emoji-picker {
        left: 3.5rem;
        width: 20rem;
        max-height: 18rem;
    }
}

/* ── Emoji Picker (container = #emoji-picker-container) ──── */
#emoji-picker-container {
    width: 20rem;
    max-width: calc(100vw - 2rem);
    overflow: hidden;
}

#emoji-picker-container [data-role="emoji-search-wrap"] {
    padding: 0.5rem;
    border-bottom: 1px solid #f3f4f6;
}

#emoji-picker-container [data-role="emoji-search"] {
    display: block !important;
    width: 100%;
    font-size: 0.75rem;
    padding: 0.5rem;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
    outline: none;
    box-sizing: border-box;
}

#emoji-picker-container [data-role="emoji-search"]:focus {
    border-color: #fcd34d;
    box-shadow: 0 0 0 2px rgba(252, 211, 77, 0.3);
}

#emoji-picker-container [data-role="emoji-tabs"] {
    display: flex !important;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-bottom: 1px solid #f3f4f6;
    overflow-x: auto;
}

#emoji-picker-container [data-role="emoji-tabs"]::-webkit-scrollbar {
    display: none;
}

#emoji-picker-container button[data-category-key] {
    flex-shrink: 0;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 0.5rem;
    border: 1px solid transparent;
    font-size: 0.875rem;
    line-height: 1;
    display: flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: #fff;
    color: #6b7280;
    transition: background-color 0.15s ease;
}

#emoji-picker-container button[data-category-key]:hover {
    background: #f3f4f6;
}

#emoji-picker-container button[data-active="1"] {
    background: #fef3c7;
    color: #b45309;
    border-color: #fcd34d;
}

.emoji-picker-grid,
[data-role="emoji-grid"] {
    display: grid !important;
    grid-template-columns: repeat(8, minmax(0, 1fr)) !important;
    gap: 0.25rem;
    padding: 0.5rem;
    max-height: 14rem;
    overflow-y: auto;
}

#emoji-picker-container button[data-emoji] {
    height: 2rem;
    width: 2rem;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    font-size: 1.1rem;
    line-height: 1;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: background-color 0.15s ease;
    padding: 0;
}

#emoji-picker-container button[data-emoji]:hover {
    background: #fef3c7;
}

#emoji-picker-container [data-role="emoji-empty"] {
    font-size: 0.75rem;
    color: #9ca3af;
    text-align: center;
    padding: 2rem 0;
}

[data-role="emoji-grid"]::-webkit-scrollbar {
    width: 6px;
}

[data-role="emoji-grid"]::-webkit-scrollbar-thumb {
    background: #e5e7eb;
    border-radius: 999px;
}

/* ---- Media Attachments in Message Bubbles ---- */
.msg-attachments {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.msg-media-img {
    max-width: 100%;
    max-height: 280px;
    object-fit: contain;
    border-radius: 0.625rem;
}

.msg-file-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 0.5rem;
    font-size: 0.75rem;
    color: #2563eb;
    text-decoration: none;
    transition: background 0.15s ease;
}

.msg-file-link--preview {
    align-items: stretch;
    gap: 0.625rem;
    padding: 0.5rem;
}

.msg-file-link--pdf-viewer {
    cursor: zoom-in;
}

.msg-file-preview-thumb {
    width: 5rem;
    min-width: 5rem;
    height: 6.5rem;
    object-fit: cover;
    border-radius: 0.5rem;
    background: #f8fafc;
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.16);
}

.msg-file-preview-meta {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    flex-direction: column;
    justify-content: center;
    gap: 0.25rem;
}

.msg-file-link:hover {
    background: rgba(0, 0, 0, 0.08);
    text-decoration: underline;
}

/* ---- Media Upload Preview Bar ---- */
#media-preview-bar {
    overflow: hidden;
}

#media-preview-content {
    scrollbar-width: none;
}

#media-preview-content::-webkit-scrollbar {
    display: none;
}

.media-preview-thumb {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    max-width: 48px;
    max-height: 48px;
    object-fit: cover;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
}

.media-preview-item {
    position: relative;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.5rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
}

.media-preview-file {
    min-width: 168px;
}

.media-preview-image-meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.media-preview-meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.media-preview-file-name {
    max-width: 132px;
    font-size: 0.6875rem;
    line-height: 1.2;
    color: #374151;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.media-preview-meta-row {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.media-preview-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    background: #fff7ed;
    color: #c2410c;
    font-size: 10px;
    font-weight: 700;
    padding: 0.125rem 0.375rem;
    letter-spacing: 0.01em;
}

.media-preview-status {
    font-size: 10px;
    color: #6b7280;
    font-weight: 600;
}

.media-preview-progress {
    width: 100%;
    height: 4px;
    display: block;
    appearance: none;
    -webkit-appearance: none;
    border-radius: 999px;
    border: 0;
    background: #e5e7eb;
    overflow: hidden;
}

.media-preview-progress::-webkit-progress-bar {
    background: #e5e7eb;
    border-radius: inherit;
}

.media-preview-progress::-webkit-progress-value {
    border-radius: inherit;
    background: linear-gradient(90deg, #f59e0b, #f97316);
    transition: width 0.2s ease, background-color 0.2s ease;
}

.media-preview-progress::-moz-progress-bar {
    border-radius: inherit;
    background: linear-gradient(90deg, #f59e0b, #f97316);
}

.media-preview-remove {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 50%;
    color: #ef4444;
    font-size: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: transform 0.1s ease;
}

.media-preview-file .media-preview-remove {
    position: static;
    box-shadow: none;
    background: transparent;
    width: auto;
    height: auto;
    color: #9ca3af;
    margin-left: auto;
}

.media-preview-file .media-preview-remove:hover {
    color: #ef4444;
}

.media-preview-remove:hover {
    transform: scale(1.15);
}

/* ---- Image Lightbox ---- */
#image-lightbox {
    display: none;
    padding: 1.5rem;
    box-sizing: border-box;
    animation: lightbox-fade-in 0.2s ease;
}

#image-lightbox:not(.hidden) {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes lightbox-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

#lightbox-image {
    display: block;
    width: auto;
    height: auto;
    max-width: min(960px, calc(100vw - 3rem));
    max-height: calc(100vh - 4rem);
    object-fit: contain;
    background: #fff7ed;
    border-radius: 1.25rem;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
    margin: auto;
    animation: lightbox-zoom-in 0.2s ease;
}

@supports (height: 100dvh) {
    #lightbox-image {
        max-height: calc(100dvh - 4rem);
    }
}

@keyframes lightbox-zoom-in {
    from {
        transform: scale(0.92);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* ---- PDF Viewer ---- */
#pdf-viewer-modal {
    animation: lightbox-fade-in 0.2s ease;
}

.pdf-viewer-panel {
    animation: lightbox-zoom-in 0.2s ease;
}

.pdf-viewer-open-link {
    white-space: nowrap;
}

.pdf-viewer-frame-shell {
    min-height: 0;
}

#pdf-viewer-frame {
    min-height: 0;
}

@media (max-width: 767px) {
    #image-lightbox {
        padding: 1rem;
    }

    #lightbox-image {
        max-width: calc(100vw - 2rem);
        max-height: calc(100vh - 2rem);
    }

    @supports (height: 100dvh) {
        #lightbox-image {
            max-height: calc(100dvh - 2rem);
        }
    }

    .pdf-viewer-panel {
        height: 92vh;
        border-radius: 1.25rem;
    }

    .pdf-viewer-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .pdf-viewer-actions {
        width: 100%;
        justify-content: space-between;
    }
}

/* ── Shared Design System ──────────────────────────────────────────────────── */

/* Primary button — amber brand CTA */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    background: #f59e0b;
    color: #fff;
    font-weight: 700;
    font-size: 0.9375rem;
    border: none;
    border-radius: 13px;
    padding: 14px 24px;
    cursor: pointer;
    box-shadow:
        0 10px 15px -3px rgba(245, 158, 11, 0.25),
        0  4px  6px -4px rgba(245, 158, 11, 0.25);
    transition: background 150ms ease, transform 100ms ease, box-shadow 150ms ease;
    text-decoration: none;
}
.btn-primary:hover  { background: #d97706; }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled {
    background: #fcd34d;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* Secondary button — outlined, neutral */
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    background: #fff;
    color: #374151;
    font-weight: 600;
    font-size: 0.9375rem;
    border: 1.5px solid #e5e7eb;
    border-radius: 13px;
    padding: 13px 24px;
    cursor: pointer;
    transition: background 150ms ease, border-color 150ms ease, transform 100ms ease;
    text-decoration: none;
}
.btn-secondary:hover  { background: #f9fafb; border-color: #d1d5db; }
.btn-secondary:active { transform: scale(0.97); }
.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Danger button */
.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: #fff;
    color: #dc2626;
    font-weight: 600;
    font-size: 0.9375rem;
    border: 1.5px solid #fecaca;
    border-radius: 13px;
    padding: 13px 24px;
    cursor: pointer;
    transition: background 150ms ease, border-color 150ms ease;
    text-decoration: none;
}
.btn-danger:hover  { background: #fef2f2; border-color: #f87171; }
.btn-danger:active { transform: scale(0.97); }

/* Ghost / icon button */
.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #6b7280;
    border-radius: 8px;
    padding: 6px;
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease;
}
.btn-ghost:hover { background: #f3f4f6; color: #374151; }

/* ── Messages shell (relative wrapper for FAB) ──────────────── */
.chat-messages-shell {
    position: relative;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

/* ── Scroll-to-bottom FAB ────────────────────────────────────── */
#scroll-to-bottom-fab {
    bottom: 1rem;
    right: 1rem;
    opacity: 0;
    transform: translateY(6px) scale(0.9);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

#scroll-to-bottom-fab:not(.hidden) {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ── Message context menu ────────────────────────────────────── */
.context-menu {
    z-index: 300;
    opacity: 0;
    transform: scale(0.95) translateY(-4px);
    pointer-events: none;
    transition: opacity 0.14s ease, transform 0.14s ease;
    transform-origin: top left;
}

.context-menu.ctx-visible {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

.context-menu.hidden {
    display: none;
}

.ctx-menu-item {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.ctx-menu-item:active {
    opacity: 0.7;
}

/* ── Reply preview bar (above composer) ─────────────────────── */
#reply-preview-bar {
    animation: reply-bar-in 0.15s ease;
}
@keyframes reply-bar-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Reply bubble (inside message) ──────────────────────────── */
.reply-quote {
    border-left: 3px solid;
    border-radius: 6px;
    padding: 4px 8px;
    margin-bottom: 6px;
    font-size: 11px;
    line-height: 1.4;
    background: rgba(0,0,0,0.04);
}
.msg-user .reply-quote  { border-color: #9ca3af; color: #6b7280; }
.msg-seller .reply-quote { border-color: #f59e0b; color: #92400e; background: rgba(251,191,36,0.1); }
.msg-bot-sent .reply-quote { border-color: #f59e0b; color: #92400e; background: rgba(251,191,36,0.1); }
.reply-quote-sender { font-weight: 600; margin-bottom: 2px; font-size: 10px; }
.reply-quote[data-scroll-to-msg] { cursor: pointer; }
.reply-quote[data-scroll-to-msg]:hover { opacity: 0.8; }

/* ── Tap-to-scroll flash ─────────────────────────────────────── */
@keyframes msg-flash {
    0%   { background-color: rgba(251,191,36,0.35); }
    60%  { background-color: rgba(251,191,36,0.2); }
    100% { background-color: transparent; }
}
.msg-flash > * { animation: msg-flash 1.2s ease forwards; border-radius: 12px; }

/* ── Swipe-to-reply indicator ────────────────────────────────── */
#swipe-reply-indicator {
    display: none;
    position: fixed;
    z-index: 400;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(245,158,11,0.15);
    border: 1.5px solid #f59e0b;
    color: #f59e0b;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    pointer-events: none;
    transition: opacity 0.1s, transform 0.1s;
}

/* ── In-chat search highlight ────────────────────────────────── */
.search-highlight { border-radius: 2px; }
[data-search-match].search-match-active .chat-bubble-shell { outline: 2px solid #f59e0b; outline-offset: 2px; border-radius: 12px; }

/* ── In-chat search bar slide-in ─────────────────────────────── */
#chat-in-search-bar:not(.hidden) {
    animation: search-bar-in 0.15s ease;
}
@keyframes search-bar-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Quick reply popup ───────────────────────────────────────── */
#quick-reply-popup:not(.hidden) {
    animation: qr-popup-in 0.14s ease;
}
@keyframes qr-popup-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.quick-reply-item { transition: background 0.1s; }

/* ── Message grouping — tighter spacing handled in JS via mt-0.5 */
/* Space-y-4 on #chat-messages-list creates 1rem gaps; grouped    */
/* messages use mt-0.5 on the wrapper div to override that.       */
#chat-messages-list { display: flex; flex-direction: column; gap: 0; }
#chat-messages-list > * { margin-top: 1rem; }
#chat-messages-list > .mt-0\.5 { margin-top: 0.125rem !important; }
#chat-messages-list > .mt-4    { margin-top: 1rem !important; }

/* ── Message reaction pills ─────────────────────────────────── */
.msg-bubble-wrap { display: flex; flex-direction: column; }

.reaction-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.reaction-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 7px;
    border-radius: 12px;
    font-size: 0.8rem;
    line-height: 1.4;
    background: rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.08);
    cursor: default;
    user-select: none;
    transition: background 0.1s;
}

.reaction-pill:hover { background: rgba(0, 0, 0, 0.1); }

.reaction-count {
    font-size: 0.72rem;
    font-weight: 600;
    color: #555;
}

/* ── Context-menu reaction strip ────────────────────────────── */
.ctx-reaction-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    transition: transform 0.12s ease, background 0.1s;
}
.ctx-reaction-btn:hover  { background: rgba(0, 0, 0, 0.06); transform: scale(1.25); }
.ctx-reaction-btn:active { transform: scale(0.9); }
