/* ========== GENERATING STATE ========== */

.gen-overlay {
    position: fixed;
    inset: 0;
    background: #030712;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.gen-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    max-width: 28rem;
    padding: 2rem;
}

.gen-logo {
    width: 5rem;
    height: 5rem;
    background: var(--blue-500);
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.gen-logo .icon {
    width: 100%;
    height: 100%;
    stroke: white;
    stroke-width: 2;
}

.gen-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    text-align: center;
}

.gen-status {
    font-size: 1rem;
    color: var(--slate-400);
    text-align: center;
    min-height: 1.5rem;
}

.gen-progress {
    width: 16rem;
    height: 0.5rem;
    background: var(--slate-800);
    border-radius: 9999px;
    overflow: hidden;
}

.gen-progress-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, var(--blue-500), var(--purple-500), var(--blue-500));
    background-size: 200% 100%;
    border-radius: 9999px;
}

.gen-timer {
    font-size: 0.875rem;
    color: var(--slate-500);
    font-variant-numeric: tabular-nums;
}

.gen-helper {
    font-size: 0.75rem;
    color: var(--slate-600);
}

.gen-error {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 0.5rem;
    text-align: center;
}

.gen-error p {
    font-size: 0.875rem;
    color: var(--red-400);
}

.gen-error-note {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--slate-500);
}

.gen-code-preview {
    margin-top: 2rem;
    max-width: 32rem;
    background: var(--slate-900);
    border: 1px solid var(--slate-800);
    border-radius: 0.75rem;
    overflow: hidden;
    max-height: 12rem;
}

.gen-code-header {
    padding: 0.75rem 1rem;
    background: var(--slate-800);
    border-bottom: 1px solid var(--slate-700);
    font-size: 0.75rem;
    color: var(--slate-400);
    font-weight: 500;
}

.gen-code-content {
    padding: 1rem;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 0.75rem;
    color: #10B981;
    overflow: auto;
    max-height: 10rem;
    position: relative;
}

.gen-code-fade {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3rem;
    background: linear-gradient(to top, var(--slate-900), transparent);
    pointer-events: none;
}

.gen-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.gen-cancel,
.gen-skip {
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    color: var(--slate-600);
    font-size: 0.875rem;
    cursor: pointer;
    transition: color 0.3s;
}

.gen-cancel:hover {
    color: var(--slate-400);
}

.gen-skip {
    color: var(--blue-400);
}

.gen-skip:hover {
    color: var(--blue-300);
}

/* ========== EDITOR STATE ========== */

.editor-wrapper {
    position: fixed;
    inset: 0;
    background: #030712;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Toolbar */
.editor-toolbar {
    height: 3.5rem;
    border-bottom: 1px solid var(--slate-800);
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    gap: 2rem;
    flex-shrink: 0;
}

.toolbar-left,
.toolbar-center,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toolbar-left {
    flex: 1;
}

.toolbar-right {
    flex: 1;
    justify-content: flex-end;
}

.toolbar-btn {
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--slate-700);
    border-radius: 0.5rem;
    color: var(--slate-400);
    cursor: pointer;
    transition: all 0.3s;
}

.toolbar-btn:hover {
    border-color: var(--slate-600);
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.toolbar-btn .icon {
    width: 1.125rem;
    height: 1.125rem;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.project-name {
    background: transparent;
    border: none;
    color: white;
    font-size: 0.9375rem;
    font-weight: 600;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-radius: 0.375rem;
    transition: background 0.3s;
}

.project-name:hover {
    background: rgba(255, 255, 255, 0.05);
}

.project-name-edit {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--slate-700);
    border-radius: 0.375rem;
    color: white;
    font-size: 0.9375rem;
    font-weight: 600;
    padding: 0.5rem 0.75rem;
    outline: none;
    transition: border-color 0.3s;
}

.project-name-edit:focus {
    border-color: var(--blue-500);
}

.save-status {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: var(--slate-500);
}

.icon-sm {
    width: 0.875rem;
    height: 0.875rem;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

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

.animate-spin {
    animation: spin 1s linear infinite;
}

.device-toggle {
    display: flex;
    gap: 0.25rem;
    background: var(--slate-900);
    border: 1px solid var(--slate-800);
    border-radius: 0.5rem;
    padding: 0.25rem;
}

.device-btn {
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 0.375rem;
    color: var(--slate-400);
    cursor: pointer;
    transition: all 0.3s;
}

.device-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--slate-300);
}

.device-btn.active {
    background: var(--slate-800);
    color: white;
}

.device-btn .icon {
    width: 1.125rem;
    height: 1.125rem;
    stroke: currentColor;
    stroke-width: 2;
}

.btn-deploy {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--blue-500);
    border: none;
    border-radius: 0.5rem;
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-deploy:hover {
    background: var(--blue-600);
}

.btn-deploy .icon {
    width: 1rem;
    height: 1rem;
    stroke: currentColor;
    stroke-width: 2;
}

/* Main Content */
.editor-main {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* Chat Panel */
.chat-panel {
    width: 24rem;
    border-right: 1px solid var(--slate-800);
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

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

.chat-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: white;
}

.chat-collapse {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 0.375rem;
    color: var(--slate-400);
    cursor: pointer;
    transition: all 0.3s;
}

.chat-collapse:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.chat-collapse .icon {
    width: 1.125rem;
    height: 1.125rem;
    stroke: currentColor;
    stroke-width: 2;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-msg {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 80%;
}

.chat-msg.user {
    align-self: flex-end;
}

.chat-msg.assistant {
    align-self: flex-start;
}

.msg-bubble {
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    font-size: 0.9375rem;
    line-height: 1.5;
}

.chat-msg.user .msg-bubble {
    background: var(--blue-600);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.chat-msg.assistant .msg-bubble {
    background: var(--slate-800);
    color: var(--slate-200);
    border-bottom-left-radius: 0.25rem;
}

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chip {
    padding: 0.5rem 0.75rem;
    background: var(--slate-800);
    border: none;
    border-radius: 9999px;
    color: var(--slate-300);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.3s;
}

.chip:hover {
    background: var(--slate-700);
}

.typing-dots {
    display: flex;
    gap: 0.375rem;
    padding: 0.75rem 1rem;
    background: var(--slate-800);
    border-radius: 1rem;
    border-bottom-left-radius: 0.25rem;
}

.typing-dots .dot {
    width: 0.5rem;
    height: 0.5rem;
    background: var(--slate-500);
    border-radius: 50%;
    animation: bounce 1.4s infinite;
}

.typing-dots .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots .dot:nth-child(3) {
    animation-delay: 0.4s;
}

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

.chat-input-area {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--slate-800);
}

.input-container {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    background: var(--slate-900);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    font-size: 0.9375rem;
    resize: none;
    max-height: 8rem;
    outline: none;
}

.chat-input::placeholder {
    color: var(--slate-500);
}

.send-btn {
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--blue-500);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
}

.send-btn:hover {
    background: var(--blue-600);
}

.send-btn .icon {
    width: 1rem;
    height: 1rem;
    stroke: currentColor;
    stroke-width: 2.5;
}

/* Preview Panel */
.preview-panel {
    flex: 1;
    background: var(--slate-900);
    overflow: hidden;
}

.preview-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.browser-frame {
    width: 100%;
    height: 90%;
    background: var(--slate-950);
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

.browser-chrome {
    height: 2rem;
    background: var(--slate-900);
    border-bottom: 1px solid var(--slate-800);
    display: flex;
    align-items: center;
    padding: 0 0.75rem;
    gap: 0.75rem;
    flex-shrink: 0;
}

.chrome-dots {
    display: flex;
    gap: 0.375rem;
}

.chrome-dots .dot {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    opacity: 0.5;
}

.chrome-dots .dot.red {
    background: #EF4444;
}

.chrome-dots .dot.yellow {
    background: #F59E0B;
}

.chrome-dots .dot.green {
    background: #10B981;
}

.chrome-url {
    flex: 1;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--slate-500);
}

.preview-iframe {
    flex: 1;
    overflow: auto;
    position: relative;
}

.preview-placeholder {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.placeholder-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #030712 0%, #1e3a8a 100%);
    opacity: 0.5;
}

.placeholder-content {
    position: relative;
    text-align: center;
    color: var(--slate-400);
}

.placeholder-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: white;
    margin-bottom: 0.5rem;
}

.placeholder-content p {
    font-size: 0.9375rem;
}

/* Mobile Chat Sheet */
.chat-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 70%;
    border-right: none;
    border-top: 1px solid var(--slate-800);
    border-radius: 1rem 1rem 0 0;
    z-index: 100;
}

/* Floating Chat Button */
.floating-chat-btn {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 3.5rem;
    height: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--blue-500);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    box-shadow: 0 10px 40px rgba(59, 130, 246, 0.4);
    z-index: 50;
}

.floating-chat-btn .icon {
    width: 1.5rem;
    height: 1.5rem;
    stroke: currentColor;
    stroke-width: 2;
}

/* Markdown Content Styles */
.markdown-content {
    word-wrap: break-word;
}

.markdown-content p {
    margin: 0.5em 0;
}

.markdown-content p:first-child {
    margin-top: 0;
}

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

.markdown-content code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 0.875em;
}

.markdown-content pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.75rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 0.75em 0;
}

.markdown-content pre code {
    background: none;
    padding: 0;
    font-size: 0.8125rem;
    line-height: 1.5;
}

.markdown-content ul,
.markdown-content ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.markdown-content li {
    margin: 0.25em 0;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    margin: 0.75em 0 0.5em 0;
    font-weight: 600;
}

.markdown-content h1 { font-size: 1.5em; }
.markdown-content h2 { font-size: 1.25em; }
.markdown-content h3 { font-size: 1.125em; }

.markdown-content blockquote {
    border-left: 3px solid rgba(255, 255, 255, 0.2);
    padding-left: 1em;
    margin: 0.75em 0;
    color: rgba(255, 255, 255, 0.8);
}

.markdown-content a {
    color: #60a5fa;
    text-decoration: underline;
}

.markdown-content a:hover {
    color: #93c5fd;
}

.markdown-content hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 1em 0;
}

.markdown-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.75em 0;
}

.markdown-content th,
.markdown-content td {
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.5em;
}

.markdown-content th {
    background: rgba(0, 0, 0, 0.2);
    font-weight: 600;
}

/* Responsive */
@media (max-width: 1024px) {
    .toolbar-center {
        display: none;
    }

    .chat-panel:not(.chat-sheet) {
        display: none;
    }
}

@media (max-width: 768px) {
    .editor-toolbar {
        padding: 0 0.75rem;
        gap: 0.5rem;
    }

    .toolbar-left,
    .toolbar-right {
        gap: 0.5rem;
    }

    .save-status {
        display: none;
    }

    .btn-deploy {
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
    }

    .preview-container {
        padding: 0.75rem;
    }

    .browser-frame {
        height: 95%;
    }

    .gen-content {
        padding: 1.5rem 1rem;
        max-width: 90%;
    }

    .gen-title {
        font-size: 1.25rem;
    }

    .gen-progress {
        width: 12rem;
    }
}

@media (max-width: 480px) {
    .editor-toolbar {
        padding: 0 0.5rem;
        height: 48px;
    }

    .toolbar-left .btn,
    .toolbar-right .btn {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
    }

    .toolbar-left .btn-icon,
    .toolbar-right .btn-icon {
        width: 1rem;
        height: 1rem;
    }

    .btn-deploy {
        padding: 0.375rem 0.625rem;
        font-size: 0.75rem;
    }

    .preview-url-bar {
        font-size: 0.75rem;
        padding: 0.375rem 0.5rem;
    }

    .browser-controls {
        gap: 0.375rem;
    }

    .browser-controls button {
        width: 2rem;
        height: 2rem;
        font-size: 0.75rem;
    }
}
