/* Raditech Mermaid Viewer Scoped Styles */
:root {
    --bg-dark: #0f172a;
    --bg-panel: #1e293b;
    --bg-editor: #0f172a;
    --accent-cyan: #06b6d4;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --header-height: 50px;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

* {
    box-sizing: border-box;
}

header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: rgba(15, 23, 42, 0.95);
    border-bottom: 1px solid var(--border-color);
}

.brand {
    font-weight: 700;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand span {
    color: var(--accent-cyan);
}

.toolbar {
    display: flex;
    gap: 8px;
}

.btn {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    background: var(--bg-panel);
    color: var(--text-main);
    transition: 0.2s;
}

.btn:hover {
    background: #334155;
}

.btn-primary {
    background: var(--accent-cyan);
    color: #fff;
}

.btn-primary:hover {
    background: #0891b2;
}

main {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    height: calc(100vh - var(--header-height));
    overflow: hidden;
}

@media (max-width: 768px) {
    main {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }
}

.editor-pane {
    background: var(--bg-editor);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: relative;
}

.pane-header {
    padding: 8px 12px;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
}

textarea {
    flex: 1;
    width: 100%;
    padding: 16px;
    background: transparent;
    color: #e2e8f0;
    border: none;
    resize: none;
    font-family: monospace;
    font-size: 13px;
    line-height: 1.6;
    outline: none;
}

.preview-pane {
    background: #f8fafc;
    position: relative;
    overflow: hidden;
    display: flex;
}

.preview-controls {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 20;
    background: rgba(255, 255, 255, 0.95);
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

.control-group {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.palette-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.1s;
}

.palette-btn:hover {
    transform: scale(1.1);
}

.palette-btn.active {
    transform: scale(1.15);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.2);
}

.palette-raditech {
    background: linear-gradient(135deg, #0f172a 50%, #06b6d4 50%);
}

.palette-simple {
    background: linear-gradient(135deg, #ffffff 50%, #333333 50%);
    border: 1px solid #cbd5e1 !important;
}

.palette-pastel {
    background: linear-gradient(135deg, #fce7f3 50%, #bae6fd 50%);
}

.p-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #334155;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.p-btn:hover {
    background: #f1f5f9;
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
}

#diagramContainer {
    flex: 1;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
    background-size: 20px 20px;
}

#diagramContainer.grabbing {
    cursor: grabbing;
}

#diagramOutput {
    transform-origin: center;
    transition: transform 0.05s linear;
    pointer-events: none;
}

#diagramOutput svg {
    max-width: none !important;
    height: auto !important;
}

#errorDisplay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ef4444;
    color: white;
    padding: 10px 16px;
    font-size: 12px;
    font-family: monospace;
    transform: translateY(100%);
    transition: transform 0.3s;
}

#errorDisplay.show {
    transform: translateY(0);
}