/* AI Chat Component Styles - Standalone CSS that doesn't affect Filament theme */

/* Floating Chat Button */
.ai-chat-button {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    background-color: rgb(var(--primary-500));
    color: white;
    border-radius: 9999px;
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.ai-chat-button:hover:not(:disabled) {
    background-color: rgb(var(--primary-600));
    transform: scale(1.05);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

.ai-chat-button:disabled {
    cursor: default;
    transform: scale(1);
}

.ai-chat-button svg {
    width: 1.5rem;
    height: 1.5rem;
}

/* Chat Window */
.ai-chat-window {
    position: fixed;
    bottom: 6rem;
    right: 1.5rem;
    z-index: 99998;
    width: 420px;
    height: 600px;
    max-width: calc(100vw - 3rem);
    max-height: calc(100vh - 8rem);
    background-color: white;
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.dark .ai-chat-window {
    background-color: rgb(30 30 30);
    border-color: rgb(64 64 64);
}

/* Chat Header */
.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background-color: rgb(var(--primary-500));
    color: white;
}

.ai-chat-header-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ai-chat-header-icon {
    width: 2rem;
    height: 2rem;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-header-icon svg {
    width: 1.125rem;
    height: 1.125rem;
}

.ai-chat-header-title {
    font-weight: 700;
    font-size: 1rem;
    margin: 0;
}

.ai-chat-header-subtitle {
    font-size: 0.75rem;
    opacity: 0.8;
    margin: 0;
}

.ai-chat-header-buttons {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.ai-chat-clear-btn {
    padding: 0.5rem;
    background: transparent;
    border: none;
    border-radius: 9999px;
    cursor: pointer;
    color: white;
    transition: background-color 0.2s;
}

.ai-chat-clear-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.ai-chat-clear-btn svg {
    width: 1rem;
    height: 1rem;
}

/* Chat Messages Container */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background-color: rgb(249 250 251);
}

/* Scrollbar styling */
.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background-color: rgba(var(--primary-400), 0.3);
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background-color: rgba(var(--primary-500), 0.5);
}

.dark .ai-chat-messages {
    background-color: rgb(24 24 24);
}

.dark .ai-chat-messages::-webkit-scrollbar-thumb {
    background-color: rgba(var(--primary-400), 0.4);
}

.dark .ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background-color: rgba(var(--primary-500), 0.6);
}

/* Message Bubbles */
.ai-chat-message {
    display: flex;
}

.ai-chat-message-user {
    justify-content: flex-end;
}

.ai-chat-message-assistant {
    justify-content: flex-start;
}

.ai-chat-bubble {
    max-width: 90%;
    padding: 0.5rem 0.75rem;
    border-radius: 0.75rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.ai-chat-bubble-user {
    background-color: rgb(var(--primary-500));
    color: white;
    border-top-right-radius: 0.25rem;
}

.ai-chat-bubble-assistant {
    background-color: white;
    color: rgb(31 41 55);
    border-top-left-radius: 0.25rem;
    border: 1px solid rgb(243 244 246);
}

.dark .ai-chat-bubble-assistant {
    background-color: rgb(45 45 45);
    color: rgb(229 229 229);
    border-color: rgb(64 64 64);
}

.ai-chat-bubble-content {
    font-size: 0.875rem;
    white-space: pre-wrap;
    line-height: 1.4;
}

/* Loading Indicator */
.ai-chat-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-chat-loading-dots {
    display: flex;
    gap: 0.25rem;
}

.ai-chat-loading-dot {
    width: 0.375rem;
    height: 0.375rem;
    background-color: rgb(var(--primary-400));
    border-radius: 9999px;
    animation: ai-chat-bounce 1s infinite;
}

.ai-chat-loading-dot:nth-child(2) {
    animation-delay: 0.1s;
}

.ai-chat-loading-dot:nth-child(3) {
    animation-delay: 0.2s;
}

@keyframes ai-chat-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-0.5rem);
    }
}

.ai-chat-loading-text {
    font-size: 0.75rem;
    color: rgb(107 114 128);
    margin-left: 0.375rem;
}

.dark .ai-chat-loading-text {
    color: rgb(156 163 175);
}

/* Chat Input */
.ai-chat-input-container {
    padding: 0.625rem 0.75rem;
    background-color: white;
    border-top: 1px solid rgb(229 231 235);
}

.dark .ai-chat-input-container {
    background-color: rgb(30 30 30);
    border-top-color: rgb(64 64 64);
}

.ai-chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-chat-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    background-color: rgb(243 244 246);
    border: none;
    border-radius: 0.5rem;
    outline: none;
    transition: box-shadow 0.2s;
}

.ai-chat-input:focus {
    box-shadow: 0 0 0 2px rgba(var(--primary-500), 0.5);
}

.ai-chat-input:disabled {
    opacity: 0.5;
}

.dark .ai-chat-input {
    background-color: rgb(45 45 45);
    color: rgb(229 229 229);
}

.ai-chat-input::placeholder {
    color: rgb(156 163 175);
}

.ai-chat-submit-btn {
    padding: 0.5rem;
    background-color: rgb(var(--primary-500));
    color: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.ai-chat-submit-btn:hover {
    background-color: rgb(var(--primary-600));
}

.ai-chat-submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-chat-submit-btn svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* Markdown Styling for AI responses - Compact version */
.ai-chat-markdown {
    font-size: 0.875rem;
    line-height: 1.4;
}

.ai-chat-markdown p {
    margin: 0 0 0.375rem 0;
}

.ai-chat-markdown p:last-child {
    margin-bottom: 0;
}

.ai-chat-markdown strong {
    font-weight: 600;
    color: rgb(17 24 39);
}

.dark .ai-chat-markdown strong {
    color: rgb(255 255 255);
}

.ai-chat-markdown em {
    font-style: italic;
}

/* Lists with accent bullets - tight spacing */
.ai-chat-markdown ul,
.ai-chat-markdown ol {
    margin: 0.25rem 0;
    padding-left: 1rem;
}

.ai-chat-markdown li {
    margin: 0.125rem 0;
    padding-left: 0;
}

.ai-chat-markdown ul li {
    list-style-type: none;
    position: relative;
}

.ai-chat-markdown ul li::before {
    content: '';
    position: absolute;
    left: -0.75rem;
    top: 0.45rem;
    width: 4px;
    height: 4px;
    background-color: rgb(var(--primary-500));
    border-radius: 50%;
}

.ai-chat-markdown ol li {
    list-style-type: decimal;
}

.ai-chat-markdown ol li::marker {
    color: rgb(var(--primary-500));
    font-weight: 600;
}

/* Headings - compact */
.ai-chat-markdown h1,
.ai-chat-markdown h2,
.ai-chat-markdown h3,
.ai-chat-markdown h4 {
    font-weight: 600;
    margin: 0.375rem 0 0.25rem 0;
    color: rgb(17 24 39);
}

.ai-chat-markdown h1:first-child,
.ai-chat-markdown h2:first-child,
.ai-chat-markdown h3:first-child,
.ai-chat-markdown h4:first-child {
    margin-top: 0;
}

.dark .ai-chat-markdown h1,
.dark .ai-chat-markdown h2,
.dark .ai-chat-markdown h3,
.dark .ai-chat-markdown h4 {
    color: rgb(255 255 255);
}

.ai-chat-markdown h1 { font-size: 0.9375rem; }
.ai-chat-markdown h2 { font-size: 0.875rem; }
.ai-chat-markdown h3 { font-size: 0.8125rem; }
.ai-chat-markdown h4 { font-size: 0.8125rem; }

/* Tables - Compact rounded style */
.ai-chat-markdown table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 0.25rem 0;
    font-size: 0.7rem;
    border-radius: 0.375rem;
    overflow: hidden;
    border: 1px solid rgb(229 231 235);
}

.dark .ai-chat-markdown table {
    border-color: rgb(64 64 64);
}

.ai-chat-markdown th,
.ai-chat-markdown td {
    padding: 0.25rem 0.375rem;
    text-align: left;
    border-bottom: 1px solid rgb(229 231 235);
}

.ai-chat-markdown tr:last-child td {
    border-bottom: none;
}

.dark .ai-chat-markdown th,
.dark .ai-chat-markdown td {
    border-color: rgb(64 64 64);
}

.ai-chat-markdown th {
    background-color: rgba(var(--primary-500), 0.1);
    font-weight: 600;
    color: rgb(var(--primary-700));
}

.dark .ai-chat-markdown th {
    background-color: rgba(var(--primary-500), 0.15);
    color: rgb(var(--primary-300));
}

.ai-chat-markdown tr:nth-child(even) td {
    background-color: rgb(249 250 251);
}

.dark .ai-chat-markdown tr:nth-child(even) td {
    background-color: rgb(50 50 50);
}

/* Inline code with accent */
.ai-chat-markdown code {
    background-color: rgba(var(--primary-500), 0.1);
    color: rgb(var(--primary-700));
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-family: ui-monospace, monospace;
    font-weight: 500;
}

.dark .ai-chat-markdown code {
    background-color: rgba(var(--primary-500), 0.2);
    color: rgb(var(--primary-300));
}

/* Code blocks - Dark compact style */
.ai-chat-markdown pre {
    background-color: rgb(24 24 27);
    color: rgb(228 228 231);
    border-radius: 0.375rem;
    overflow: hidden;
    margin: 0.25rem 0;
    border: 1px solid rgb(39 39 42);
}

.ai-chat-markdown pre code {
    display: block;
    padding: 0.5rem 0.625rem;
    background: none;
    color: inherit;
    font-size: 0.6875rem;
    line-height: 1.4;
    overflow-x: auto;
}

.dark .ai-chat-markdown pre {
    background-color: rgb(9 9 11);
    border-color: rgb(39 39 42);
}

/* Links with accent */
.ai-chat-markdown a {
    color: rgb(var(--primary-500));
    text-decoration: none;
    border-bottom: 1px solid rgba(var(--primary-500), 0.3);
}

.ai-chat-markdown a:hover {
    color: rgb(var(--primary-600));
    border-bottom-color: rgb(var(--primary-500));
}

/* Blockquotes with accent */
.ai-chat-markdown blockquote {
    border-left: 2px solid rgb(var(--primary-500));
    padding: 0.25rem 0.5rem;
    margin: 0.25rem 0;
    background-color: rgba(var(--primary-500), 0.05);
    border-radius: 0 0.25rem 0.25rem 0;
    color: rgb(75 85 99);
    font-size: 0.75rem;
}

.ai-chat-markdown blockquote p {
    margin: 0;
}

.dark .ai-chat-markdown blockquote {
    background-color: rgba(var(--primary-500), 0.1);
    color: rgb(156 163 175);
}

/* Horizontal rule */
.ai-chat-markdown hr {
    border: none;
    height: 1px;
    background: linear-gradient(to right, transparent, rgb(var(--primary-300)), transparent);
    margin: 0.5rem 0;
}

.dark .ai-chat-markdown hr {
    background: linear-gradient(to right, transparent, rgb(var(--primary-700)), transparent);
}

/* Fullscreen Transition Wrapper - Clips overflow to main content area */
.ai-chat-transition-wrapper {
    position: fixed;
    top: 4rem; /* Below header */
    left: 20rem; /* Right of sidebar on desktop - 320px to fully clear sidebar */
    right: 0;
    bottom: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 30;
}

/* Mobile: sidebar is hidden, so start from left edge */
@media (max-width: 1023px) {
    .ai-chat-transition-wrapper {
        left: 0;
    }
}

/* Fullscreen Transition Overlay - Animates within wrapper */
.ai-chat-transition-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgb(var(--primary-500)) 0%, rgb(var(--primary-600)) 100%);
    clip-path: circle(0% at calc(100% - 3.25rem) calc(100% - 3.25rem));
    will-change: clip-path;
}

.ai-chat-transition-active {
    animation: ai-chat-expand 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes ai-chat-expand {
    0% {
        clip-path: circle(0% at calc(100% - 3.25rem) calc(100% - 3.25rem));
    }
    100% {
        clip-path: circle(150% at calc(100% - 3.25rem) calc(100% - 3.25rem));
    }
}

/* Shrink animation when returning from fullscreen chat */
.ai-chat-transition-shrink {
    clip-path: circle(150% at calc(100% - 3.25rem) calc(100% - 3.25rem));
    animation: ai-chat-shrink 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes ai-chat-shrink {
    0% {
        clip-path: circle(150% at calc(100% - 3.25rem) calc(100% - 3.25rem));
    }
    100% {
        clip-path: circle(0% at calc(100% - 3.25rem) calc(100% - 3.25rem));
    }
}

/* Add a subtle icon in the center during expand transition only */
.ai-chat-transition-active::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4rem;
    height: 4rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0;
    animation: ai-chat-icon-fade 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    animation-delay: 0.15s;
}

@keyframes ai-chat-icon-fade {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.2);
    }
}
