:root {
    --bg-base: #F8FAFC;
    --bg-surface: #FFFFFF;
    --border: #E2E8F0;
    --text-primary: #0F172A;
    --text-muted: #64748B;
    --primary: #3B82F6;
    --primary-hover: #2563EB;
    --danger: #EF4444;
    --danger-hover: #DC2626;
    --canvas-bg: #F1F5F9;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.theme-dark {
    --bg-base: #0F172A;
    --bg-surface: #1E293B;
    --border: #334155;
    --text-primary: #F8FAFC;
    --text-muted: #94A3B8;
    --canvas-bg: #0B1120;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Header */
.topbar {
    height: 60px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary);
}

.brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* Buttons */
.btn {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn:hover {
    background: var(--border);
}

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

.btn-danger {
    color: var(--danger);
    border-color: var(--border);
}
.btn-danger:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-icon {
    padding: 0.4rem;
    font-size: 1rem;
}

.cursor-pointer {
    cursor: pointer;
}

/* Split View */
.split-view {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Editor Pane */
.editor-pane {
    width: 400px;
    min-width: 300px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    resize: horizontal;
    overflow: auto;
}

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

.editor-header h2 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.editor-actions {
    display: flex;
    gap: 0.5rem;
}

textarea {
    flex: 1;
    background: transparent;
    border: none;
    padding: 1rem;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    resize: none;
    outline: none;
}

.error-msg {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    padding: 1rem;
    font-size: 0.875rem;
    border-top: 1px solid var(--border);
    font-family: monospace;
    white-space: pre-wrap;
    max-height: 150px;
    overflow-y: auto;
}

.error-msg.hidden {
    display: none;
}

/* Canvas Pane */
.canvas-pane {
    flex: 1;
    position: relative;
    background: var(--canvas-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Diagonal lined pattern */
    background-image: repeating-linear-gradient(45deg, var(--border) 0, var(--border) 1px, transparent 0, transparent 50%);
    background-size: 20px 20px;
}

.canvas-header {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 10;
}

.zoom-controls {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-surface);
    padding: 0.25rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.diagram-container {
    flex: 1;
    width: 100%;
    height: 100%;
    overflow: hidden;
    cursor: grab;
}

.diagram-container:active {
    cursor: grabbing;
}

/* The mermaid div takes full space for svg pan zoom */
.mermaid {
    width: 100%;
    height: 100%;
}

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

.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-muted);
    pointer-events: none;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state.hidden {
    display: none;
}

/* Toasts */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: var(--bg-surface);
    padding: 0.75rem 1.5rem;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Mermaid Custom overrides to ensure visibility in dark mode */
.theme-dark .mermaid .er.entityBox {
    fill: #1E293B !important;
    stroke: #3B82F6 !important;
}
.theme-dark .mermaid .er.entityLabel {
    fill: #F8FAFC !important;
}
.theme-dark .mermaid .er.attributeBoxEven {
    fill: #0F172A !important;
}
.theme-dark .mermaid .er.attributeBoxOdd {
    fill: #1E293B !important;
}
.theme-dark .mermaid .er.relationshipLine {
    stroke: #94A3B8 !important;
}
