/* Perazim Otto AI Agent - Widget Styles v2.0 */

:root {
    --pca-teal:    #00d4c0;
    --pca-purple:  #5b3fff;
    --pca-bg:      #0d1a26;
    --pca-surface: #122030;
    --pca-border:  rgba(0,212,192,0.10);
    --pca-text:    #d8eeff;
    --pca-muted:   #456070;
    --pca-green:   #00e676;
    --pca-green-g: rgba(0,230,118,0.55);
    --pca-accent:  var(--pca-teal);
}

/* -- Root containers -- */
#pca-root.pca-floating {
    position: fixed;
    bottom: 100px;
    right: 52px; /* room for the orbit dots (56px radius) inside the screen */
    z-index: 999999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 14px;
    font-family: 'DM Sans', 'Inter', sans-serif;
}

#pca-root.pca-inline {
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    font-family: 'DM Sans', 'Inter', sans-serif;
}

/* -- Panel -- */
#pca-panel {
    width: 390px;
    height: 580px;
    background: var(--pca-bg);
    border: 1px solid var(--pca-border);
    border-radius: 22px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow:
        0 0 0 1px rgba(0,212,192,0.03),
        0 32px 80px rgba(0,0,0,0.70),
        inset 0 1px 0 rgba(0,212,192,0.07);
    transform-origin: bottom right;
}

.pca-floating #pca-panel {
    animation: pca-panel-in 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
.pca-floating #pca-panel.pca-hidden { display: none; }

.pca-inline #pca-panel {
    width: 100%;
    height: 520px;
    border-radius: 16px;
}

@keyframes pca-panel-in {
    from { opacity:0; transform:scale(0.87) translateY(18px); }
    to   { opacity:1; transform:scale(1)    translateY(0); }
}

/* -- Header -- */
.pca-header {
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(0,212,192,0.05), rgba(91,63,255,0.05));
    border-bottom: 1px solid var(--pca-border);
    display: flex;
    align-items: center;
    gap: 11px;
    flex-shrink: 0;
}

/* Avatar + halo */
.pca-avatar-wrap {
    position: relative;
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    animation: pca-float 3.6s ease-in-out infinite;
}

.pca-avatar-wrap img {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    position: relative;
    z-index: 2;
}

.pca-halo {
    position: absolute;
    inset: -11px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--pca-green-g) 0%, rgba(0,230,118,0.18) 40%, transparent 70%);
    animation: pca-halo-pulse 2.2s ease-in-out infinite;
    z-index: 1;
    pointer-events: none;
}

@keyframes pca-halo-pulse {
    0%,100% { opacity:0.45; transform:scale(0.88); }
    50%      { opacity:1;    transform:scale(1.18); }
}

@keyframes pca-float {
    0%,100% { transform:translateY(0); }
    50%      { transform:translateY(-5px); }
}

.pca-agent-info { flex:1; min-width:0; }
.pca-agent-name {
    font-family: 'Syne', sans-serif;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--pca-teal);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pca-agent-title {
    font-size: 10.5px;
    color: var(--pca-muted);
    margin-top: 1px;
}

.pca-online-pill {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(0,230,118,0.08);
    border: 1px solid rgba(0,230,118,0.20);
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 9.5px;
    color: var(--pca-green);
    font-weight: 500;
    white-space: nowrap;
}

.pca-online-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--pca-green);
    animation: pca-blink 2s ease-in-out infinite;
}

@keyframes pca-blink { 0%,100%{opacity:1} 50%{opacity:0.3} }

.pca-close-btn {
    flex: none;
    width: 34px; height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(216, 238, 255, 0.08);
    border: 1px solid rgba(216, 238, 255, 0.18);
    color: var(--pca-text);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0 0 2px;
    border-radius: 50%;
    transition: color .2s, background .2s, border-color .2s, transform .2s;
}
.pca-close-btn:hover,
.pca-close-btn:focus-visible {
    color: #fff;
    background: rgba(0, 212, 192, 0.22);
    border-color: var(--pca-teal);
    transform: rotate(90deg);
    outline: none;
}

/* -- Messages -- */
.pca-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 13px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
.pca-messages::-webkit-scrollbar { width: 3px; }
.pca-messages::-webkit-scrollbar-thumb { background: rgba(0,212,192,0.15); border-radius:2px; }

.pca-msg {
    display: flex;
    gap: 7px;
    animation: pca-msg-in 0.26s ease;
}
.pca-msg.pca-user { flex-direction: row-reverse; }

@keyframes pca-msg-in {
    from { opacity:0; transform:translateY(6px); }
    to   { opacity:1; transform:translateY(0); }
}

.pca-msg-av {
    width: 27px; height: 27px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 1px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}
.pca-msg-av img { width:100%; height:100%; object-fit:cover; }
.pca-msg-av.pca-user-av {
    background: linear-gradient(135deg, var(--pca-purple), var(--pca-teal));
    color: #fff;
}

.pca-msg-body { max-width: 82%; }

/* -- Chat bubble font bumped to 14px (was 13px) -- */
.pca-bubble {
    padding: 9px 12px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.58;
    font-weight: 400;
}
.pca-msg.pca-agent .pca-bubble {
    background: var(--pca-surface);
    border: 1px solid var(--pca-border);
    border-top-left-radius: 3px;
    color: var(--pca-text);
}
.pca-msg.pca-user .pca-bubble {
    background: linear-gradient(135deg, rgba(91,63,255,0.26), rgba(0,212,192,0.12));
    border: 1px solid rgba(0,212,192,0.16);
    border-top-right-radius: 3px;
    color: var(--pca-text);
}
.pca-msg-time {
    font-size: 9px;
    color: var(--pca-muted);
    margin-top: 3px;
    padding: 0 1px;
}
.pca-msg.pca-user .pca-msg-time { text-align:right; }

/* Typing indicator */
.pca-typing-row { display:flex; gap:7px; animation: pca-msg-in .26s ease; }
.pca-typing-dots {
    background: var(--pca-surface);
    border: 1px solid var(--pca-border);
    border-radius: 14px;
    border-top-left-radius: 3px;
    padding: 11px 14px;
    display: flex;
    gap: 4px;
    align-items: center;
}
.pca-typing-dots span {
    width:5px; height:5px;
    border-radius:50%;
    background: var(--pca-teal);
    animation: pca-dot 1.4s ease-in-out infinite;
}
.pca-typing-dots span:nth-child(2){animation-delay:.2s}
.pca-typing-dots span:nth-child(3){animation-delay:.4s}
@keyframes pca-dot{0%,80%,100%{opacity:.2;transform:scale(.8)}40%{opacity:1;transform:scale(1)}}

/* -- Quick replies -- */
.pca-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 0 12px 8px;
    flex-shrink: 0;
}
.pca-qr-btn {
    padding: 5px 11px;
    border-radius: 20px;
    border: 1px solid var(--pca-border);
    background: rgba(0,212,192,0.04);
    color: var(--pca-teal);
    font-size: 11.5px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
}
.pca-qr-btn:hover {
    background: rgba(0,212,192,0.1);
    border-color: var(--pca-teal);
    transform: translateY(-1px);
}

/* -- Drop zone -- */
.pca-drop-zone {
    margin: 0 12px;
    padding: 9px 14px;
    border: 1px dashed rgba(0,212,192,0.2);
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    transition: all .3s;
    background: rgba(0,212,192,0.02);
    display: none;
    flex-shrink: 0;
}
.pca-drop-zone.pca-open { display: block; }
.pca-drop-zone.active,
.pca-drop-zone:hover { border-color: var(--pca-teal); background: rgba(0,212,192,0.05); }
.pca-drop-icon { font-size: 18px; margin-bottom: 2px; }
.pca-drop-text { font-size: 11.5px; color: var(--pca-muted); }

/* -- Input area -- */
.pca-input-area {
    padding: 11px 12px;
    border-top: 1px solid var(--pca-border);
    background: rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}
.pca-input-row { display:flex; gap:7px; align-items:flex-end; }

/* -- Input font bumped to 14px (was 13px) -- */
.pca-input {
    flex: 1;
    background: var(--pca-surface) !important;
    border: 1px solid var(--pca-border) !important;
    border-radius: 11px;
    padding: 9px 11px;
    color: #ffffff !important;
    font-family: inherit;
    font-size: 14px;
    resize: none;
    outline: none !important;
    transition: border-color .2s;
    max-height: 85px;
    line-height: 1.4;
    caret-color: var(--pca-teal);
    -webkit-text-fill-color: #ffffff !important;
}
.pca-input:focus { border-color: rgba(0,212,192,0.3) !important; }
.pca-input::placeholder { color: var(--pca-muted) !important; opacity: 1; }

.pca-icon-btn {
    width: 36px; height: 36px;
    border-radius: 10px;
    border: 1px solid var(--pca-border);
    background: var(--pca-surface);
    color: var(--pca-muted);
    cursor: pointer;
    display: flex; align-items:center; justify-content:center;
    transition: all .2s;
    flex-shrink: 0;
}
.pca-icon-btn svg { width:14px; height:14px; }
.pca-icon-btn:hover { border-color: var(--pca-teal); color: var(--pca-teal); background: rgba(0,212,192,0.05); }

.pca-send-btn {
    width: 36px; height: 36px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, var(--pca-purple), var(--pca-teal));
    cursor: pointer;
    display: flex; align-items:center; justify-content:center;
    transition: all .2s;
    flex-shrink: 0;
    box-shadow: 0 4px 16px rgba(0,212,192,0.22);
}
.pca-send-btn:hover { transform:scale(1.07); box-shadow:0 6px 22px rgba(0,212,192,0.38); }
.pca-send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.pca-send-btn svg { width:14px; height:14px; }

.pca-hint {
    font-size: 9px;
    color: var(--pca-muted);
    text-align: center;
    letter-spacing: .5px;
}

/* -- Launcher -- */
.pca-launcher {
    position: relative;
    width: 84px; height: 84px;
    cursor: pointer;
    animation: pca-float 3.6s ease-in-out infinite;
    transition: transform .3s cubic-bezier(.2,.8,.2,1);
}

/* Soft brand glow (purple + teal) that breathes behind Otto. */
.pca-launcher-halo {
    position: absolute;
    inset: -22px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(124,92,255,0.55) 0%, rgba(0,212,192,0.28) 42%, transparent 70%);
    animation: pca-halo-pulse 2.6s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

/* Rotating brand ring: purple -> blue -> Otto teal. */
.pca-launcher::before {
    content: "";
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, #7c5cff, #6aa8ff, #00d4c0, #7c5cff);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
    animation: pca-ring-spin 6s linear infinite;
    z-index: 2;
    pointer-events: none;
}
@keyframes pca-ring-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .pca-launcher, .pca-launcher::before, .pca-launcher-halo { animation: none; }
}

/* -- Otto comes alive (widget.js bringOttoToLife) -- */
/* He leans toward the cursor (--pca-rx/--pca-ry) and glows with proximity (--pca-near). */
.pca-otto {
    position: relative;
    z-index: 1;
    border-radius: 50%;
    transform: perspective(320px) rotateX(var(--pca-rx, 0deg)) rotateY(var(--pca-ry, 0deg)) rotate(var(--pca-rz, 0deg));
    filter: drop-shadow(0 0 calc(var(--pca-near, 0) * 22px) rgba(0, 212, 192, .85));
    transition: transform .25s ease-out, filter .25s ease-out;
}

/* Visor scan: a light sweeps across Otto when he wakes. */
.pca-scan {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    overflow: hidden;
    pointer-events: none;
    z-index: 2;
}
.pca-scan::after {
    content: "";
    position: absolute;
    top: -10%; bottom: -10%;
    left: -60%;
    width: 45%;
    background: linear-gradient(90deg, transparent, rgba(0, 212, 192, .0) 10%, rgba(0, 212, 192, .55) 50%, rgba(160, 139, 255, .0) 90%, transparent);
    transform: skewX(-18deg);
    opacity: 0;
}
.pca-awake .pca-scan::after { animation: pca-scan 1.1s cubic-bezier(.5, 0, .3, 1) .05s 1 both; }
@keyframes pca-scan {
    0%   { left: -60%; opacity: 0; }
    15%  { opacity: 1; }
    85%  { opacity: 1; }
    100% { left: 120%; opacity: 0; }
}

/* Curious head tilt on wake. */
.pca-awake .pca-otto { --pca-rz: -7deg; transition: transform .45s cubic-bezier(.34, 1.56, .64, 1), filter .25s ease-out; }

/* Ring revs up and brightens. */
.pca-awake::before { animation-duration: 1.4s; filter: brightness(1.35) drop-shadow(0 0 6px rgba(124, 92, 255, .9)); }

/* Three energy dots orbit Otto while he is awake. */
.pca-orbit {
    position: absolute;
    inset: -14px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 3;
    opacity: 0;
    transform: scale(.7);
    transition: opacity .3s ease, transform .45s cubic-bezier(.34, 1.56, .64, 1);
}
.pca-awake .pca-orbit { opacity: 1; transform: scale(1); animation: pca-ring-spin 2.4s linear infinite; }
.pca-orbit i {
    position: absolute;
    top: 50%; left: 50%;
    width: 7px; height: 7px;
    margin: -3.5px 0 0 -3.5px;
    border-radius: 50%;
    background: #00d4c0;
    box-shadow: 0 0 10px #00d4c0, 0 0 18px rgba(0, 212, 192, .6);
}
.pca-orbit i:nth-child(1) { transform: rotate(0deg)   translateX(56px); }
.pca-orbit i:nth-child(2) { transform: rotate(120deg) translateX(56px); background: #7c5cff; box-shadow: 0 0 10px #7c5cff, 0 0 18px rgba(124, 92, 255, .6); }
.pca-orbit i:nth-child(3) { transform: rotate(240deg) translateX(56px); background: #6aa8ff; box-shadow: 0 0 10px #6aa8ff, 0 0 18px rgba(106, 168, 255, .6); }

/* Speech bubble types out to the left of Otto. */
.pca-hello {
    position: absolute;
    right: calc(100% + 18px);
    top: 50%;
    min-width: 0;
    max-width: 240px;
    padding: 10px 14px;
    border-radius: 14px 14px 4px 14px;
    background: rgba(13, 26, 38, .92);
    border: 1px solid rgba(0, 212, 192, .45);
    box-shadow: 0 8px 30px rgba(0, 0, 0, .35), 0 0 18px rgba(0, 212, 192, .18);
    color: #d8eeff;
    font: 600 13px/1.35 'Manrope', 'DM Sans', sans-serif;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translate(10px, -50%) scale(.92);
    transform-origin: right center;
    transition: opacity .25s ease, transform .35s cubic-bezier(.34, 1.56, .64, 1);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}
.pca-hello.pca-hello-on { opacity: 1; transform: translate(0, -50%) scale(1); }
.pca-hello::after {
    content: "|";
    margin-left: 1px;
    color: #00d4c0;
    animation: pca-blink 1s step-end infinite;
}

/* Idle "stir" every 9-16 s (widget.js): a quick tilt, ring rev, dot flash and visor scan, no bubble. */
.pca-stir .pca-otto { animation: pca-stir-tilt 1.5s cubic-bezier(.34, 1.56, .64, 1) 1; }
@keyframes pca-stir-tilt {
    0%, 100% { transform: perspective(320px) rotateX(var(--pca-rx, 0deg)) rotateY(var(--pca-ry, 0deg)) rotate(0deg); }
    25%      { transform: perspective(320px) rotateX(var(--pca-rx, 0deg)) rotateY(var(--pca-ry, 0deg)) rotate(-9deg); }
    55%      { transform: perspective(320px) rotateX(var(--pca-rx, 0deg)) rotateY(var(--pca-ry, 0deg)) rotate(5deg); }
}
.pca-stir::before { animation-duration: 1.4s; filter: brightness(1.35) drop-shadow(0 0 6px rgba(124, 92, 255, .9)); }
.pca-stir .pca-orbit { opacity: 1; transform: scale(1); transition: none; animation: pca-ring-spin 1.6s linear infinite; }
.pca-stir .pca-scan::after { animation: pca-scan 1.1s cubic-bezier(.5, 0, .3, 1) .15s 1 both; }

/* Click: a teal shockwave ripples out as the chat opens. */
.pca-ripple {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid #00d4c0;
    opacity: 0;
    pointer-events: none;
    z-index: 0;
}
.pca-rippling .pca-ripple { animation: pca-ripple .7s ease-out 1; }
@keyframes pca-ripple {
    0%   { opacity: .9; transform: scale(1); }
    100% { opacity: 0;  transform: scale(2.4); }
}

@media (prefers-reduced-motion: reduce) {
    .pca-otto, .pca-orbit, .pca-hello { transition: none; }
    .pca-awake .pca-orbit, .pca-awake .pca-scan::after, .pca-rippling .pca-ripple { animation: none; }
}

.pca-launcher img {
    width: 84px; height: 84px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    position: relative;
    z-index: 1;
}

.pca-launcher-badge {
    position: absolute;
    top: -6px; right: -6px;
    z-index: 3;
    background: var(--pca-purple);
    color: #fff;
    font-family: 'Syne', sans-serif;
    font-size: 8px; font-weight: 700;
    padding: 2px 5px;
    border-radius: 5px;
    letter-spacing: 1px;
    box-shadow: 0 2px 8px rgba(91,63,255,0.5);
}

/* -- Responsive -- */
@media (max-width: 480px) {
    #pca-root.pca-floating {
        bottom: 80px;
        right: 24px;
        left: 10px;
        align-items: stretch;
    }
    #pca-panel {
        width: 100%;
        height: 72vh;
        max-height: 520px;
        border-radius: 18px;
    }
    .pca-launcher {
        align-self: flex-end;
        width: 68px; height: 68px;
    }
    .pca-launcher img { width: 68px; height: 68px; }
}

/* Phones: tighter orbit so the dots stay on screen. */
@media (max-width: 480px) {
    .pca-orbit { inset: -10px; }
    .pca-orbit i:nth-child(1) { transform: rotate(0deg)   translateX(46px); }
    .pca-orbit i:nth-child(2) { transform: rotate(120deg) translateX(46px); }
    .pca-orbit i:nth-child(3) { transform: rotate(240deg) translateX(46px); }
}
