/* Design Tokens */
:root {
    --color-teal-dark: #007979;
    --color-teal-light: #24B1B1;
    --color-peach: #FFE2AF;
    --color-orange: #E37434;

    --color-bg-main: #FFFFFF;
    --color-surface: #F8F9FA;
    --color-border: #E5E7EB;

    --color-text-primary: #111827;
    --color-text-secondary: #4B5563;
    --color-text-muted: #9CA3AF;
    --color-error: #DC2626;

    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --radius-sm: 4px;
    --radius-md: 8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    color: var(--color-text-primary);
    background-color: var(--color-bg-main);
    min-height: 100vh;
    line-height: 1.5;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Wide stripes in background of the main content specifically */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background-color: var(--color-bg-main);
    position: relative;
    overflow: hidden;
}

.sidebar-toggle {
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    z-index: 1001;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.sidebar-toggle:hover {
    background: var(--color-teal-light);
    color: white;
    border-color: var(--color-teal-light);
}

.sidebar {
    width: 250px;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: -250px;
    height: 100vh;
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    transition: left 0.3s cubic-bezier(0.2, 1, 0.2, 1);
}

.sidebar.open {
    left: 0;
}

.sidebar-brand {
    padding: 5rem 1.5rem 1.5rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-teal-dark);
}

.sidebar-brand h2 {
    color: #FFFFFF;
    font-size: 1.25rem;
    font-weight: 600;
}

.sidebar-brand p {
    color: var(--color-peach);
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.sidebar-nav {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #FFFFFF;
    background: rgba(255, 255, 255, 0.85);
    border-radius: var(--radius-md);
    color: var(--color-teal-dark);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.2, 1, 0.2, 1);
    text-align: left;
}

.nav-btn:hover {
    background: #FFFFFF;
    border-color: var(--color-teal-light);
}

.nav-btn.active {
    background: #FFFFFF;
    border: 1px solid var(--color-teal-dark);
    box-shadow: 0 4px 6px -1px rgba(0, 121, 121, 0.1);
}

.pre-launch .app-layout {
    opacity: 0;
}

.launched .app-layout {
    animation: fadeInContent 1s cubic-bezier(0.2, 1, 0.2, 1) forwards;
}

@keyframes fadeInContent {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1.5rem;
    width: 100%;
}

/* Page Views */
.page-view {
    display: none;
    flex-direction: column;
    position: relative;
    z-index: 10;
}

.page-view.active-page {
    display: flex;
}

/* Chatbot Layout Updates */
.chatbot-layout {
    height: 100vh;
    padding: 0;
    max-width: 100%;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 5rem 2rem 2rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    min-height: 0;
}

.chat-card {
    background: #FFFFFF;
    padding: 2rem;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Chat user message box */
.chat-message.user {
    align-self: flex-end;
    background: #FFFFFF;
    padding: 1rem 1.5rem;
    border-radius: 18px 18px 0 18px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 80%;
    margin-left: auto;
    font-size: 1.15rem;
    color: var(--color-teal-dark);
    font-weight: 500;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-message.assistant {
    align-self: flex-start;
    background: var(--color-surface);
    padding: 1.5rem;
    border-radius: 18px 18px 18px 0;
    border: 1px solid var(--color-border);
    max-width: 85%;
    margin-right: auto;
    font-size: 1.15rem;
    color: var(--color-text-primary);
}

.chat-message.assistant pre {
    background: #FFFFFF;
    padding: 1rem;
    border-radius: var(--radius-md);
    overflow-x: auto;
    border: 1px solid var(--color-border);
    margin: 1rem 0;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--color-teal-dark);
}

.chat-message.assistant code:not(pre code) {
    background: #E5E7EB;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.875rem;
}

/* Markdown Formatting Fixes */
.markdown-body p {
    margin-bottom: 1rem;
    line-height: 1.6;
}

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

.markdown-body ul,
.markdown-body ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
}

.markdown-body ul:last-child,
.markdown-body ol:last-child {
    margin-bottom: 0;
}

.markdown-body li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.markdown-body li:last-child {
    margin-bottom: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    line-height: 1.25;
    color: var(--color-teal-dark);
}

.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child,
.markdown-body h4:first-child,
.markdown-body h5:first-child,
.markdown-body h6:first-child {
    margin-top: 0;
}

.markdown-body blockquote {
    border-left: 4px solid var(--color-border);
    padding-left: 1rem;
    margin-left: 0;
    margin-right: 0;
    margin-bottom: 1rem;
    color: var(--color-text-secondary);
    font-style: italic;
}

.markdown-body strong {
    font-weight: 600;
}

.markdown-body a {
    color: var(--color-teal-light);
    text-decoration: none;
}

.markdown-body a:hover {
    text-decoration: underline;
}

.chat-input-wrapper {
    background: transparent;
    padding: 1.5rem 2rem;
    border-top: none;
    position: sticky;
    bottom: 0;
    box-shadow: none;
}

.chat-form {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-input-container {
    display: flex;
    align-items: flex-end;
    background: #FFFFFF;
    border: 1px solid var(--color-border);
    border-radius: 24px;
    padding: 0.5rem 1rem;
    transition: box-shadow 0.2s, border-color 0.2s;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.chat-input-container:focus-within {
    border-color: var(--color-teal-light);
    box-shadow: 0 0 0 2px rgba(36, 177, 177, 0.1);
}

.chat-input-container textarea {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.5rem;
    font-size: 1rem;
    resize: none;
    min-height: 24px;
    max-height: 150px;
    outline: none;
    line-height: 1.5;
}

.send-btn {
    background: var(--color-teal-dark);
    color: #FFF;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    margin-left: 0.5rem;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    background: var(--color-teal-light);
}

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

/* Presets */
.presets {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.presets-label {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    font-weight: 500;
}

.preset-btn {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--color-text-primary);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.2, 1, 0.2, 1);
}

.preset-btn:hover:not(:disabled) {
    background: var(--color-peach);
    border-color: var(--color-orange);
    color: var(--color-text-primary);
}

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

/* Button & Tool Shared Actions */
.secondary-btn {
    background: #FAFAFA;
    color: var(--color-teal-dark);
    border: 1px solid var(--color-teal-light);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.2, 1, 0.2, 1);
}

.secondary-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.secondary-btn:hover:not(:disabled) {
    background: #FFFFFF;
}

.secondary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: var(--color-border);
    color: var(--color-text-muted);
}

/* Loader */
.loader {
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Error Message */
.error-message {
    color: var(--color-error);
    background: #FEF2F2;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid #F87171;
    font-size: 0.875rem;
}

/* Output Section overrides for chatbot */
.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.output-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-teal-dark);
}

.output-actions {
    display: flex;
    gap: 0.5rem;
}

.code-workspace {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    min-height: 200px;
    display: flex;
    flex-direction: column;
}

.code-display {
    margin: 0;
    padding: 1rem;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--color-teal-dark);
    max-height: 400px;
}

/* Execution Guide overrides for chatbot */
.execution-guide {
    background: #FFFFFF;
    border-left: 4px solid var(--color-orange);
    padding: 1.5rem;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.execution-guide h2 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--color-teal-dark);
}

.execution-guide ol {
    margin-left: 1.5rem;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

.execution-guide li {
    margin-bottom: 0.25rem;
}

/* Trial Room */
.trial-room-container {
    background: #FFFFFF;
    border: none;
    border-radius: var(--radius-md);
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: 85vh;
    min-height: 600px;
}

.trial-room-header h2 {
    color: var(--color-teal-dark);
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.trial-room-header p {
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

.preview-workspace {
    flex: 1;
    background: var(--color-surface);
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-md);
    display: flex;
    justify-content: center;
    align-items: center;
}

.preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    color: var(--color-text-muted);
}

.preview-placeholder .preview-icon {
    margin-bottom: 1rem;
    color: var(--color-text-muted);
}

.preview-placeholder p {
    font-weight: 500;
    color: var(--color-text-secondary);
}

.preview-subtext {
    font-size: 0.875rem;
    margin-top: 0.5rem;
    max-width: 280px;
}

/* Launch Overlay */
.launch-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #FFFFFF;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.8s cubic-bezier(0.8, 0, 0.2, 1);
}

.launch-overlay.slide-up {
    transform: translateY(-100%);
    pointer-events: none;
}

.launch-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.launch-title {
    font-size: 4.5rem;
    font-weight: 900;
    color: #000000;
    display: flex;
    overflow: visible;
    text-shadow: 
        -2px -2px 0 #FFF,
        2px -2px 0 #FFF,
        -2px 2px 0 #FFF,
        2px 2px 0 #FFF,
        0 0 10px rgba(255, 255, 255, 0.8);
}

.launch-title .letter {
    display: inline-block;
    transform: translateY(60px);
    opacity: 0;
    animation: smoothFadeUp 0.7s cubic-bezier(0.2, 1, 0.2, 1) forwards;
}

.launch-title .letter:nth-child(1) { animation-delay: 0.1s; }
.launch-title .letter:nth-child(2) { animation-delay: 0.15s; }
.launch-title .letter:nth-child(3) { animation-delay: 0.2s; }
.launch-title .letter:nth-child(4) { animation-delay: 0.25s; }
.launch-title .letter:nth-child(5) { animation-delay: 0.3s; }
.launch-title .letter:nth-child(6) { animation-delay: 0.35s; }
.launch-title .letter:nth-child(7) { animation-delay: 0.4s; }

.launch-title .letter.ai {
    color: #000000;
    animation-delay: 0.5s;
}

.launch-line {
    width: 0;
    height: 6px;
    background: #000000;
    border-radius: 3px;
    animation: expandLine 0.7s cubic-bezier(0.2, 1, 0.2, 1) 0.8s forwards;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.9);
}

@keyframes smoothFadeUp {
    0% {
        transform: translateY(60px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes expandLine {
    0% {
        width: 0;
        opacity: 0;
    }

    100% {
        width: 100%;
        opacity: 1;
    }
}

/* =========================================================
   HOMEPAGE STYLES
   ========================================================= */
#page-home {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 3rem;
    position: relative;
}

.global-bg-blurred,
.global-bg-reveal {
    position: absolute;
    top: -5%;
    left: -5%;
    right: -5%;
    bottom: -5%;
    background: url('../assets/chatbackground.webp') center/cover no-repeat;
    z-index: 0;
    transition: background-image 0.5s ease;
}

body[data-current-page="page-generator"] .global-bg-blurred,
body[data-current-page="page-generator"] .global-bg-reveal,
body[data-current-page="page-debugger"] .global-bg-blurred,
body[data-current-page="page-debugger"] .global-bg-reveal {
    background-image: url('../assets/chatbg.jpg');
}

.global-bg-blurred {
    filter: blur(12px);
}

.global-bg-blurred::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.2);
}

.global-bg-reveal {
    filter: url(#water-ripple);
    mask-image: radial-gradient(circle 180px at var(--mx, -500px) var(--my, -500px), black 0%, transparent 100%);
    -webkit-mask-image: radial-gradient(circle 180px at var(--mx, -500px) var(--my, -500px), black 0%, transparent 100%);
    pointer-events: none;
}

.home-content-wrapper {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

@keyframes crossFadeIn {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}

.home-hero {
    text-align: center;
    margin-bottom: 4rem;
}

.home-title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--color-text-primary);
    background: #FFFFFF;
    border-radius: 100px;
    padding: 1rem 3rem;
    display: inline-block;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.home-title .accent-wrapper {
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4));
    display: inline-block;
}

.home-title .accent {
    font-family: 'JetBrains Mono', monospace;
    font-size: 4.5rem;
    font-weight: 900;
    display: inline-block;
    background: linear-gradient(135deg, var(--color-teal-dark) 45%, #e67e22 55%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: none;
    margin-top: 0.5rem;
}

.home-subtitle {
    font-size: 1.25rem;
    font-weight: 600;
    color: #000000;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.9), 0 0 20px rgba(255, 255, 255, 0.7);
}

.home-cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    width: 100%;
    max-width: 1000px;
}

.home-card {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-md);
    padding: 2.5rem 2rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.2, 1, 0.2, 1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02), 0 10px 15px rgba(0, 0, 0, 0.03);
    position: relative;
    overflow: hidden;
}

.home-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.home-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border-color: var(--color-teal-light);
}

.home-card:hover::before {
    opacity: 1;
}

.home-card .card-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    color: var(--color-teal-dark);
    transition: transform 0.3s ease;
}

.home-card:hover .card-icon {
    transform: scale(1.1);
    color: var(--color-orange);
}

.home-card h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--color-text-primary);
    position: relative;
    z-index: 1;
}

.home-card p {
    color: var(--color-text-secondary);
    line-height: 1.6;
    position: relative;
    z-index: 1;
}

/* Custom Dropdown Styles */
.custom-dropdown-wrapper {
    position: relative;
    width: 100%;
}

.custom-dropdown-selected {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    user-select: none;
    transition: all 0.2s ease;
}

.custom-dropdown-selected:hover,
.custom-dropdown-selected:focus {
    border-color: var(--color-primary);
    outline: none;
}

.custom-dropdown-selected .chevron {
    transition: transform 0.2s ease;
}

.custom-dropdown-wrapper.open .custom-dropdown-selected .chevron {
    transform: rotate(180deg);
}

.custom-dropdown-options {
    position: absolute;
    bottom: calc(100% + 0.5rem);
    left: 0;
    width: 100%;
    max-height: 250px;
    overflow-y: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.2);
    z-index: 100;
    display: none;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.2s ease;
}

.custom-dropdown-wrapper.open .custom-dropdown-options {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.custom-option {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.2s ease;
    color: var(--color-text);
    font-size: 0.95rem;
}

.custom-option:hover {
    background: var(--color-bg);
    color: var(--color-primary);
}

/* Custom Scrollbar for Dropdown */
.custom-dropdown-options::-webkit-scrollbar {
    width: 6px;
}

.custom-dropdown-options::-webkit-scrollbar-track {
    background: transparent;
}

.custom-dropdown-options::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

.custom-dropdown-options::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary);
}