/* AI Fullscreen Chat Styles - Unique prefix: ai-fs- */

/* Hide elements with x-cloak until Alpine.js loads */
[x-cloak] {
    display: none !important;
}

/* Override Filament's main content area completely */
main.fi-main:has(.ai-fs-container) {
    padding: 0 !important;
    max-width: none !important;
    position: relative;
    height: calc(100vh - 4rem);
    overflow: hidden;
}

main.fi-main:has(.ai-fs-container) > div {
    padding: 0 !important;
    max-width: none !important;
    height: 100%;
}

/* Main Container - Fill the main content area */
.ai-fs-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    background-color: rgb(249 250 251);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.dark .ai-fs-container {
    background-color: rgb(17 17 17);
}

/* Header */
.ai-fs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background-color: white;
    border-bottom: 1px solid rgb(229 231 235);
    flex-shrink: 0;
}

.dark .ai-fs-header {
    background-color: rgb(24 24 27);
    border-bottom-color: rgb(39 39 42);
}

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

.ai-fs-header-icon {
    width: 2.5rem;
    height: 2.5rem;
    background-color: rgb(var(--primary-500));
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.ai-fs-header-icon svg {
    width: 1.25rem;
    height: 1.25rem;
}

.ai-fs-header-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: rgb(17 24 39);
    margin: 0;
}

.dark .ai-fs-header-title {
    color: white;
}

.ai-fs-header-subtitle {
    font-size: 0.75rem;
    color: rgb(107 114 128);
    margin: 0;
}

.dark .ai-fs-header-subtitle {
    color: rgb(161 161 170);
}

.ai-fs-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-fs-clear-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: rgb(243 244 246);
    color: rgb(55 65 81);
    border: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-fs-clear-btn:hover {
    background-color: rgb(229 231 235);
}

.dark .ai-fs-clear-btn {
    background-color: rgb(39 39 42);
    color: rgb(161 161 170);
    border: 1px solid rgb(63 63 70);
}

.dark .ai-fs-clear-btn:hover {
    background-color: rgb(63 63 70);
    color: rgb(228 228 231);
}

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

.ai-fs-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    background-color: rgb(243 244 246);
    color: rgb(55 65 81);
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.ai-fs-back-btn:hover {
    background-color: rgb(229 231 235);
    color: rgb(17 24 39);
}

.dark .ai-fs-back-btn {
    background-color: rgb(39 39 42);
    color: rgb(161 161 170);
    border: 1px solid rgb(63 63 70);
}

.dark .ai-fs-back-btn:hover {
    background-color: rgb(63 63 70);
    color: rgb(228 228 231);
}

.ai-fs-back-btn svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* Messages Area */
.ai-fs-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2rem 1rem;
    scrollbar-width: thin;
    scrollbar-color: rgb(75 85 99) transparent;
    position: relative;
}

/* Webkit Scrollbar Styling */
.ai-fs-messages::-webkit-scrollbar {
    width: 8px;
}

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

.ai-fs-messages::-webkit-scrollbar-thumb {
    background-color: rgb(75 85 99);
    border-radius: 4px;
}

.ai-fs-messages::-webkit-scrollbar-thumb:hover {
    background-color: rgb(107 114 128);
}

.dark .ai-fs-messages {
    scrollbar-color: rgb(55 55 55) transparent;
}

.dark .ai-fs-messages::-webkit-scrollbar-thumb {
    background-color: rgb(55 55 55);
}

.dark .ai-fs-messages::-webkit-scrollbar-thumb:hover {
    background-color: rgb(75 75 75);
}

/* Welcome State - Centered */
.ai-fs-messages-welcome {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

/* Decorative Chat Bubbles */
.ai-fs-chat-bubbles {
    position: absolute;
    pointer-events: none;
    z-index: 0;
}

.ai-fs-bubbles-right {
    top: 0;
    right: 0;
    width: 300px;
    height: 250px;
}

.ai-fs-bubbles-left {
    bottom: 20%;
    left: 0;
    width: 200px;
    height: 200px;
}

.ai-fs-bubble {
    position: absolute;
    border-radius: 50%;
    background: rgba(var(--primary-400), 0.12);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-fs-bubble-1 {
    top: -40px;
    right: -40px;
    width: 180px;
    height: 180px;
    background: rgba(var(--primary-400), 0.12);
}

.ai-fs-bubble-2 {
    top: 80px;
    right: 100px;
    width: 100px;
    height: 100px;
    background: rgba(var(--primary-400), 0.08);
}

.ai-fs-bubble-3 {
    top: 30px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: rgba(var(--primary-400), 0.06);
}

/* Left side bubbles */
.ai-fs-bubble-4 {
    top: 20px;
    left: -50px;
    width: 140px;
    height: 140px;
    background: rgba(var(--primary-400), 0.10);
}

.ai-fs-bubble-5 {
    top: 100px;
    left: 40px;
    width: 80px;
    height: 80px;
    background: rgba(var(--primary-400), 0.06);
}

/* Exit animation - bubbles float away to the right */
.ai-fs-bubbles-exit .ai-fs-bubble-1 {
    transform: translate(150px, 20px) scale(0.5);
    opacity: 0;
}

.ai-fs-bubbles-exit .ai-fs-bubble-2 {
    transform: translate(120px, 30px) scale(0.3);
    opacity: 0;
    transition-delay: 0.1s;
}

.ai-fs-bubbles-exit .ai-fs-bubble-3 {
    transform: translate(100px, 10px) scale(0.2);
    opacity: 0;
    transition-delay: 0.05s;
}

/* Exit animation - left bubbles float away to the left */
.ai-fs-bubbles-exit .ai-fs-bubble-4 {
    transform: translate(-150px, 20px) scale(0.5);
    opacity: 0;
}

.ai-fs-bubbles-exit .ai-fs-bubble-5 {
    transform: translate(-100px, 30px) scale(0.3);
    opacity: 0;
    transition-delay: 0.1s;
}

.ai-fs-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-width: 32rem;
}

.ai-fs-welcome-icon {
    width: 4rem;
    height: 4rem;
    background-color: rgb(var(--primary-500));
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    margin-bottom: 1.5rem;
}

.ai-fs-welcome-icon svg {
    width: 2rem;
    height: 2rem;
}

.ai-fs-welcome-title {
    font-size: 1.75rem;
    font-weight: 600;
    color: rgb(17 24 39);
    margin: 0 0 0.5rem 0;
}

.dark .ai-fs-welcome-title {
    color: rgb(250 250 250);
}

.ai-fs-welcome-subtitle {
    font-size: 1rem;
    color: rgb(107 114 128);
    margin: 0;
}

.dark .ai-fs-welcome-subtitle {
    color: rgb(161 161 170);
}

.ai-fs-messages-inner {
    max-width: 56rem;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Individual Message */
.ai-fs-message {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

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

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

/* Avatar */
.ai-fs-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-fs-avatar svg {
    width: 1.25rem;
    height: 1.25rem;
}

.ai-fs-avatar-assistant {
    background-color: rgb(var(--primary-500));
    color: white;
}

.ai-fs-avatar-user {
    background-color: transparent;
    overflow: hidden;
}

.ai-fs-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0.5rem;
}

/* Message Content */
.ai-fs-message-content {
    max-width: 70%;
    padding: 1rem 1.25rem;
    border-radius: 1rem;
}

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

.ai-fs-content-assistant {
    background-color: white;
    color: rgb(31 41 55);
    border-top-left-radius: 0.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.dark .ai-fs-content-assistant {
    background-color: rgb(24 24 27);
    color: rgb(228 228 231);
    box-shadow: none;
    border: 1px solid rgb(39 39 42);
}

.ai-fs-text {
    font-size: 0.9375rem;
    line-height: 1.6;
}

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

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

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

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

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

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

.ai-fs-loading-text {
    font-size: 0.875rem;
    color: rgb(107 114 128);
}

.dark .ai-fs-loading-text {
    color: rgb(161 161 170);
}

/* Input Area */
.ai-fs-input-area {
    flex-shrink: 0;
    padding: 1rem 2rem 1.5rem;
    background: transparent;
}

.dark .ai-fs-input-area {
    background: transparent;
}

.ai-fs-input-container {
    max-width: 56rem;
    margin: 0 auto;
}

/* Suggestion Cards Grid */
.ai-fs-suggestion-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-top: 2rem;
    width: 100%;
    max-width: 42rem;
}

@media (max-width: 640px) {
    .ai-fs-suggestion-grid {
        grid-template-columns: 1fr;
        max-width: 20rem;
    }
}

.ai-fs-suggestion-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.625rem;
    padding: 1rem;
    background-color: white;
    border: 1px solid rgb(229 231 235);
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.ai-fs-suggestion-card:hover:not(:disabled) {
    border-color: rgb(var(--primary-300));
    background-color: rgb(250 250 250);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.ai-fs-suggestion-card:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.dark .ai-fs-suggestion-card {
    background-color: rgb(24 24 27);
    border-color: rgb(39 39 42);
}

.dark .ai-fs-suggestion-card:hover:not(:disabled) {
    border-color: rgb(var(--primary-500));
    background-color: rgb(32 32 35);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.ai-fs-suggestion-card-icon {
    width: 2rem;
    height: 2rem;
    color: rgb(var(--primary-500));
}

.ai-fs-suggestion-card-icon svg {
    width: 100%;
    height: 100%;
}

.ai-fs-suggestion-card-text {
    font-size: 0.8125rem;
    color: rgb(75 85 99);
    line-height: 1.4;
}

.dark .ai-fs-suggestion-card-text {
    color: rgb(161 161 170);
}

.ai-fs-form {
    width: 100%;
}

.ai-fs-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    background-color: white;
    border: 1px solid rgb(209 213 219);
    border-radius: 1rem;
    padding: 0.75rem 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ai-fs-input-wrapper:focus-within {
    border-color: rgb(var(--primary-500));
    box-shadow: 0 0 0 3px rgba(var(--primary-500), 0.1);
    outline: none;
}

.dark .ai-fs-input-wrapper {
    background-color: rgb(24 24 27);
    border-color: rgb(39 39 42);
}

.dark .ai-fs-input-wrapper:focus-within {
    border-color: rgb(var(--primary-500));
    box-shadow: 0 0 0 3px rgba(var(--primary-500), 0.15);
}

.ai-fs-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.9375rem;
    line-height: 1.5;
    resize: none;
    outline: none !important;
    max-height: 200px;
    color: rgb(17 24 39);
}

.ai-fs-input:focus {
    outline: none !important;
    box-shadow: none !important;
}

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

.dark .ai-fs-input {
    color: rgb(229 229 229);
}

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

.ai-fs-submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    background-color: rgb(var(--primary-500));
    color: white;
    border: none;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

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

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

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

.ai-fs-disclaimer {
    text-align: center;
    font-size: 0.75rem;
    color: rgb(156 163 175);
    margin-top: 0.75rem;
}

/* Markdown Styling for fullscreen chat - ChatGPT style */
.ai-fs-markdown {
    font-size: 0.9375rem;
    line-height: 1.7;
}

.ai-fs-markdown p {
    margin: 0 0 1rem 0;
}

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

/* Bold & Italic with accent */
.ai-fs-markdown strong {
    font-weight: 600;
    color: rgb(17 24 39);
}

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

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

/* Highlighted/marked text uses accent color */
.ai-fs-markdown mark {
    background-color: rgba(var(--primary-500), 0.2);
    color: rgb(var(--primary-700));
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
}

.dark .ai-fs-markdown mark {
    background-color: rgba(var(--primary-500), 0.3);
    color: rgb(var(--primary-300));
}

/* Lists with custom styling */
.ai-fs-markdown ul,
.ai-fs-markdown ol {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.ai-fs-markdown li {
    margin: 0.5rem 0;
    padding-left: 0.25rem;
}

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

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

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

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

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

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

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

.ai-fs-markdown h1 { font-size: 1.375rem; }
.ai-fs-markdown h2 { font-size: 1.25rem; }
.ai-fs-markdown h3 { font-size: 1.125rem; }
.ai-fs-markdown h4 { font-size: 1rem; }

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

.dark .ai-fs-markdown table {
    border-color: rgb(63 63 70);
}

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

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

.dark .ai-fs-markdown th,
.dark .ai-fs-markdown td {
    border-color: rgb(63 63 70);
}

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

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

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

.dark .ai-fs-markdown tr:nth-child(even) td {
    background-color: rgb(24 24 27);
}

/* Inline code - with accent */
.ai-fs-markdown code {
    background-color: rgba(var(--primary-500), 0.1);
    color: rgb(var(--primary-700));
    padding: 0.2rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 500;
}

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

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

.ai-fs-markdown pre code {
    display: block;
    padding: 1rem 1.25rem;
    background: none;
    color: inherit;
    font-size: 0.8125rem;
    line-height: 1.6;
    overflow-x: auto;
}

/* Code block header simulation */
.ai-fs-markdown pre::before {
    content: 'Code';
    display: block;
    padding: 0.5rem 1rem;
    background-color: rgb(39 39 42);
    color: rgb(161 161 170);
    font-size: 0.75rem;
    font-family: inherit;
    border-bottom: 1px solid rgb(63 63 70);
}

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

.dark .ai-fs-markdown pre::before {
    background-color: rgb(24 24 27);
    border-color: rgb(39 39 42);
}

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

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

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

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

.dark .ai-fs-markdown blockquote {
    background-color: rgba(var(--primary-500), 0.1);
    color: rgb(161 161 170);
}

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

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

/* Close Transition Overlay - Just covers the chat before navigation */
.ai-fs-close-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%);
    z-index: 100;
    opacity: 0;
}

.ai-fs-close-active {
    animation: ai-fs-cover 0.25s ease-out forwards;
}

@keyframes ai-fs-cover {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .ai-fs-container {
        margin: -1rem;
        height: calc(100vh - 3rem);
    }

    .ai-fs-header {
        padding: 0.75rem 1rem;
    }

    .ai-fs-header-title {
        font-size: 1rem;
    }

    .ai-fs-clear-btn span {
        display: none;
    }

    .ai-fs-clear-btn {
        padding: 0.5rem;
    }

    .ai-fs-messages {
        padding: 1rem 0.75rem;
    }

    .ai-fs-message-content {
        max-width: 85%;
    }

    .ai-fs-input-area {
        padding: 0.75rem 1rem 1rem;
    }
}
