/* Χάρτης σχέσεων / Relationship Graph. Dataly Tech, GPL-3.0-or-later */

.relgraph-trigger {
    display: inline-flex; align-items: center; gap: .35em;
    border: 1px solid #2448A8; background: #fff; color: #2448A8;
    border-radius: 999px; padding: .3em .8em; font-size: .9em; font-weight: 600;
    cursor: pointer; line-height: 1.3;
}
.relgraph-trigger:hover { background: #E6ECFA; color: #16306F; }
.relgraph-trigger-sm { padding: .15em .35em; margin-left: .35em; vertical-align: middle; }
#userauthsearchresults .relgraph-trigger-sm, .searchresults td .relgraph-trigger-sm { margin-left: .6em; padding: .2em .65em; white-space: nowrap; font-size: .85em; }
.relgraph-trigger:focus-visible, .relgraph-dialog button:focus-visible, .relgraph-dialog a:focus-visible,
.relgraph-dialog select:focus-visible, .relgraph-dialog input:focus-visible { outline: 3px solid #F2B705; outline-offset: 2px; }
.relgraph-bar { margin: .5em 0 1em; }

.relgraph-dialog {
    width: min(1400px, 96vw); height: min(900px, 92vh); max-width: none; max-height: none;
    padding: 0; border: 0; border-radius: 12px; color: #16202A; background: #F3F5F7;
    box-shadow: 0 20px 60px rgba(22, 32, 42, .35); overflow: hidden;
    font-size: 15px;
}
.relgraph-dialog[open] { display: flex; flex-direction: column; }
.relgraph-dialog::backdrop { background: rgba(22, 32, 42, .55); }

.relgraph-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1em; padding: 14px 20px; background: #16202A; color: #fff; }
.relgraph-title { margin: 0; font-size: 1.3em; color: #fff; }
.relgraph-focus { margin: .2em 0 0; color: #DCE3EA; font-size: .95em; }
.relgraph-focus strong { color: #fff; }
.relgraph-close { border: 0; background: none; color: #fff; font-size: 28px; line-height: 1; cursor: pointer; width: 44px; height: 44px; }

.relgraph-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 10px 20px; background: #fff; border-bottom: 1px solid #D9DEE3; }
.relgraph-group { display: inline-flex; align-items: center; gap: 6px; }
.relgraph-label { font-size: .85em; color: #55606B; }
.relgraph-seg, .relgraph-btn {
    border: 1px solid #C5CDD5; background: #fff; color: #3A4652; padding: 7px 12px; min-height: 36px;
    font-size: .9em; font-weight: 600; cursor: pointer; border-radius: 8px;
}
.relgraph-group .relgraph-seg { border-radius: 0; margin-left: -1px; }
.relgraph-group .relgraph-seg:first-of-type { border-radius: 8px 0 0 8px; }
.relgraph-group .relgraph-seg:last-of-type { border-radius: 0 8px 8px 0; }
.relgraph-seg[aria-pressed="true"] { background: #2448A8; border-color: #2448A8; color: #fff; }
.relgraph-btn:disabled { opacity: .45; cursor: default; }
.relgraph-count { margin-left: auto; font-size: .9em; color: #55606B; }

.relgraph-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 260px minmax(0, 1fr) 300px; gap: 16px; padding: 16px 20px; overflow: auto; }
.relgraph-filters, .relgraph-details, .relgraph-main { background: #fff; border: 1px solid #D9DEE3; border-radius: 10px; }
.relgraph-filters { padding: 12px 14px; overflow: auto; }
.relgraph-filters > summary { font-weight: 700; cursor: pointer; margin-bottom: .6em; }
.relgraph-fs { border: 0; margin: 0 0 1em; padding: 0; }
.relgraph-fs legend, .relgraph-field label { font-size: .75em; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #55606B; margin-bottom: .4em; padding: 0; }
.relgraph-check { display: flex; align-items: center; gap: 8px; margin: .35em 0; }
.relgraph-check input { width: 18px; height: 18px; accent-color: #2448A8; margin: 0; }
.relgraph-check label { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: .92em; cursor: pointer; }
.relgraph-field { margin-bottom: .9em; display: flex; flex-direction: column; }
.relgraph-field select, .relgraph-years input { width: 100%; min-height: 36px; border: 1px solid #C5CDD5; border-radius: 6px; padding: 4px 8px; background: #fff; font-size: .92em; }
.relgraph-years { display: grid; grid-template-columns: auto 1fr; gap: 6px 8px; align-items: center; }
.relgraph-years label { font-size: .85em; margin: 0; }
.relgraph-reset { width: 100%; }

.relgraph-main { position: relative; display: flex; flex-direction: column; min-height: 420px; overflow: hidden; }
.relgraph-graph { flex: 1; min-height: 380px; background-color: #fff;
    background-image: radial-gradient(#D3D9DF 1px, transparent 1px); background-size: 20px 20px; }
.relgraph-status { padding: 12px 16px; color: #3A4652; }
.relgraph-list { flex: 1; overflow: auto; padding: 4px 16px 16px; }
.relgraph-legend { list-style: none; margin: 0; padding: 8px 14px; display: flex; flex-wrap: wrap; gap: 6px 16px; border-top: 1px solid #E4E8EC; font-size: .8em; color: #3A4652; }
.relgraph-legend li { display: inline-flex; align-items: center; gap: 6px; }
.relgraph-hint { margin: 0; padding: 0 14px 10px; font-size: .78em; color: #55606B; }

.relgraph-dot { display: inline-block; width: 16px; height: 11px; border-radius: 999px; border: 1.5px solid; box-sizing: border-box; }
.rg-n-agent { background: #2448A8; border-color: #2448A8; }
.rg-n-work { background: #2E3640; border-color: #2E3640; border-radius: 3px; }
.rg-n-topic { background: #FCEEE5; border-color: #B04A12; }
.rg-n-geo { background: #EFE9F8; border-color: #6B46A8; }

.relgraph-swatch { display: inline-block; width: 22px; height: 0; border-top: 2px solid #2448A8; vertical-align: middle; }
.relgraph-swatch.rg-added { border-top-style: dashed; }
.relgraph-swatch.rg-about { border-top: 3px dotted #B04A12; }
.relgraph-swatch.rg-subject, .relgraph-swatch.rg-topics { border-top: 2px solid #D59A74; }
.relgraph-swatch.rg-persons { border-top: 2px solid #A3AEB9; }
.relgraph-swatch.rg-more, .relgraph-swatch.rg-resp { border-top: 2px solid #C5CDD5; }

.relgraph-gtitle { display: flex; align-items: center; gap: 8px; margin: 18px 0 8px; font-size: .78em; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #55606B; }
.relgraph-items { list-style: none; margin: 0; padding: 0; border: 1px solid #E4E8EC; border-radius: 10px; overflow: hidden; }
.relgraph-items li + li { border-top: 1px solid #EEF1F4; }
.relgraph-item { width: 100%; display: flex; justify-content: space-between; gap: 12px; text-align: left; background: #fff; border: 0; padding: 11px 14px; min-height: 44px; cursor: pointer; font-size: .95em; color: #16202A; }
.relgraph-item:hover { background: #F3F6FC; }
.relgraph-item-sub { color: #55606B; font-size: .88em; white-space: nowrap; }

.relgraph-details { padding: 16px; overflow: auto; }
.relgraph-kicker { margin: 0; font-size: .75em; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #55606B; }
.relgraph-dtitle { margin: .3em 0 .8em; font-size: 1.2em; line-height: 1.3; color: #16202A; font-weight: 700; }
.relgraph-details dl { margin: 0; }
.relgraph-dhead .relgraph-dtitle { margin-bottom: .2em; }
.relgraph-dhead { margin-bottom: .8em; }
.relgraph-life { margin: 0 0 .5em; color: #3A4652; font-size: .95em; font-variant-numeric: tabular-nums; }
/* ISNI / VIAF / Wikidata links under the name */
.relgraph-ids { list-style: none; margin: .4em 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.relgraph-ids li { margin: 0; padding: 0; }
.relgraph-id { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 6px; border: 1px solid #C9D2DC; border-radius: 999px;
    background: #fff; color: #16202A; font-size: .8em; line-height: 1.4; text-decoration: none; }
.relgraph-id:hover, .relgraph-id:focus-visible { border-color: #2448A8; background: #F2F5FC; color: #16202A; text-decoration: none; }
.relgraph-id:focus-visible { outline: 3px solid #F2B705; outline-offset: 2px; }
.relgraph-id svg { flex: none; }
.relgraph-id-name { font-weight: 700; }
.relgraph-id-val { color: #55606B; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; max-width: 11em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Wikidata card: photo above the name, attributes under the facts */
.relgraph-photo { margin: 0 0 12px; }
.relgraph-photo a { display: block; }
.relgraph-photo img { display: block; width: 100%; max-height: 300px; object-fit: cover; object-position: center 20%; border-radius: 8px; background: #EEF1F4; }
.relgraph-has-wd .relgraph-photo + .relgraph-dhead .relgraph-kicker { margin-top: 2px; }
.relgraph-details dl.relgraph-wd { margin-top: 4px; }
.relgraph-details .relgraph-wd > div:first-child { border-top: 2px solid #E1E7F0; }
.relgraph-details .relgraph-wd dd { font-weight: 500; }
.relgraph-details .relgraph-wd-desc dd { font-weight: 400; font-style: italic; color: #2A3440; }
.relgraph-details .relgraph-wd-src { border-top: 0; padding-top: 2px; }
.relgraph-details .relgraph-wd-src dd { font-weight: 400; font-size: .8em; }
.relgraph-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.relgraph-details dl > div { border-top: 1px solid #EEF1F4; padding: 8px 0; }
.relgraph-details dt { font-size: .8em; color: #55606B; font-weight: normal; }
.relgraph-details dd { margin: 2px 0 0; font-weight: 600; }
.relgraph-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.relgraph-primary, .relgraph-secondary { display: block; text-align: center; border-radius: 8px; padding: 10px 12px; font-size: .92em; font-weight: 600; text-decoration: none; cursor: pointer; }
.relgraph-primary { background: #2448A8; color: #fff !important; border: 1px solid #2448A8; }
.relgraph-primary:hover { background: #16306F; }
.relgraph-secondary { background: #fff; color: #2448A8; border: 1px solid #2448A8; }
.relgraph-muted { color: #55606B; }

.relgraph-details-close { display: none; }
.relgraph-filter-count { display: inline-block; min-width: 1.6em; margin-left: .4em; padding: 0 .45em; border-radius: 999px;
    background: #2448A8; color: #fff; font-size: .8em; line-height: 1.6; text-align: center; }
.relgraph-filter-count:empty { display: none; }

/* Koha's OPAC CSS (Bootstrap reboot) floats and enlarges legends, styles labels and
   form controls: neutralise what would leak into the dialog. */
.relgraph-dialog legend { float: none; width: auto; line-height: 1.3; }
.relgraph-dialog label { font-weight: normal; max-width: none; }
.relgraph-dialog fieldset { min-width: 0; }
.relgraph-dialog .relgraph-details dd { margin: 2px 0 0; padding: 0; }
.relgraph-dialog .relgraph-details dt { float: none; width: auto; text-align: left; padding: 0; }
.relgraph-dialog select, .relgraph-dialog input[type="number"] { height: auto; font-family: inherit; }
.relgraph-dialog summary { list-style-position: inside; }

@media (max-width: 1100px) {
    /* rows sized by their content: panels with overflow must not be squeezed */
    .relgraph-body { grid-template-columns: 230px minmax(0, 1fr); grid-auto-rows: max-content; }
    .relgraph-main { min-height: 60vh; }
    .relgraph-details { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
    .relgraph-dialog { width: 100vw; height: 100vh; height: 100dvh; max-width: 100vw; max-height: 100dvh; margin: 0; border-radius: 0; }
    .relgraph-head { padding: 10px 12px 10px 16px; }
    .relgraph-toolbar { padding: 8px 12px; gap: 8px 10px; }
    .relgraph-count { margin-left: 0; width: 100%; }

    /* one scrolling column; no panel is ever squeezed */
    .relgraph-body { display: flex; flex-direction: column; gap: 10px; padding: 10px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
    .relgraph-body > * { flex: 0 0 auto; }

    /* filters: a collapsible bar that shows how many filters are active */
    .relgraph-filters { overflow: visible; padding: 0; }
    .relgraph-filters > summary { margin: 0; padding: 12px 14px; min-height: 44px; box-sizing: border-box; display: flex; align-items: center; }
    .relgraph-filters[open] > summary { border-bottom: 1px solid #E4E8EC; margin-bottom: 12px; }
    .relgraph-filters > :not(summary) { margin-left: 14px; margin-right: 14px; }
    .relgraph-filters > .relgraph-reset { width: calc(100% - 28px); margin-bottom: 14px; }
    .relgraph-field select, .relgraph-years input { min-height: 44px; font-size: 16px; } /* 16px: no iOS zoom on focus */
    .relgraph-check { min-height: 36px; }

    .relgraph-main { min-height: 0; overflow: visible; }
    .relgraph-graph { flex: none; height: 62vh; height: 62dvh; min-height: 320px; }
    .relgraph-list { flex: none; overflow: visible; }
    .relgraph-hint { display: none; }

    /* details: bottom sheet over the graph */
    .relgraph-details {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
        max-height: 55vh; max-height: 55dvh; overflow-y: auto;
        border-radius: 14px 14px 0 0; border: 0; box-shadow: 0 -8px 30px rgba(22, 32, 42, .25);
        padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
        transform: translateY(105%); transition: transform .2s ease-out; visibility: hidden;
    }
    .relgraph-details.is-open { transform: none; visibility: visible; }
    .relgraph-details-close {
        display: block; position: absolute; top: 6px; right: 6px; width: 44px; height: 44px;
        border: 0; background: none; font-size: 26px; line-height: 1; color: #3A4652; cursor: pointer;
    }
    .relgraph-details .relgraph-dtitle { padding-right: 36px; }
}
@media (max-width: 760px) and (prefers-reduced-motion: reduce) { .relgraph-details { transition: none; } }
@media (prefers-reduced-motion: reduce) { .relgraph-dialog * { scroll-behavior: auto !important; } }

/* Staff interface: the toolbar button keeps Koha's .btn look; only the icon is aligned */
.relgraph-staff-btn svg { vertical-align: -2px; }
#auth_searchresultlist td .relgraph-trigger-sm { margin-left: .6em; padding: .15em .6em; white-space: nowrap; font-size: .85em; }

/* Embedded map on the authority page */
.relgraph-inline { margin: 1.5em 0; border: 1px solid #D9DEE3; border-radius: 10px; background: #fff; color: #16202A; overflow: hidden; }
.relgraph-inline-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 12px 16px; border-bottom: 1px solid #E4E8EC; }
.relgraph-inline-title { margin: 0; font-size: 1.15rem; font-weight: 700; color: #16202A; }
.relgraph-inline-count { margin: .15em 0 0; font-size: .85rem; color: #55606B; }
.relgraph-inline-count:empty { display: none; }
.relgraph-btn.relgraph-expand { display: inline-flex; align-items: center; gap: .3em; color: #2448A8; border-color: #2448A8; }
.relgraph-btn.relgraph-expand:hover { background: #E6ECFA; }
.relgraph-inline-stage { position: relative; }
.relgraph-inline .relgraph-status { position: absolute; inset: 0 auto auto 0; margin: 0; z-index: 1; }
.relgraph-inline-graph { height: 440px; min-height: 0; }
.relgraph-zoom { position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 4px; z-index: 1; }
.relgraph-zbtn { width: 34px; height: 34px; border: 1px solid #C5CDD5; border-radius: 8px; background: #fff; color: #3A4652; font-size: 18px; line-height: 1; cursor: pointer; padding: 0; }
.relgraph-zbtn:hover { background: #F3F6FC; }
.relgraph-inline .relgraph-legend { margin: 0; }
.relgraph-inline-info { padding: 10px 16px 14px; border-top: 1px solid #E4E8EC; font-size: .92rem; }
.relgraph-inline-info p { margin: 0; }
.relgraph-inline-sel { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.relgraph-inline-label { font-weight: 700; }
.relgraph-inline-role { color: #1A3480; font-weight: 600; }
.relgraph-inline-sel .relgraph-life { margin: 0; flex-basis: auto; }
.relgraph-inline-sel .relgraph-ids { margin: 0; flex-basis: 100%; }
.relgraph-inline-links { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 6px !important; }
.relgraph-inline-links a, .relgraph-linkbtn { font-weight: 600; }
.relgraph-linkbtn { border: 0; background: none; padding: 0; color: #2448A8; text-decoration: underline; cursor: pointer; font-size: inherit; }
.relgraph-inline button:focus-visible, .relgraph-inline a:focus-visible { outline: 3px solid #F2B705; outline-offset: 2px; }
#auth_detail .relgraph-inline { margin: 1em 0 1.5em; }
.relgraph-inline-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.relgraph-inline.is-collapsed .relgraph-inline-head { border-bottom: 0; }
@media (max-width: 760px) {
    .relgraph-inline-graph { height: 340px; }
    .relgraph-inline-head { padding: 10px 12px; }
    .relgraph-btn.relgraph-expand { width: 100%; justify-content: center; min-height: 44px; }
    .relgraph-zbtn { width: 40px; height: 40px; }
}
@media (max-width: 760px) { .relgraph-photo img { max-height: 190px; } }
