@import 'tailwindcss';

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

/* =============================================================================
   Laravel Blade File Sources (Tailwind Just-In-Time Mode)
============================================================================= */
@source '../../vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php';
@source '../../storage/framework/views/*.php';
@source '../**/*.blade.php';
@source '../**/*.js';

/* =============================================================================
   Root CSS Variables
============================================================================= */
:root {
    /* Brand Colors */
    --btc-orange: #f7931a;
    --btc-orange-dark: #d87c00;
    --btc-orange-light: #fdba74;

    /* Background & Surface */
    --btc-bg-dark: #111827;
    --btc-bg-lighter-dark: #1f2937;

    /* Text Colors */
    --btc-text-light: #f3f4f6;
    --btc-text-dark: #111827;
    --btc-muted: #9ca3af;

    /* Borders & Alerts */
    --btc-border-dark: #374151;
    --btc-alert-dark: #78350f;
    --btc-border-default: #e5e7eb;

    /* Default Body Background */
    --body-bg: #fff;
    --body-bg-rgb: 255, 255, 255;

    /* Additional Colors */
    --btc-bg-light: #f9fafb;
    --btc-gray: #6b7280;
    --btc-border-light: #d1d5db;
    --btc-surface-light: #f3f4f6;

    /* Fonts */
    --font-sans: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif,
    'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
}

/* =============================================================================
   Base Styles: Body, Typography
============================================================================= */
body {
    font-family: var(--font-sans);
    background: var(--btc-bg-light);
    color: var(--btc-text-dark);
    padding: 1.5rem;
    max-width: 1440px;
    margin: auto;
}

button {
    cursor: pointer;
}

.body-container {
    max-width: 100%;
    margin: 0 auto;
}

@media (min-width: 1024px) {
    .body-container {
        width: 1000px;
        max-width: none;
    }
}


h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

h2 {
    color: var(--btc-bg-lighter-dark);
}


button:disabled {
    pointer-events: none;
    opacity: 0.7;
    cursor: not-allowed;
}

/* =============================================================================
   Header & Branding
============================================================================= */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--btc-border-default);
}


.brand {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--btc-orange);
    text-decoration: none;
}

/* =============================================================================
   Navigation
============================================================================= */
.nav-links {
    display: flex;
    gap: 1rem;
    color: var(--btc-border-dark);
}


.nav-links a {
    text-decoration: none;
}

.nav-links .link-text {
    margin-left: 6px;
}

.nav-link {
    font-size: 0.95rem;
    text-decoration: none;
    color: var(--btc-border-dark);
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.3s ease;
}


.nav-link:hover {
    color: var(--btc-orange-dark);
    text-decoration: none;
}


.profile-menu a.nav-link:hover,
.profile-menu button.nav-link:hover {
    color: var(--btc-orange-dark);
}

/* Mobile nav tweaks */
@media (max-width: 640px) {
    .nav-links {
        gap: 1rem;
    }

    .nav-links .link-text {
        display: none;
    }

    .nav-links i {
        font-size: 1.5rem;
    }
}

/* =============================================================================
   Footer
============================================================================= */
footer {
    border-top: 1px solid var(--btc-border-default);
    font-size: 0.9rem;
    color: var(--btc-gray);
    margin-top: auto;
    padding-top: 2rem;
}


/* =============================================================================
   Form Elements
============================================================================= */
select,
.form-checkbox,
.form-input,
.box,
pre,
.code-block {
    background: var(--btc-surface-light);
    border: 1px solid var(--btc-border-light);
    color: var(--btc-text-dark);
    padding: 0.4rem;
    border-radius: 0.375rem;
}


.form-button {
    @apply inline-flex items-center justify-center gap-1;
    padding: 0.5rem 1.25rem;
    font-size: 1rem;
    background: var(--btc-orange);
    color: white;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.form-button:hover {
    background: var(--btc-orange-dark);
    box-shadow: 0 2px 6px rgba(234, 88, 12, 0.3);
}

.form-button:disabled {
    background: var(--btc-muted);
    cursor: not-allowed;
}

/* Form Helpers */
.subtitle,
.form-help,
.checkbox-help,
.checkbox-label {
    color: var(--btc-gray);
}


/* =============================================================================
   Alerts & Error Messages
============================================================================= */
.alert-warning {
    background-color: #fef3c7;
    color: #92400e;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
}


.error {
    color: #dc2626;
}


/* =============================================================================
   FAQ Section
============================================================================= */
.faq-card {
    background-color: #ffffff;
    color: var(--btc-bg-lighter-dark);
}


.faq-answer {
    color: var(--btc-border-dark);
}


.faq-highlight {
    color: var(--btc-orange-dark);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.03em;
}


/* =============================================================================
   Custom Components
============================================================================= */
.category-badge {
    padding: 0.1rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
    background-color: var(--btc-surface-light);
    color: var(--btc-bg-lighter-dark);
    border: 1px solid var(--btc-border-light);
}


.chat-item {
    @apply p-5 rounded-lg shadow-sm transition hover:shadow-md mb-4;
    @apply bg-white text-gray-900;
}


.chat-question {
    @apply mb-2 text-sm italic px-3 py-2 rounded;
    @apply bg-orange-50 text-orange-700;
}


.profile-card {
    @apply bg-white text-gray-900 border border-gray-200 rounded-lg shadow;
}


.profile-stat {
    @apply p-4 rounded-lg bg-white text-gray-900 border border-gray-200 shadow;
}


label {
    color: var(--btc-bg-lighter-dark);
}


/* =============================================================================
   Utilities & Animations
============================================================================= */
@layer utilities {
    @keyframes bounce-wave {
        0%, 100% {
            transform: translateY(0);
        }
        50% {
            transform: translateY(-12px);
        }
    }

    .animate-bounce-wave {
        animation: bounce-wave 4s ease-in-out infinite;
    }

    .delay-\[0ms\] {
        animation-delay: 0ms;
    }

    .delay-\[150ms\] {
        animation-delay: 150ms;
    }

    .delay-\[300ms\] {
        animation-delay: 300ms;
    }

    .delay-\[450ms\] {
        animation-delay: 450ms;
    }

    .delay-\[600ms\] {
        animation-delay: 600ms;
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Lucide Icons */
[data-lucide] {
    stroke: currentColor;
    vertical-align: middle;
}

button i[data-lucide] {
    cursor: pointer;
    vertical-align: middle;
    stroke-width: 2;
    color: currentColor;
}

[data-lucide="loader-2"] {
    animation: spin 1s linear infinite;
}

/* Modal Helpers */
.backdrop-blur-sm {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.z-50 {
    z-index: 50;
}

body.modal-open {
    overflow: hidden;
}

/* =============================================================================
   Answer Level Buttons
============================================================================= */
@layer components {
    .answer-level-btn {
        @apply inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-xs font-medium border transition-colors duration-150 cursor-pointer;
        @apply text-[color:var(--btc-text-dark)];
    }

    .answer-level-active {
        @apply bg-orange-100 text-orange-800 border-orange-300;
    }

    .answer-level-inactive {
        @apply bg-transparent text-gray-600 border-gray-300 hover:bg-gray-100;
    }
    .persona-btn {
        @apply px-3 py-2 rounded-md text-sm font-medium border cursor-pointer transition;
        @apply bg-white text-gray-800 border-gray-300 hover:bg-gray-100;
        background-color: white;
        color: var(--btc-text-dark);
        border-color: var(--btc-border-light);
    }

    .persona-btn--active {
        @apply bg-orange-100 text-orange-800 border-orange-300;
    }
}

a,
.link {
    color: var(--btc-orange, orange);
    cursor: pointer;
}

a:hover,
.link:hover {
    text-decoration: underline;
}

/* =============================================================================
   Prose Styling (Markdown / Rich Text)
============================================================================= */
/* General prose styles for standalone pages */
.prose ul > li {
    position: relative;
    padding-left: 1.5em;
    margin-bottom: 0.5em;
}

.prose ul > li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--btc-orange, orange);
    font-weight: bold;
}

.prose ol {
    list-style: decimal inside;
}

.prose ol > li {
    padding-left: 0.5em;
    margin-bottom: 0.5em;
}

.prose p {
    margin-bottom: 1rem;
}

.prose h2,
.prose h3,
.prose h4 {
    font-weight: 700;
    line-height: 1.2;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

.prose h2 { font-size: 1.5rem; }
.prose h3 { font-size: 1.25rem; }
.prose h4 { font-size: 1.125rem; }
#chat-container ul > li {
    position: relative;
    padding-left: 1.5em;
    margin-bottom: 0.5em;
}

#chat-container ul > li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--btc-orange, orange);
    font-weight: bold;
}

#chat-container ol {
    list-style: decimal inside;
}

#chat-container ol > li {
    padding-left: 0.5em;
    margin-bottom: 0.5em;
}

#chat-container p {
    margin-bottom: 1rem;
}

#chat-container pre {
    background-color: var(--btc-surface-light);
    color: var(--btc-text-dark);
}


#chat-container blockquote {
    border-left: 4px solid var(--btc-orange, orange);
    padding-left: 1em;
    font-style: italic;
    color: #555;
}

#chat-container hr {
    border: none;
    border-top: 2px solid var(--btc-orange, orange);
    margin: 2rem 0;
}

#chat-container table {
    width: 100%;
    border-collapse: collapse;
}

#chat-container th,
#chat-container td {
    border: 1px solid #ccc;
    padding: 0.5em;
    text-align: left;
}

#chat-container h2, #chat-container h3, #chat-container h4 {
    font-weight: 700;
    line-height: 1.2;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

#chat-container h2 {
    font-size: 1.5rem;
}

#chat-container h3 {
    font-size: 1.25rem;
}

#chat-container h4 {
    font-size: 1.125rem;
}

/* ============================================================================
   Collapsed Description Fade Effect (Light & Dark Modes)
============================================================================ */

/* Clickable chat body */
#history .chat-body {
    cursor: pointer;
}

/* Collapsed gradient fade (shared) */
.chat-body.collapsed::after {
    content: '';
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    height: 3.5rem;
    pointer-events: none;
    border-bottom-left-radius: 0.5rem;
    border-bottom-right-radius: 0.5rem;
    opacity: 0.8;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0) 0%,
        var(--body-bg) 100%
    );
}

/* Collapsed text mask (shared light/dark logic) */
.chat-body.collapsed > .markdown-content {
    -webkit-mask-image: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 1) 70%,
        rgba(0, 0, 0, 0) 100%
    );
    mask-image: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 1) 70%,
        rgba(0, 0, 0, 0) 100%
    );
}

/* Dark mode overrides */

/* ============================================================================
   Suggested Question Prompt Styles (Light & Dark Modes)
============================================================================ */

.suggested-question-prompt {
    display: inline-block;
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    cursor: pointer;
    transition: background-color 0.05s ease, color 0.05s ease;

    background-color: var(--btc-text-light);
    color: var(--btc-text-dark);
}


.suggested-question-prompt:not(:disabled):hover {
    background-color: var(--btc-orange-light);
    color: var(--btc-text-dark);
}

/* ============================================================================
   Spinner Animation
============================================================================ */

.spinner-border {
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.75s linear infinite;
}


/* ============================================================================
   Loader
============================================================================ */

.dots-loader {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 1rem;
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 9999px;
    background-color: #facc15; /* Tailwind yellow-400 */
    animation: dotBounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(2)  { animation-delay: 0.2s; }
.dot:nth-child(3)  { animation-delay: 0.4s; }
.dot:nth-child(4)  { animation-delay: 0.6s; }
.dot:nth-child(5)  { animation-delay: 0.8s; }
.dot:nth-child(6)  { animation-delay: 1.0s; }

@keyframes dotBounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    60% {
        transform: scale(1);
    }
}

/* ============================================================================
   Others
============================================================================ */

/* Share link toast */
.share-info {
    white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   Skeleton Loading
----------------------------------------------------------------------------*/
.skeleton {
    @apply bg-gray-200 animate-pulse text-transparent;
}
