:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --border-radius: 8px;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--gray-800);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
header {
    background: white;
    box-shadow: var(--shadow);
    padding: 2rem 0;
    margin-bottom: 2rem;
}

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

.subtitle {
    color: var(--gray-600);
    font-size: 1.1rem;
}

/* Main Content */
main {
    background: white;
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    margin-bottom: 2rem;
}

/* Controls */
.controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--gray-100);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.control-group label {
    font-weight: 600;
    color: var(--gray-700);
}

select {
    padding: 0.5rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius);
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

select:hover {
    border-color: var(--primary-color);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 1.2rem;
    height: 1.2rem;
    cursor: pointer;
}

.button-group {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-outline {
    background: white;
    color: var(--gray-700);
    border: 2px solid var(--gray-300);
}

.btn-outline:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Editor Container */
.editor-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    min-height: 600px;
}

.editor-panel {
    display: flex;
    flex-direction: column;
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.panel-header {
    background: var(--gray-50);
    padding: 1rem;
    border-bottom: 2px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    font-size: 1.25rem;
    color: var(--gray-800);
}

.char-count {
    font-size: 0.875rem;
    color: var(--gray-600);
}

.output-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.stats {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-right: 0.5rem;
}

/* Textarea */
textarea {
    flex: 1;
    padding: 1rem;
    border: none;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    resize: none;
    outline: none;
}

/* Output */
.output-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.mermaid-container,
.code-view {
    flex: 1;
    overflow: auto;
    padding: 1rem;
}

.placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--gray-600);
    text-align: center;
}

.placeholder svg {
    margin-bottom: 1rem;
}

.code-view pre {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.view-toggle {
    display: flex;
    border-top: 2px solid var(--gray-200);
    background: var(--gray-50);
}

.view-toggle button {
    flex: 1;
    padding: 0.75rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
    color: var(--gray-600);
    transition: all 0.2s;
}

.view-toggle button.active {
    background: white;
    color: var(--primary-color);
    border-top: 3px solid var(--primary-color);
}

.view-toggle button:hover:not(.active) {
    background: var(--gray-100);
}

/* Error Message */
.error-message {
    margin-top: 1rem;
    padding: 1rem;
    background: #fee;
    border: 2px solid var(--danger-color);
    border-radius: var(--border-radius);
    color: #c00;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 0;
    color: white;
}

footer p {
    margin: 0.5rem 0;
}

.footer-links a {
    color: white;
    text-decoration: none;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.footer-links a:hover {
    opacity: 1;
    text-decoration: underline;
}

/* Spinner */
.spinner {
    display: inline-block;
    animation: spin 1s linear infinite;
}

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

/* Responsive */
@media (max-width: 968px) {
    .editor-container {
        grid-template-columns: 1fr;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .button-group {
        margin-left: 0;
    }

    header h1 {
        font-size: 2rem;
    }
}

/* Mermaid diagram styling */
.mermaid {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.mermaid svg {
    max-width: 100%;
    height: auto;
}
