/*
 * EPE website assistant - chat box (resources/views/components/assistant.blade.php).
 * Brand tokens come from app.css (--pp-*); no new colours are defined here.
 * The closed launcher sits under the cookie banner (z 9997); an open chat sits above it.
 * Input text is 16px: smaller makes iPhone Safari zoom the page on focus.
 */

.epa {
    --epa-radius: 18px;
    --epa-line: rgba(255, 255, 255, 0.1);
    --epa-online: #22c55e;
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9990;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
}

/* Open: above the cookie banner, or on a phone the banner covers the input
   (seen on staging 2026-10-19). The closed launcher stays below it. */
.epa-open { z-index: 9998; }

.epa-icon { width: 20px; height: 20px; flex-shrink: 0; }
/* The monogram artwork sits 8% right of centre and 3% high in its square image
   (the letters touch the right edge), so it looked pushed right in the round
   badges. Shift it back by the measured amount (MonogramCentringTest). */
.epa-mark { display: block; object-fit: contain; transform: translate(-8%, 3%); }

.epa-sr {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ── Launcher ─────────────────────────────────────────────────────────── */
.epa-launcher {
    display: inline-flex; align-items: center; gap: 10px;
    padding: 8px 20px 8px 8px; border: 0; border-radius: 999px; cursor: pointer;
    background: var(--pp-blue); color: var(--pp-white);
    font: 600 15px/1 inherit; letter-spacing: 0.01em;
    box-shadow: 0 10px 30px rgba(0, 85, 255, 0.35);
    transition: transform 0.2s ease, background 0.2s ease;
}
.epa-launcher:hover { background: var(--pp-blue-dark); transform: translateY(-2px); }
.epa-launcher-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 50%; background: var(--pp-dark);
}
.epa-launcher-mark .epa-mark { width: 24px; height: 24px; }
.epa-open .epa-launcher { display: none; }

/* "Have you read...?" bubble above the launcher (a post switched on as an alert in admin). */
.epa-alert {
    position: absolute; right: 0; bottom: calc(100% + 14px);
    width: min(300px, calc(100vw - 24px)); padding: 14px 16px;
    background: var(--pp-dark-light); color: var(--pp-grey-dark);
    border: 1px solid var(--epa-line); border-radius: 14px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
    animation: epa-in 0.22s ease-out;
}
.epa-alert[hidden] { display: none; }
.epa-alert::after {
    content: ''; position: absolute; right: 34px; bottom: -7px; width: 12px; height: 12px;
    background: var(--pp-dark-light); border-right: 1px solid var(--epa-line); border-bottom: 1px solid var(--epa-line);
    transform: rotate(45deg);
}
.epa-alert-label { font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--pp-orange); }
.epa-alert-title { margin-top: 4px; font-size: 14px; font-weight: 600; line-height: 1.35; color: var(--pp-white); }
.epa-alert-ask { margin-top: 4px; font-size: 13px; color: var(--pp-grey-dark); }
.epa-alert-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.epa-alert-read {
    border: 0; border-radius: 999px; padding: 6px 16px; cursor: pointer;
    background: var(--pp-blue); color: var(--pp-white); font: 600 13px/1.2 inherit;
}
.epa-alert-read:hover { background: var(--pp-blue-dark); }
.epa-alert-close {
    display: inline-flex; border: 0; padding: 6px; border-radius: 8px; cursor: pointer;
    background: transparent; color: var(--pp-grey-dark);
}
.epa-alert-close:hover { color: var(--pp-white); background: rgba(255, 255, 255, 0.06); }
.epa-alert-read:focus-visible, .epa-alert-close:focus-visible { outline: 2px solid var(--pp-blue-light); outline-offset: 2px; }
.epa-open .epa-alert { display: none; }

/* ── Panel ────────────────────────────────────────────────────────────── */
.epa-panel {
    display: flex; flex-direction: column;
    width: 400px; height: min(640px, calc(100vh - 40px));
    background: var(--pp-dark-light); color: var(--pp-grey-dark);
    border: 1px solid var(--epa-line); border-radius: var(--epa-radius);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    animation: epa-in 0.22s ease-out;
}
.epa-panel[hidden] { display: none; }

@keyframes epa-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: none; }
}

.epa-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 16px; border-bottom: 1px solid var(--epa-line);
    background: var(--pp-dark);
}
.epa-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.epa-head-mark {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 42px; height: 42px; border-radius: 12px;
    background: var(--pp-dark-light); border: 1px solid var(--epa-line);
}
.epa-head-mark .epa-mark { width: 28px; height: 28px; }
/* Name + favourite language, then the subtitle */
.epa-who { min-width: 0; }
.epa-title { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 700; font-size: 16px; color: var(--pp-white); }
.epa-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.epa-lang {
    padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
    color: var(--pp-grey-dark); background: rgba(255, 255, 255, 0.07); border: 1px solid var(--epa-line);
}
.epa-lang:empty { display: none; }
.epa-sub { margin: 3px 0 0; font-size: 12px; line-height: 1.35; color: var(--pp-text-muted); }

/* The persona's avatar beside the close button. --epa-p1/--epa-p2/--epa-ink are its
   language colours (config/assistant_personas.php), set by assistant.js. */
.epa-head-end { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.epa-persona {
    position: relative; display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
    background: linear-gradient(135deg, var(--epa-p1, var(--pp-blue)), var(--epa-p2, var(--pp-blue-dark)));
    color: var(--epa-ink, var(--pp-white));
    box-shadow: 0 0 0 2px var(--pp-dark), 0 0 0 3px rgba(255, 255, 255, 0.14);
}
.epa-persona-face { width: 30px; height: 30px; }
/* Online: a small dot on the avatar, the way messaging apps show presence, with a soft pulse. */
.epa-presence {
    position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%;
    background: var(--epa-online); box-shadow: 0 0 0 2.5px var(--pp-dark);
}
.epa-presence::after {
    content: ''; position: absolute; inset: 0; border-radius: 50%;
    background: var(--epa-online); opacity: 0.5; animation: epa-pulse 2.4s ease-out infinite; pointer-events: none;
}
@keyframes epa-pulse { 0% { transform: scale(1); opacity: 0.5; } 70%, 100% { transform: scale(2.2); opacity: 0; } }
.epa-close {
    display: inline-flex; padding: 8px; border: 0; border-radius: 10px; cursor: pointer;
    background: transparent; color: var(--pp-text-muted);
}
.epa-close:hover { color: var(--pp-white); background: rgba(255, 255, 255, 0.06); }

/* ── Conversation ─────────────────────────────────────────────────────── */
.epa-log {
    flex: 1; overflow-y: auto; padding: 16px 14px 8px;
    display: flex; flex-direction: column; gap: 12px;
    overscroll-behavior: contain;
}
.epa-turn { display: flex; align-items: flex-end; gap: 8px; }
.epa-turn-user { justify-content: flex-end; }
.epa-turn-bot { justify-content: flex-start; }
.epa-avatar {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--pp-dark); border: 1px solid var(--epa-line);
}
.epa-avatar .epa-mark { width: 18px; height: 18px; }

.epa-msg {
    max-width: 86%; min-width: 0; padding: 11px 14px; border-radius: 14px;
    font-size: 14px; line-height: 1.5;
    overflow-wrap: anywhere; word-break: normal;
}
.epa-msg p { margin: 0; }
.epa-msg p + p { margin-top: 6px; }
.epa-bot { background: rgba(255, 255, 255, 0.06); border-bottom-left-radius: 4px; }
.epa-user { background: var(--pp-blue); color: var(--pp-white); border-bottom-right-radius: 4px; }
.epa-answer-title { font-weight: 700; color: var(--pp-white); }
/* The persona's own line in front of an answer (config/assistant_personas.php) */
.epa-say { color: var(--pp-blue-light); font-style: italic; }

/* Forms the chat fills in (assistant-flows.js): progress, review list, QR */
.epa-flow-progress { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--pp-text-muted); }
.epa-flow-note { font-size: 12px; color: var(--pp-grey-dark); }
.epa-flow-nav { display: flex; gap: 6px; margin-top: 10px; }
.epa-review { list-style: none; margin: 8px 0 4px; padding: 0; display: grid; gap: 6px; }
.epa-review li { display: grid; grid-template-columns: 84px 1fr auto; gap: 8px; align-items: baseline; font-size: 13px; }
.epa-review-label { color: var(--pp-text-muted); }
.epa-review-value { color: var(--pp-white); overflow-wrap: anywhere; }
.epa-review .epa-link { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; font-size: 12px; }
.epa-qr { display: block; width: 100%; max-width: 220px; margin: 10px 0 4px; border-radius: 10px; background: #FFFFFF; }

/* Details card, offered once with the third answer */
.epa-lead { width: 86%; }
.epa-lead-form { display: grid; gap: 8px; margin-top: 10px; }
.epa-lead-field { display: grid; gap: 4px; }
.epa-lead-field label { font-size: 12px; color: var(--pp-text-muted); }
.epa-lead-form input[type="text"], .epa-lead-form input[type="email"], .epa-lead-form input[type="tel"], .epa-lead-form input[type="date"] {
    width: 100%; padding: 10px 12px; border: 1px solid var(--epa-line); border-radius: 10px;
    background: var(--pp-dark); color: var(--pp-white); font-size: 16px;
}
.epa-lead-consent { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 12px; color: var(--pp-grey-dark); }
.epa-lead-consent input { width: 16px; height: 16px; margin: 0 4px 0 0; accent-color: var(--pp-blue); }
/* Background-check authorization in the chat's final card (its own block, like the page) */
.epa-fcra { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--epa-line); border-radius: 10px; }
.epa-fcra-title { font-size: 12px; font-weight: 700; color: var(--pp-white); }
.epa-fcra .epa-link { font-size: 12px; }
.epa-fcra-tick { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: start; font-size: 12px; color: var(--pp-white); }
.epa-fcra-tick input { width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--pp-blue); }
.epa-lead-error { color: var(--pp-orange); font-size: 12px; }
.epa-lead-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 2px; }
.epa-lead-actions .epa-cta { cursor: pointer; }
.epa-lead-actions .epa-cta:disabled { opacity: 0.6; cursor: default; }

/* Actions: Book a call, Call us, Get a quote */
.epa-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.epa-cta {
    display: inline-flex; align-items: center; padding: 8px 14px; border-radius: 999px;
    font-weight: 600; font-size: 13px; text-decoration: none;
    border: 1px solid rgba(51, 119, 255, 0.5); color: var(--pp-white); background: rgba(0, 85, 255, 0.14);
}
.epa-cta:hover { background: var(--pp-blue); border-color: var(--pp-blue); }
.epa-cta-primary { background: var(--pp-orange); border-color: var(--pp-orange); }
.epa-cta-primary:hover { background: var(--pp-orange-dark); border-color: var(--pp-orange-dark); }

.epa-link {
    color: var(--pp-blue-light); font-weight: 600; font-size: 13px; text-decoration: none;
    border-bottom: 1px solid rgba(51, 119, 255, 0.4);
}
.epa-link:hover { color: var(--pp-white); border-color: var(--pp-white); }
.epa-more { margin-top: 8px !important; }

.epa-related-label { margin-top: 12px !important; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--pp-text-muted); }
.epa-related { margin: 6px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; }

/* Choices and next questions, inside the reply */
.epa-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.epa-chip {
    padding: 7px 12px; border-radius: 999px; cursor: pointer;
    border: 1px solid var(--epa-line); background: var(--pp-dark); color: var(--pp-grey-dark);
    font: 500 13px/1.2 inherit; text-align: left;
}
.epa-chip:hover { border-color: var(--pp-blue); color: var(--pp-white); background: rgba(0, 85, 255, 0.14); }
/* Pick-several steps (tech quote features): a picked chip stays highlighted. */
.epa-chip[aria-pressed="true"] { border-color: var(--pp-blue); color: var(--pp-white); background: rgba(0, 85, 255, 0.28); }

.epa-typing { display: inline-flex; gap: 4px; padding: 14px; }
.epa-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pp-text-muted); animation: epa-blink 1.2s infinite ease-in-out; }
.epa-dot:nth-child(2) { animation-delay: 0.15s; }
.epa-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes epa-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* ── Composer ─────────────────────────────────────────────────────────── */
.epa-form {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    padding: 12px 14px 6px; border-top: 1px solid var(--epa-line);
}
.epa-form input {
    flex: 1; min-width: 0; padding: 12px 14px;
    border: 1px solid var(--epa-line); border-radius: 12px;
    background: var(--pp-dark); color: var(--pp-white);
    font-size: 16px;
}
.epa-form input::placeholder { color: var(--pp-text-muted); }
.epa-send {
    display: inline-flex; padding: 12px; border: 0; border-radius: 12px; cursor: pointer;
    background: var(--pp-blue); color: var(--pp-white);
}
.epa-send:hover { background: var(--pp-blue-dark); }
.epa-busy .epa-send, .epa-busy input { opacity: 0.6; }
.epa-captcha { flex-basis: 100%; }
.epa-captcha p { margin: 0 !important; font-size: 11px; color: rgba(255, 255, 255, 0.35); }
.epa-captcha a { color: var(--pp-blue-light); }
.epa-note { margin: 0; padding: 0 14px 14px; font-size: 11px; color: var(--pp-text-muted); }

/* Keyboard focus */
.epa button:focus-visible, .epa a:focus-visible, .epa input:focus-visible {
    outline: 2px solid var(--pp-blue-light); outline-offset: 2px;
}

/* Phones: a bottom sheet */
@media (max-width: 640px) {
    .epa { right: 12px; bottom: 12px; }
    .epa-open { left: 0; right: 0; bottom: 0; }
    .epa-panel {
        width: 100%; height: 88vh; height: 88dvh;
        border-radius: var(--epa-radius) var(--epa-radius) 0 0; border-bottom: 0;
    }
    .epa-msg { max-width: 90%; }
}

@media (prefers-reduced-motion: reduce) {
    .epa-panel, .epa-dot, .epa-presence::after, .epa-alert { animation: none; }
    .epa-launcher { transition: none; }
}
