/*
 * DevyaPOS layer on top of the Structurizr static viewer:
 * app palette (pos-app/app/globals.css), toolbar, hover focus, Arabic typography.
 */

:root,
:root[data-theme="dark"] {
    --bg: #0f0c0a;
    --surface: #181310;
    --surface-2: #221b15;
    --line: #33281f;
    --text: #f6ecdd;
    --text-dim: #a8927c;
    --accent: #e0a264;
    --accent-strong: #c77f3c;
    --accent-ink: #201409;
}

:root[data-theme="light"] {
    --bg: #f7f2ea;
    --surface: #ffffff;
    --surface-2: #f1e8db;
    --line: #e0d3c1;
    --text: #241a12;
    --text-dim: #6f5b48;
    --accent: #8f5518;
    --accent-strong: #74400f;
    --accent-ink: #fffaf3;
}

body,
#diagram,
.structurizrDiagramViewport {
    background: var(--bg) !important;
}

body {
    font-family: "Cairo", "Open Sans", "Segoe UI", sans-serif;
    color: var(--text);
}

/* ------------------------------------------------------------------ toolbar */

.bohub-toolbar {
    position: fixed;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1040;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
    font-family: "Cairo", "Open Sans", sans-serif;
    /* Stays out of the way of tall diagrams until you reach for it. */
    opacity: 0.55;
    transition: opacity 0.15s ease;
}

.bohub-toolbar:hover,
.bohub-toolbar:focus-within {
    opacity: 1;
}

.bohub-group {
    display: flex;
    gap: 4px;
}

.bohub-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--text-dim);
    font-size: 15px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}

.bohub-btn:hover {
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
}

.bohub-btn.is-off {
    opacity: 0.45;
}

.bohub-lang {
    border-color: var(--line);
    background: var(--accent);
    color: var(--accent-ink);
}

.bohub-lang:hover {
    background: var(--accent-strong);
    color: var(--accent-ink);
}

.bohub-select {
    max-width: 320px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.bohub-select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

@media (max-width: 720px) {
    .bohub-select { max-width: 140px; }
    .bohub-toolbar { gap: 4px; padding: 5px; }
}

/* --------------------------------------------------------------- hover focus */

#diagram g.joint-element,
#diagram g.joint-link {
    transition: opacity 0.12s ease;
}

#diagram .bohub-fade {
    opacity: 0.15;
}

#diagram .bohub-link-on path.connection {
    stroke: var(--accent) !important;
    stroke-width: 4 !important;
}

#diagram .bohub-link-on .marker-target,
#diagram .bohub-link-on .marker-source {
    fill: var(--accent) !important;
    stroke: var(--accent) !important;
}

#diagram .bohub-link-on text {
    fill: var(--accent) !important;
}

#diagram .bohub-node-on {
    filter: drop-shadow(0 0 14px rgba(224, 162, 100, 0.55));
}

/* ------------------------------------------------------------------- Arabic */

/* The viewer draws diagram/boundary labels with text-anchor:start. Inheriting
   dir=rtl flips their base direction and pushes them off the left edge of the
   canvas, so pin the SVG text base direction back to ltr — Arabic runs still
   shape right-to-left inside it. */
html[dir="rtl"] #diagram svg text,
html[dir="rtl"] #diagramKey svg text {
    direction: ltr;
}

html[dir="rtl"] .modal-header,
html[dir="rtl"] .modal-footer {
    flex-direction: row-reverse;
}

/* --------------------------------------------------------------- modals etc */

.modal-content {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    color: var(--text);
    font-family: "Cairo", "Open Sans", sans-serif;
}

.modal-content code {
    color: var(--accent);
}

.modal-content .btn-primary {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--accent-ink);
}

#tooltip {
    font-family: "Cairo", "Open Sans", sans-serif;
}

/* ------------------------------------------------------------ screenshots
 * Additive overlay: a small corner card when the focused element has a
 * registered screenshot, expanding to a lightbox. Driven by
 * js/devyapos-enhance.js + screenshots/manifest.json. Purely optional — the
 * card only appears when a shot exists, and never covers the toolbar (which is
 * bottom-centre; the card is bottom-end).
 */
.bohub-shot-card {
    position: fixed;
    bottom: 18px;
    inset-inline-end: 18px;
    z-index: 1035;
    width: 260px;
    max-width: 40vw;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
    font-family: "Cairo", "Open Sans", sans-serif;
    cursor: zoom-in;
    transition: opacity 0.12s ease, transform 0.12s ease;
}
.bohub-shot-card.is-hidden {
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    visibility: hidden;
}
.bohub-shot-thumb {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: var(--surface-2);
}
.bohub-shot-cap {
    margin: 7px 2px 1px;
    font-size: 13px;
    line-height: 1.35;
    color: var(--text);
}
.bohub-shot-hint {
    margin: 2px 2px 0;
    font-size: 11px;
    color: var(--text-dim);
}

.bohub-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 4vh 4vw;
    background: rgba(8, 6, 4, 0.82);
    backdrop-filter: blur(6px);
    cursor: zoom-out;
}
.bohub-lightbox.is-hidden {
    display: none;
}
.bohub-lightbox img {
    max-width: 92vw;
    max-height: 78vh;
    border-radius: 12px;
    border: 1px solid var(--line);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
    background: var(--surface);
}
.bohub-lightbox-cap {
    max-width: 80vw;
    color: #f6ecdd;
    font-family: "Cairo", "Open Sans", sans-serif;
    font-size: 16px;
    text-align: center;
}
.bohub-lightbox-close {
    position: fixed;
    top: 16px;
    inset-inline-end: 20px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    color: var(--text);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}
