/* AI Assistance panel. Layout and read-only stance follow the Pinewood Accelerator prototype. */

:root {
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --chat-w: 400px;
  --tile: #f7f6fa;
  --field-line: #d6d4df;
  --plate: #ffd93b;
}

/* Shared text helpers, also used by the dashboards. Small icons share the .sm class and must keep their own colour. */
:where(:not(svg)).sm { font-size: 12.5px; line-height: 18px; color: var(--ink-2); }
.xs { font-size: 11.5px; line-height: 15px; }
.muted { color: var(--muted); }
.col { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.spark { width: 28px; height: 28px; flex: none; border-radius: 9px; display: flex; align-items: center; justify-content: center; color: #fff; background: linear-gradient(135deg, #3fb5a6, #7b3fc4); }

/* Panel */
.chat { position: relative; width: var(--chat-w); flex: none; min-height: 0; display: flex; flex-direction: column; overflow: hidden; background: #fff; border-left: 1px solid var(--line); animation: chat-in .32s var(--ease-out); }
.chat > * { min-width: min(var(--chat-w), 100vw); }
.chat.closing { animation: chat-out .2s ease-in forwards; }
@keyframes chat-in { from { width: 0; opacity: 0; } }
@keyframes chat-out { to { width: 0; opacity: 0; } }

.chat-h { position: relative; z-index: 2; flex: none; display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; background: #fff; box-shadow: 0 1px 0 var(--line-2); transition: box-shadow .2s; }
.chat-h.scrolled { box-shadow: 0 1px 0 var(--line), 0 6px 14px -8px rgba(35, 28, 62, .22); }
.chat-h b { font-family: 'Outfit', sans-serif; font-size: 14.5px; font-weight: 600; white-space: nowrap; }
.chat.busy .chat-h .spark { animation: spark-pulse 1.4s ease-in-out infinite; }
@keyframes spark-pulse { 50% { box-shadow: 0 0 0 5px rgba(123, 63, 196, .14); transform: scale(.94); } }
.ctx { padding: 2px 8px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; font-weight: 600; color: var(--ink-2); background: var(--tile); border-radius: 20px; }
.chat-h .icbtn { width: 30px; height: 30px; transition: background .15s, color .15s, transform .15s var(--ease-out); }
.chat-h .icbtn:active { transform: scale(.9); }

.chat-b { position: relative; flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: 14px; padding: 18px 14px 20px; scrollbar-width: thin; scrollbar-color: #dcdae4 transparent; overscroll-behavior: contain; }

/* Messages */
.msg { flex: none; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.msg.enter { animation: msg-in .42s var(--ease-out) backwards; }
@keyframes msg-in { from { opacity: 0; transform: translateY(10px); } }
.msg.enter .msg-u { animation: bubble-in .36s var(--ease-out) backwards; transform-origin: 100% 100%; }
@keyframes bubble-in { from { transform: translateY(8px) scale(.94); } }
.pop { animation: msg-in .28s var(--ease-out) backwards; }

.msg-u { align-self: flex-end; max-width: 86%; padding: 9px 14px; color: #fff; line-height: 19px; white-space: pre-wrap; background: var(--brand); border-radius: 18px 18px 5px 18px; overflow-wrap: anywhere; }
.msg-a { max-width: 100%; color: var(--ink); line-height: 20px; text-wrap: pretty; }
.w-in { animation: word-in .34s ease-out backwards; }
@keyframes word-in { from { opacity: 0; filter: blur(3px); } }

.ccard { display: flex; flex-direction: column; gap: 10px; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 1px 2px rgba(35, 28, 62, .04), 0 6px 18px -12px rgba(35, 28, 62, .18); }
.ccard > .safe { display: flex; align-items: center; gap: 6px; padding-top: 10px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line-2); }
.ccard.is-done { border-color: #cfe5d1; background: linear-gradient(180deg, #f6fbf6, #fff 64px); }
.c-result { font-size: 15px; line-height: 21px; font-weight: 650; text-wrap: pretty; }
.done-tick { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; margin-right: 6px; vertical-align: -4px; color: #fff; background: var(--ok); border-radius: 50%; }
.enter .done-tick { animation: tick-pop .5s var(--ease-spring) .08s backwards; }
.c-result .done-tick svg { color: #fff; stroke-width: 3; width: 12px; height: 12px; vertical-align: 0; }
@keyframes tick-pop { from { transform: scale(0); } }
.c-note { display: flex; gap: 6px; color: var(--ink-2); }
.c-note svg { margin-top: 2px; }

/* An answer reads as prose, with no box around it */
.ans { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.ans .kv3 { align-self: stretch; }
.enter .ans > :not(.c-result) { animation: msg-in .4s var(--ease-out) .16s backwards; }

.kv3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.kv3 div { padding: 9px 10px; background: var(--tile); border-radius: 10px; min-width: 0; }
.kv3 span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kv3 b { display: block; font-family: 'Outfit', sans-serif; font-size: 17px; line-height: 23px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Follow-up suggestions */
.c-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; }
.qchip { display: inline-flex; padding: 6px 12px; color: var(--brand); font-size: 12.5px; font-weight: 550; text-align: left; background: #fff; border: 1px solid var(--brand-200); border-radius: 16px; cursor: pointer; transition: background .15s, border-color .15s, color .15s, transform .18s var(--ease-out), box-shadow .15s; }
.qchip:hover { background: var(--brand-50); border-color: var(--brand); transform: translateY(-1px); box-shadow: 0 3px 8px -3px rgba(83, 27, 124, .3); }
.qchip:active { transform: scale(.97); }
.enter .c-chips > .qchip { animation: msg-in .36s var(--ease-out) backwards; animation-delay: calc(.28s + var(--i, 0) * 45ms); }

.lnk { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 9px 12px; font-weight: 600; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; transition: border-color .15s, background .15s; }
.lnk:hover { border-color: var(--brand); background: var(--brand-50); }
.chat .btn { border-radius: 9px; transition: background .15s, border-color .15s, transform .15s var(--ease-out), box-shadow .15s; }
.chat .btn:active:not(:disabled) { transform: scale(.97); }
.chat .btn.p { box-shadow: 0 1px 2px rgba(83, 27, 124, .3); }
.chat .btn.p:hover { box-shadow: 0 4px 12px -4px rgba(83, 27, 124, .6); }

/* First screen */
.c-empty { display: flex; flex-direction: column; gap: 4px; padding: 10px 2px 4px; }
.c-empty h2 { margin: 0; font-family: 'Outfit', sans-serif; font-size: 23px; line-height: 30px; font-weight: 600; letter-spacing: -.01em; }
.c-empty h2 span { background: linear-gradient(95deg, #2f9f92, #7b3fc4 55%, #c2409a); -webkit-background-clip: text; background-clip: text; color: transparent; }
.c-today { margin: 0 0 16px; color: var(--ink-2); line-height: 20px; }
.c-starts { display: flex; flex-direction: column; margin: 0 -6px 16px; }
.c-start { display: flex; align-items: center; gap: 11px; width: 100%; padding: 8px 8px 8px 6px; font-weight: 500; text-align: left; background: none; border: 0; border-radius: 10px; cursor: pointer; transition: background .15s; }
.enter .c-start { animation: msg-in .42s var(--ease-out) backwards; animation-delay: calc(.08s + var(--i, 0) * 40ms); }
.c-start-i { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; flex: none; color: var(--brand); background: var(--brand-50); border-radius: 8px; transition: background .15s, color .15s; }
.c-start > span:nth-child(2) { flex: 1; min-width: 0; }
.c-start > svg { color: var(--brand); opacity: 0; transform: translateX(-6px); transition: opacity .15s, transform .22s var(--ease-out); }
.c-start:hover, .c-start:focus-visible { background: var(--tile); }
.c-start:hover .c-start-i, .c-start:focus-visible .c-start-i { color: #fff; background: var(--brand); }
.c-start:hover > svg, .c-start:focus-visible > svg { opacity: 1; transform: none; }
.c-safe { display: flex; gap: 7px; margin: 0; font-size: 11.5px; line-height: 16px; color: var(--muted); }
.c-safe svg { margin-top: 1px; }

/* Showing its working: a live list that folds away when done */
.thinking { display: flex; align-items: center; gap: 8px; min-height: 20px; }
.orb { width: 10px; height: 10px; flex: none; border-radius: 50%; background: conic-gradient(from 0deg, #63d6c8, #9aa3d6, #e0489f, #b24bc8, #63d6c8); animation: spin 1s linear infinite; }
.shim { font-weight: 550; color: transparent; background: linear-gradient(90deg, var(--muted) 30%, var(--brand-200) 50%, var(--muted) 70%); background-size: 220% 100%; -webkit-background-clip: text; background-clip: text; animation: shim 1.5s linear infinite; }
@keyframes shim { from { background-position: 110% 0; } to { background-position: -110% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

.steps-h { display: none; align-items: center; gap: 6px; padding: 2px 0; font-size: 12.5px; color: var(--muted); background: none; border: 0; cursor: pointer; transition: color .15s; }
.steps-h:hover { color: var(--ink); }
.steps-h > svg:first-child { color: var(--ok); }
.steps-h .chev { width: 13px; height: 13px; transition: transform .24s var(--ease-out); }
.steps.fin .steps-h { display: inline-flex; }
.steps.open .steps-h .chev { transform: rotate(180deg); }
.steps-w { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .3s var(--ease-out), opacity .2s; }
.steps.fin:not(.open) .steps-w { grid-template-rows: 0fr; opacity: 0; }
.steps-l { min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 6px; }
.steps.fin.open .steps-l { padding: 6px 0 0 2px; }
.step { display: flex; align-items: flex-start; gap: 8px; font-size: 12.5px; line-height: 17px; color: var(--muted); }
.step.todo { display: none; }
.step.run { animation: msg-in .3s var(--ease-out); }
.step.run > span:last-child { font-weight: 550; }
.step.done { color: var(--ink-2); }
.step svg, .step .spin { margin-top: 1.5px; }
.step.done svg { color: var(--ok); animation: tick-pop .34s var(--ease-spring); }
.steps.fin .step.done svg { animation: none; }
.spin { width: 14px; height: 14px; flex: none; border: 2px solid var(--brand-100); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }

/* Composer */
.chat-f { position: relative; z-index: 2; flex: none; display: flex; flex-direction: column; gap: 6px; padding: 4px 12px 10px; background: #fff; }
.cmp { position: relative; display: flex; align-items: flex-end; gap: 6px; padding: 5px 5px 5px 14px; border: 1.5px solid transparent; border-radius: 22px; background: linear-gradient(#fff, #fff) padding-box, linear-gradient(var(--field-line), var(--field-line)) border-box; transition: box-shadow .2s; }
.cmp:focus-within, .chat.busy .cmp { background: linear-gradient(#fff, #fff) padding-box, var(--ai-gradient) border-box; background-size: 100% 100%, 240% 100%; }
.cmp:focus-within { box-shadow: 0 4px 18px -8px rgba(123, 63, 196, .45); }
.chat.busy .cmp { animation: cmp-flow 2.2s linear infinite; }
@keyframes cmp-flow { from { background-position: 0 0, 0% 0; } to { background-position: 0 0, 240% 0; } }
.cmp textarea { font: inherit; flex: 1; min-width: 0; display: block; height: 30px; max-height: 118px; padding: 6px 0; line-height: 18px; color: var(--ink); background: none; border: 0; outline: 0; resize: none; overflow-y: auto; scrollbar-width: thin; }
.cmp textarea::placeholder { color: var(--muted); opacity: 1; }
.send { display: flex; align-items: center; justify-content: center; flex: none; width: 30px; height: 30px; padding: 0; color: #fff; background: var(--brand); border: 0; border-radius: 50%; cursor: pointer; transition: transform .22s var(--ease-spring), background .15s, opacity .15s; }
.send svg { width: 15px; height: 15px; stroke-width: 2.4; }
.send:hover:not(:disabled) { background: var(--brand-600); transform: scale(1.07); }
.send:active:not(:disabled) { transform: scale(.92); }
.send:disabled { color: var(--muted); background: #eeedf2; cursor: default; }
.chat-fine { margin: 0; font-size: 11px; line-height: 14px; text-align: center; color: var(--muted); }
.chat-fine.gone { display: none; }
.chat-jump { position: absolute; left: 50%; top: -38px; display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 12px; font-size: 12px; font-weight: 600; color: var(--ink-2); background: #fff; border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 6px 16px -6px rgba(35, 28, 62, .35); cursor: pointer; transform: translate(-50%, 6px); opacity: 0; pointer-events: none; transition: opacity .18s, transform .24s var(--ease-out), color .15s; }
.chat-jump.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.chat-jump:hover { color: var(--brand); }

/* Booking form */
.bk { gap: 10px; }
.bk-h { font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.bk-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.bk-f { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.bk-f > span { font-size: 11.5px; line-height: 14px; font-weight: 500; color: var(--ink-2); }
.bk-f input, .bk-f select { width: 100%; min-width: 0; height: 34px; padding: 0 10px; color: var(--ink); background: #fff; border: 1px solid var(--field-line); border-radius: 9px; outline: 0; transition: border-color .15s, box-shadow .15s; }
.bk-f input::placeholder { color: #8d8b9b; }
.bk-f input:hover, .bk-f select:hover { border-color: #b4b1c2; }
.bk-f input:focus, .bk-f select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.bk-f select { appearance: none; padding-right: 28px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23484463' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 9px center; cursor: pointer; }
.bk-f input.plate-in { font-family: 'Outfit', sans-serif; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; background: #fffbe8; border-color: #e8cf6a; }
.bk-f input.plate-in::placeholder { font-weight: 500; letter-spacing: .02em; color: #8a7a35; text-transform: none; }
.bk-f input.plate-in:focus { background: #fff6c9; border-color: #c9a400; box-shadow: 0 0 0 3px #fbedb0; }
.plate { display: inline-block; padding: 0 6px; font-family: 'Outfit', sans-serif; font-size: 12px; line-height: 18px; font-weight: 600; letter-spacing: .05em; white-space: nowrap; color: #1d1a12; background: var(--plate); border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14); }
.fold { display: grid; grid-template-rows: 0fr; opacity: 0; margin-top: -10px; transition: grid-template-rows .28s var(--ease-out), opacity .2s, margin-top .28s var(--ease-out); }
.fold > div { min-height: 0; overflow: hidden; }
.fold.on { grid-template-rows: 1fr; opacity: 1; margin-top: 0; }
.bk-match { display: flex; align-items: center; gap: 6px; font-size: 12.5px; line-height: 17px; color: var(--ok); }
.bk-types { display: flex; flex-wrap: wrap; gap: 6px; }
.bk-types .qchip { padding: 5px 11px; }
.bk-types .qchip[aria-pressed="true"] { color: #fff; background: var(--brand); border-color: var(--brand); box-shadow: 0 3px 8px -3px rgba(83, 27, 124, .55); }
.bk-err { display: flex; gap: 6px; color: var(--amber); }
.bk-err svg { margin-top: 2px; }
.bk-sum { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }

/* Technician suggestion */
.bk-s { gap: 8px; }
.bk-best { align-self: flex-start; padding: 2px 8px; font-size: 11px; line-height: 15px; font-weight: 650; color: var(--brand); background: var(--brand-50); border-radius: 10px; }
.bk-slot { font-family: 'Outfit', sans-serif; font-size: 19px; line-height: 25px; font-weight: 600; letter-spacing: -.005em; }
.bk-who { font-weight: 600; }
.bk-stats { display: flex; flex-wrap: wrap; gap: 5px; }
.bk-stats span { padding: 2px 8px; font-size: 11.5px; line-height: 16px; border-radius: 10px; background: #f3f2f6; }
.bk-stats .good { color: var(--ok); background: var(--ok-bg); }
.bk-stats .bad { color: var(--amber); background: var(--amber-bg); }
.bk-alt { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line-2); }
.bk-alt-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.bk-alt-h b { display: block; font-weight: 600; }
.bk-alt-h span { font-size: 12.5px; color: var(--ink-2); }
.bk-will { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; font-size: 12.5px; line-height: 17px; background: var(--tile); border-radius: 10px; }

/* Extras worth offering on the booking call */
.bx { gap: 0; }
.bx > .sm + .c-acts, .bx > .bx-car + .sm { margin-top: 8px; }
.bx-car { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 4px; padding: 9px 10px 9px 12px; font-size: 12.5px; line-height: 17px; background: var(--tile); border-radius: 10px; }
.bx-car b { display: block; }
.bx-car span { color: var(--ink-2); }
.bx-miles { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.bx-miles span { font-size: 11px; line-height: 14px; color: var(--amber); }
.bx-miles input { width: 78px; height: 28px; padding: 0 8px; font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); background: var(--amber-bg); border: 1px solid #f0d39b; border-radius: 8px; outline: 0; transition: border-color .15s, box-shadow .15s; }
.bx-miles input:focus { border-color: var(--amber); box-shadow: 0 0 0 3px #fbe7c0; }
.bx-item { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 10px; width: calc(100% + 16px); margin: 0 -8px; padding: 10px 8px; color: inherit; text-align: left; background: none; border: 0; border-radius: 10px; cursor: pointer; transition: background .15s; }
button.bx-item:hover { background: var(--tile); }
div.bx-item { cursor: default; }
.bx-item.off > :not(.bx-box) { opacity: .62; }
.bx-item b { display: block; font-weight: 600; }
.bx-box { display: flex; align-items: center; justify-content: center; width: 18px; height: 18px; margin-top: 1px; color: #fff; background: #fff; border: 1.5px solid #a8a5b8; border-radius: 6px; transition: background .15s, border-color .15s, transform .24s var(--ease-spring); }
button.bx-item:hover .bx-box:not(.on) { border-color: var(--brand); }
button.bx-item:active .bx-box { transform: scale(.86); }
.bx-box svg { width: 12px; height: 12px; stroke-width: 3; transform: scale(0); transition: transform .24s var(--ease-spring); }
.bx-box.on { background: var(--brand); border-color: var(--brand); }
.bx-box.on svg { transform: none; }
.bx-item.off .bx-box { border-style: dashed; opacity: .62; }
.bx-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.bx-tags span { padding: 1px 8px; font-size: 11.5px; line-height: 16px; border-radius: 10px; color: var(--ink-2); background: #f3f2f6; }
.bx-tags .safe { color: var(--red); background: var(--red-bg); }
.bx-tags .ok { color: var(--ok); background: var(--ok-bg); }
.bx-tags .amb { color: var(--amber); background: var(--amber-bg); }
.bx-tags .off { font-weight: 600; }
.bx-price { text-align: right; font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bx-price span { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.bx-more { display: inline-flex; align-items: center; gap: 4px; align-self: flex-start; padding: 6px 0 8px; font-size: 12.5px; font-weight: 600; color: var(--brand); background: none; border: 0; cursor: pointer; }
.bx-more svg { transition: transform .24s var(--ease-out); }
.bx-more[aria-expanded="true"] svg { transform: rotate(180deg); }
.bx:has(> .bx-total) { padding-bottom: 0; }
.bx-total { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 4px -14px 0; padding: 10px 14px; font-variant-numeric: tabular-nums; border-top: 1px solid var(--line-2); border-radius: 0 0 14px 14px; }
.msg:last-child .bx-total { position: sticky; bottom: 0; z-index: 1; background: rgba(255, 255, 255, .95); backdrop-filter: blur(6px); }
.bx-total b { display: block; font-weight: 650; }
.bx-total small { display: block; font-size: 12px; line-height: 15px; color: var(--muted); }
.chat:has(.msg:last-child .bx-total) .chat-jump { display: none; }

@media (max-width: 980px) {
  .chat { position: fixed; top: 49px; right: 0; bottom: 0; z-index: 30; width: min(var(--chat-w), 100%); box-shadow: -8px 0 24px rgba(0, 0, 0, .15); animation-name: chat-slide; }
  .chat > * { min-width: 0; }
  .chat.closing { animation-name: chat-slide-out; }
  @keyframes chat-slide { from { transform: translateX(100%); } }
  @keyframes chat-slide-out { to { transform: translateX(100%); } }
}

@media (prefers-reduced-motion: reduce) {
  .chat *, .chat { animation-delay: 0s !important; }
  .chat.busy .cmp { animation: none; }
}
