:root {
    --primary-color: #6366f1;
    --secondary-color: #4f46e5;
    --text-color: #1f2937;
    --bg-color: #f9fafb;
    --container-bg: #ffffff;
    --border-color: #e5e7eb;
    --success-color: #10b981;
    --loading-overlay: rgba(243, 244, 246, 0.8);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 0.5rem;
}

header p {
    color: #6b7280;
    font-size: 1.1rem;
}

.input-section {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    margin-bottom: 2rem;
}

textarea {
    width: 100%;
    flex-grow: 1;
    min-height: 350px;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    resize: vertical;
    font-size: 1rem;
    margin-bottom: 1rem;
    transition: border-color 0.2s;
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

button {
    cursor: pointer;
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    transition: background-color 0.2s;
}

button:hover {
    background-color: var(--secondary-color);
}

button:disabled {
    background-color: #9ca3af !important;
    cursor: not-allowed !important;
}

button:disabled:hover {
    background-color: #9ca3af !important;
}

.button-group {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

#generateBtn {
    display: inline-block;
    margin-right: 10px;
}

#loadBtn, #saveBtn, #loadHtmlBtn {
    background-color: #4b5563;
}

#loadBtn:hover, #saveBtn:hover, #loadHtmlBtn:hover {
    background-color: #374151;
}

.copy-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    background-color: #e5e7eb;
    color: #374151;
}

.copy-btn:hover {
    background-color: #d1d5db;
}

.code-preview {
    background-color: var(--container-bg);
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    background-color: transparent;
    color: #6b7280;
    padding: 1rem 1.5rem;
    border-radius: 0;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-btn:hover {
    background-color: #f3f4f6;
    color: var(--text-color);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background-color: transparent;
}

.tab-content {
    position: relative;
    min-height: 400px;
}

.tab-pane {
    display: none;
    padding: 1rem;
    height: 100%;
}

.tab-pane.active {
    display: block;
}

#codeTab, #previewTab, #promptTab {
    position: relative;
    min-height: 400px;
    max-height: none;
    height: 70vh;
    overflow: auto;
}

#codeContainer {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: 100%;
}

.code-item {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 200px;
}

.code-item textarea {
    width: 100%;
    height: 100%;
    min-height: 200px;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.875rem;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    background-color: #f8fafc;
    resize: vertical;
    margin-bottom: 0;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.code-buttons {
    display: flex;
    gap: 0.5rem;
}

.save-code-btn {
    background-color: #059669;
    color: white;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 0.25rem;
}

.save-code-btn:hover {
    background-color: #047857;
}

.copy-code-btn {
    background-color: #e5e7eb;
    color: #374151;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 0.25rem;
}

.copy-code-btn:hover {
    background-color: #d1d5db;
}

#previewContainer {
    min-height: 100%;
    height: 100%;
    overflow: auto;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    padding: 1rem;
}

pre {
    white-space: pre-wrap;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.875rem;
    padding: 1rem;
    border-radius: 0.25rem;
    background-color: #f8fafc;
    overflow-x: auto;
}

code {
    font-family: 'Fira Code', 'Consolas', monospace;
}

#createPromptTab h3 {
    color: var(--text-color);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.create-prompt-section {
    display: flex;
    gap: 2rem;
    height: 100%;
}

.description-input-section {
    flex: 1;
    min-width: 300px;
}

.prompt-output-section {
    flex: 2;
    min-width: 400px;
    display: flex;
    flex-direction: column;
}

.prompt-output-section h3 {
    color: var(--text-color);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.prompt-standard-container {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    background-color: #f9fafb;
    margin-bottom: 1rem;
}

.prompt-standard-container textarea {
    width: 100%;
    height: 100%;
    min-height: 350px;
    margin-bottom: 0;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
}

#createPromptTab .description-input-section textarea {
    min-height: 200px;
}

#generatePromptBtn {
    background-color: var(--primary-color);
}

#usePromptBtn {
    background-color: var(--success-color);
}

#usePromptBtn:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
}

#usePromptBtn:disabled:hover {
    background-color: #9ca3af;
}

#keyTab h3 {
    color: var(--text-color);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

#keyTab .input-section {
    gap: 1rem;
}

#apiKeyInput {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    margin-bottom: 1rem;
    transition: border-color 0.2s;
}

#apiKeyInput:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.model-select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    margin-bottom: 1rem;
    background-color: white;
    transition: border-color 0.2s;
}

.model-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.model-note {
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 0;
    font-style: italic;
}

.api-key-section {
    margin-top: 2rem;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background-color: #f9fafb;
}

.api-key-section h3 {
    color: var(--text-color);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

#groqApiKeyInput,
#cerebrasApiKeyInput,
#apiKeyInput {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    margin-bottom: 1rem;
    transition: border-color 0.2s;
}

#groqApiKeyInput:focus,
#cerebrasApiKeyInput:focus,
#apiKeyInput:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

#saveGroqKeyBtn,
#saveCerebrasKeyBtn,
#saveKeyBtn {
    background-color: var(--success-color);
}

#saveGroqKeyBtn:hover,
#saveCerebrasKeyBtn:hover,
#saveKeyBtn:hover {
    background-color: #059669;
}

#appIdeasTab h3 {
    color: var(--text-color);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

#appIdeasTab .input-section {
    display: none;
}

#appIdeasTab .ideas-input-section h3 {
    color: var(--text-color);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

#appIdeasTab .ideas-input-section textarea {
    min-height: 150px;
    margin-bottom: 1rem;
}

#appIdeasTab .ideas-input-section input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    margin-bottom: 1rem;
    transition: border-color 0.2s;
}

#appIdeasTab .ideas-input-section input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

#ideaCount {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    margin-bottom: 1rem;
    transition: border-color 0.2s;
}

#ideaCount:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

#generateIdeasBtn {
    background-color: var(--primary-color);
}

#useIdeaBtn {
    background-color: var(--success-color);
}

#useIdeaBtn:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
}

#useIdeaBtn:disabled:hover {
    background-color: #9ca3af;
}

#saveKeyBtn {
    background-color: var(--success-color);
}

#saveKeyBtn:hover {
    background-color: #059669;
}

#loadingOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--loading-overlay);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.hidden {
    display: none !important;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(99, 102, 241, 0.2);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

.success-message {
    background-color: var(--success-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    opacity: 0;
    transform: translateY(10px);
    animation: fadeIn 0.3s ease forwards, fadeOut 0.3s ease 2s forwards;
}

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

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateY(10px);
    }
}

.preview-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 250px;
    color: #9ca3af;
}

.prompt-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

.prompt-item {
    position: relative;
    width: 100%;
}

.prompt-item textarea {
    margin-bottom: 0;
}

.prompt-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.prompt-title {
    font-weight: 500;
    color: var(--text-color);
}

.remove-prompt-btn {
    background-color: #ef4444;
    color: white;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 0.25rem;
}

.remove-prompt-btn:hover {
    background-color: #dc2626;
}

.add-prompt-btn {
    background-color: #3b82f6;
    color: white;
    margin-bottom: 1rem;
}

.add-prompt-btn:hover {
    background-color: #2563eb;
}

.undo-btn {
    background-color: #f59e0b;
    color: white;
    margin-left: 0.5rem;
    margin-bottom: 1rem;
}

.undo-btn:hover {
    background-color: #d97706;
}

.undo-btn:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
}

.undo-btn:disabled:hover {
    background-color: #9ca3af;
}

.idea-item {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background-color: #f9fafb;
}

.idea-checkbox {
    margin-top: 1rem;
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.idea-textarea {
    flex: 1;
    min-height: 120px;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.9rem;
    resize: vertical;
    background-color: white;
    transition: border-color 0.2s;
}

.idea-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.ideas-container {
    flex: 1;
    max-height: none;
    overflow-y: auto;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    background-color: #f9fafb;
}

.app-ideas-section {
    display: flex;
    gap: 2rem;
    height: 100%;
}

.ideas-input-section {
    flex: 1;
    min-width: 300px;
}

.ideas-output-section {
    flex: 2;
    min-width: 400px;
    display: flex;
    flex-direction: column;
}

.ideas-output-section h3 {
    color: var(--text-color);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.section-divider {
    width: 1px;
    background-color: var(--border-color);
    margin: 0 1rem;
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .tabs {
        flex-wrap: wrap;
        gap: 0.25rem;
        padding: 0.5rem;
    }
    
    .tab-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
        flex: 1;
        min-width: calc(50% - 0.125rem);
    }
    
    .tab-content {
        min-height: 300px;
    }
    
    .tab-pane {
        padding: 0.75rem;
    }
    
    #codeTab, #previewTab, #promptTab {
        height: 60vh;
        min-height: 300px;
    }
    
    textarea {
        min-height: 200px;
        font-size: 0.875rem;
        padding: 0.75rem;
    }
    
    button {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }
    
    .button-group {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .button-group button {
        flex: 1;
        min-width: 120px;
    }
    
    .code-item textarea {
        min-height: 150px;
        font-size: 0.75rem;
    }
    
    .code-buttons {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .save-code-btn, .copy-code-btn {
        font-size: 0.625rem;
        padding: 0.25rem 0.375rem;
    }
    
    .prompt-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .remove-prompt-btn, .undo-btn {
        font-size: 0.625rem;
        padding: 0.25rem 0.375rem;
    }
    
    .add-prompt-btn {
        width: 100%;
        margin-bottom: 0.75rem;
    }
    
    #apiKeyInput {
        font-size: 0.875rem;
        padding: 0.625rem;
    }
    
    .key-note {
        font-size: 0.75rem;
    }
    
    #ideaCount {
        font-size: 0.875rem;
        padding: 0.625rem;
    }
    
    .idea-item {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.75rem;
    }
    
    .idea-checkbox {
        align-self: flex-start;
        margin-top: 0;
    }
    
    .idea-textarea {
        min-height: 100px;
        font-size: 0.875rem;
        padding: 0.625rem;
    }
    
    .ideas-container {
        max-height: 250px;
        padding: 0.75rem;
    }
    
    .prompt-standard-container {
        padding: 0.75rem;
    }
    
    .prompt-standard-container textarea {
        min-height: 200px;
        font-size: 0.875rem;
        padding: 0.75rem;
    }
    
    #createPromptTab .description-input-section textarea {
        min-height: 150px;
    }
    
    #previewContainer {
        padding: 0.75rem;
        min-height: 200px;
    }
    
    .app-ideas-section {
        flex-direction: column;
        gap: 1rem;
    }
    
    .section-divider {
        width: 100%;
        height: 1px;
        margin: 0.5rem 0;
    }
    
    .ideas-input-section,
    .ideas-output-section {
        min-width: unset;
    }
    
    .create-prompt-section {
        flex-direction: column;
        gap: 1rem;
    }
    
    .description-input-section,
    .prompt-output-section {
        min-width: unset;
    }
    
    h3 {
        font-size: 1rem;
    }
    
    .spinner {
        width: 40px;
        height: 40px;
    }
    
    #loadingOverlay p {
        font-size: 0.875rem;
        text-align: center;
        padding: 0 1rem;
    }
    
    .success-message {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        font-size: 0.875rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0.75rem;
    }
    
    header h1 {
        font-size: 1.75rem;
    }
    
    header p {
        font-size: 1rem;
    }
    
    .tab-btn {
        padding: 0.5rem;
        font-size: 0.75rem;
        min-width: calc(33.33% - 0.167rem);
    }
    
    .tab-pane {
        padding: 0.5rem;
    }
    
    textarea {
        min-height: 150px;
        font-size: 0.8125rem;
        padding: 0.625rem;
    }
    
    button {
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
    }
    
    .button-group button {
        min-width: 100px;
    }
    
    .code-item textarea {
        min-height: 120px;
        font-size: 0.6875rem;
    }
    
    .idea-textarea {
        min-height: 80px;
        font-size: 0.8125rem;
    }
    
    .ideas-container {
        max-height: 200px;
    }
    
    .prompt-standard-container textarea {
        min-height: 150px;
        font-size: 0.8125rem;
    }
    
    #createPromptTab .description-input-section textarea {
        min-height: 120px;
    }
    
    h3 {
        font-size: 0.9375rem;
    }
    
    .key-note {
        font-size: 0.6875rem;
    }
}