/* Raya Orbit Widget — modern, accessible and provider-theme aware. */
:root {
    --accent-rgb: 101, 48, 170;
    --accent-contrast: #fff;
    --widget-bg: #f7f7fa;
    --widget-surface: #ffffff;
    --widget-surface-2: #f0f0f4;
    --widget-text: #1c1c24;
    --widget-muted: #777783;
    --widget-border: #e6e6ec;
    --widget-danger: #d94854;
    --widget-success: #15966a;
    --widget-radius: 20px;
    --widget-shadow: 0 24px 70px rgba(21, 18, 35, .16), 0 3px 12px rgba(21, 18, 35, .07);
    --soft-transition: 170ms cubic-bezier(.2,.8,.2,1);
}

body.light-mode {
    --bg-primary: var(--widget-surface);
    --bg-secondary: var(--widget-bg);
    --glass-bg: var(--widget-surface);
    --glass-border: var(--widget-border);
    --text-primary: var(--widget-text);
    --text-secondary: var(--widget-muted);
    --accent-admin: var(--widget-surface-2);
    --border-color: var(--widget-border);
}

body.dark-mode {
    --widget-bg: #101016;
    --widget-surface: #18181f;
    --widget-surface-2: #22222b;
    --widget-text: #f7f7f8;
    --widget-muted: #9a9aa6;
    --widget-border: #2d2d37;
    --bg-primary: var(--widget-surface);
    --bg-secondary: var(--widget-bg);
    --glass-bg: var(--widget-surface);
    --glass-border: var(--widget-border);
    --text-primary: var(--widget-text);
    --text-secondary: var(--widget-muted);
    --accent-admin: var(--widget-surface-2);
    --border-color: var(--widget-border);
}

body { background: transparent; font-feature-settings: "ss01", "tnum"; }
#chat-container { border-radius: var(--widget-radius); background: var(--widget-bg); }
#chat-window { position: relative; }

.chat-header {
    min-height: 78px; box-sizing: border-box; padding: 15px 16px;
    color: var(--widget-text); background: rgba(255,255,255,.88) !important;
    border-bottom: 1px solid var(--widget-border); backdrop-filter: blur(20px) saturate(150%);
}
body.dark-mode .chat-header { background: rgba(24,24,31,.9) !important; }
.header-identity { min-width: 0; display: flex; align-items: center; gap: 11px; }
.widget-avatar {
    position: relative; width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center;
    border-radius: 14px; color: var(--accent-contrast); background: var(--accent-primary);
    box-shadow: 0 8px 20px var(--accent-primary-glow); font-family: system-ui,sans-serif; font-size: 14px; font-weight: 800;
}
.widget-avatar i { position: absolute; left: -2px; bottom: -2px; width: 10px; height: 10px; border: 2px solid var(--widget-surface); border-radius: 50%; background: var(--widget-success); }
.header-status { min-width: 0; align-items: flex-start; }
.header-status h3 { max-width: 185px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; line-height: 1.5; letter-spacing: -.25px; }
#chat-mode-status, #chat-mode-status[data-mode="bot"], #chat-mode-status[data-mode="admin"] { margin-top: 2px; color: var(--widget-muted) !important; font-size: 10px; }
#chat-mode-status::before { content: ""; display: inline-block; width: 5px; height: 5px; margin-left: 5px; border-radius: 50%; background: var(--widget-success); vertical-align: 1px; }
.header-buttons { direction: ltr; gap: 3px; }
.header-btn { width: 34px; height: 34px; padding: 0; color: var(--widget-muted) !important; border-radius: 10px; }
.header-btn:hover { color: var(--widget-text) !important; background: var(--widget-surface-2); }
.header-btn.close-button:hover { color: #fff !important; background: var(--widget-danger); }
#handoff-btn:hover { color: var(--accent-primary) !important; background: rgba(var(--accent-rgb),.1); }

.chat-tabs { padding: 7px 12px 0; gap: 5px; background: var(--widget-surface); border-bottom: 1px solid var(--widget-border); }
.tab-btn { position: relative; padding: 8px 10px 10px; color: var(--widget-muted); border-radius: 9px 9px 0 0; font-size: 11px; font-weight: 650; }
.tab-btn:hover { color: var(--widget-text); background: var(--widget-surface-2); }
.tab-btn.active { color: var(--accent-primary); background: transparent; box-shadow: none; }
.tab-btn.active::after { content: ""; position: absolute; right: 20%; bottom: -1px; left: 20%; height: 2px; border-radius: 3px 3px 0 0; background: var(--accent-primary); }
.tab-btn i { font-size: 12px; }

.page-container { background: var(--widget-bg); }
#messages { padding: 18px 14px 28px; }
.message { max-width: 82%; margin-bottom: 11px; padding: 10px 13px; border-radius: 15px; font-size: 12px; line-height: 1.8; box-shadow: 0 1px 2px rgba(20,20,30,.025); }
.message .text { padding-bottom: 13px; }
.message time { bottom: 5px; left: 10px; font-size: 8px; }
.message.customer { color: var(--accent-contrast); background: var(--accent-primary); border-bottom-right-radius: 5px; }
.message.admin, .message.bot { color: var(--widget-text); background: var(--widget-surface); border: 1px solid var(--widget-border); border-bottom-left-radius: 5px; }
.message.bot { padding-top: 31px; border-left: 1px solid var(--widget-border); }
.message.bot::before { top: 8px; right: 13px; color: var(--accent-primary); font-size: 8px; letter-spacing: .1px; }
.message.system { margin: 12px auto; padding: 5px 10px; border: 0; color: var(--widget-muted); background: transparent; font-size: 9px; box-shadow: none; }
.message.system.date-separator { display: flex; align-items: center; gap: 9px; width: 100%; max-width: 100%; box-sizing: border-box; }
.message.system.date-separator::before, .message.system.date-separator::after { content: ""; height: 1px; flex: 1; background: var(--widget-border); }

#typing-indicator { bottom: 8px; left: 14px; }
.typing-content, body.light-mode .typing-content { padding: 7px 10px; border-color: var(--widget-border); border-radius: 13px; color: var(--widget-text); background: var(--widget-surface); box-shadow: 0 5px 18px rgba(20,20,30,.09); }
.typing-content.bot-progress, body.light-mode .typing-content.bot-progress { padding: 8px 11px; border-color: rgba(var(--accent-rgb),.25); color: var(--widget-text); background: var(--widget-surface); box-shadow: 0 9px 25px rgba(20,20,30,.12); }
.bot-progress .typing-progress-icon { background: var(--accent-primary); box-shadow: 0 5px 12px var(--accent-primary-glow); }
.typing-text, body.light-mode .typing-text { color: var(--widget-muted); }
.typing-dots span, body.light-mode .typing-dots span { background: var(--accent-primary); }

#quick-actions-bar { padding: 8px 13px; background: var(--widget-bg); }
.action-chip { padding: 7px 11px; border-color: var(--widget-border); border-radius: 10px; color: var(--widget-muted); background: var(--widget-surface); font-size: 10px; }
.action-chip:hover { color: var(--accent-primary); border-color: rgba(var(--accent-rgb),.35); background: rgba(var(--accent-rgb),.06); box-shadow: none; }

.chat-input-area { padding: 11px 12px 12px; background: var(--widget-surface); border-top: 1px solid var(--widget-border); backdrop-filter: blur(18px); }
.chat-input { gap: 8px; padding: 5px 5px 5px 7px; border: 1px solid var(--widget-border); border-radius: 15px; background: var(--widget-bg); transition: border-color var(--soft-transition), box-shadow var(--soft-transition), background var(--soft-transition); }
.chat-input:focus-within { border-color: rgba(var(--accent-rgb),.58); background: var(--widget-surface); box-shadow: 0 0 0 3px rgba(var(--accent-rgb),.1); }
#message-input { height: 38px; padding: 0 9px; border: 0; border-radius: 10px; background: transparent; box-shadow: none; font-size: 12px; }
#message-input:focus { border: 0; box-shadow: none; }
#send-btn { width: 38px; height: 38px; border-radius: 11px; box-shadow: 0 6px 14px var(--accent-primary-glow); }
#send-btn:hover { transform: translateX(-1px); }
#send-btn i { font-size: 13px; }

#registration-gate { padding: 9px 4px 2px; }
#registration-gate p { margin: 0 0 11px; font-size: 10px; }
#registration-gate input, .track-input { min-height: 42px; padding: 9px 11px; border-color: var(--widget-border); border-radius: 11px; background: var(--widget-bg); }
.primary-btn { min-height: 42px; border-radius: 11px; box-shadow: none; }
#track-order-panel { padding: 22px 16px 16px; color: var(--widget-text); background: var(--widget-surface); border-radius: 20px 20px 0 0; border-top-color: var(--widget-border); box-shadow: 0 -18px 50px rgba(20,20,30,.13); }

@media (max-width: 480px) {
    #chat-container { border-radius: 0; }
    .chat-header { min-height: 72px; padding: 12px 14px; }
    .widget-avatar { width: 39px; height: 39px; flex-basis: 39px; border-radius: 13px; }
    .header-btn { width: 32px; height: 32px; }
    #messages { padding-inline: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Keep the exact brand color for filled controls and a legible variant for small text. */
#send-btn, .primary-btn, .message.customer a, .bot-progress .typing-progress-icon { color: var(--accent-contrast); }
.tab-btn.active, .message.bot::before, .action-chip:hover { color: var(--accent-readable, var(--accent-primary)); }
#handoff-btn:hover { color: var(--accent-readable, var(--accent-primary)) !important; }
body { height: 100dvh; }
#chat-window { min-height: 0; }
.header-buttons { flex-shrink: 0; }

/* Tonal surfaces share the customer's accent and keep actions above the scrollable transcript. */
:root {
    --widget-ease: cubic-bezier(.2,.8,.25,1.05);
    --widget-enter: 260ms;
    --widget-control: 44px;
}
body {
    --widget-tonal: color-mix(in srgb,var(--widget-surface) 88%,var(--accent-primary));
    --widget-tint: color-mix(in srgb,var(--widget-bg) 93%,var(--accent-primary));
    --widget-keyline: color-mix(in srgb,var(--widget-border) 78%,var(--accent-primary));
}
#chat-container { border-radius: 23px; }
.chat-header, body.dark-mode .chat-header {
    min-height: 76px;
    padding: 11px 13px;
    gap: 6px;
    background: linear-gradient(120deg,var(--widget-surface) 18%,var(--widget-tonal)) !important;
    border-color: var(--widget-keyline);
}
.header-identity { flex: 1; gap: 9px; }
.widget-avatar {
    width: 43px; height: 43px; flex-basis: 43px;
    isolation: isolate; overflow: hidden;
    background: var(--accent-primary);
    border-radius: 15px;
    font-size: 21px;
}
.widget-avatar::before {
    content: "";
    position: absolute; z-index: -1;
    width: 86%; height: 48%;
    border-radius: 50%;
    border: 1px solid currentColor;
    opacity: .28;
    transform: rotate(-36deg);
}
.widget-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.widget-avatar:has(img)::before { display: none; }
.widget-avatar-mark { animation: widget-mark-in 430ms var(--widget-ease) both; }
@keyframes widget-mark-in {
    from { opacity: 0; transform: rotate(-35deg) scale(.55); }
    to { opacity: 1; transform: none; }
}
.header-status h3 { max-width: 100%; font-size: 14px; line-height: 1.55; }
#chat-mode-status { line-height: 1.55; }
#chat-mode-status::before { background: var(--accent-readable,var(--accent-primary)); }
.header-buttons {
    gap: 1px;
    padding: 1px;
    border: 1px solid var(--widget-border);
    border-radius: 999px;
    background: color-mix(in srgb,var(--widget-surface) 84%,transparent);
}
.header-btn { width: 37px; height: var(--widget-control); border-radius: 999px; transition: background 160ms ease, color 160ms ease; }
.header-btn svg { width: 18px; height: 18px; }
.chat-tabs { gap: 5px; padding: 6px 13px; }
.chat-tabs:has(#tab-faq[hidden]) { display: none; }
.tab-btn { min-height: var(--widget-control); border-radius: 999px; }
.tab-btn.active { background: var(--widget-tonal); }
.tab-btn.active::after { display: none; }

.page-container { background: radial-gradient(ellipse at 82% 0,var(--widget-tint),transparent 72%),var(--widget-bg); }
#messages { padding: 15px 13px 26px; overscroll-behavior: contain; }
.message { font-size: .82rem; line-height: 1.8; border-radius: 18px; animation: widget-message-in var(--widget-enter) var(--widget-ease) both; }
.message.customer { border-bottom-right-radius: 6px; }
.message.bot,.message.admin { border-bottom-left-radius: 6px; }
.message.bot::before { font-size: .65rem; }
.message time { font-size: .59rem; }
@keyframes widget-message-in {
    from { opacity: 0; transform: translateY(6px) scale(.985); }
    to { opacity: 1; transform: none; }
}
#initial-loading, .widget-empty {
    display: grid;
    justify-items: center;
    align-content: center;
    min-height: min(100%,210px);
    box-sizing: border-box;
    gap: .65rem;
    padding: 1rem .65rem;
    text-align: center;
    color: var(--widget-muted);
    font-size: .81rem;
}
#initial-loading::before {
    content: "";
    width: 24px; height: 24px;
    border-radius: 50%;
    border: 2px solid var(--widget-keyline);
    border-top-color: var(--accent-readable,var(--accent-primary));
    animation: widget-progress .75s linear infinite;
}
#initial-loading[data-error]::before { display: none; }
@keyframes widget-progress { to { transform: rotate(1turn); } }
.widget-empty > span {
    display: grid; place-items: center; width: 55px; height: 55px;
    border-radius: 20px;
    background: var(--widget-tonal);
    color: var(--accent-readable,var(--accent-primary));
    border: 1px solid var(--widget-keyline);
    font-size: 25px;
}
.widget-empty strong { font-size: .95rem; color: var(--widget-text); }
.widget-empty p { margin: 0; }

#quick-actions-bar { background: var(--widget-bg); }
.action-chip { min-height: 36px; border-radius: 999px; font-size: .74rem; }
.chat-input-area {
    padding: 9px 11px max(11px,env(safe-area-inset-bottom));
    background: var(--widget-surface);
}
.chat-input {
    gap: 4px; padding: 4px 6px;
    border-radius: 19px;
    border-color: var(--widget-keyline);
    background: var(--widget-tint);
}
#message-input { height: var(--widget-control); min-width: 0; font-size: .87rem; }
#send-btn { width: var(--widget-control); height: var(--widget-control); border-radius: 50%; transition: transform 180ms var(--widget-ease), background 150ms ease; }
#send-btn:hover { transform: translateX(-1px); }
#send-btn:active { transform: scale(.93); }
#track-order-panel { border-top-color: var(--widget-keyline); }
.track-header h2 { margin: 0; color: var(--widget-text); font-size: 1rem; }
#registration-gate p { color: var(--widget-text-2,var(--widget-muted)); font-size: .76rem; }
:where(button,input,summary,a):focus-visible { outline: 2px solid var(--accent-readable,var(--accent-primary)); outline-offset: 2px; }

@media (max-width: 480px) {
    #chat-container { border-radius: 0; }
    .chat-header { min-height: 70px; }
}
@media (max-width: 350px) {
    .chat-header { padding-inline: 9px; }
    .header-identity { gap: 6px; }
    .header-btn { width: 35px; }
    .widget-avatar { width: 36px; height: 36px; flex-basis: 36px; border-radius: 12px; }
}
@media (prefers-reduced-motion: reduce) {
    .widget-avatar-mark, .message, #initial-loading::before { animation: none !important; }
    #messages { scroll-behavior: auto; }
    #send-btn:is(:hover,:active) { transform: none; }
}

/* Direct chat links use a full-page layout. Embedded conversations keep their compact layout. */
body.widget-standalone {
    display: grid;
    grid-template-columns: minmax(15rem,.78fr) minmax(0,1.35fr);
    align-items: stretch;
    gap: clamp(.9rem,2vw,1.65rem);
    max-width: 1450px;
    margin-inline: auto;
    padding: clamp(1rem,3.6vw,3.25rem);
    box-sizing: border-box;
    background: radial-gradient(ellipse at 98% 5%,var(--widget-tonal),transparent 60%),var(--widget-bg);
}
body.widget-standalone #chat-container {
    min-width: 0;
    min-height: 0;
    box-sizing: border-box;
    border: 1px solid var(--widget-keyline);
    border-radius: clamp(17px,2.4vw,31px);
    box-shadow: 0 22px 75px color-mix(in srgb,var(--accent-primary) 13%,transparent);
    animation: standalone-reveal 400ms var(--widget-ease) both;
}
body.widget-standalone .chat-header {
    padding-inline: clamp(.9rem,2vw,1.55rem);
}
body.widget-standalone .header-status h3 { font-size: 1rem; }
body.widget-standalone #close-btn[hidden] { display: none; }
body.widget-standalone #messages {
    padding: clamp(1rem,3vw,2rem) clamp(1rem,4vw,3rem) 1.15rem;
}
body.widget-standalone #chat-page.typing-active #messages { padding-bottom: 78px; }
body.widget-standalone .message { width: fit-content; max-width: min(83%,37rem); font-size: .94rem; }
body.widget-standalone .chat-input-area { padding-inline: clamp(.75rem,3vw,2rem); }
body.widget-standalone #message-input { font-size: 1rem; }
body.widget-standalone .widget-empty { min-height: 100%; }
body.widget-standalone .widget-empty strong { font-size: 1.1rem; }

.standalone-cover {
    --cover-ink: #fff;
    isolation: isolate;
    position: relative;
    min-width: 0;
    display: grid;
    grid-template-rows: 1fr auto;
    overflow: hidden;
    align-content: stretch;
    padding: clamp(1rem,3.2vw,2.8rem);
    border-radius: clamp(19px,2.6vw,36px);
    color: var(--cover-ink);
    background: radial-gradient(ellipse at 20% 18%,color-mix(in srgb,var(--accent-primary) 44%,#171728),transparent 78%),
        linear-gradient(142deg,#19172d,color-mix(in srgb,var(--accent-primary) 45%,#17172b));
    animation: standalone-reveal 500ms var(--widget-ease) both;
}
.standalone-cover[hidden] { display: none; }
.standalone-cover::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background-image: linear-gradient(#ffffff16 1px,transparent 1px),linear-gradient(90deg,#ffffff16 1px,transparent 1px);
    background-size: 29px 29px;
    mask-image: linear-gradient(150deg,#000,transparent 84%);
    pointer-events: none;
}
.standalone-cover-art {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 0;
    opacity: .92;
    animation: standalone-orbit-in 650ms var(--widget-ease) both;
}
.standalone-orbit {
    --orbit-tilt: 0deg;
    position: absolute;
    width: clamp(8rem,20vw,19rem);
    aspect-ratio: 1.64;
    border: 1px solid #f2ecffa8;
    border-radius: 50%;
    transform: rotate(var(--orbit-tilt));
    box-shadow: 0 0 16px #ded2ff43,inset 0 0 16px #ded2ff2e;
}
.standalone-orbit-b { --orbit-tilt: 60deg; }
.standalone-orbit-c { --orbit-tilt: -60deg; }
.standalone-orbit::after {
    content: "";
    position: absolute;
    inset: 18% 8% auto auto;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #f2ecff;
    box-shadow: 0 0 14px 3px #f2ecff98;
}
.standalone-core {
    display: grid;
    place-items: center;
    width: clamp(3.5rem,9vw,7rem);
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 28%;
    border: 1px solid #ffffff8f;
    background: #ffffff2e;
    color: #fff;
    backdrop-filter: blur(12px);
    font-size: clamp(2.1rem,5vw,4.2rem);
    line-height: 1;
    box-shadow: 0 12px 32px #08061460;
}
.standalone-core img { width: 100%; height: 100%; object-fit: cover; }
.standalone-copy { position: relative; z-index: 1; }
.standalone-channel { margin: 0 0 .4rem; color: #f4edff; font-size: .88rem; }
.standalone-copy h1 { margin: 0 0 1.05rem; color: #fff; font-size: clamp(1.45rem,3.7vw,3.3rem); line-height: 1.35; overflow-wrap: anywhere; }
#standalone-compose {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    min-height: 44px;
    padding: .45rem .9rem;
    border: 1px solid #ffffff4f;
    border-radius: 999px;
    color: #fff;
    background: #ffffff21;
    font: inherit;
    cursor: pointer;
    transition: background 170ms, transform 200ms var(--widget-ease);
}
#standalone-compose:hover { background: #ffffff39; transform: translateY(-2px); }
#standalone-compose:focus-visible { outline-color: #fff; }
@keyframes standalone-reveal { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes standalone-orbit-in { from { opacity: 0; transform: scale(.84) rotate(-12deg); } to { opacity: .92; transform: none; } }

@media (max-height: 530px) {
    .standalone-cover { grid-template-rows: minmax(70px,1fr) auto; }
    .standalone-orbit { width: min(15vw,10rem); }
}
@media (max-width: 760px) {
    body.widget-standalone { grid-template-columns: minmax(0,1fr); padding: clamp(0px,calc(6vw - 20px),14px); gap: 0; }
    body.widget-standalone .standalone-cover { display: none; }
    body.widget-standalone #chat-container { border-radius: 14px; }
    body.widget-standalone #messages { padding-inline: .85rem; }
}
@media (max-width: 430px) {
    body.widget-standalone { padding: 0; }
    body.widget-standalone #chat-container { border: 0; border-radius: 0; }
}
@media (prefers-reduced-motion: reduce) {
    body.widget-standalone #chat-container, .standalone-cover, .standalone-cover-art { animation: none; }
    #standalone-compose:hover { transform: none; }
}
body.widget-standalone .message.customer { margin-inline-end: auto; }
body.widget-standalone :is(.message.admin,.message.bot) { margin-inline-start: auto; }
body.widget-standalone .message.system { margin-inline: auto; }

/* Geometry shared by the widget's inline SVG symbols. */
.widget-icon-library { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }
.widget-icon {
    display: block; flex: none;
    width: 19px; height: 19px;
    fill: none; stroke: currentColor; stroke-width: 1.7;
    stroke-linecap: round; stroke-linejoin: round;
}
.header-btn .widget-icon, .tab-btn .widget-icon, .action-chip .widget-icon { width: 18px; height: 18px; }
#send-btn .widget-icon { width: 22px; height: 22px; stroke-width: 2.4; }
#end-chat-btn { color: #ad3044 !important; }
body.dark-mode #end-chat-btn { color: #ffadb9 !important; }
#end-chat-btn:hover:not(:disabled) { background: color-mix(in srgb,currentColor 13%,transparent); }
#end-chat-btn .widget-icon { width: 20px; height: 20px; }
.btn-icon-small .widget-icon, #standalone-compose .widget-icon, .faq-question .widget-icon { width: 16px; height: 16px; }
.widget-avatar .widget-icon { width: 25px; height: 25px; }
.typing-progress-icon .widget-icon { width: 14px; height: 14px; }
.widget-empty .widget-icon { width: 29px; height: 29px; }
.standalone-core .widget-icon { width: 57%; height: 57%; stroke-width: 1.35; }
