:root {
    --primary-color: #0051ba;
    --primary-light: #0066ff;
    --primary-dark: #003d87;
    --secondary-color: #f8fafc;
    --accent-color: #ff6b35;
    --success-color: #059669;
    --border-color: #cbd5e1;
    --text-dark: #0f172a;
    --text-light: #475569;
    --text-muted: #64748b;
    --error-color: #dc2626;
    --bg-light: #f1f5f9;
    --bg-dark: #e2e8f0;
    --bg-color: #ffffff;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px 0 rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 10px 25px 0 rgba(0, 0, 0, 0.15);
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
    background: linear-gradient(180deg, #f1f5f9 0%, #e0e7ff 100%);
    color: var(--text-dark);
    line-height: 1.6;
}

body {
    display: flex;
    flex-direction: column;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Header */
.header {
    background: linear-gradient(135deg, #0051ba 0%, #0066ff 100%);
    color: white;
    padding: 2.5rem 1rem;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255, 107, 53, 0.15) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(100px, -100px);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.logo {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    letter-spacing: -0.8px;
}

.tagline {
    font-size: 1rem;
    opacity: 0.95;
    font-weight: 300;
    letter-spacing: 0.3px;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 2.5rem 1rem;
}

.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    height: 100%;
}

@media (max-width: 1024px) {
    .grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

/* Sections */
.input-section,
.output-section {
    background: var(--bg-color);
    border: 1.5px solid var(--border-color);
    border-radius: 1rem;
    padding: 2.5rem;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
}

.input-section::before,
.output-section::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(0, 102, 255, 0.05) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.input-section:hover,
.output-section:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-lg);
}

.input-section h2,
.output-section h2 {
    font-size: 1.4rem;
    margin-bottom: 0.75rem;
    color: var(--text-dark);
    font-weight: 700;
    position: relative;
    z-index: 1;
}

.description {
    color: var(--text-light);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    position: relative;
    z-index: 1;
}

/* Textarea */
.input-textarea {
    width: 100%;
    padding: 1.25rem;
    border: 2px solid var(--border-color);
    border-radius: 0.75rem;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 0.95rem;
    resize: vertical;
    min-height: 200px;
    transition: all 0.2s ease;
    color: var(--text-dark);
    background-color: #fafbfc;
}

.input-textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    background-color: var(--bg-color);
    box-shadow: 0 0 0 4px rgba(0, 102, 255, 0.1);
}

.input-textarea::placeholder {
    color: var(--text-muted);
}

/* Buttons */
.button-group {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
}

.btn {
    padding: 0.85rem 2rem;
    border: none;
    border-radius: 0.75rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: none;
    letter-spacing: 0.3px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    flex: 1;
    min-width: 150px;
    border: 2px solid transparent;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
}

.btn-primary:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--secondary-color);
    color: var(--text-dark);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-dark);
    border-color: var(--primary-color);
}

/* Info Box */
.info-box {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-left: 4px solid var(--primary-light);
    padding: 1.5rem;
    border-radius: 0.75rem;
    margin-top: 2rem;
    font-size: 0.9rem;
    position: relative;
    z-index: 1;
}

.info-box strong {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
    font-weight: 700;
}

.info-box ul {
    list-style: none;
    padding-left: 0;
}

.info-box li {
    margin-bottom: 0.5rem;
    padding-left: 1.5rem;
    position: relative;
    color: var(--text-light);
}

.info-box li:before {
    content: "→";
    position: absolute;
    left: 0.25rem;
    color: var(--primary-light);
    font-weight: bold;
}

/* Output Section */
.output-section {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.output-section h2 {
    color: var(--text-dark);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.output-section h3 {
    color: var(--text-dark);
    font-size: 1.1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

/* Pseudocode Container */
.pseudocode-container {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.pseudocode-output {
    background: #1e1e1e;
    color: #e0e0e0;
    border: 1px solid #333;
    border-radius: 0.5rem;
    padding: 1.5rem;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.5;
}

.pseudocode-output .placeholder {
    color: #888;
    font-style: italic;
}
.output-container {
    flex: 1;
    border: 2px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 2rem;
    background: linear-gradient(135deg, #fafbfc 0%, #f0f4f8 100%);
    overflow: auto;
    min-height: 350px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

#flowchartOutput {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flowchart-placeholder {
    color: var(--text-muted);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 250px;
    font-size: 1rem;
}

.flowchart-placeholder p {
    font-weight: 500;
}

.mermaid {
    display: flex;
    justify-content: center;
}

/* Loading Spinner */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 2rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-light);
    border-right-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading p {
    color: var(--text-light);
    font-weight: 600;
    font-size: 1rem;
}

/* Error Message */
.error-message {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border: 2px solid #fca5a5;
    border-left: 4px solid var(--error-color);
    padding: 1.25rem;
    border-radius: 0.75rem;
    margin-top: 1.5rem;
    position: relative;
    z-index: 1;
}

.error-message strong {
    color: var(--error-color);
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.error-message p {
    color: #7f1d1d;
    font-size: 0.9rem;
    line-height: 1.6;
}

.error-message code {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
}

.action-buttons .btn {
    flex: 1;
    min-width: 150px;
}

/* Footer */
.footer {
    background: linear-gradient(180deg, var(--bg-color) 0%, var(--secondary-color) 100%);
    border-top: 2px solid var(--border-color);
    padding: 2rem 1rem;
    margin-top: auto;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    text-align: center;
}

.copyright {
    color: var(--text-dark);
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.copyright a {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 700;
    transition: all 0.2s ease;
    padding: 0 2px;
}

.copyright a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.powered-by {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 400;
}

/* Mermaid Flowchart Styling */
.mermaid {
    display: flex;
    justify-content: center;
    width: 100%;
}

.mermaid svg {
    max-width: 100%;
    height: auto;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.08));
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        padding: 1.5rem;
    }

    .input-section,
    .output-section {
        padding: 2rem;
    }

    .header {
        padding: 2rem 1rem;
    }

    .logo {
        font-size: 1.75rem;
    }

    .tagline {
        font-size: 0.95rem;
    }

    .button-group {
        gap: 0.75rem;
        margin-top: 1.5rem;
    }

    .btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.9rem;
    }

    .info-box {
        margin-top: 1.5rem;
    }
}

@media (max-width: 480px) {
    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .btn-primary {
        flex: none;
        min-width: auto;
    }

    .input-textarea {
        min-height: 150px;
    }

    .header {
        padding: 1rem;
    }

    .logo {
        font-size: 1.25rem;
    }

    .tagline {
        font-size: 0.85rem;
    }
}
