/*
 * The chat page of the personal assistant (App\Filament\Pages\AssistantChat).
 *
 * The panel has no compiled Tailwind theme, so the page is styled here with Filament's
 * color variables. Edit this file, then run `php artisan filament:assets` to publish it.
 */

.ac-shell {
    --ac-surface: #fff;
    --ac-surface-muted: var(--gray-50);
    --ac-border: var(--gray-200);
    --ac-text: var(--gray-950);
    --ac-text-muted: var(--gray-500);
    --ac-user-bubble: var(--primary-600);
    --ac-user-text: #fff;
    --ac-assistant-bubble: var(--gray-100);
    --ac-hover: var(--gray-100);

    position: relative;
    display: flex;
    height: calc(100dvh - 8.5rem);
    min-height: 32rem;
    overflow: hidden;
    border: 1px solid var(--ac-border);
    border-radius: 1rem;
    background: var(--ac-surface);
    color: var(--ac-text);
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
}

.dark .ac-shell {
    --ac-surface: var(--gray-900);
    --ac-surface-muted: color-mix(in oklab, var(--gray-950) 60%, var(--gray-900));
    --ac-border: color-mix(in oklab, #fff 10%, transparent);
    --ac-text: #fff;
    --ac-text-muted: var(--gray-400);
    --ac-user-bubble: var(--primary-500);
    --ac-assistant-bubble: color-mix(in oklab, #fff 6%, transparent);
    --ac-hover: color-mix(in oklab, #fff 6%, transparent);
}

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

.ac-icon {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

.ac-muted {
    color: var(--ac-text-muted);
}

.ac-mono {
    font-variant-numeric: tabular-nums;
    direction: ltr;
}

/* Sidebar */

.ac-sidebar {
    display: flex;
    flex-direction: column;
    width: 17rem;
    flex-shrink: 0;
    border-inline-end: 1px solid var(--ac-border);
    background: var(--ac-surface-muted);
}

.ac-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 1rem 1rem 0.75rem;
}

.ac-sidebar-title {
    font-weight: 600;
}

.ac-new-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    background: var(--primary-600);
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: background 0.15s;
}

.ac-new-btn:hover {
    background: var(--primary-500);
}

.ac-new-btn .ac-icon {
    width: 1rem;
    height: 1rem;
}

.ac-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 1rem 0.5rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--ac-border);
    border-radius: 0.5rem;
    background: var(--ac-surface);
}

.ac-search input {
    width: 100%;
    border: 0;
    padding: 0;
    background: transparent;
    font-size: 0.875rem;
    outline: none;
    box-shadow: none;
}

.ac-search .ac-icon {
    width: 1rem;
    height: 1rem;
}

.ac-conversations {
    flex: 1;
    overflow-y: auto;
    padding: 0 0.5rem 1rem;
}

.ac-group-label {
    padding: 0.75rem 0.5rem 0.25rem;
    color: var(--ac-text-muted);
    font-size: 0.75rem;
    font-weight: 500;
}

.ac-conversation {
    display: flex;
    align-items: center;
    border-radius: 0.5rem;
    transition: background 0.15s;
}

.ac-conversation:hover {
    background: var(--ac-hover);
}

.ac-conversation.is-active {
    background: color-mix(in oklab, var(--primary-500) 14%, transparent);
    color: var(--primary-700);
}

.dark .ac-conversation.is-active {
    color: var(--primary-300);
}

.ac-conversation-link {
    display: flex;
    flex: 1;
    min-width: 0;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    font-size: 0.875rem;
    text-align: start;
}

.ac-conversation-link .ac-icon {
    width: 1rem;
    height: 1rem;
}

.ac-conversation-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ac-conversation-actions {
    opacity: 0;
    padding-inline-end: 0.25rem;
    transition: opacity 0.15s;
}

.ac-conversation:hover .ac-conversation-actions,
.ac-conversation.is-active .ac-conversation-actions {
    opacity: 1;
}

.ac-empty-list {
    padding: 2rem 1rem;
    color: var(--ac-text-muted);
    font-size: 0.875rem;
    text-align: center;
}

.ac-backdrop,
.ac-sidebar-toggle {
    display: none;
}

/* Main area */

.ac-main {
    position: relative;
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
}

.ac-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--ac-border);
}

.ac-header-text {
    flex: 1;
    min-width: 0;
}

.ac-header-title {
    overflow: hidden;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ac-header-status {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--ac-text-muted);
    font-size: 0.75rem;
}

.ac-status-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 9999px;
    background: var(--success-500, #22c55e);
}

.ac-status-dot.is-busy {
    background: var(--warning-500, #f59e0b);
    animation: ac-pulse 1s ease-in-out infinite;
}

.ac-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.5rem;
    color: var(--ac-text-muted);
    transition: background 0.15s, color 0.15s;
}

.ac-icon-btn:hover {
    background: var(--ac-hover);
    color: var(--ac-text);
}

.ac-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    flex-shrink: 0;
    border-radius: 9999px;
}

.ac-avatar-assistant {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    color: #fff;
    box-shadow: 0 4px 12px color-mix(in oklab, var(--primary-500) 35%, transparent);
}

.ac-avatar-sm {
    width: 2rem;
    height: 2rem;
}

.ac-avatar-sm .ac-icon {
    width: 1rem;
    height: 1rem;
}

/* Messages */

.ac-messages {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-behavior: auto;
}

.ac-messages-inner {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    max-width: 52rem;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

.ac-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 0 1rem;
    text-align: center;
}

.ac-welcome-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 4rem;
    height: 4rem;
    border-radius: 1.25rem;
    background: linear-gradient(135deg, var(--primary-400), var(--primary-700));
    color: #fff;
    box-shadow: 0 10px 30px color-mix(in oklab, var(--primary-500) 35%, transparent);
    animation: ac-float 4s ease-in-out infinite;
}

.ac-welcome-icon .ac-icon {
    width: 2rem;
    height: 2rem;
}

.ac-welcome-title {
    margin-top: 1.25rem;
    font-size: 1.5rem;
    font-weight: 700;
}

.ac-welcome-text {
    max-width: 32rem;
    margin-top: 0.5rem;
    color: var(--ac-text-muted);
    line-height: 1.8;
}

.ac-suggestions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: 0.625rem;
    width: 100%;
    margin-top: 2rem;
}

.ac-suggestion {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--ac-border);
    border-radius: 0.75rem;
    background: var(--ac-surface);
    font-size: 0.875rem;
    text-align: start;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.ac-suggestion:hover {
    border-color: var(--primary-400);
    box-shadow: 0 4px 14px color-mix(in oklab, var(--primary-500) 15%, transparent);
    transform: translateY(-1px);
}

.ac-suggestion-icon {
    font-size: 1.125rem;
}

.ac-message {
    display: flex;
    align-items: flex-end;
    gap: 0.625rem;
    animation: ac-appear 0.25s ease-out;
}

.ac-message.is-user {
    flex-direction: row-reverse;
}

.ac-bubble-wrap {
    display: flex;
    min-width: 0;
    max-width: min(42rem, 85%);
    flex-direction: column;
    gap: 0.25rem;
}

.ac-message.is-user .ac-bubble-wrap {
    align-items: flex-end;
}

.ac-bubble {
    padding: 0.625rem 0.875rem;
    border-radius: 1.125rem;
    line-height: 1.75;
    overflow-wrap: anywhere;
}

.ac-message.is-user .ac-bubble {
    border-end-end-radius: 0.375rem;
    background: var(--ac-user-bubble);
    color: var(--ac-user-text);
}

.ac-message.is-assistant .ac-bubble {
    border-end-start-radius: 0.375rem;
    background: var(--ac-assistant-bubble);
}

.ac-message.is-pending .ac-bubble {
    opacity: 0.75;
}

.ac-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.ac-tool {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    background: color-mix(in oklab, var(--info-500, #0ea5e9) 12%, transparent);
    color: var(--info-700, #0369a1);
    font-size: 0.6875rem;
}

.dark .ac-tool {
    color: var(--info-300, #7dd3fc);
}

.ac-tool .ac-icon {
    width: 0.75rem;
    height: 0.75rem;
}

.ac-meta {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding-inline: 0.25rem;
    color: var(--ac-text-muted);
    font-size: 0.6875rem;
}

.ac-meta-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 0.375rem;
    transition: background 0.15s, color 0.15s;
}

.ac-meta-btn:hover,
.ac-meta-btn.is-active {
    background: var(--ac-hover);
    color: var(--primary-600);
}

.ac-meta-btn .ac-icon {
    width: 0.9375rem;
    height: 0.9375rem;
}

.ac-voice-note,
.ac-voice-pending {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.375rem;
}

.ac-voice-note audio {
    height: 2.25rem;
    max-width: 16rem;
}

.ac-voice-note .ac-icon,
.ac-voice-pending .ac-icon {
    width: 1rem;
    height: 1rem;
}

.ac-voice-pending {
    margin-bottom: 0;
}

/* Files */

.ac-files {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.625rem;
}

.ac-image {
    overflow: hidden;
    border-radius: 0.75rem;
    background: var(--ac-surface);
}

.ac-image img {
    display: block;
    width: 100%;
    max-width: 24rem;
    height: auto;
}

.ac-image figcaption {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
}

.ac-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--primary-600);
}

.ac-link .ac-icon {
    width: 0.875rem;
    height: 0.875rem;
}

.ac-file {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--ac-border);
    border-radius: 0.75rem;
    background: var(--ac-surface);
    transition: border-color 0.15s;
}

.ac-file:hover {
    border-color: var(--primary-400);
}

.ac-file-icon {
    display: inline-flex;
    padding: 0.5rem;
    border-radius: 0.5rem;
    background: color-mix(in oklab, var(--danger-500, #ef4444) 12%, transparent);
    color: var(--danger-600, #dc2626);
}

.ac-file-text {
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
}

.ac-file-name {
    overflow: hidden;
    font-size: 0.875rem;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ac-file-caption {
    color: var(--ac-text-muted);
    font-size: 0.75rem;
}

/* Markdown of the replies */

.ac-prose > :first-child {
    margin-top: 0;
}

.ac-prose > :last-child {
    margin-bottom: 0;
}

.ac-prose p,
.ac-prose ul,
.ac-prose ol,
.ac-prose table,
.ac-prose pre,
.ac-prose blockquote {
    margin: 0.5rem 0;
}

.ac-prose h1,
.ac-prose h2,
.ac-prose h3,
.ac-prose h4 {
    margin: 0.875rem 0 0.375rem;
    font-weight: 700;
}

.ac-prose h1 {
    font-size: 1.25rem;
}

.ac-prose h2 {
    font-size: 1.125rem;
}

.ac-prose h3,
.ac-prose h4 {
    font-size: 1rem;
}

.ac-prose ul {
    padding-inline-start: 1.25rem;
    list-style: disc;
}

.ac-prose ol {
    padding-inline-start: 1.25rem;
    list-style: decimal;
}

.ac-prose li + li {
    margin-top: 0.125rem;
}

.ac-prose strong {
    font-weight: 700;
}

.ac-prose a {
    color: var(--primary-600);
    text-decoration: underline;
}

.ac-prose code {
    padding: 0.1rem 0.3rem;
    border-radius: 0.25rem;
    background: var(--ac-hover);
    font-size: 0.85em;
}

.ac-prose pre {
    overflow-x: auto;
    padding: 0.75rem;
    border-radius: 0.5rem;
    background: var(--gray-950);
    color: var(--gray-100);
    direction: ltr;
}

.ac-prose pre code {
    padding: 0;
    background: none;
}

.ac-prose blockquote {
    padding-inline-start: 0.75rem;
    border-inline-start: 3px solid var(--primary-400);
    color: var(--ac-text-muted);
}

.ac-prose table {
    display: block;
    overflow-x: auto;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.ac-prose th,
.ac-prose td {
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--ac-border);
    text-align: start;
    white-space: nowrap;
}

.ac-prose th {
    background: var(--ac-hover);
    font-weight: 600;
}

/* Typing indicator */

.ac-typing {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.ac-typing > span:not(.ac-typing-label) {
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 9999px;
    background: var(--ac-text-muted);
    animation: ac-bounce 1.2s ease-in-out infinite;
}

.ac-typing > span:nth-child(2) {
    animation-delay: 0.15s;
}

.ac-typing > span:nth-child(3) {
    animation-delay: 0.3s;
}

.ac-typing-label {
    margin-inline-start: 0.375rem;
    color: var(--ac-text-muted);
    font-size: 0.8125rem;
}

.ac-scroll-down {
    position: absolute;
    bottom: 7.5rem;
    left: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid var(--ac-border);
    border-radius: 9999px;
    background: var(--ac-surface);
    box-shadow: 0 4px 12px rgb(0 0 0 / 0.1);
    translate: -50% 0;
}

.ac-scroll-down .ac-icon {
    width: 1rem;
    height: 1rem;
}

/* Composer */

.ac-composer {
    padding: 0.75rem 1rem 0.625rem;
    border-top: 1px solid var(--ac-border);
}

.ac-composer-box {
    max-width: 52rem;
    margin: 0 auto;
    padding: 0.375rem;
    border: 1px solid var(--ac-border);
    border-radius: 1.5rem;
    background: var(--ac-surface-muted);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.ac-composer-box:focus-within {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--primary-500) 18%, transparent);
}

.ac-composer-box.is-recording {
    border-color: var(--danger-400, #f87171);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--danger-500, #ef4444) 15%, transparent);
}

.ac-composer-row {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

.ac-composer-row textarea {
    flex: 1;
    max-height: 200px;
    padding: 0.5rem 0.75rem;
    border: 0;
    background: transparent;
    line-height: 1.6;
    resize: none;
    outline: none;
    box-shadow: none;
}

.ac-composer-row textarea:focus {
    box-shadow: none;
}

.ac-round-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    flex-shrink: 0;
    border-radius: 9999px;
    transition: background 0.15s, transform 0.15s, opacity 0.15s;
}

.ac-round-btn:active {
    transform: scale(0.94);
}

.ac-round-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.ac-mic-btn {
    color: var(--ac-text-muted);
}

.ac-mic-btn:hover:not(:disabled) {
    background: var(--ac-hover);
    color: var(--primary-600);
}

.ac-send-btn {
    background: var(--primary-600);
    color: #fff;
}

.ac-send-btn:hover:not(:disabled) {
    background: var(--primary-500);
}

.ac-cancel-btn {
    color: var(--danger-600, #dc2626);
}

.ac-cancel-btn:hover {
    background: color-mix(in oklab, var(--danger-500, #ef4444) 12%, transparent);
}

/* The paper plane points to the reading direction. */
[dir='rtl'] .ac-flip {
    transform: scaleX(-1);
}

.ac-recorder {
    align-items: center;
}

.ac-rec-dot {
    width: 0.625rem;
    height: 0.625rem;
    flex-shrink: 0;
    border-radius: 9999px;
    background: var(--danger-500, #ef4444);
    animation: ac-pulse 1s ease-in-out infinite;
}

.ac-rec-time {
    min-width: 2.75rem;
    font-weight: 500;
}

.ac-wave {
    display: flex;
    flex: 1;
    height: 2rem;
    min-width: 0;
    align-items: center;
    justify-content: center;
    gap: 3px;
    overflow: hidden;
    direction: ltr;
}

.ac-wave span {
    width: 3px;
    flex-shrink: 0;
    border-radius: 9999px;
    background: var(--primary-500);
    transition: height 0.08s linear;
}

.ac-hint {
    margin-top: 0.375rem;
    color: var(--ac-text-muted);
    font-size: 0.6875rem;
    text-align: center;
}

/* Small screens: the conversations slide in over the chat. */

@media (max-width: 64rem) {
    .ac-shell {
        height: calc(100dvh - 7rem);
    }

    .ac-sidebar {
        position: absolute;
        inset-block: 0;
        inset-inline-start: 0;
        z-index: 20;
        width: min(19rem, 85%);
        box-shadow: 0 10px 40px rgb(0 0 0 / 0.2);
        transform: translateX(100%);
        transition: transform 0.25s ease;
    }

    [dir='ltr'] .ac-sidebar {
        transform: translateX(-100%);
    }

    .ac-sidebar.is-open,
    [dir='ltr'] .ac-sidebar.is-open {
        transform: none;
    }

    .ac-backdrop {
        position: absolute;
        inset: 0;
        z-index: 10;
        display: block;
        background: rgb(0 0 0 / 0.35);
    }

    .ac-sidebar-toggle {
        display: inline-flex;
    }

    .ac-conversation-actions {
        opacity: 1;
    }

    .ac-bubble-wrap {
        max-width: 88%;
    }
}

@keyframes ac-bounce {
    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.5;
    }

    30% {
        transform: translateY(-0.3rem);
        opacity: 1;
    }
}

@keyframes ac-pulse {
    50% {
        opacity: 0.35;
    }
}

@keyframes ac-appear {
    from {
        opacity: 0;
        transform: translateY(0.375rem);
    }
}

@keyframes ac-float {
    50% {
        transform: translateY(-0.375rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    .ac-shell *,
    .ac-shell *::before,
    .ac-shell *::after {
        animation: none !important;
        transition: none !important;
    }
}

/*
 * The reply while it is streamed: the typing dots give way to the text once it starts,
 * a cursor follows the text, and the tool being used shows below it.
 */

.ac-stream-reply:empty,
.ac-stream-status:empty {
    display: none;
}

.ac-bubble:has(.ac-stream-reply:not(:empty)) .ac-typing {
    display: none;
}

.ac-stream-reply > :last-child::after {
    content: '';
    display: inline-block;
    width: 0.5rem;
    height: 1em;
    margin-inline-start: 0.125rem;
    vertical-align: -0.15em;
    border-radius: 1px;
    background: currentColor;
    opacity: 0.6;
    animation: ac-pulse 0.9s steps(2, start) infinite;
}

.ac-stream-status {
    margin-top: 0.375rem;
    color: var(--ac-text-muted);
    font-size: 0.8125rem;
    animation: ac-pulse 1.4s ease-in-out infinite;
}

.ac-stream-reply:not(:empty) + .ac-typing + .ac-stream-status {
    padding-top: 0.375rem;
    border-top: 1px dashed var(--ac-border);
}

/* Choosing the microphone */

.ac-mic-picker {
    position: relative;
    align-self: center;
    margin-inline-start: -0.5rem;
}

.ac-mic-picker-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 2.5rem;
    border-radius: 0.375rem;
    color: var(--ac-text-muted);
}

.ac-mic-picker-btn:hover:not(:disabled) {
    background: var(--ac-hover);
    color: var(--ac-text);
}

.ac-mic-picker-btn .ac-icon {
    width: 0.875rem;
    height: 0.875rem;
}

.ac-mic-menu {
    position: absolute;
    bottom: calc(100% + 0.5rem);
    inset-inline-end: 0;
    z-index: 30;
    width: 18rem;
    max-height: 16rem;
    overflow-y: auto;
    padding: 0.375rem;
    border: 1px solid var(--ac-border);
    border-radius: 0.75rem;
    background: var(--ac-surface);
    box-shadow: 0 10px 30px rgb(0 0 0 / 0.15);
}

.ac-mic-menu-title {
    padding: 0.375rem 0.5rem;
    color: var(--ac-text-muted);
    font-size: 0.75rem;
    font-weight: 500;
}

.ac-mic-option {
    display: block;
    width: 100%;
    padding: 0.5rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    text-align: start;
    overflow-wrap: anywhere;
}

.ac-mic-option:hover {
    background: var(--ac-hover);
}

.ac-mic-option.is-active {
    background: color-mix(in oklab, var(--primary-500) 14%, transparent);
    color: var(--primary-700);
    font-weight: 500;
}

.dark .ac-mic-option.is-active {
    color: var(--primary-300);
}

.ac-rec-mic {
    max-width: 9rem;
    overflow: hidden;
    color: var(--ac-text-muted);
    font-size: 0.75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}
