/* kidecon/guide/static/guide/css/guide_panel.css
 *
 * Self-contained styling for the page-aware guide ✨ panel and the sparkle
 * launcher buttons. The panel renders on every authenticated page, so it
 * cannot rely on --ke-card-bg / --ke-input-bg / --ke-muted being defined
 * elsewhere (those live only in onboarding_wizard.css / home.html). Rather
 * than redeclare a global :root (which would clobber those other pages'
 * definitions), the fallbacks are scoped to the panel and sparkle elements
 * themselves, so they apply only where the panel renders. Structural colors
 * come from the reliably-global vars declared in base.html
 * (--ke-dark/--ke-light/--ke-primary/--ke-secondary/--ke-border/--ke-radius),
 * each referenced with an inline fallback. No hardcoded structural palette
 * colors; the terminal aesthetic (--ke-terminal-*) is referenced with
 * fallbacks so the green-on-black console look works wherever defined and
 * degrades gracefully elsewhere.
 */

[x-cloak] { display: none !important; }

/* Scoped fallback palette — applies only to guide elements, never overrides
 * the global --ke-* vars on other pages. */
.guide-sparkle,
.guide-panel {
    --ke-card-bg: var(--ke-card-bg, oklch(0.16 0.01 85));
    --ke-input-bg: var(--ke-input-bg, oklch(0.14 0.01 85));
    --ke-muted: var(--ke-muted, oklch(0.60 0.01 85));
    --ke-success: var(--ke-success, oklch(0.65 0.2 142));
    --ke-danger: var(--ke-danger, oklch(0.55 0.2 25));
    --ke-terminal-bg: var(--ke-terminal-bg, #0d0d0d);
    --ke-terminal-text: var(--ke-terminal-text, #00ff41);
    --ke-terminal-accent: var(--ke-terminal-accent, #98ffb2);
}

/* ---------- Sparkle launcher buttons ---------- */
.guide-sparkle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    border-radius: var(--ke-radius, 0.75rem);
    border: 1px solid var(--ke-border, oklch(0.25 0.01 85));
    background: var(--ke-card-bg);
    color: var(--ke-light);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    line-height: 1;
}
.guide-sparkle:hover {
    border-color: var(--ke-primary, oklch(0.75 0.2 142));
    box-shadow: 0 0 0 0.2rem oklch(0.75 0.2 142 / 0.18);
}
.guide-sparkle:active { transform: scale(0.96); }
.guide-sparkle__icon {
    font-size: 1rem;
    color: var(--ke-primary, oklch(0.75 0.2 142));
    /* gentle twinkle */
    animation: guide-twinkle 1.6s ease-in-out infinite;
    display: inline-block;
}
.guide-sparkle__label { color: var(--ke-light); }

/* Floating (bottom-right) variant for guide_button */
.guide-sparkle--button {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 1040;
    padding: 0.65rem 1rem;
    border-radius: 999px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
.guide-sparkle--button .guide-sparkle__icon { font-size: 1.15rem; }

/* Inline variant for guide_spark — icon-only, tiny footprint next to an
   element. No visible text; the label is a title tooltip only. */
.guide-sparkle--spark {
    padding: 0.1rem 0.3rem;
    background: transparent;
    border: none;
    box-shadow: none;
}
.guide-sparkle--spark:hover {
    border: none;
    box-shadow: none;
    filter: drop-shadow(0 0 4px oklch(0.75 0.2 142 / 0.5));
}
.guide-sparkle--spark .guide-sparkle__icon { font-size: 0.9rem; }

@keyframes guide-twinkle {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.25) rotate(12deg); opacity: 0.65; }
}

/* ---------- Floating panel ---------- */
.guide-panel {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    width: min(92vw, 380px);
    max-height: min(70vh, 520px);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    background: var(--ke-card-bg);
    color: var(--ke-light);
    border: 1px solid var(--ke-border, oklch(0.25 0.01 85));
    border-radius: var(--ke-radius, 0.75rem);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    overflow: hidden;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

.guide-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.85rem;
    background: var(--ke-secondary, oklch(0.18 0.01 85));
    border-bottom: 1px solid var(--ke-border, oklch(0.25 0.01 85));
}
.guide-panel__title {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 700;
    color: var(--ke-light);
}
.guide-panel__spark { color: var(--ke-primary, oklch(0.75 0.2 142)); }
.guide-panel__close {
    background: transparent;
    border: none;
    color: var(--ke-muted);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.25rem;
    border-radius: 4px;
}
.guide-panel__close:hover { color: var(--ke-light); }

.guide-panel__icon {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.78rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    text-decoration: none;
}
.guide-panel__icon:hover { color: rgba(255, 255, 255, 0.85); }
.guide-panel__icon:disabled { opacity: 0.4; cursor: default; }

.guide-panel__body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    scrollbar-width: thin;
}

/* ---------- Messages / bubbles ---------- */
.guide-msg { display: flex; flex-direction: column; gap: 0.35rem; align-items: flex-start; }
.guide-bubble {
    max-width: 88%;
    padding: 0.55rem 0.75rem;
    border-radius: var(--ke-radius, 0.75rem);
    word-break: break-word;
    line-height: 1.4;
    font-size: 0.92rem;
}
/* pre-line on the inner span, NOT the bubble div — otherwise template
 * indentation between <div> and <span> renders as an empty line. */
.guide-bubble span {
    white-space: pre-line;
}
.guide-bubble--user {
    align-self: flex-end;
    background: var(--ke-primary, oklch(0.75 0.2 142));
    color: #000;
    font-weight: 500;
}
/* Bot bubble leans into the terminal aesthetic: green-on-black console. */
.guide-bubble--bot {
    background: var(--ke-input-bg);
    color: var(--ke-light);
    border: 1px solid var(--ke-border, oklch(0.25 0.01 85));
}
.guide-bubble--console {
    background: var(--ke-terminal-bg, #0d0d0d);
    color: var(--ke-terminal-text, #00ff41);
    border: 1px solid oklch(0.75 0.2 142 / 0.35);
    font-family: "Menlo", "Monaco", "Courier New", monospace;
    font-size: 0.86rem;
    text-shadow: 0 0 3px oklch(0.75 0.2 142 / 0.25);
}

/* ---------- Typing indicator ---------- */
.guide-typing { display: inline-flex; gap: 0.25rem; padding: 0.55rem 0.8rem; }
.guide-typing__dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--ke-terminal-text, #00ff41);
    opacity: 0.4;
    animation: guide-blink 1.2s infinite ease-in-out;
}
.guide-typing__dot:nth-child(2) { animation-delay: 0.2s; }
.guide-typing__dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes guide-blink {
    0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-2px); }
}

/* ---------- Route card (the payoff) ---------- */
.guide-route-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 92%;
    margin-top: 0.15rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--ke-radius, 0.75rem);
    background: var(--ke-card-bg);
    border: 1px solid var(--ke-primary, oklch(0.75 0.2 142));
    color: var(--ke-light);
    text-decoration: none;
    transition: transform 0.12s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.guide-route-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px oklch(0.75 0.2 142 / 0.18);
    text-decoration: none;
    color: var(--ke-light);
}
.guide-route-card__icon {
    font-size: 1.15rem;
    color: var(--ke-primary, oklch(0.75 0.2 142));
    flex-shrink: 0;
}
.guide-route-card__text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.guide-route-card__label { font-weight: 700; font-size: 0.9rem; }
.guide-route-card__desc {
    font-size: 0.78rem;
    color: var(--ke-muted, oklch(0.60 0.01 85));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.guide-route-card__arrow {
    color: var(--ke-primary, oklch(0.75 0.2 142));
    font-size: 1.3rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* ---------- Input row ---------- */
.guide-panel__input {
    display: flex;
    gap: 0.4rem;
    padding: 0.6rem;
    border-top: 1px solid var(--ke-border, oklch(0.25 0.01 85));
    background: var(--ke-secondary, oklch(0.18 0.01 85));
}
.guide-panel__text {
    flex: 1;
    min-width: 0;
    padding: 0.5rem 0.7rem;
    border-radius: var(--ke-radius, 0.75rem);
    background: var(--ke-input-bg);
    border: 1px solid var(--ke-border, oklch(0.25 0.01 85));
    color: var(--ke-light);
    font-size: 0.9rem;
}
.guide-panel__text:focus {
    outline: none;
    border-color: var(--ke-primary, oklch(0.75 0.2 142));
    box-shadow: 0 0 0 0.2rem oklch(0.75 0.2 142 / 0.2);
}
.guide-panel__text::placeholder { color: var(--ke-muted, oklch(0.60 0.01 85)); }
.guide-panel__send {
    flex-shrink: 0;
    width: 2.4rem;
    border: none;
    border-radius: var(--ke-radius, 0.75rem);
    background: var(--ke-primary, oklch(0.75 0.2 142));
    color: #000;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: filter 0.15s ease;
}
.guide-panel__send:hover:not(:disabled) { filter: brightness(0.9); }
.guide-panel__send:disabled { opacity: 0.45; cursor: default; }

/* Tiny spinner for the send button while loading */
.guide-spinner {
    width: 1rem; height: 1rem;
    border: 2px solid rgba(0,0,0,0.25);
    border-top-color: #000;
    border-radius: 50%;
    display: inline-block;
    animation: guide-spin 0.7s linear infinite;
}
@keyframes guide-spin { to { transform: rotate(360deg); } }

@media (max-width: 480px) {
    .guide-panel { right: 0.5rem; left: 0.5rem; bottom: 0.5rem; width: auto; }
    .guide-sparkle--button { right: 0.75rem; bottom: 0.75rem; }
}
