/* Venty assistant — overlay sur assistant_empty.png */

:root {
    --cyan: #35f2ef;
    --cyan-dim: rgba(53, 242, 239, 0.55);
    --cyan-glow: rgba(53, 242, 239, 0.28);
    --text-light: #b9f7f4;
    --text-muted: rgba(185, 247, 244, 0.65);
    --screen-bg: rgba(0, 30, 28, 0.45);
    --input-text: #3d2a18;
    --input-placeholder: rgba(61, 42, 24, 0.55);
    --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

    /* Cible écran distributeur (portrait) — max même sur PC */
    --assistant-kiosk-w: 820;
    --assistant-kiosk-h: 1180;

    /* 9-slice assistant_parts — assemblage 1156×1018 */
    --assistant-ref-w: 1156;
    --assistant-ref-h: 1018;
    --assistant-slice-left: 214;
    --assistant-slice-right: 214;
    --assistant-slice-top: 197;
    --assistant-slice-bottom: 196;
    --assistant-center-w: 728;
    --assistant-center-h: 625;
}

.assistant-device,
.assistant-device--static {
    /* Mobile / kiosk réel : plein écran par défaut */
    --assistant-device-width: 100vw;
    --assistant-device-height: 100dvh;

    /* Échelle typo fluide — calée sur la largeur device (820px max) */
    --text-greeting: clamp(1.32rem, calc(var(--assistant-device-width) * 0.062), 1.65rem);
    --text-role: clamp(0.88rem, calc(var(--assistant-device-width) * 0.04), 1.05rem);
    --text-bubble: clamp(1.05rem, calc(var(--assistant-device-width) * 0.048), 1.22rem);
    --text-action: clamp(0.95rem, calc(var(--assistant-device-width) * 0.044), 1.12rem);
    --text-input: clamp(1.02rem, calc(var(--assistant-device-width) * 0.046), 1.18rem);
    --text-time: clamp(0.55rem, calc(var(--assistant-device-width) * 0.023), 0.62rem);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body:has(.assistant-page) {
    height: 100%;
    min-height: 100%;
    min-height: 100svh;
    min-height: 100dvh;
    overflow: hidden;
    background: #0a0806;
}

.assistant-page {
    min-height: 100svh;
    min-height: 100dvh;
    height: 100svh;
    height: 100dvh;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: stretch;
    padding: 0;
    overflow: hidden;
    background: radial-gradient(ellipse at 50% 0%, #1a1208 0%, #0a0806 70%);
    font-family: var(--font);
}

/* Mobile : occupe tout l'écran (iPhone, émulation devtools ≤ 820px) */
@media (max-width: 820px) {
    html:has(.assistant-page),
    body:has(.assistant-page) {
        height: 100%;
        min-height: 100%;
        min-height: -webkit-fill-available;
    }

    .assistant-page {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        min-height: 100%;
        min-height: -webkit-fill-available;
        max-height: none;
    }

    .assistant-device,
    .assistant-device--static {
        --assistant-device-width: 100vw;
        --assistant-device-height: 100%;
        width: 100%;
        height: 100%;
        min-height: 100%;
        min-height: -webkit-fill-available;
        max-width: none;
        max-height: none;
    }
}

/* ── Device : plein écran mobile, 820×1180 max sur grand écran ── */
.assistant-device {
    /* Déborde légèrement dans les colonnes latérales du cadre */
    --assistant-bleed-x: calc(
        var(--assistant-device-width) * var(--assistant-slice-left) / var(--assistant-ref-w) * 0.38
    );
    --assistant-content-inset-x: 0.4rem;

    position: relative;
    flex-shrink: 0;
    width: var(--assistant-device-width);
    height: var(--assistant-device-height);
    max-width: none;
    max-height: none;
    display: grid;
    grid-template-columns:
        calc(var(--assistant-slice-left) / var(--assistant-ref-w) * 100%)
        calc(var(--assistant-center-w) / var(--assistant-ref-w) * 100%)
        calc(var(--assistant-slice-right) / var(--assistant-ref-w) * 100%);
    grid-template-rows:
        calc(var(--assistant-slice-top) / var(--assistant-ref-w) * var(--assistant-device-width))
        1fr
        calc(var(--assistant-slice-bottom) / var(--assistant-ref-w) * var(--assistant-device-width));
    grid-template-areas:
        'tl t tr'
        'l c r'
        'bl b br';
}

/* Écran vert — plein fond, sous les bords */
.assistant-device__part--center {
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
}

.assistant-device__part:not(.assistant-device__part--center) {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    pointer-events: none;
    user-select: none;
    object-fit: fill;
}

.assistant-device__part--top-left,
.assistant-device__part--top-right,
.assistant-device__part--bottom-left,
.assistant-device__part--bottom-right {
    object-fit: cover;
    object-position: center;
}

.assistant-device__part--top-left { grid-area: tl; }
.assistant-device__part--top { grid-area: t; }
.assistant-device__part--top-right { grid-area: tr; }
.assistant-device__part--left { grid-area: l; }
.assistant-device__part--right { grid-area: r; }
.assistant-device__part--bottom-left { grid-area: bl; }
.assistant-device__part--bottom-center { grid-area: b; }
.assistant-device__part--bottom-right { grid-area: br; }

.assistant-device--static {
    display: block;
    width: var(--assistant-device-width);
    height: var(--assistant-device-height);
    max-width: none;
    max-height: none;
    aspect-ratio: auto;
    pointer-events: none;
    user-select: none;
}

.assistant-device--static .assistant-device__bg {
    display: block;
    width: 100%;
    height: auto;
}

/* ── Écran vert (zone conversation) ── */
.assistant-overlay {
    grid-area: c;
    position: relative;
    z-index: 2;
    min-width: 0;
    min-height: 0;
    justify-self: stretch;
    width: calc(100% + 2 * var(--assistant-bleed-x));
    margin-inline: calc(var(--assistant-bleed-x) * -1);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: var(--text-light);
    padding-inline: var(--assistant-content-inset-x);
    padding-bottom: clamp(0.35rem, 1.6vw, 0.6rem);
}

/* ── Header ── */
.assistant-header {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    flex-shrink: 0;
    padding: 0;
}

.assistant-header__icon {
    flex-shrink: 0;
    width: clamp(2.6rem, 12vw, 3.4rem);
    height: clamp(2.6rem, 12vw, 3.4rem);
    color: var(--cyan);
    filter: drop-shadow(0 0 6px var(--cyan-glow));
}

.assistant-header__icon svg {
    width: 100%;
    height: 100%;
}

.assistant-header__text {
    min-width: 0;
    line-height: 1.15;
}

.assistant-header__greeting {
    margin: 0;
    font-size: var(--text-greeting);
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-light);
}

.assistant-header__name {
    margin: 0.1rem 0 0;
    font-size: var(--text-role);
    font-weight: 400;
    line-height: 1.3;
    color: var(--text-muted);
}

.assistant-header__venty {
    color: var(--cyan);
    font-weight: 700;
    text-shadow: 0 0 10px var(--cyan-glow);
}

.assistant-header__role {
    margin: 0.12rem 0 0;
    font-size: var(--text-role);
    font-weight: 400;
    line-height: 1.3;
    color: var(--text-muted);
}

/* ── Séparateur 3 points ── */
.assistant-divider {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0.45rem 0 0.5rem;
    flex-shrink: 0;
}

.assistant-divider__line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--cyan-dim), transparent);
}

.assistant-divider__dots {
    display: flex;
    gap: 0.2rem;
}

.assistant-divider__dots span {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 0 4px var(--cyan-glow);
}

/* ── Zone chat scrollable ── */
.assistant-chat {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    padding-right: 0.1rem;
    padding-bottom: clamp(0.35rem, 1.6vw, 0.65rem);
    -webkit-overflow-scrolling: touch;
}

.assistant-chat::-webkit-scrollbar {
    width: 3px;
}

.assistant-chat::-webkit-scrollbar-thumb {
    background: var(--cyan-dim);
    border-radius: 2px;
}

.assistant-messages {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    flex: 0 0 auto;
    padding-top: clamp(0.65rem, 3.2vw, 1.1rem);
    padding-bottom: clamp(0.85rem, 4vw, 1.4rem);
}

.assistant-messages > .assistant-bubble:first-child {
    padding-top: clamp(0.65rem, 3.2vw, 1rem);
    padding-bottom: clamp(1.2rem, 5.5vw, 1.55rem);
    margin-bottom: clamp(0.5rem, 2.5vw, 0.85rem);
}

/* ── Bulles ── */
.assistant-bubble {
    position: relative;
    padding: 0.45rem 0.55rem 1.1rem;
    border-radius: 0.45rem;
    border: 1px solid var(--cyan-dim);
    background: var(--screen-bg);
    box-shadow: 0 0 12px var(--cyan-glow), inset 0 0 20px rgba(53, 242, 239, 0.04);
    max-width: 100%;
}

.assistant-bubble--user {
    align-self: flex-end;
    margin-left: 12%;
    border-color: rgba(53, 242, 239, 0.35);
    background: rgba(0, 45, 42, 0.55);
}

.assistant-bubble--assistant {
    align-self: flex-start;
    margin-right: 4%;
}

.assistant-bubble__text {
    margin: 0;
    font-size: var(--text-bubble);
    font-weight: 500;
    line-height: 1.45;
    color: var(--text-light);
    white-space: pre-wrap;
    word-break: break-word;
}

.assistant-bubble__products {
    margin: 0.65rem 0 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.assistant-bubble__product {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.55rem 0.65rem;
    border-radius: 0.65rem;
    background: rgba(53, 242, 239, 0.08);
    border: 1px solid rgba(53, 242, 239, 0.18);
}

.assistant-bubble__product--interactive {
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.assistant-bubble__product--interactive:hover,
.assistant-bubble__product--interactive:focus-visible {
    background: rgba(53, 242, 239, 0.12);
    border-color: rgba(53, 242, 239, 0.32);
    outline: none;
    box-shadow: 0 0 0 2px rgba(53, 242, 239, 0.18);
}

.assistant-bubble__product--expanded {
    background: rgba(53, 242, 239, 0.14);
    border-color: rgba(53, 242, 239, 0.34);
}

.assistant-bubble__product-name {
    font-size: var(--text-bubble);
    font-weight: 600;
    color: var(--cyan);
}

.assistant-bubble__product-reason {
    font-size: calc(var(--text-bubble) * 0.88);
    line-height: 1.35;
    color: var(--text-muted);
}

.assistant-bubble__product-hint {
    font-size: calc(var(--text-bubble) * 0.78);
    line-height: 1.3;
    color: rgba(53, 242, 239, 0.72);
}

.assistant-bubble__product--expanded .assistant-bubble__product-hint {
    display: none;
}

.assistant-bubble__product-nutrition {
    margin-top: 0.35rem;
    padding-top: 0.45rem;
    border-top: 1px solid rgba(53, 242, 239, 0.16);
}

.assistant-bubble__product-nutrition-list {
    margin: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.2rem 0.75rem;
}

.assistant-bubble__product-nutrition-list dt {
    margin: 0;
    font-size: calc(var(--text-bubble) * 0.82);
    color: var(--text-muted);
    font-weight: 500;
}

.assistant-bubble__product-nutrition-list dd {
    margin: 0;
    font-size: calc(var(--text-bubble) * 0.82);
    color: var(--text-light);
    font-weight: 600;
    text-align: right;
}

.assistant-bubble__time {
    position: absolute;
    right: 0.45rem;
    bottom: 0.25rem;
    font-size: var(--text-time);
    font-weight: 400;
    line-height: 1;
    color: var(--text-muted);
}

.assistant-bubble--thinking .assistant-bubble__text {
    opacity: 0.7;
    font-style: italic;
}

/* ── Boutons action rapide ── */
.assistant-actions {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 0.35rem;
    margin-top: auto;
    min-height: 0;
    padding-top: clamp(0.35rem, 1.8vw, 0.65rem);
    padding-bottom: clamp(0.5rem, 2.2vw, 0.85rem);
}

.assistant-action {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    flex: 0 0 auto;
    padding: 0.5rem 0.45rem;
    border: 1px solid var(--cyan-dim);
    border-radius: 0.4rem;
    background: var(--screen-bg);
    color: var(--text-light);
    font-family: var(--font);
    font-size: var(--text-action);
    font-weight: 600;
    line-height: 1.35;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    box-shadow: 0 0 8px rgba(53, 242, 239, 0.08);
}

.assistant-action:hover,
.assistant-action:focus-visible {
    border-color: var(--cyan);
    box-shadow: 0 0 14px var(--cyan-glow);
    background: rgba(0, 40, 38, 0.6);
    outline: none;
}

.assistant-action:active {
    transform: scale(0.98);
}

.assistant-action__icon {
    flex-shrink: 0;
    width: 1.35em;
    height: 1.35em;
    color: var(--cyan);
}

.assistant-action__icon svg {
    width: 100%;
    height: 100%;
}

.assistant-action__label {
    flex: 1;
    min-width: 0;
}

.assistant-action__chevron {
    flex-shrink: 0;
    color: var(--cyan);
    font-size: 1.35em;
    line-height: 1;
    opacity: 0.85;
}

/* ── Bandeau saisie (contact incident — à la place des actions) ── */
.assistant-actions--hidden,
.assistant-input-bar--hidden {
    display: none !important;
}

.assistant-chat .assistant-input-bar {
    flex: 0 0 auto;
    margin-top: auto;
    align-self: stretch;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.45rem;
    padding-top: clamp(0.35rem, 1.8vw, 0.65rem);
    padding-bottom: clamp(0.5rem, 2.2vw, 0.85rem);
    background: var(--screen-bg);
    border: 1px solid var(--cyan-dim);
    border-radius: 0.4rem;
    box-shadow: 0 0 8px rgba(53, 242, 239, 0.08);
}

#assistant-input-form,
.assistant-input-bar {
    position: relative;
    z-index: 2;
}

#assistant-input-form label,
.assistant-input-bar label {
    color: #fff;
}

.assistant-input-bar__field {
    display: block;
    flex: 1 1 auto;
    align-self: stretch;
    min-width: 0;
    width: 100%;
    min-height: 2.25em;
    border: none;
    background: transparent;
    color: #fff;
    font-family: var(--font);
    font-size: var(--text-input);
    font-weight: 500;
    line-height: 1.35;
    outline: none;
    padding: 0;
    margin: 0;
    resize: none;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.35) transparent;
}

.assistant-input-bar__field::-webkit-scrollbar {
    width: 3px;
}

.assistant-input-bar__field::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.35);
    border-radius: 2px;
}

.assistant-input-bar__field::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

/* Bouton envoyer — intégré au bandeau */
.assistant-input-bar__action {
    position: relative;
    flex-shrink: 0;
    align-self: center;
    width: 2.35rem;
    height: 2.35rem;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--cyan);
    box-shadow: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s ease, filter 0.15s ease;
}

.assistant-input-bar__action-icon {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    margin: auto;
    width: 44%;
    height: 44%;
    pointer-events: none;
    color: var(--cyan);
    filter: drop-shadow(0 0 4px var(--cyan-glow));
}

.assistant-input-bar__action-icon.is-visible {
    display: flex;
}

.assistant-input-bar__action-icon svg {
    width: 100%;
    height: 100%;
}

.assistant-input-bar__action:disabled {
    opacity: 0.35;
    cursor: default;
    filter: none;
}

.assistant-input-bar__action:focus-visible {
    outline: 2px solid var(--cyan-dim);
    outline-offset: 2px;
}

.assistant-input-bar__action:active {
    color: var(--cyan);
    filter: drop-shadow(0 0 6px var(--cyan-glow));
}

.assistant-input-bar__action--listening {
    color: var(--cyan);
    filter: drop-shadow(0 0 8px var(--cyan-dim));
    animation: assistant-mic-pulse 1.2s ease-in-out infinite;
}

@keyframes assistant-mic-pulse {
    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(53, 242, 239, 0.45);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(53, 242, 239, 0);
    }
}

.assistant-input-bar__send {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Media queries petits écrans ── */
@media (max-width: 360px) {
    .assistant-device,
    .assistant-device--static {
        --text-greeting: clamp(1.25rem, calc(var(--assistant-device-width) * 0.065), 1.55rem);
        --text-role: clamp(0.82rem, calc(var(--assistant-device-width) * 0.042), 1rem);
        --text-bubble: clamp(1rem, calc(var(--assistant-device-width) * 0.05), 1.15rem);
        --text-action: clamp(0.9rem, calc(var(--assistant-device-width) * 0.046), 1.05rem);
        --text-input: clamp(0.98rem, calc(var(--assistant-device-width) * 0.048), 1.12rem);
    }

    .assistant-overlay {
        padding-bottom: clamp(0.3rem, 1.4vw, 0.55rem);
    }

    .assistant-input-bar {
        padding-top: 0.28rem;
        padding-bottom: 0.5rem;
    }

    .assistant-header {
        gap: 0.4rem;
    }

    .assistant-action {
        padding: 0.45rem 0.38rem;
    }

}

@media (max-height: 640px) and (orientation: portrait) {
    .assistant-overlay {
        padding-bottom: 0.25rem;
    }
}

/* Grand écran : cadre kiosk 820×1180 centré (preview PC) */
@media (min-width: 821px) {
    .assistant-page {
        align-items: center;
    }

    .assistant-device,
    .assistant-device--static {
        --assistant-device-width: min(
            calc(var(--assistant-kiosk-w) * 1px),
            100vw,
            calc(100dvh * var(--assistant-kiosk-w) / var(--assistant-kiosk-h))
        );
        --assistant-device-height: calc(
            var(--assistant-device-width) * var(--assistant-kiosk-h) / var(--assistant-kiosk-w)
        );
    }

    .assistant-device,
    .assistant-device--static {
        width: var(--assistant-device-width);
        height: var(--assistant-device-height);
        max-width: calc(var(--assistant-kiosk-w) * 1px);
        max-height: calc(var(--assistant-kiosk-h) * 1px);
    }
}
