/**
 * Entity Relationship Diagram (in TypeScript)
 * @author  Levente Hunyadi
 * @version 1.0
 * @remarks Copyright (C) 2022-2024 Levente Hunyadi
 * @remarks Licensed under MIT, see https://opensource.org/licenses/MIT
 * @see     https://github.com/hunyadi/entity-relationship-diagram/
 **/

:root {
    --font-family: Lato, -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Roboto, Helvetica, "Helvetica Neue", Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", Arial, sans-serif, "Apple Color Emoji", "Twemoji Mozilla", "Segoe UI Emoji", "Android Emoji";
    --font-heading: Lato, -apple-system, BlinkMacSystemFont, "Segoe UI Variable Heading", "Segoe UI", Roboto, Helvetica, "Helvetica Neue", Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", Arial, sans-serif, "Apple Color Emoji", "Twemoji Mozilla", "Segoe UI Emoji", "Android Emoji";
    --font-monospace: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

body {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font-family);
    color: #273540;
}

.header {
    display: flex;
    flex: 0 1;
    flex-direction: row;
    height: 36px;
    padding: 12px 24px;
    border-bottom: solid 1px #D7DADE;
}

.logo {
    display: flex;
    flex: 1;
    gap: 8px;
    align-items: center
}

.logo h1 {
    margin: 0;
    font-size: 14px;
}

.tabs {
    display: flex;
    flex-grow: 1;
    align-self: center;
    gap: 8px;
}

.tab {
    border-bottom: none;
    padding: 8px;
    color: #273540;
    cursor: pointer;
    font-size: 14px;
}

.tab-active {
    font-weight: 700;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 6px;
    text-decoration-color: #0E68B3;
}

.btn-primary {
    display: inline-flex;
    min-width: 60px;
    padding: 4px 6px;
    justify-content: center;
    align-items: center;
    gap: 4px;
    border-radius: 4px;
    border: 1px solid #0E68B3;
    background: #2B7ABC;
    font-size: 14px;
    font-style: normal;
    font-weight: 400;
    line-height: 20px;
    color: #fff;
}

.tab-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tab-view {
    flex: 1;
    position: relative;
    background: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='6' cy='6' r='1' fill='%23DFDFDF'/%3E%3C/svg%3E%0A") #F2F2F2;
}

.tab-panel>.tab-view>* {
    visibility: hidden;
    position: absolute !important;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
}

.tab-panel>.tab-view>.tab-active {
    visibility: visible;
}

.toolbar-button {
    margin: 2px;
    padding: 2px 4px;
}

.toolbar-button>i {
    display: inline-block;
    width: 24px;
    height: 24px;
}

.diagram {
    display: flex;
    flex-direction: column;
}

.diagram-canvas {
    position: relative;
    overflow: hidden;
    flex: 1;

    /* SVG export requires font properties to be declared for entire diagram */
    font-family: var(--font-family);
    font-size: 12px;
}

.diagram-canvas>div,
.diagram-canvas>svg {
    display: block;
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.diagram-canvas>div>.selected {
    border: 2px solid #2B7ABC;
    z-index: 1;
}

.diagram-canvas>svg>path {
    stroke: #B7B7B7;
    fill: transparent;
}

.diagram-canvas>svg>defs>marker>polygon {
    fill: #B7B7B7;
}

.diagram-canvas.canvaslike>svg>path {
    stroke: #B7B7B7;
}

.diagram-canvas.canvaslike>svg>path.source-selected {
    stroke: #EE6D15;
}

.diagram-canvas.canvaslike>svg>path.target-selected {
    stroke: #EE6D15;
}

.diagram-canvas.canvaslike>svg>defs>marker>polygon {
    fill: #B7B7B7;
}

.diagram-canvas.canvaslike>svg>defs>marker.source-selected>polygon {
    fill: #EE6D15;
}

.diagram-canvas.canvaslike>svg>defs>marker.target-selected>polygon {
    fill: #EE6D15;
}

.diagram-canvas.elastic>div>* {
    margin: 0;
}

table.entity {
    position: absolute;
    box-sizing: border-box;
    background: #fff;
    border: 1px solid #D7DADE;
    border-collapse: collapse;
    overflow: hidden;
    white-space: nowrap;
    text-align: left;
    text-overflow: ellipsis;
    box-shadow: 0px 1px 4px 0px rgba(0, 0, 0, 0.12);
    border-radius: 2px;
}

table.entity .hidden {
    display: none;
}

table.entity>thead {
    background: #F2F4F4;
    cursor: default;
}

table.entity>thead>tr:first-child>th {
    display: flex;
    padding: 8px;
    justify-content: center;
    gap: 4px;
    align-self: stretch;
}

table.entity>thead span.toggle:before {
    display: inline-block;
    height: 14px;
    content: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 14 14' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M11.6379 10.1111L7.00001 5.47325L2.36215 10.1111L1.55557 9.30453L7.00001 3.86008L12.4445 9.30453L11.6379 10.1111Z' fill='%23273540'/%3E%3C/svg%3E%0A");
    padding: 0 2px;
}

table.entity>thead span.toggle.collapsed:before {
    content: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 14 14' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M2.36214 3.88889L7 8.52675L11.6379 3.88889L12.4444 4.69547L7 10.1399L1.55556 4.69547L2.36214 3.88889Z' fill='%23273540'/%3E%3C/svg%3E");
}

table.entity.selected>thead {
    background-color: #EEF6FE;
    color: #0E68B3;
}

table.entity td {
    display: flex;
    padding: 4px 8px;
    align-items: flex-end;
    gap: 4px;
    align-self: stretch;
    background: #FAFAFA;
}

table.entity td:before {
    content: " ";
    display: inline-block;
    width: 12px;
    height: 16px;
    padding: 0 2px;
}

table.entity span.entity-property-name {
    flex: 1 0 0;
    padding-right: 8px;
    font-weight: bold;
}

table.entity span:before {
    content: " ";
    font-weight: bold;
    padding: 0 2px;
}

table.entity span.entity-property-type {
    color: #586874;
}

table.entity span.entity-property-nullable:before {
    display: inline-block;
    content: " ";
    width: 8px;
    padding: 0 2px;
    color: #586874;
    font-weight: bold;
}

table.entity span.entity-property-nullable.nullable:before {
    content: "N";
}

table.entity .entity-key:before {
    content: "🔑";
}

.diagram-canvas.navigable span.entity-name {
    flex-grow: 1;
    text-align: center;
    cursor: pointer;
}

.diagram-canvas.navigable span.entity-name:hover {
    color: #2B7ABC;
}

.diagram-canvas.navigable {
    overflow-y: auto;
}

.navigator {
    display: flex;
    position: absolute;
    width: 100%;
    min-height: 100%;
    align-items: stretch;
}

.navigator>div {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.navigator>div>* {
    position: unset;
    margin: 5px;
}

.navigator select {
    padding: 8px;
}
