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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    overflow: hidden;
}

.image-upload-disabled .optional-section {
    display: none;
}

.header {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 700;
}

.header p {
    font-size: 1.1em;
    opacity: 0.9;
}

.main-content {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 0;
    min-height: 600px;
}

.input-section {
    padding: 40px;
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
}

.output-section {
    padding: 40px;
    background: white;
}

.form-group {
    margin-bottom: 25px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #374151;
    font-size: 14px;
}

input, textarea, select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 14px;
    transition: all 0.3s ease;
    font-family: inherit;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #4facfe;
    box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.1);
}

textarea {
    resize: vertical;
    min-height: 120px;
}

.file-input-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

.file-input {
    position: absolute;
    left: -9999px;
}

.file-input-label {
    display: block;
    width: 100%;
    padding: 12px 16px;
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    color: #6b7280;
    transition: all 0.3s ease;
    background: white;
}

.file-input-label:hover {
    border-color: #4facfe;
    color: #4facfe;
}

.file-input:focus + .file-input-label {
    border-color: #4facfe;
    box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.1);
}

.file-selected {
    border-color: #10b981;
    color: #10b981;
    background: #f0fdf4;
}

.ask-btn {
    width: 100%;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    border: none;
    padding: 16px 24px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ask-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(79, 172, 254, 0.3);
}

.ask-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.loading {
    display: none;
    text-align: center;
    padding: 40px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e5e7eb;
    border-top: 4px solid #4facfe;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.result {
    display: none;
}

.result-content {
    background: #f8fafc;
    border-radius: 12px;
    padding: 24px;
    border-left: 4px solid #4facfe;
    line-height: 1.6;
    max-height: 600px;
    overflow-y: auto;
    overflow-x: auto;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.error {
    background: #fef2f2;
    border-left-color: #ef4444;
    color: #dc2626;
}

/* Markdown-specific styling */
.result-content h1,
.result-content h2,
.result-content h3,
.result-content h4,
.result-content h5,
.result-content h6 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
    color: #1f2937;
}

.result-content h1 { font-size: 1.8em; border-bottom: 2px solid #e5e7eb; padding-bottom: 0.3em; }
.result-content h2 { font-size: 1.5em; border-bottom: 1px solid #e5e7eb; padding-bottom: 0.3em; }
.result-content h3 { font-size: 1.3em; }
.result-content h4 { font-size: 1.1em; }
.result-content h5 { font-size: 1em; }
.result-content h6 { font-size: 0.9em; }

.result-content p {
    margin-bottom: 1em;
    color: #374151;
}

.result-content ul,
.result-content ol {
    margin-bottom: 1em;
    padding-left: 1.5em;
}

.result-content li {
    margin-bottom: 0.5em;
    color: #374151;
}

.result-content blockquote {
    border-left: 4px solid #d1d5db;
    margin: 1em 0;
    padding: 0.5em 1em;
    background: #f9fafb;
    font-style: italic;
    color: #6b7280;
}

.result-content code {
    background: #f3f4f6;
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
    color: #e11d48;
}

.result-content pre {
    background: #1a1a1a;
    border-radius: 8px;
    padding: 1em;
    margin: 1em 0;
    overflow-x: auto;
    position: relative;
}

.result-content pre code {
    background: none;
    padding: 0;
    color: #f8f8f2;
    font-size: 0.9em;
}

.result-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
    border: 1px solid #e5e7eb;
}

.result-content th,
.result-content td {
    border: 1px solid #e5e7eb;
    padding: 0.75em;
    text-align: left;
}

.result-content th {
    background: #f9fafb;
    font-weight: 600;
}

.result-content a {
    color: #4facfe;
    text-decoration: none;
}

.result-content a:hover {
    text-decoration: underline;
}

.result-content strong {
    font-weight: 600;
    color: #1f2937;
}

.result-content em {
    font-style: italic;
}

.result-content hr {
    border: none;
    border-top: 2px solid #e5e7eb;
    margin: 2em 0;
}

/* Copy button for code blocks */
.code-block-wrapper {
    position: relative;
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #374151;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.copy-btn:hover {
    opacity: 1;
}

.image-preview {
    margin-top: 15px;
    text-align: center;
    display: none;
}

.image-preview img {
    max-width: 100%;
    max-height: 150px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.clear-image {
    background: #ef4444;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    margin-top: 8px;
}

.status {
    margin-top: 15px;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    display: none;
}

.status.success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.status.error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.optional-section {
    background: #f1f5f9;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.optional-title {
    font-size: 16px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
}

.optional-title::before {
    content: "📎";
    margin-right: 8px;
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .input-section {
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }
    
    .header h1 {
        font-size: 2em;
    }
    
    .result-content {
        max-height: 400px; /* Reduce height on mobile */
    }
}