/* =========================================================================
   app-extra.css — enhancements layered on top of app-tool.css
   Reuses the .apptool design tokens (--tr-*). No backend / token changes.
   Scoped under .apptool to avoid leaking into the rest of the site.
   ========================================================================= */

/* ---- Sidebar brand mark: subtle living glow ---- */
.apptool__title::before {
    animation: apptool-pulse 2.8s var(--tr-ease) infinite;
}

@keyframes apptool-pulse {
    0%, 100% { box-shadow: 0 0 8px 1px var(--tr-brand-soft); opacity: 1; }
    50%      { box-shadow: 0 0 14px 3px var(--tr-brand-soft); opacity: 0.78; }
}

/* ---- Toolbar: model hint line under the select ---- */
.apptool__field-hint {
    margin: 4px 0 0;
    font-size: 11px;
    line-height: 1.4;
    color: var(--tr-text-3);
    max-width: 260px;
}

/* ---- Stream: gentle top/bottom fade so messages feel anchored ---- */
.apptool__stream {
    position: relative;
    scroll-padding-bottom: 12px;
}

/* ---- Empty state: richer layout + suggestion chips ---- */
.apptool__empty-ico {
    display: inline-grid;
    place-items: center;
    width: 64px;
    height: 64px;
    margin: 0 auto 14px;
    border-radius: var(--tr-r-full);
    background: var(--tr-brand-soft);
    border: 1px solid rgba(50, 240, 140, 0.25);
    font-size: 1.9rem;
    animation: apptool-fade 0.4s var(--tr-ease);
}

.apptool__suggest {
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}

.apptool__suggest-head {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: var(--tr-text-3);
    margin: 0 0 2px;
    text-align: center;
}

.apptool__suggest-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--tr-border-1);
    border-radius: var(--tr-r-8);
    background: var(--tr-ovl-1);
    color: var(--tr-text);
    font-family: var(--tr-font);
    font-size: 13px;
    line-height: 1.4;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.16s var(--tr-ease), background 0.16s var(--tr-ease), transform 0.1s var(--tr-ease);
}

.apptool__suggest-btn::before {
    content: "\2192";
    color: var(--tr-brand);
    font-weight: 600;
}

.apptool__suggest-btn:hover {
    border-color: rgba(50, 240, 140, 0.35);
    background: var(--tr-brand-soft);
}

.apptool__suggest-btn:active {
    transform: scale(0.99);
}

/* ---- Messages: slightly stronger depth + hover affordance on tools ---- */
.apptool__msg-bubble {
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
}

.apptool__msg--assistant .apptool__msg-bubble {
    border-top-left-radius: var(--tr-r-4);
}

.apptool__msg--user {
    flex-direction: row-reverse;
}

.apptool__msg--user .apptool__msg-bubble {
    border-top-right-radius: var(--tr-r-4);
}

.apptool__msg--user > div:not(.apptool__msg-avatar) {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.apptool__msg-tools {
    opacity: 0;
    transition: opacity 0.16s var(--tr-ease);
}

.apptool__msg:hover .apptool__msg-tools,
.apptool__msg:focus-within .apptool__msg-tools {
    opacity: 1;
}

@media (hover: none) {
    .apptool__msg-tools { opacity: 1; }
}

.apptool__copy {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid transparent;
    border-radius: var(--tr-r-full);
    padding: 3px 9px;
}

.apptool__copy:hover {
    border-color: var(--tr-border-2);
    background: var(--tr-ovl-2);
}

/* ---- Streaming: animated three-dot indicator while waiting ---- */
.apptool__typing {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 0;
}

.apptool__typing span {
    width: 6px;
    height: 6px;
    border-radius: var(--tr-r-full);
    background: var(--tr-text-3);
    animation: apptool-typing 1.2s var(--tr-ease) infinite;
}

.apptool__typing span:nth-child(2) { animation-delay: 0.18s; }
.apptool__typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes apptool-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

/* ---- Composer: counter + clear button + keyboard hint ---- */
.apptool__composer {
    flex-wrap: wrap;
}

.apptool__composer-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    margin: 4px 2px 0;
    order: 5;
}

.apptool__enter-hint {
    font-size: 11px;
    color: var(--tr-text-3);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.apptool__enter-hint kbd {
    font-family: var(--tr-mono);
    font-size: 10px;
    padding: 1px 5px;
    border: 1px solid var(--tr-border-2);
    border-radius: var(--tr-r-4);
    background: var(--tr-ovl-2);
    color: var(--tr-text-2);
}

.apptool__counter {
    font-size: 11px;
    font-family: var(--tr-mono);
    color: var(--tr-text-3);
    white-space: nowrap;
    transition: color 0.16s var(--tr-ease);
}

.apptool__counter.is-near {
    color: var(--tr-warning, #e0b450);
}

.apptool__counter.is-max {
    color: var(--tr-error);
}

/* ---- Send button: glow ring while idle, calmer focus ring ---- */
.apptool__send:focus-visible,
.apptool__attach:focus-visible,
.apptool__select:focus-visible,
.apptool__newchat:focus-visible,
.apptool__suggest-btn:focus-visible,
.apptool__chip:focus-visible {
    outline: 2px solid var(--tr-brand);
    outline-offset: 2px;
}

.apptool__send.is-stop {
    animation: apptool-stop-pulse 1.4s var(--tr-ease) infinite;
}

@keyframes apptool-stop-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(246, 90, 90, 0.45); }
    50%      { box-shadow: 0 0 0 5px rgba(246, 90, 90, 0); }
}

/* ---- Image view: prompt tip + nicer presets row ---- */
.apptool__img-tip {
    margin: 0 18px 4px;
    font-size: 11px;
    color: var(--tr-text-3);
    display: flex;
    align-items: center;
    gap: 6px;
}

.apptool__img-tip::before {
    content: "\1F4A1";
    filter: grayscale(0.2);
}

.apptool__imgcard {
    box-shadow: 0 8px 24px -12px rgba(0, 0, 0, 0.6);
}

.apptool__imgcard img {
    transition: transform 0.4s var(--tr-ease);
}

.apptool__imgcard:hover img {
    transform: scale(1.015);
}

/* Loading skeleton shimmer for the image area */
.apptool__spinner {
    position: relative;
}

.apptool__spinner::after {
    content: attr(data-label);
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 12px;
    color: var(--tr-text-2);
}

/* ---- Scroll-to-bottom floating button ---- */
.apptool__scrolldown {
    position: absolute;
    right: 18px;
    bottom: 14px;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 1px solid var(--tr-border-2);
    border-radius: var(--tr-r-full);
    background: var(--tr-bg-3);
    color: var(--tr-text);
    cursor: pointer;
    box-shadow: 0 6px 18px -8px rgba(0, 0, 0, 0.7);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.18s var(--tr-ease), transform 0.18s var(--tr-ease), visibility 0.18s var(--tr-ease);
    z-index: 3;
}

.apptool__scrolldown.is-shown {
    opacity: 1;
    visibility: visible;
    transform: none;
}

.apptool__scrolldown:hover {
    border-color: var(--tr-brand);
    color: var(--tr-brand);
}

/* The stream wrapper needs relative positioning for the float button */
.apptool__streamwrap {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    .apptool__title::before,
    .apptool__send.is-stop,
    .apptool__typing span,
    .apptool__msg,
    .apptool__imgcard {
        animation: none !important;
    }
    .apptool__imgcard:hover img { transform: none; }
}

/* ---- RWD tweaks layered on the existing breakpoints ---- */
@media (max-width: 860px) {
    .apptool__field-hint { max-width: 100%; }

    .apptool__suggest-btn {
        font-size: 14px;
        min-height: 44px;
    }

    .apptool__enter-hint { display: none; }

    .apptool__composer-meta {
        justify-content: flex-end;
    }

    .apptool__scrolldown {
        right: 14px;
        bottom: 90px;
        width: 42px;
        height: 42px;
    }
}
