/* Database diagram and related harness styles */

h1text {
    font-size: 1.25rem;
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
}

/* ── Full-overlay / dock wrapper ── */

.dg__ {
    display: flex;
    flex-direction: column;
    padding: 0.5rem;
}

.dg__--fulloverlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    overflow: auto;
    background: var(--slm-color-surface, #fff);
}

.dg__--docked {
    position: relative;
    width: 100%;
    height: 100%;
}

.dg__header {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.dg__header-spacer {
    flex: 1 1 auto;
}

.dg__header h1text {
    margin: 0 0.5rem 0 0;
}

/* ── Diagram layout ── */

.diagram-layout {
    display: flex;
    flex-direction: column;
    margin-top: 0.0rem;
}

.diagram-layout__diagram {
    width: 100%;
}

.diagram-layout--full .diagram-layout__diagram {
    height: 700px;
}

/* In full-overlay mode, fill remaining viewport height */
.dg__--fulloverlay .diagram-layout--full .diagram-layout__diagram {
    height: auto;
    flex: 1 1 0;
}

.dg__--fulloverlay .diagram-layout {
    flex: 1 1 0;
    min-height: 0;
}

.diagram-layout--with-selector .diagram-layout__diagram {
    min-height: 400px;
}

.slm-db-diagram-load-button-row {
    margin-top: .5rem;
}

/* Column description dialog */
.slm-db-column-dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.slm-db-column-dialog {
    background: #fff;
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    min-width: 360px;
    max-width: 520px;
    box-shadow: 0 4px 18px rgba(0,0,0,.18);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: .95rem;
}

.slm-db-column-dialog h3 {
    margin-top: 0;
    margin-bottom: .75rem;
    font-size: 1.05rem;
}

.slm-db-column-dialog dl {
    margin: 0 0 .75rem 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .15rem .75rem;
}

.slm-db-column-dialog dt {
    font-weight: 600;
}

.slm-db-column-dialog dd {
    margin: 0;
}

.slm-db-column-dialog-label {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    margin-bottom: .75rem;
    font-size: .9rem;
}

.slm-db-column-dialog-label textarea {
    resize: vertical;
    min-height: 70px;
    padding: .35rem .45rem;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: .9rem;
}

.dialog-buttons {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
}

/* Table selector dialog (reuses backdrop, larger surface) */
.slm-db-selector-dialog {
    background: #fff;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    min-width: 640px;
    max-width: 1100px;
    max-height: 80vh;
    box-shadow: 0 4px 18px rgba(0,0,0,.18);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: .95rem;
    overflow: auto;
}

@media (max-width: 900px) {
    .slm-db-diagram-load-button-row {
        margin-top: .75rem;
    }
}

/* Database diagram surface */
.slm-db-diagram-viewport {
    position: relative;
    min-height: 400px;
    height: calc(100vh - 160px); /* grow with viewport, leaving room for header */
    border: 1px solid #ddd;
    margin-top: 1rem;
    overflow: hidden; /* viewport handles its own panning */
    cursor: grab;
}

.slm-db-diagram-viewport:active {
    cursor: grabbing;
}

.slm-db-diagram-grid {
    position: relative;
    /* grid is larger than the viewport and is panned via translate() */
}

.slm-db-diagram-overlay {
    position: absolute;
    left: 0;
    top: 0;
    pointer-events: none; /* let mouse events pass through to tables */
    overflow: visible;
}

.slm-db-diagram-table {
    position: absolute;
    border-radius: 8px;
    border: 1px solid #cfd1d4;
    background: rgba(255,255,255,0.75); /* 25% transparent to reveal connectors under table */
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 11px;
    padding: .25rem .4rem .35rem .4rem;
    box-sizing: border-box;
    cursor: move;
}

.slm-db-diagram-table-header {
    font-weight: 600;
    font-size: 12px;
    margin-bottom: .2rem;
    border-bottom: 1px solid #eee;
    padding-bottom: .15rem;
}

.slm-db-diagram-columns-container {
    max-height: 220px;
    overflow-y: auto;
}

.slm-db-diagram-fk-line {
    stroke: rgba(13, 110, 253, 0.65);
    stroke-width: 1.5;
}

.slm-db-diagram-fk-anchor {
    fill: rgba(13, 110, 253, 0.9);
    stroke: #ffffff;
    stroke-width: 1;
}

.slm-db-diagram-fk-crowsfoot {
    stroke: rgba(13, 110, 253, 0.65);
    stroke-width: 1.5;
    fill: none;
}

/* Diagram table context menu */
.slm-db-context-menu {
    position: fixed;
    z-index: 2100;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 12px;
}

.slm-db-context-menu-list {
    list-style: none;
    margin: 0;
    padding: .25rem 0;
}

.slm-db-context-menu-list li {
    padding: .25rem .75rem;
    cursor: pointer;
}

.slm-db-context-menu-list li:hover {
    background: #f2f2f2;
}

.slm-db-context-menu-list li[disabled] {
    color: #999;
    cursor: default;
}
