@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

@font-face {
    font-family: 'JetBrains Mono';
    src: url('assets/JetBrainsMono-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

:root {
    --background: #000000;
    --foreground: #ffffff;
    
    --card: rgba(255, 255, 255, 0.03);
    --card-hover: rgba(255, 255, 255, 0.06);
    --card-foreground: #ffffff;
    
    --popover: #000000;
    --popover-foreground: #ffffff;
    
    --primary: #ffffff;
    --primary-foreground: #000000;
    
    --secondary: #1a1a1a;
    --secondary-foreground: #ffffff;
    
    --muted: #1a1a1a;
    --muted-foreground: #a1a1aa;
    
    --accent: rgba(255, 255, 255, 0.1);
    --accent-foreground: #ffffff;
    
    --destructive: #7f1d1d;
    --destructive-foreground: #ffffff;
    
    --border: rgba(255, 255, 255, 0.1);
    --input: rgba(255, 255, 255, 0.1);
    --ring: #ffffff;
    
    --saffron: #FF9933;
    --green: #128100;
    --white: #ffffff;
    
    --radius: 0.25rem;
    --glass-blur: 12px;
}

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

body {
    background-color: var(--background);
    color: var(--foreground);
    font-family: 'JetBrains Mono', monospace;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Glassmorphism Utilities */
.glass {
    background: var(--card);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.glass-hover:hover {
    background: var(--card-hover);
    border-color: rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
    transition: all 0.3s ease;
}

.app-container.center-mode {
    justify-content: center;
}

.app-container.center-mode .sidebar {
    width: 100%;
    max-width: 800px;
    border-right: none;
    margin: 0 auto;
}

.app-container.center-mode .main-content {
    display: none;
}

/* Sidebar (Chat UI) */
.sidebar {
    width: 400px;
    min-width: 340px;
    background: #0b0b0c;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 20;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scrollbar-width: none;
    transition: opacity 0.3s ease;
}

.app-container.center-mode .chat-messages {
    opacity: 0;
    pointer-events: none;
    display: none;
}

/* Example Prompts Styling */
.example-prompts {
    display: none;
    padding: 2rem;
    gap: 0.8rem;
    flex-direction: column;
    max-width: 650px;
    margin: 0 auto;
    width: 100%;
}

.app-container.center-mode .example-prompts {
    display: flex;
    position: fixed;
    bottom: calc(50% + 50px); /* Position 50px above the vertical center */
    left: 50%;
    transform: translateX(-50%);
    z-index: 55;
    animation: fadeIn 0.8s ease forwards;
}

.prompt-hint {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #555;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.prompt-card {
    background: #111112;
    border: 1px solid var(--border);
    padding: 0.9rem 1.25rem;
    border-radius: 0.85rem;
    font-size: 0.9rem;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.prompt-card:hover {
    background: #1a1a1c;
    border-color: rgba(255, 153, 51, 0.4);
    color: #fff;
    transform: translateY(-3px);
    box-shadow: 0 10px 25px -10px rgba(0,0,0,0.5);
}

.chat-input-container {
    padding: 1.5rem;
    padding-bottom: 2rem;
    background: #0b0b0c;
    position: relative;
    z-index: 50;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.app-container.center-mode .chat-input-container {
    width: 100%;
    max-width: 650px;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 0;
    background: transparent;
}

.message {
    max-width: 95%;
    padding: 0.5rem 0;
    font-size: 0.9375rem;
    line-height: 1.6;
}

.message.ai {
    background: transparent;
    align-self: flex-start;
    color: var(--foreground);
    border: none;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
}

.message.user {
    background: var(--accent);
    align-self: flex-end;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    border-bottom-right-radius: 0.2rem;
    color: var(--foreground);
}

.chat-input-container {
    padding: 1.5rem;
    padding-bottom: 2rem;
}

.chat-input-wrapper {
    background: #1a1a1c;
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    padding: 0.4rem 0.6rem 0.4rem 1.25rem;
    display: flex;
    align-items: flex-end; /* Keep buttons at the bottom during multiline */
    gap: 0.6rem;
    transition: all 0.2s ease;
}

.chat-input-wrapper:focus-within {
    border-color: rgba(255, 255, 255, 0.2);
    background: #202022;
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--foreground);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    padding: 0.35rem 0;
    resize: none;
    max-height: 200px;
    min-height: 24px;
    line-height: 1.4;
    word-break: break-word;
}

.chat-input::placeholder {
    color: #666;
}

/* Custom Model Dropdown */
.custom-select {
    position: relative;
    user-select: none;
}

.select-trigger {
    background: rgba(255, 255, 255, 0.05);
    color: #888;
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 0 0.75rem;
    font-size: 0.6rem;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    height: 1.8rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.2s ease;
}

.select-trigger:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.select-trigger::after {
    content: '';
    width: 0;
    height: 0;
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
    border-top: 4px solid currentColor;
    margin-left: 2px;
}

.select-options {
    position: absolute;
    bottom: calc(100% + 0.75rem);
    right: 0;
    background: #1a1a1c;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.4rem;
    display: none;
    flex-direction: column;
    min-width: 110px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    z-index: 100;
}

.select-options.active {
    display: flex;
}

.option {
    padding: 0.6rem 0.8rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: #888;
    cursor: pointer;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.option:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.option.selected {
    color: var(--saffron);
    background: rgba(255, 153, 51, 0.05);
}

.chat-send-btn {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #444, #222);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255,255,255,0.1);
    cursor: pointer;
    transition: all 0.2s ease;
}

.key-btn {
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 0.4rem;
    background: rgba(255, 255, 255, 0.05);
    color: #888;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s ease;
}

.key-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.key-btn.active {
    color: var(--saffron);
    border-color: var(--saffron);
}

.chat-send-btn:hover {
    background: linear-gradient(135deg, #555, #333);
    transform: scale(1.05);
}

.chat-send-btn.loading {
    pointer-events: none;
    background: linear-gradient(135deg, #333, #111);
}

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

.chat-send-btn.loading svg.spinner {
    animation: spin 1s linear infinite;
    opacity: 0.8;
}

/* API Blocked Overlay */
.chat-input-wrapper.blocked textarea,
.chat-input-wrapper.blocked .custom-select,
.chat-input-wrapper.blocked .chat-send-btn {
    opacity: 0.15;
    pointer-events: none;
    filter: grayscale(1);
}

.chat-input-wrapper .key-btn {
    pointer-events: auto !important;
    opacity: 1 !important;
}

.chat-input-wrapper.blocked {
    border-color: rgba(255, 153, 51, 0.1);
}

/* Dynamic Footer Label */
.chat-footer-label {
    font-size: 0.72rem;
    text-align: center;
    margin-top: 0.75rem;
    transition: all 0.3s ease;
    font-weight: 500;
}

.chat-footer-label.warning {
    color: #ef4444; /* Indian Flag Red/Saffron warning hint */
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.chat-footer-label.success {
    color: #444;
}

/* Reasoning (Think Tags) */
.think-container {
    background: rgba(255, 255, 255, 0.03);
    border-left: 2px solid var(--border);
    padding: 0.75rem 1rem;
    margin: 0.5rem 0 1rem;
    font-size: 0.85rem;
    color: #888;
    border-radius: 0 0.5rem 0.5rem 0;
}

.think-header {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--saffron);
    opacity: 0.7;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.app-deployed-badge {
    background: rgba(18, 129, 0, 0.1);
    border: 1px solid var(--green);
    color: var(--green);
    padding: 0.5rem 1rem;
    border-radius: 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
    margin: 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #0b0b0c;
    border: 1px solid var(--border);
    width: 100%;
    max-width: 400px;
    padding: 2rem;
    border-radius: 0.5rem;
    position: relative;
}

.modal-header {
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.modal-desc {
    font-size: 0.8rem;
    color: #666;
}

.api-input {
    width: 100%;
    background: #1a1a1c;
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    padding: 0.75rem;
    color: #fff;
    font-family: inherit;
    font-size: 0.9rem;
    margin: 1.5rem 0;
    outline: none;
}

.api-input:focus {
    border-color: rgba(255, 153, 51, 0.5);
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    background: #000000;
    position: relative;
    scrollbar-width: thin;
    display: flex;
    flex-direction: column;
}

.main-content::before, .main-content::after {
    display: none;
}

.app-frame-container {
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
}

.preview-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    z-index: 60;
    color: var(--saffron);
}

.preview-loader .spinner {
    animation: spin 1.5s linear infinite;
}

.preview-tabs {
    display: flex;
    background: #0b0b0c;
    border-bottom: 1px solid var(--border);
    padding: 0 1rem;
    z-index: 70;
}

.tab {
    padding: 0.75rem 1.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tab:hover {
    color: #aaa;
}

.tab.active {
    color: #fff;
    border-bottom-color: var(--saffron);
}

.tab-pane {
    display: none;
    position: relative;
    flex: 1;
    width: 100%;
    height: calc(100vh - 40px); /* account for tab bar height */
    overflow: hidden;
}

.tab-pane.active {
    display: flex;
    flex-direction: column;
}

#codeEditor {
    width: 100%;
    flex: 1;
    /* Monaco sets its own background, so we don't override */
}

.download-btn {
    position: absolute;
    bottom: 1.5rem;
    right: 1.5rem;
    background: #0b0b0c;
    border: 1px solid var(--border);
    color: #fff;
    padding: 0.6rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-family: 'JetBrains Mono', monospace;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.download-btn:hover {
    background: #1a1a1c;
    border-color: rgba(255, 255, 255, 0.2);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #222;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: #333;
}

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

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

/* Responsive */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: 50vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
}
