/* Rotozoom Sales Assistant Chat UI — v1.3.0 */

#rotozoom-chat-app {
    display: grid;
    grid-template-columns: 220px 1fr;
    /* Own our horizontal footprint — without this the host theme decides it:
       constrained themes shrink the app to content-size (leaving huge empty
       space), full-width templates let the 1fr column collapse to the left.
       The ID selector outranks the theme's :where() layout rule (no !important
       needed). The widget (480px panel) is unaffected — 100% = 480px < cap. */
    width: 100%;
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
    height: 620px;
    max-height: 80vh;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #fff;
    box-shadow: 0 4px 24px rgba(0,0,0,0.10);
    transition: grid-template-columns 0.2s ease;
}

#rotozoom-chat-app.sidebar-collapsed {
    grid-template-columns: 44px 1fr;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.rotozoom-sidebar {
    background: #1a1a2e;
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 10px 8px;
    gap: 8px;
    overflow: hidden;
    min-height: 0;
    transition: padding 0.2s ease;
}

.rotozoom-sidebar.collapsed {
    padding: 10px 6px;
    align-items: center;
}

/* Sidebar toggle button */
#rotozoom-sidebar-toggle {
    background: none;
    border: none;
    color: #a0a0c0;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
    align-self: flex-end;
}
#rotozoom-sidebar-toggle:hover { color: #fff; background: rgba(255,255,255,0.08); }
#rotozoom-sidebar-toggle svg { width: 16px; height: 16px; }

/* Sidebar content — hidden when collapsed */
.rotozoom-sidebar-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
.rotozoom-sidebar.collapsed .rotozoom-sidebar-content { display: none; }

/* New project icon shown when collapsed */
.rotozoom-new-project-icon {
    display: none;
    background: none;
    border: none;
    color: #a0a0c0;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}
.rotozoom-new-project-icon:hover { color: #fff; background: rgba(255,255,255,0.08); }
.rotozoom-new-project-icon svg { width: 18px; height: 18px; }
.rotozoom-sidebar.collapsed .rotozoom-new-project-icon { display: flex; }

.rotozoom-sidebar h3 {
    margin: 0 0 4px 0;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #a0a0c0;
}

#rotozoom-projects-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Projects loading spinner */
.rotozoom-projects-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px 0;
    flex: 1;
}

.rotozoom-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255,255,255,0.15);
    border-top-color: #a0a0c0;
    border-radius: 50%;
    animation: rotozoom-spin 0.75s linear infinite;
}

@keyframes rotozoom-spin {
    to { transform: rotate(360deg); }
}

/* Project items */
.rotozoom-project-item {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #c8c8e8;
    transition: background 0.15s;
    border: 1px solid transparent;
    word-break: break-word;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    position: relative;
}

@media (hover: hover) {
    .rotozoom-project-item:hover {
        background: rgba(255,255,255,0.08);
        color: #fff;
    }
}

.rotozoom-project-item.active {
    background: #16213e;
    border-color: #4a6fa5;
    color: #fff;
}

/* Red dot = a reply in this project the shopper has not seen (class set by chat.js). */
.rotozoom-project-unread {
    display: none;
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e53935;
    margin-top: 5px;
}
.rotozoom-project-item.has-unread .rotozoom-project-unread { display: inline-block; }
.rotozoom-project-item.has-unread .rotozoom-project-title { color: #fff; font-weight: 600; }

.rotozoom-project-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rotozoom-project-delete {
    flex-shrink: 0;
    background: none;
    border: none;
    color: rgba(255,255,255,0.25);
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    padding: 0 2px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.rotozoom-project-item:hover .rotozoom-project-delete {
    visibility: visible;
    opacity: 1;
}

.rotozoom-project-delete:hover {
    color: #ff6b6b;
    background: rgba(255,107,107,0.12);
}

/* Rename (pencil) — same visual language as the ×: hidden until hover on desktop.
   Inline edit swaps the title span for `.rotozoom-project-rename-input` (chat.js
   `startRename`); both action buttons step aside while it is open. */
.rotozoom-project-rename {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: rgba(255,255,255,0.25);
    cursor: pointer;
    line-height: 1;
    padding: 1px 2px;
    margin: 0;
    border-radius: 4px;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
}

.rotozoom-project-rename svg {
    display: block;
    width: 13px;
    height: 13px;
}

.rotozoom-project-item:hover .rotozoom-project-rename {
    visibility: visible;
    opacity: 1;
}

.rotozoom-project-rename:hover {
    color: #fff;
    background: rgba(255,255,255,0.12);
}

/* Touch devices have no hover — both controls must always be reachable (the
   `.rotozoom-project-item:hover` rule above is wrapped in `(hover: hover)` for the
   same reason: sticky hover on iOS). 16px on the input stops iOS zoom-on-focus. */
@media (hover: none) {
    .rotozoom-project-rename,
    .rotozoom-project-delete {
        visibility: visible;
        opacity: 1;
        color: rgba(255,255,255,0.45);
        padding: 2px 5px;
    }
}

.rotozoom-project-item.rotozoom-renaming { cursor: default; }
.rotozoom-project-item.rotozoom-renaming .rotozoom-project-rename,
.rotozoom-project-item.rotozoom-renaming .rotozoom-project-delete { display: none; }

/* `#… input.…` on purpose: XStore styles `input[type="text"]` (height 2.642rem, white
   background, 0 radius) at specificity 0,1,1 — a bare class loses to it. */
#rotozoom-projects-list input.rotozoom-project-rename-input {
    flex: 1;
    min-width: 0;
    width: 100%;
    height: auto;
    min-height: 0;
    margin: -3px 0;
    padding: 2px 6px;
    font: inherit;
    font-size: 13px;
    line-height: 1.4;
    color: #fff;
    background: rgba(255,255,255,0.08);
    border: 1px solid #4a6fa5;
    border-radius: 4px;
    outline: none;
    box-shadow: 0 0 0 3px rgba(74,111,165,0.18);
    box-sizing: border-box;
}

#rotozoom-projects-list input.rotozoom-project-rename-input:disabled {
    opacity: 0.6;
}

/* After the base rule on purpose (same specificity — source order decides): 16px stops
   iOS zoom-on-focus on touch devices. */
@media (hover: none) {
    #rotozoom-projects-list input.rotozoom-project-rename-input { font-size: 16px; }
}

/* ── Chat Panel ───────────────────────────────────────────────────────────── */
.rotozoom-chat-panel {
    display: flex;
    flex-direction: column;
    background: #fafafa;
    overflow: hidden;
    min-height: 0;
}

#rotozoom-chat-header {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    padding: 14px 20px;
    font-weight: 600;
    font-size: 15px;
    color: #1a1a2e;
    min-height: 52px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    gap: 10px;
}

.rotozoom-header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.rotozoom-header-icon-btn {
    background: none;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    padding: 5px 7px;
    cursor: pointer;
    color: #4a6fa5;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.rotozoom-header-icon-btn svg { width: 16px; height: 16px; }
.rotozoom-header-icon-btn:hover:not(:disabled) { background: #e3f2fd; border-color: #90caf9; }
.rotozoom-header-icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
/* wporg-strip-start */
.rotozoom-header-icon-btn.support-active { background: #e3f2fd; border-color: #90caf9; color: #1565c0; }

.rotozoom-support-badge {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: #e3f2fd;
    color: #1565c0;
    padding: 3px 9px;
    border-radius: 12px;
    border: 1px solid #90caf9;
    animation: rotozoom-pulse 2s infinite;
}

@keyframes rotozoom-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* wporg-strip-end */
#rotozoom-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
    /* Беше calc(620px - 52px - 90px) — 90px беше зашитата височина на полето при rows="3".
       Полето вече е променливо, а истинското оразмеряване го прави flex (`flex:1; min-height:0`). */
    max-height: none;
    /* Стигне ли скролът края на списъка, докосването продължаваше да движи СТРАНИЦАТА зад
       панела и чатът „заяждаше" (собственик, 07.09, телефон). `contain` спира веригата. */
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* ── Питане за гледания продукт (карта в разговора, 07.09) ─────────────────── */
.rotozoom-start-about {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
    padding: 14px;
    border: 1px solid #d0d5dd;
    border-radius: 12px;
    background: #fff;
}

.rotozoom-start-about-text {
    font-size: 14px;
    font-weight: 600;
    color: #1f2b3a;
    line-height: 1.4;
}

.rotozoom-start-about .rotozoom-product-card { width: 100%; }

.rotozoom-start-about-btn {
    align-self: stretch;
    padding: 10px 14px;
    border: none;
    border-radius: 8px;
    background: #4a6fa5;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

.rotozoom-start-about-btn:hover { background: #3d5c8a; }

/* ── Messages ─────────────────────────────────────────────────────────────── */
.rotozoom-msg {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
}

.rotozoom-msg.user {
    background: #1a1a2e;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 3px;
}

.rotozoom-msg.assistant {
    background: #fff;
    color: #222;
    align-self: flex-start;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 3px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.rotozoom-msg.assistant.has-products {
    max-width: 95%;
}

.rotozoom-msg-content {
    white-space: pre-wrap;
}

/* AI avatar: sits in the gutter left of the bubble, aligned to its last line (like
   messengers). Positioned, not wrapped, so every piece of code that appends into a
   .rotozoom-msg keeps working unchanged. */
.rotozoom-msg.assistant.rz-ai {
    position: relative;
    margin-left: 40px;
    max-width: calc(75% - 40px);
}
.rotozoom-msg.assistant.rz-ai.has-products { max-width: calc(95% - 40px); }
.rotozoom-msg-avatar {
    position: absolute;
    left: -40px;
    bottom: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
    border: 1px solid #e0e0e0;
    box-sizing: border-box;
}
/* wporg-strip-start */
.rotozoom-msg-avatar.rz-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .02em;
    color: #fff;
    background: var(--rotozoom-sa-color, #1565c0);
    border-color: transparent;
}

/* Support sender label */
.rotozoom-support-sender {
    font-size: 11px;
    font-weight: 700;
    color: #1565c0;
    background: #e3f2fd;
    padding: 1px 6px;
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 5px;
}

/* wporg-strip-end */
.rotozoom-msg .rotozoom-msg-time {
    font-size: 11px;
    opacity: 0.55;
    margin-top: 6px;
    display: block;
}

/* ── Product cards ────────────────────────────────────────────────────────── */
/* Компактна карта с голяма снимка (собственик, 08.09): снимката е квадрат на цялата
   ширина на картата (≥ 50% от височината ѝ), името е до 2 реда, цената и наличността
   са на ЕДИН ред, бутоните са на един ред — „Add to cart" разтегнат + квадратна икона
   „View product". Преди: снимка 120px, име до 3+ реда, два бутона един под друг →
   текстът и бутоните заемаха 60–70% от картата. */
.rotozoom-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin-top: 14px;
    width: 100%;
}

.rotozoom-product-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
    transition: box-shadow 0.15s;
}

.rotozoom-product-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

/* Снимката е линк към продукта (същата атрибуция като името). Квадратна кутия на
   цялата ширина; в поздрава (една карта на цял ред) височината ѝ е ограничена, за да
   не стане гигантска. */
.rotozoom-product-card .rotozoom-product-img {
    position: relative; /* anchor for the „× N" quantity pill */
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 6px;
    background: #f5f7fa;
    overflow: hidden;
    line-height: 0;
}

@supports not (aspect-ratio: 1 / 1) {
    .rotozoom-product-card .rotozoom-product-img { height: 140px; }
}

.rotozoom-product-card img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 6px;
    background: #f5f7fa;
}

.rotozoom-product-no-img {
    width: 100%;
    height: 100%;
    background: #f0f2f7;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #aab0c0;
    font-size: 11px;
    line-height: 1.3;
}

.rotozoom-start-about .rotozoom-product-card .rotozoom-product-img { max-height: 180px; }

/* Количество в пакет („× 5") — тъмна капсула в горния ляв ъгъл на снимката; само при
   qty > 1 (карти в .rotozoom-bundle). Същият език като баджа за наличност: 11px/10.5px. */
.rotozoom-product-qty {
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 1;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(26, 26, 46, 0.88);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.4;
    white-space: nowrap;
    pointer-events: none;
}

.rotozoom-product-card .rotozoom-product-name {
    font-weight: 600;
    font-size: 12px;
    line-height: 1.35;
    color: #1a1a2e;
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 0 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

.rotozoom-product-card .rotozoom-product-name:hover {
    color: #4a6fa5;
    text-decoration: underline;
}

/* Цена + наличност на ЕДИН ред при всяка ширина: цената никога не се свива,
   наличността се съкращава с многоточие (пълният текст е в title). */
.rotozoom-product-card .rotozoom-product-price {
    display: flex;
    align-items: baseline;
    flex-wrap: nowrap;
    gap: 6px;
    min-width: 0;
    white-space: nowrap;
    color: #e05c00;
    font-weight: 700;
    font-size: 14px;
    line-height: 1.3;
}

.rotozoom-price-value { flex: 0 0 auto; }

.rotozoom-product-stock {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 10.5px;
    font-weight: 500;
    color: #6b7280;
}

.rotozoom-product-stock::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    margin-right: 4px;
    vertical-align: 1px;
}

.rotozoom-product-stock.is-instock     { color: #1e8e3e; }
.rotozoom-product-stock.is-onbackorder { color: #b45309; }
.rotozoom-product-stock.is-outofstock  { color: #8a8f98; }

/* Един ред бутони: основният („Add to cart" / „Choose options" / „Out of stock")
   се разтяга, „View product" е квадратна икона в същия стил като досегашния бутон. */
.rotozoom-product-actions {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 5px;
    margin-top: auto;
    min-width: 0;
}

.rotozoom-btn-sm {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    text-align: center;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.25;
    text-decoration: none;
    cursor: pointer;
    border: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.15s, color 0.15s;
    box-sizing: border-box;
}

.rotozoom-add-to-cart {
    background: #1a1a2e;
    color: #fff;
}

.rotozoom-add-to-cart:hover:not(:disabled) {
    background: #4a6fa5;
    color: #fff;
}

.rotozoom-add-to-cart.added { background: #27ae60; color: #fff; }
.rotozoom-add-to-cart.error { background: #c0392b; color: #fff; }
.rotozoom-add-to-cart:disabled { opacity: 0.6; cursor: not-allowed; }

.rotozoom-view-product {
    background: #f0f3f8;
    color: #1a1a2e;
    border: 1px solid #d0d8e8;
}

.rotozoom-view-product:hover {
    background: #e0e8f5;
    color: #1a1a2e;
    text-decoration: none;
}

/* Квадратната икона-бутон („View product"): фиксирана ширина, не се разтяга. */
.rotozoom-btn-icon {
    flex: 0 0 auto;
    width: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.rotozoom-btn-icon svg { width: 14px; height: 14px; display: block; }

.rotozoom-btn-disabled {
    background: #f0f0f0;
    color: #aaa;
    cursor: not-allowed;
}

/* ── Input Area ───────────────────────────────────────────────────────────── */
#rotozoom-input-area {
    background: #fff;
    border-top: 1px solid #e0e0e0;
    padding: 14px 20px;
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-shrink: 0;
}

/* Notice under the input: replies come from AI + who processes the messages (+ the store's privacy page). */
#rotozoom-chat-app p.rotozoom-ai-notice {
    margin: 0;
    padding: 0 20px 8px;
    background: #fff;
    font-size: 11px;
    line-height: 1.4;
    color: #8c8f94;
    flex-shrink: 0;
}
#rotozoom-chat-app p.rotozoom-ai-notice a {
    color: inherit;
    text-decoration: underline;
}

#rotozoom-message-input {
    flex: 1;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    /* Едноредово, докато има какво да покаже. Полето расте с текста до таван, после
       се скролва вътрешно (owner, 07.09: „голямо текстово поле, което се вижда постоянно").
       Височината я движи `RZChat.autosizeInput` — `resize:none` пази ръчното дърпане. */
    min-height: 40px;
    max-height: 140px;
    overflow-y: auto;
    box-sizing: border-box;
    resize: none;
    outline: none;
    transition: border-color 0.15s;
    font-family: inherit;
    line-height: 1.5;
}

/* Докато полето е празно, дългият плейсхолдър се пренася на втори ред и се отрязва от
   едноредовата височина — на телефон изглежда счупен. Без пренасяне текстът просто свършва
   на ръба. Щом клиентът напише нещо, `:placeholder-shown` спира да съвпада, пренасянето се
   връща и полето започва да расте. */
#rotozoom-message-input:placeholder-shown {
    white-space: nowrap;
    overflow-x: hidden;
    text-overflow: ellipsis;
}

#rotozoom-message-input:focus {
    border-color: #4a6fa5;
    box-shadow: 0 0 0 3px rgba(74,111,165,0.12);
}

.rotozoom-send-icon-btn {
    background: #1a1a2e;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    align-self: stretch;
    transition: background 0.15s, transform 0.1s;
}
.rotozoom-send-icon-btn svg { width: 18px; height: 18px; }
.rotozoom-send-icon-btn:hover:not(:disabled) { background: #4a6fa5; }
.rotozoom-send-icon-btn:active:not(:disabled) { transform: scale(0.94); }
.rotozoom-send-icon-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.rotozoom-btn-primary {
    background: #1a1a2e;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    white-space: nowrap;
}

.rotozoom-btn-primary:hover:not(:disabled) { background: #4a6fa5; }
.rotozoom-btn-primary:active:not(:disabled) { transform: scale(0.97); }
.rotozoom-btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

.rotozoom-btn-secondary {
    background: transparent;
    color: #4a6fa5;
    border: 1px solid #4a6fa5;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.rotozoom-btn-secondary:hover:not(:disabled) { background: #4a6fa5; color: #fff; }
.rotozoom-btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }

.rotozoom-btn-ghost {
    background: transparent;
    color: #666;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.rotozoom-btn-ghost:hover { background: #f5f5f5; }

.rotozoom-btn-danger {
    background: #c0392b;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.rotozoom-btn-danger:hover { background: #e74c3c; }

#rotozoom-new-project {
    width: 100%;
    padding: 10px 12px;
    font-size: 13px;
    border-radius: 8px;
}

.rotozoom-disabled { opacity: 0.45 !important; pointer-events: none !important; cursor: not-allowed !important; }

/* ── Messages loading spinner (project switch) ────────────────────────────── */
.rotozoom-messages-loading {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #9aa0b0;
    font-size: 13px;
}
.rotozoom-messages-loading .rotozoom-load-spinner {
    width: 34px;
    height: 34px;
    border: 3px solid #e6e8ef;
    border-top-color: #4a6fa5;
    border-radius: 50%;
    animation: rotozoom-spin 0.75s linear infinite;
}

/* ── Typing indicator ─────────────────────────────────────────────────────── */
.rotozoom-typing {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    align-self: flex-start;
    border-bottom-left-radius: 3px;
    flex-shrink: 0;
}

.rotozoom-typing span {
    width: 7px;
    height: 7px;
    background: #9aa0b0;
    border-radius: 50%;
    animation: rotozoom-bounce 1.2s infinite;
}

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

@keyframes rotozoom-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
    40% { transform: translateY(-6px); opacity: 1; }
}

/* ── Empty state ──────────────────────────────────────────────────────────── */
.rotozoom-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #9aa0b0;
    gap: 10px;
    font-size: 14px;
    text-align: center;
    padding: 20px;
}

.rotozoom-empty-state svg { opacity: 0.3; }

/* ── Modals ───────────────────────────────────────────────────────────────── */
.rotozoom-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rotozoom-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(2px);
}

.rotozoom-modal-content {
    position: relative;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 48px rgba(0,0,0,0.24);
    width: 440px;
    max-width: 96vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: rotozoom-modal-in 0.18s ease;
}

.rotozoom-modal-small {
    width: 380px;
}

@keyframes rotozoom-modal-in {
    from { opacity: 0; transform: scale(0.93) translateY(-10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.rotozoom-modal-header {
    padding: 18px 20px 14px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.rotozoom-modal-header h3 {
    margin: 0;
    font-size: 16px;
    color: #1a1a2e;
}

.rotozoom-modal-close {
    background: none;
    border: none;
    font-size: 22px;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: color 0.15s;
}

.rotozoom-modal-close:hover { color: #333; }

.rotozoom-modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
}

.rotozoom-modal-body p {
    margin: 0 0 14px;
    color: #555;
    font-size: 14px;
}

.rotozoom-modal-footer {
    padding: 14px 20px 18px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* wporg-strip-start */
/* Support users list */
.rotozoom-support-users {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rotozoom-support-user-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border: 2px solid #e8e8e8;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.rotozoom-support-user-option:hover {
    border-color: #4a6fa5;
    background: #f5f9ff;
}

.rotozoom-support-user-option.selected {
    border-color: #1a1a2e;
    background: #f0f4ff;
}

.rotozoom-support-user-option input[type="radio"] {
    margin: 0;
    accent-color: #1a1a2e;
}

.rotozoom-support-user-info { flex: 1; }

.rotozoom-support-user-name {
    font-weight: 600;
    font-size: 14px;
    color: #1a1a2e;
}

.rotozoom-support-user-email {
    font-size: 12px;
    color: #888;
    margin-top: 2px;
}

/* ── Support paused message ───────────────────────────────────────────────── */
.rotozoom-support-paused {
    align-self: center;
    font-size: 13px;
    color: #1565c0;
    background: #e3f2fd;
    border: 1px solid #90caf9;
    border-radius: 20px;
    padding: 6px 16px;
    margin: 4px 0;
}

/* wporg-strip-end */
.rotozoom-consultation-ended {
    align-self: center;
    text-align: center;
    font-size: 13px;
    line-height: 1.5;
    color: #6b5800;
    background: #fcf9e8;
    border: 1px solid #f0e2a8;
    border-radius: 10px;
    padding: 12px 18px;
    margin: 10px auto;
    max-width: 460px;
}

/* ── Extra/accessory products ─────────────────────────────────────────────── */
.rotozoom-extra-products {
    margin-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.15);
    padding-top: 10px;
}

.rotozoom-extra-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255,255,255,0.55);
    margin-bottom: 8px;
}

/* ── Fade-in animation ────────────────────────────────────────────────────── */
@keyframes rotozoom-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.rotozoom-fade-in {
    animation: rotozoom-fade-in 0.25s ease forwards;
}

/* ── Mobile drawer toggle (hidden on desktop) ─────────────────────────────── */
.rotozoom-mobile-menu-btn {
    display: none;
    background: none;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    padding: 5px 7px;
    cursor: pointer;
    color: #1a1a2e;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.rotozoom-mobile-menu-btn svg { width: 18px; height: 18px; }
.rotozoom-mobile-backdrop { display: none; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    /* Single column — the chat panel fills the screen; sidebar becomes a drawer */
    #rotozoom-chat-app,
    #rotozoom-chat-app.sidebar-collapsed {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
        height: 88vh;
        position: relative;
    }

    /* Sidebar -> slide-in drawer, hidden off-screen by default */
    .rotozoom-sidebar,
    .rotozoom-sidebar.collapsed {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        width: 78%;
        max-width: 280px;
        max-height: none;
        z-index: 50;
        padding: 14px 12px;
        align-items: stretch;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 2px 0 18px rgba(0,0,0,0.35);
    }
    #rotozoom-chat-app.mobile-drawer-open .rotozoom-sidebar { transform: translateX(0); }

    /* Always reveal the projects content inside the drawer */
    .rotozoom-sidebar.collapsed .rotozoom-sidebar-content { display: flex; }
    .rotozoom-sidebar.collapsed .rotozoom-new-project-icon { display: none; }
    #rotozoom-sidebar-toggle { display: none; }

    /* Dim backdrop behind the open drawer */
    .rotozoom-mobile-backdrop {
        position: absolute;
        inset: 0;
        background: rgba(0,0,0,0.45);
        z-index: 40;
    }
    #rotozoom-chat-app.mobile-drawer-open .rotozoom-mobile-backdrop { display: block; }

    /* Hamburger trigger in the header */
    .rotozoom-mobile-menu-btn { display: flex; }

    /* Tighter spacing — reclaim screen real estate */
    #rotozoom-chat-header { padding: 9px 12px; min-height: 46px; gap: 8px; }
    #rotozoom-project-title { font-size: 15px; }
    #rotozoom-messages { padding: 12px 10px; gap: 10px; max-height: none; }
    #rotozoom-input-area { padding: 9px 10px; gap: 8px; }
    #rotozoom-chat-app p.rotozoom-ai-notice { padding: 0 10px 6px; }

    /* Larger chat type for 45+ readability */
    .rotozoom-msg {
        max-width: 88%;
        font-size: 16px;
        line-height: 1.55;
        padding: 11px 14px;
    }
    .rotozoom-msg.assistant.has-products { max-width: 100%; }
    .rotozoom-msg .rotozoom-msg-time { font-size: 12px; }
    .rotozoom-msg.assistant.rz-ai { margin-left: 34px; max-width: calc(88% - 34px); }
    .rotozoom-msg.assistant.rz-ai.has-products { max-width: calc(100% - 34px); }
    .rotozoom-msg-avatar { left: -34px; width: 28px; height: 28px; }
    #rotozoom-message-input { font-size: 16px; padding: 9px 12px; } /* 16px also prevents iOS zoom-on-focus */

    .rotozoom-products-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
    .rotozoom-product-card .rotozoom-product-name { font-size: 13px; }
    .rotozoom-product-card .rotozoom-product-price { font-size: 13px; gap: 4px; }
    .rotozoom-product-stock { font-size: 10.5px; }
    .rotozoom-product-qty { font-size: 10.5px; padding: 2px 6px; top: 5px; left: 5px; }
    .rotozoom-btn-sm { font-size: 12px; padding: 7px 8px; }
    .rotozoom-btn-icon { width: 32px; padding: 0; }
}

/* wporg-strip-start */
/* Phase 1 Live Support — contact-capture form */
.rotozoom-contact-input{display:block;width:100%;box-sizing:border-box;margin:8px 0;padding:9px 12px;border:1px solid #dcdcde;border-radius:6px;font-size:14px;}
.rotozoom-contact-input:focus{outline:none;border-color:#6366f1;}
.rotozoom-contact-error{color:#d63638;font-size:13px;margin-top:6px;}

/* Personal-offer lead card (complex_project escalation, offline lane) — inline under the reply,
   same warm palette as .rotozoom-consultation-ended; inputs reuse .rotozoom-contact-input */
.rotozoom-lead-card{align-self:flex-start;width:100%;max-width:460px;box-sizing:border-box;margin:-4px 0 4px;padding:14px 16px;background:#fcf9e8;border:1px solid #f0e2a8;border-radius:10px;color:#3d3300;}
.rotozoom-lead-intro{font-size:13px;line-height:1.5;color:#6b5800;margin:0 0 2px;}
.rotozoom-lead-row{display:flex;gap:8px;}
.rotozoom-lead-row .rotozoom-contact-input{flex:1 1 0;min-width:0;}
.rotozoom-lead-card .rotozoom-contact-input{margin:8px 0 0;background:#fff;}
.rotozoom-lead-card .rotozoom-contact-error{margin-top:8px;}
/* Guest wall: the inquiry textarea reuses the input look; the bubble's second way forward is a link-styled button */
.rotozoom-lead-card textarea.rotozoom-contact-input{resize:vertical;min-height:72px;height:auto;font-family:inherit;line-height:1.4;}
.rotozoom-msg-content .rotozoom-guest-login{color:#6366f1;font-weight:600;}
.rotozoom-msg-content .rotozoom-guest-inquiry{background:none;border:none;padding:0;margin:0;font:inherit;color:#6366f1;font-weight:600;text-decoration:underline;cursor:pointer;}
.rotozoom-msg-content .rotozoom-guest-inquiry:hover{color:#4338ca;}
.rotozoom-lead-actions{display:flex;align-items:center;gap:10px;margin-top:12px;flex-wrap:wrap;}
.rotozoom-lead-card .rotozoom-btn-primary{padding:9px 18px;font-size:13px;}
.rotozoom-lead-card .rotozoom-btn-ghost{padding:8px 14px;font-size:13px;background:transparent;border-color:#e6d99a;color:#6b5800;}
.rotozoom-lead-card .rotozoom-btn-ghost:hover{background:#f6efcf;}
.rotozoom-lead-card .rotozoom-btn-ghost:disabled{opacity:.5;cursor:not-allowed;}
.rotozoom-lead-card.is-muted,.rotozoom-lead-card.is-done{align-self:center;text-align:center;padding:10px 16px;font-size:13px;}
.rotozoom-lead-card.is-muted{background:#f6f6f6;border-color:#e0e0e0;color:#777;}
.rotozoom-lead-card.is-done{background:#e8f5e9;border-color:#a5d6a7;color:#1b5e20;font-weight:600;}
.rotozoom-lead-note{line-height:1.5;}
@media (max-width: 700px) {
    .rotozoom-lead-card{max-width:100%;}
    .rotozoom-lead-row{flex-direction:column;gap:0;}
    .rotozoom-lead-card .rotozoom-contact-input{font-size:16px;} /* no iOS zoom-on-focus */
}

/* Phase 3 CSAT — rating card */
.rotozoom-rating-card{align-self:center;max-width:420px;margin:14px auto;padding:14px 16px;background:#fcfcfe;border:1px solid #e0e0e0;border-radius:10px;text-align:center;}
.rotozoom-rating-title{font-size:14px;font-weight:600;color:#1a1a2e;margin-bottom:8px;}
.rotozoom-rating-stars{display:flex;justify-content:center;gap:4px;margin-bottom:8px;}
.rotozoom-rate-star{background:none;border:none;cursor:pointer;font-size:26px;line-height:1;color:#dcdcde;padding:2px;transition:color .12s;}
.rotozoom-rate-star:hover,.rotozoom-rate-star.on{color:#f5b301;}
.rotozoom-rating-comment{display:block;width:100%;box-sizing:border-box;margin:0 0 10px;padding:8px 10px;border:1px solid #dcdcde;border-radius:6px;font-size:13px;resize:vertical;}
.rotozoom-rating-comment:focus{outline:none;border-color:#6366f1;}
.rotozoom-rating-actions{display:flex;justify-content:center;gap:8px;}
.rotozoom-rating-submit{background:#6366f1;color:#fff;border:none;border-radius:6px;padding:8px 16px;font-size:13px;font-weight:600;cursor:pointer;}
.rotozoom-rating-submit:disabled{opacity:.5;cursor:not-allowed;}
.rotozoom-rating-skip{background:none;border:none;color:#a0a0c0;font-size:13px;cursor:pointer;padding:8px 10px;}
.rotozoom-rating-thanks{font-size:14px;font-weight:600;color:#1a1a2e;}

/* Guest AI Search */
.rotozoom-guest-banner{padding:8px 14px;background:#eef2ff;border-bottom:1px solid #e0e7ff;color:#4338ca;font-size:13px;text-align:center}
.rotozoom-turnstile{margin:0 0 8px}
#rotozoom-chat-app.rotozoom-guest .rotozoom-sidebar,#rotozoom-chat-app.rotozoom-guest #rotozoom-sidebar-toggle,#rotozoom-chat-app.rotozoom-guest #rotozoom-mobile-menu{display:none!important}
/* A guest has no sidebar at all: with it display:none the grid's first column (220px / 44px collapsed) stays and the
   main panel auto-places INTO it - desktop guests got a 44px-wide chat (measured 09.09). One column for guests. */
#rotozoom-chat-app.rotozoom-guest{grid-template-columns:1fr!important}

/* Credits-exhausted → live agent CTA (turns a dead-end into a lead) */
.rotozoom-credits-cta {
    align-self: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    max-width: 320px;
    margin: 14px auto 4px;
    padding: 16px 18px;
    text-align: center;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 12px;
}
.rotozoom-credits-cta-text { margin: 0; font-size: 13px; color: #3730a3; line-height: 1.5; }
.rotozoom-credits-cta-btn {
    appearance: none;
    border: 0;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: var(--rotozoom-sa-color, #6366f1);
    border-radius: 8px;
    padding: 9px 20px;
    transition: opacity .15s ease;
}
.rotozoom-credits-cta-btn:hover { opacity: .9; }
.rotozoom-credits-cta-btn:disabled { opacity: .55; cursor: default; }

/* Auto-translate: 🌐 indicator + show-original toggle on a translated agent message */
.rotozoom-translated-note { display:flex; align-items:center; gap:8px; margin-top:4px; font-size:11px; }
.rotozoom-translated-badge { color:#4338ca; background:#eef2ff; border-radius:10px; padding:1px 8px; }
.rotozoom-show-original { appearance:none; border:0; background:none; color:#6b7280; cursor:pointer; font-size:11px; text-decoration:underline; padding:0; }
.rotozoom-show-original:hover { color:#374151; }
/* wporg-strip-end */

/* ── Order status card (templated, real WC data) ──────────────────────────── */
.rotozoom-order-status {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 3px solid #6366f1;
    border-radius: 10px;
    padding: 12px 16px;
    margin: 8px 0 12px;
    font-size: 13.5px;
    max-width: 85%;
}
.rotozoom-order-title { font-weight: 600; margin-bottom: 8px; }
.rotozoom-order-row { padding: 6px 0; border-top: 1px solid #eef2f7; }
.rotozoom-order-row:first-child { border-top: none; }
.rotozoom-order-head { font-weight: 500; }
.rotozoom-order-meta { color: #64748b; margin-top: 2px; }
.rotozoom-order-track { display: inline-block; margin-top: 4px; color: #6366f1; text-decoration: underline; }

/* ── Bundle (composed package) ─────────────────────────────────────────────── */
.rotozoom-bundle {
    border: 2px solid #6366f1;
    border-radius: 12px;
    padding: 12px;
    margin: 10px 0 4px;
    background: linear-gradient(180deg, #f5f6ff 0%, #ffffff 55%);
    max-width: 95%;
}
.rotozoom-bundle-title {
    font-weight: 600;
    font-size: 14px;
    color: #4338ca;
    margin-bottom: 8px;
}
.rotozoom-bundle-title::before { content: "\1F4E6  "; }
.rotozoom-bundle .rotozoom-products-grid { margin: 0; }
.rotozoom-bundle-addall {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    background: #6366f1;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.rotozoom-bundle-addall:hover { background: #4f46e5; }
.rotozoom-bundle-addall.added { background: #16a34a; }
.rotozoom-cart-error { margin-top: 6px; padding: 6px 8px; border-radius: 6px; background: #fef2f2; color: #b91c1c; font-size: 12px; line-height: 1.4; }
.rotozoom-cart-error a { color: #b91c1c; text-decoration: underline; font-weight: 600; }
.rotozoom-bundle-addall:disabled { opacity: 0.75; cursor: default; }

.rotozoom-typing .rotozoom-typing-status {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    font-style: normal;
    color: #94a3b8;
}

.rotozoom-msg.rotozoom-streaming .rotozoom-msg-content::after {
    content: "▍";
    margin-left: 2px;
    animation: rotozoom-caret 1s steps(1) infinite;
    color: #6366f1;
}
@keyframes rotozoom-caret { 50% { opacity: 0; } }

/* Streaming 'reset' placeholder (09.09): the answer shown so far was withdrawn (a model
   rung fell back after its first bytes) and is being regenerated — the bubble must not
   sit empty. Muted italic text; the streaming caret keeps blinking after it. */
.rotozoom-msg-content .rotozoom-refining {
    font-style: italic;
    opacity: .6;
}

/* wporg-strip-start */
/* "Not now" line keeps a way back to the form (review 09.09) */
.rotozoom-lead-card .rotozoom-lead-reopen {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    color: #4a6fa5;
    text-decoration: underline;
    cursor: pointer;
}
.rotozoom-lead-card .rotozoom-lead-reopen:hover { color: #1a1a2e; }
/* wporg-strip-end */
