/* ═════════════════════════════════════════════════════════
   STYRA CHAT WIDGET — Styles
   ═════════════════════════════════════════════════════════ */

/* ── Full-screen /styra page override ─────────────────────── */
/* Hides everything except the inline chat panel so it takes   */
/* the entire viewport — no header, footer, sidebars, etc.    */

body.empyra-styra-page #header,
body.empyra-styra-page #footer,
body.empyra-styra-page .site-header,
body.empyra-styra-page .site-footer,
body.empyra-styra-page header,
body.empyra-styra-page footer,
body.empyra-styra-page .ct-header,
body.empyra-styra-page .ct-footer,
body.empyra-styra-page .ct-sidebar,
body.empyra-styra-page aside,
body.empyra-styra-page nav,
body.empyra-styra-page .elementor-section-wrap > .elementor-element:not(:has(.empyra-chat-panel)),
body.empyra-styra-page .site-content .entry-header,
body.empyra-styra-page .site-content .page-title,
body.empyra-styra-page .site-content .entry-footer,
body.empyra-styra-page .breadcrumbs,
body.empyra-styra-page #wpadminbar {
    display: none !important;
}

body.empyra-styra-page {
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden;
}

body.empyra-styra-page .site-content,
body.empyra-styra-page .content-area,
body.empyra-styra-page .site-main,
body.empyra-styra-page main,
body.empyra-styra-page .elementor-shortcode,
body.empyra-styra-page .elementor-section-wrap,
body.empyra-styra-page .elementor-widget-wrap,
body.empyra-styra-page .elementor-widget-shortcode,
body.empyra-styra-page .elementor-section,
body.empyra-styra-page .elementor-top-section,
body.empyra-styra-page article {
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    height: 100vh !important;
    height: 100dvh !important;
    overflow: hidden !important;
    background: transparent !important;
}

body.empyra-styra-page .empyra-chat-panel--inline {
    position: fixed !important;
    top: 0 !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    right: auto !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 650px !important;
    height: 100vh !important;
    height: 100dvh !important;
    z-index: 999999 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

/* ── Floating Button ──────────────────────────────────────── */

/* ── Back link (inline full-screen only) ─────────────────── */

.empyra-chat-panel__back {
    color: #fff;
    text-decoration: none;
    font-family: var(--emp-font-body);
    font-size: 14px;
    font-weight: 500;
    margin-right: 8px;
    white-space: nowrap;
    opacity: 0.85;
    transition: opacity 0.2s;
}
.empyra-chat-panel__back:hover {
    opacity: 1;
}

.empyra-chat-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999998;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--emp-coral);
    border: none;
    cursor: pointer;
    box-shadow: var(--emp-shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
}
.empyra-chat-btn:hover {
    background: var(--emp-coral-dark);
    transform: scale(1.05);
}
.empyra-chat-btn svg {
    width: 28px;
    height: 28px;
    fill: #fff;
}

/* ── Side Panel ───────────────────────────────────────────── */

.empyra-chat-panel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    height: 100vh;
    height: 100dvh;
    background: var(--emp-bg-card);
    box-shadow: -4px 0 24px rgba(0,0,0,0.12);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
}
.empyra-chat-panel--open {
    right: 0;
}
.empyra-chat-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--emp-coral);
    color: #fff;
    font-family: var(--emp-font-heading);
    font-size: 18px;
    font-weight: 600;
}
.empyra-chat-panel__header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.empyra-chat-panel__new,
.empyra-chat-panel__expand,
.empyra-chat-panel__close {
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    padding: 6px 12px;
    font-family: var(--emp-font-body);
    font-size: 13px;
    transition: background 0.2s;
}
.empyra-chat-panel__new:hover,
.empyra-chat-panel__expand:hover,
.empyra-chat-panel__close:hover {
    background: rgba(255,255,255,0.35);
}

/* ── Messages Area ────────────────────────────────────────── */

.empyra-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--emp-bg-site);
}

/* ── Message Bubbles ──────────────────────────────────────── */

.empyra-chat-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    font-family: var(--emp-font-body);
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
}
.empyra-chat-msg--bot {
    align-self: flex-start;
    max-width: 85%;
}
.empyra-chat-msg--user {
    align-self: flex-end;
    max-width: 85%;
}

/* ── Message Content Wrapper ─────────────────────────────── */

.empyra-chat-msg-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ── Sender Label ─────────────────────────────────────────── */

.empyra-chat-msg-sender {
    font-family: var(--emp-font-body);
    font-size: 11px;
    font-weight: 600;
    color: var(--emp-muted);
    margin-bottom: 2px;
    padding-left: 2px;
}

/* ── Avatars ─────────────────────────────────────────────── */

.empyra-chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--emp-font-heading);
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
    line-height: 1;
}
.empyra-chat-avatar--bot {
    background: var(--emp-coral);
    color: #fff;
}
.empyra-chat-avatar--user {
    background: var(--emp-teal);
    color: #fff;
}

/* ── Chat Bubble ─────────────────────────────────────────── */

.empyra-chat-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    min-width: 0;
}
.empyra-chat-msg--bot .empyra-chat-bubble {
    background: var(--emp-bg-card);
    color: var(--emp-charcoal);
    border-bottom-left-radius: 4px;
    box-shadow: var(--emp-shadow);
}
.empyra-chat-msg--user .empyra-chat-bubble {
    background: var(--emp-coral);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* ── Timestamps ───────────────────────────────────────────── */

.empyra-chat-msg-time {
    font-family: var(--emp-font-body);
    font-size: 10px;
    color: var(--emp-muted);
    margin-top: 3px;
    padding-left: 2px;
}
.empyra-chat-msg--user .empyra-chat-msg-time {
    text-align: right;
}

/* ── Product Cards ─────────────────────────────────────────── */

.empyra-chat-products {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 4px;
}
.empyra-chat-product {
    display: flex;
    gap: 12px;
    padding: 10px;
    border-radius: var(--emp-r-card);
    background: var(--emp-bg-card);
    box-shadow: var(--emp-shadow);
    text-decoration: none;
    color: var(--emp-charcoal);
    transition: box-shadow 0.2s, transform 0.15s;
    border: 1px solid var(--emp-border);
}
.empyra-chat-product:hover {
    box-shadow: var(--emp-shadow-md);
    transform: translateY(-1px);
}
.empyra-chat-product__img {
    width: 64px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--emp-cream);
}
.empyra-chat-product__img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.empyra-chat-product__placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}
.empyra-chat-product__info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    justify-content: center;
}
.empyra-chat-product__title {
    font-family: var(--emp-font-body);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.empyra-chat-product__brand {
    font-family: var(--emp-font-body);
    font-size: 11px;
    color: var(--emp-teal);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.empyra-chat-product__variants {
    font-family: var(--emp-font-body);
    font-size: 12px;
    color: var(--emp-muted);
    line-height: 1.4;
    margin-top: 2px;
}
.empyra-chat-product__stock {
    font-family: var(--emp-font-body);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 2px;
}
.empyra-chat-product__stock--in {
    color: #2e7d32;
}
.empyra-chat-product__stock--out {
    color: #c62828;
}
.empyra-chat-product__date {
    font-family: var(--emp-font-body);
    font-size: 11px;
    color: var(--emp-muted);
    margin-top: 2px;
}

/* ── Suggestion Chips ─────────────────────────────────────── */

.empyra-chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.empyra-chat-chip {
    display: inline-block;
    padding: 6px 14px;
    border: 1.5px solid var(--emp-teal);
    border-radius: var(--emp-r-btn);
    color: var(--emp-teal);
    background: transparent;
    font-family: var(--emp-font-body);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.empyra-chat-chip:hover {
    background: var(--emp-teal-light);
}


/* ── Input Area ───────────────────────────────────────────── */

.empyra-chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--emp-border);
    background: var(--emp-bg-card);
    flex-wrap: wrap;
    /* Sticky bottom so keyboard doesn't hide it */
    position: sticky;
    bottom: 0;
    z-index: 10;
    flex-shrink: 0;
}
.empyra-chat-input-area.has-preview {
    padding-top: 8px;
}
.empyra-chat-attach {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: 1.5px solid var(--emp-border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s, background 0.2s;
    flex-shrink: 0;
    color: var(--emp-muted);
}
.empyra-chat-attach:hover {
    border-color: var(--emp-coral);
    color: var(--emp-coral);
    background: var(--emp-coral-light);
}
.empyra-chat-attach svg {
    width: 20px;
    height: 20px;
}

/* ── Image Preview ─────────────────────────────────────────── */

.empyra-chat-preview {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    margin-bottom: 4px;
}
.empyra-chat-preview__thumb {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    border: 2px solid var(--emp-border);
}
.empyra-chat-preview__name {
    flex: 1;
    font-family: var(--emp-font-body);
    font-size: 12px;
    color: var(--emp-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.empyra-chat-preview__remove {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: var(--emp-border);
    color: var(--emp-charcoal);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    flex-shrink: 0;
    transition: background 0.2s;
}
.empyra-chat-preview__remove:hover {
    background: var(--emp-coral-light);
    color: var(--emp-coral);
}

/* ── Image in Message ──────────────────────────────────────── */

.empyra-chat-msg--user .empyra-chat-msg__image {
    display: block;
    max-width: 200px;
    max-height: 160px;
    border-radius: 8px;
    margin-top: 6px;
    object-fit: cover;
}

/* ── Name Prompt ──────────────────────────────────────────── */

.empyra-chat-name-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
    text-align: center;
    gap: 12px;
    animation: empyra-fade-in 0.3s ease;
}
.empyra-chat-name-prompt__avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--emp-coral);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--emp-font-heading);
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}
.empyra-chat-name-prompt__title {
    font-family: var(--emp-font-heading);
    font-size: 22px;
    font-weight: 600;
    color: var(--emp-charcoal);
}
.empyra-chat-name-prompt__subtitle {
    font-family: var(--emp-font-body);
    font-size: 14px;
    color: var(--emp-muted);
}
.empyra-chat-name-prompt__input {
    width: 100%;
    max-width: 260px;
    border: 1.5px solid var(--emp-border);
    border-radius: var(--emp-r-btn);
    padding: 12px 16px;
    font-family: var(--emp-font-body);
    font-size: 15px;
    outline: none;
    text-align: center;
    background: var(--emp-cream);
    transition: border-color 0.2s;
    margin-top: 4px;
}
.empyra-chat-name-prompt__input:focus {
    border-color: var(--emp-coral);
}
.empyra-chat-name-prompt__btn {
    background: var(--emp-coral);
    color: #fff;
    border: none;
    border-radius: var(--emp-r-btn);
    padding: 12px 32px;
    font-family: var(--emp-font-body);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.empyra-chat-name-prompt__btn:hover {
    background: var(--emp-coral-dark);
}
@keyframes empyra-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.empyra-chat-input {
    flex: 1;
    border: 1.5px solid var(--emp-border);
    border-radius: var(--emp-r-btn);
    padding: 10px 16px;
    font-family: var(--emp-font-body);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    background: var(--emp-cream);
}
.empyra-chat-input:focus {
    border-color: var(--emp-coral);
}
.empyra-chat-input::placeholder {
    color: var(--emp-muted);
}
.empyra-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--emp-coral);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}
.empyra-chat-send:hover {
    background: var(--emp-coral-dark);
}
.empyra-chat-send svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

/* ── Welcome Message ──────────────────────────────────────── */

.empyra-chat-welcome {
    text-align: center;
    padding: 32px 20px 16px;
}
.empyra-chat-welcome h3 {
    font-family: var(--emp-font-heading);
    font-size: 20px;
    color: var(--emp-charcoal);
    margin: 0 0 8px;
}
.empyra-chat-welcome p {
    font-family: var(--emp-font-body);
    font-size: 14px;
    color: var(--emp-muted);
    margin: 0;
}

/* ── Full-Page Layout (/styra) ─────────────────────────────── */

.empyra-styra-fullpage {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    background: var(--emp-bg-card);
    box-shadow: var(--emp-shadow-md);
}
.empyra-styra-fullpage .empyra-chat-panel__header {
    border-radius: 0;
}
.empyra-styra-fullpage .empyra-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--emp-bg-site);
}
.empyra-styra-fullpage .empyra-chat-input-area {
    border-top: 1px solid var(--emp-border);
}

/* ── Inline Mode ─────────────────────────────────────────── */

.empyra-chat-panel--inline {
    position: relative !important;
    top: 0 !important;
    right: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    margin: 0;
    box-shadow: none;
    border-radius: 0;
    overflow: hidden;
    z-index: 1;
    display: flex;
    flex-direction: column;
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 480px) {
    .empyra-chat-panel {
        width: 100%;
        right: -100%;
        height: 100vh;
        height: 100dvh;
    }
    .empyra-chat-panel--inline {
        position: relative !important;
        right: 0 !important;
        height: 100vh !important;
        height: 100dvh !important;
        border-radius: 0;
        max-width: 100%;
    }
    /* Input stays sticky at bottom of flex container;
       the JS visualViewport fix handles the panel height so
       the input is always visible without position:fixed quirks */
    .empyra-chat-input-area {
        position: sticky;
        bottom: 0;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        z-index: 10;
    }
    .empyra-chat-messages {
        flex: 1;
        min-height: 0;
    }
    .empyra-styra-fullpage {
        height: 100vh;
        height: 100dvh;
    }
}

/* ── iOS PWA viewport fix ──────────────────────────────────── */
/* JS sets --chat-vh on the panel via visualViewport.height.  */
/* This overrides all height declarations when present, ensuring */
/* the panel never exceeds the real visible viewport.            */
.empyra-chat-panel[style*="--chat-vh"] {
    height: var(--chat-vh) !important;
}
body.empyra-styra-page .empyra-chat-panel--inline[style*="--chat-vh"] {
    height: var(--chat-vh) !important;
}

/* ── Streaming cursor ────────────────────────────────────── */
.empyra-chat-cursor {
    display: inline-block;
    width: 0;
    margin-left: 1px;
    animation: empyra-blink 0.7s steps(1) infinite;
    color: var(--emp-coral, #E07856);
    font-weight: 400;
}
@keyframes empyra-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}