/* ─────────────────────────────────────────────────────────────────
   PRESTON — floating chat helper styles
   ─────────────────────────────────────────────────────────────────
   Companion stylesheet for /plugins/astro.js. Inject in <head>:
       <link rel="stylesheet" href="/plugins/astro.css">

   CSS class names use the .astro- prefix for backward compatibility.
   The visible name shown to users is "Preston" (set in the JS).
   ───────────────────────────────────────────────────────────── */

.astro {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9000;
    pointer-events: none;
    opacity: 0;
    transform: translateY(20px) scale(0.85);
    transition:
        opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.6s cubic-bezier(0.16, 1, 0.3, 1),
        right 1.6s cubic-bezier(0.4, 0, 0.2, 1),
        bottom 1.6s cubic-bezier(0.4, 0, 0.2, 1),
        left 1.6s cubic-bezier(0.4, 0, 0.2, 1),
        top 1.6s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
}

.astro.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.astro.hidden {
    opacity: 0;
    transform: translateY(20px) scale(0.85);
    pointer-events: none;
}

/* ── Robot ── */

.astro-robot {
    width: 92px;
    height: 92px;
    cursor: pointer;
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    animation: astro-float 3.4s ease-in-out infinite;
    filter: drop-shadow(0 8px 18px rgba(30, 69, 102, 0.18));
    outline: none;
}

.astro-robot:hover {
    transform: translateY(-4px) scale(1.06);
}

.astro-robot:focus-visible {
    outline: 3px solid rgba(124, 196, 240, 0.7);
    outline-offset: 6px;
    border-radius: 50%;
}

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

.astro-eye {
    animation: astro-blink 4s infinite;
}

@keyframes astro-blink {
    0%, 92%, 100% { transform: scaleY(1); }
    96%           { transform: scaleY(0.1); }
}

.astro-visor-shine {
    animation: astro-shine 5s ease-in-out infinite;
}

@keyframes astro-shine {
    0%, 100%      { opacity: 0.35; }
    50%           { opacity: 0.55; }
}

/* ── Speech bubble (idle attention prompt) ── */

.astro-bubble {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 12px;
    background: #FFFFFF;
    color: #1e4566;
    padding: 10px 16px;
    border-radius: 18px 18px 4px 18px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 6px 18px rgba(30, 69, 102, 0.15);
    opacity: 0;
    transform: translateY(8px) scale(0.9);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
}

.astro-bubble.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.astro-bubble::after {
    content: '';
    position: absolute;
    bottom: -5px;
    right: 18px;
    width: 12px;
    height: 12px;
    background: #FFFFFF;
    transform: rotate(45deg);
    box-shadow: 2px 2px 4px rgba(30, 69, 102, 0.05);
}

.astro.left-side .astro-bubble {
    right: auto;
    left: 0;
    border-radius: 18px 18px 18px 4px;
}

.astro.left-side .astro-bubble::after {
    right: auto;
    left: 18px;
}

/* ── Chat panel ── */

.astro-panel {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 18px;
    width: 360px;
    max-width: calc(100vw - 56px);
    height: 480px;
    max-height: calc(100vh - 140px);
    background: #FFFFFF;
    border-radius: 20px;
    box-shadow: 0 16px 48px rgba(30, 69, 102, 0.22), 0 4px 12px rgba(30, 69, 102, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px) scale(0.96);
    pointer-events: none;
    transition:
        opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.astro-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.astro.left-side .astro-panel {
    right: auto;
    left: 0;
}

.astro-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: #1e4566;
    color: #FFFFFF;
    flex-shrink: 0;
}

.astro-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: -0.01em;
}

.astro-panel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #5DD39E;
    box-shadow: 0 0 0 3px rgba(93, 211, 158, 0.25);
    animation: astro-pulse 2.4s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes astro-pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(93, 211, 158, 0.25); }
    50%      { box-shadow: 0 0 0 5px rgba(93, 211, 158, 0.10); }
}

.astro-panel-tag {
    font-size: 11px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.65);
    margin-left: 4px;
    letter-spacing: 0;
}

.astro-panel-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.astro-panel-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #FFFFFF;
}

.astro-panel-close:focus-visible {
    outline: 2px solid rgba(124, 196, 240, 0.7);
    outline-offset: 1px;
}

/* ── Messages area ── */

.astro-panel-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #F7F8FB;
    scroll-behavior: smooth;
}

.astro-panel-messages::-webkit-scrollbar {
    width: 6px;
}

.astro-panel-messages::-webkit-scrollbar-thumb {
    background: rgba(30, 69, 102, 0.15);
    border-radius: 3px;
}

.astro-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: astro-msg-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.astro-msg-astro {
    align-self: flex-start;
    background: #FFFFFF;
    color: #1e4566;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(30, 69, 102, 0.06);
}

.astro-msg-user {
    align-self: flex-end;
    background: #7CC4F0;
    color: #FFFFFF;
    border-bottom-right-radius: 4px;
}

.astro-msg-streaming {
    min-height: 38px;
    display: flex;
    align-items: center;
}

/* Typing indicator (3 bouncing dots while waiting for the first chunk) */
.astro-typing {
    display: inline-flex;
    gap: 4px;
    padding: 4px 0;
}

.astro-typing span {
    width: 7px;
    height: 7px;
    background: #1e4566;
    opacity: 0.4;
    border-radius: 50%;
    animation: astro-bounce 1.2s infinite;
}

.astro-typing span:nth-child(2) { animation-delay: 0.15s; }
.astro-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes astro-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%           { transform: translateY(-5px); opacity: 0.9; }
}

/* ── Quick reply chips ── */

.astro-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 14px 6px;
    background: #F7F8FB;
    border-top: 1px solid rgba(30, 69, 102, 0.05);
}

.astro-chip {
    background: #FFFFFF;
    color: #1e4566;
    border: 1px solid rgba(30, 69, 102, 0.12);
    padding: 7px 12px;
    font-size: 12.5px;
    font-weight: 500;
    border-radius: 14px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    white-space: nowrap;
}

.astro-chip:hover {
    background: #1e4566;
    color: #FFFFFF;
    border-color: #1e4566;
}

.astro-chip:active {
    transform: scale(0.97);
}

.astro-chip:focus-visible {
    outline: 2px solid rgba(124, 196, 240, 0.7);
    outline-offset: 2px;
}

/* ── Input area ── */

.astro-panel-input {
    display: flex;
    gap: 8px;
    padding: 12px 14px;
    background: #FFFFFF;
    border-top: 1px solid rgba(30, 69, 102, 0.08);
    flex-shrink: 0;
}

.astro-panel-input input {
    flex: 1;
    border: 1px solid rgba(30, 69, 102, 0.18);
    background: #F7F8FB;
    border-radius: 22px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    color: #1e4566;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
}

.astro-panel-input input::placeholder {
    color: rgba(30, 69, 102, 0.45);
}

.astro-panel-input input:focus {
    border-color: #7CC4F0;
    background: #FFFFFF;
    box-shadow: 0 0 0 3px rgba(124, 196, 240, 0.18);
}

.astro-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #1e4566;
    color: #FFFFFF;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    flex-shrink: 0;
}

.astro-send:hover:not(:disabled) {
    background: #2d5d85;
}

.astro-send:active:not(:disabled) {
    transform: scale(0.94);
}

.astro-send:disabled {
    background: rgba(30, 69, 102, 0.25);
    cursor: not-allowed;
}

.astro-send:focus-visible {
    outline: 2px solid rgba(124, 196, 240, 0.7);
    outline-offset: 2px;
}

/* ── Mobile (≤700px) ── */

@media (max-width: 700px) {
    .astro {
        bottom: 18px;
        right: 18px;
    }

    .astro-robot {
        width: 76px;
        height: 76px;
    }

    .astro-robot svg {
        width: 76px;
        height: 76px;
    }

    .astro-panel {
        width: calc(100vw - 36px);
        max-width: calc(100vw - 36px);
        height: calc(100vh - 120px);
        max-height: 600px;
        right: 0;
        bottom: 100%;
        margin-bottom: 14px;
    }

    .astro-bubble {
        font-size: 13px;
        padding: 8px 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .astro,
    .astro-robot,
    .astro-bubble,
    .astro-panel,
    .astro-eye,
    .astro-visor-shine,
    .astro-panel-dot,
    .astro-typing span,
    .astro-msg {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
}
