@import url('./icons.css');

/* Focus indicator: zobrazí sa iba pri keyboard/screen-reader navigation,
   nie pri mouse click ani programmatic focus po mouse interaction.
   Modern web pattern — accessibility friendly bez vizuálneho šumu. */
:focus:not(:focus-visible) {
    outline: none;
}

:focus-visible {
    outline: 2px solid var(--dxds-color-content-primary-default-rest);
    outline-offset: 2px;
    border-radius: 0.25rem;
}

/* H1 nie je interaktívny element — FocusOnNavigate ho focusne iba pre screen readers
   (tí outline nevidia, navigujú cez focus events). Vizuálny outline tu nepatrí. */
h1:focus,
h1:focus-visible {
    outline: none;
}

html, body {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    margin: 0;
}

/* Level-1 grid (EntityGrid volaný zo stránky) vyplní výšku page-content-container
   a scrolluje interne (vlastný DxGrid scrollbar) — pri veľa záznamoch nevyskočí
   vonkajší/body scrollbar. V sub-gridoch (detail row nie je flex column) sú flex
   vlastnosti inertné, takže ich neovplyvní. */
/* Detail row EntityGridu: lišta (nadpis + Zavrieť) nad obsahom, ktorý otvorilo kontextové menu. */
/* Tlačidlo hneď za nadpisom (nie space-between): detail row môže byť širší než viewport
   (sub-grid + vodorovný scroll), vpravo by bolo tlačidlo mimo obrazovky. */
.eg-detail-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: .5rem;
}

.eg-detail-caption {
    font-weight: 600;
}

.eg-fill {
    flex: 1 1 auto;
    min-height: 0;
}

/* /admin/reports — obsah tabu (pivot / matica) potrebuje konkrétnu výšku, aby `eg-fill`
   deti (DxPivotTable / DxGrid) mali do čoho rásť a scrollovali interne. DxTabs neprenáša
   flex výšku na panel spoľahlivo pre OBA taby (flex-fill funguje pre pivot so scroll-viewerom,
   ale maticový DxGrid potom prerastie), preto viewport-calc fallback. */
.report-tab-content {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 230px);
    min-height: 360px;
}

/* PerStay tenant má nad tabmi lištu „Uzavrieť obdobie teraz" (~48px) → bez tejto korekcie
   pivot pretečie cez 100% a vyskočí page scrollbar (nahlásené). Odčítame ju navyše. */
.report-tabs-with-closebar .report-tab-content {
    height: calc(100vh - 280px);
}

/* Editor šablón dokumentov (/admin/templates, Krok 10a). */
.tpl-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.tpl-toolbar .tpl-spacer {
    flex: 1;
}
.tpl-layout {
    display: flex;
    gap: 12px;
    height: calc(100vh - 230px);
    min-height: 420px;
}
.tpl-editor-wrap {
    flex: 1;
    min-width: 0;
}
.tpl-editor {
    height: 100%;
}
.tpl-tags {
    width: 230px;
    overflow-y: auto;
    border: 1px solid var(--dxbl-border-color, #dee2e6);
    border-radius: 6px;
    padding: 10px;
}
.tpl-tags-title {
    font-weight: 600;
    margin-bottom: 2px;
}
.tpl-tags-hint {
    font-size: .75rem;
    margin-bottom: 8px;
}
.tpl-tag-group {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--dxbl-text-muted, #6c757d);
    margin: 10px 0 4px;
}
.tpl-tag {
    display: block;
    width: 100%;
    text-align: left;
    background: var(--dxbl-list-item-bg, transparent);
    border: 1px solid var(--dxbl-border-color, #dee2e6);
    border-radius: 4px;
    padding: 4px 8px;
    margin-bottom: 4px;
    cursor: pointer;
    font-size: .85rem;
}
.tpl-tag:hover {
    background: var(--dxbl-primary, #0d6efd);
    color: #fff;
}

/* Bunka obligation matice (zariadenie × obdobie). */
.report-matrix-cell {
    font-size: .85rem;
    line-height: 1.2;
}
.report-matrix-cell .rm-tax {
    display: block;
    font-weight: 700;
    color: var(--dxbl-success, #198754);
}
.report-matrix-cell .rm-sub {
    font-size: .75rem;
    color: var(--dxbl-text-muted, #6c757d);
}
.report-matrix-cell .rm-multi {
    font-weight: 600;
}
.report-matrix-cell .rm-missing {
    font-weight: 600;
}
.report-matrix-cell .rm-muted {
    text-align: center;
}
.report-matrix-cell .rm-fine {
    display: block;
    margin-top: 2px;
    font-size: .72rem;
    color: #b8860b;
}
/* Badge pokuty je klikateľný (otvorí detail) — button bez button vzhľadu. */
.report-matrix-cell .rm-fine-btn {
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    text-align: left;
}
.report-matrix-cell .rm-fine-btn:hover {
    text-decoration: underline;
}

/* Akcie bunky (F2/F3) — overlay vpravo hore, viditeľný až na hover bunky/riadku,
   aby matica ostala vizuálne pokojná. */
.report-matrix-cell {
    position: relative;
}
.report-matrix-cell .rm-actions {
    position: absolute;
    top: -2px;
    right: 0;
    display: none;
    gap: 0;
    background: var(--dxbl-bg, #fff);
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}
.report-matrix-cell:hover .rm-actions {
    display: inline-flex;
}
.rm-act.dxbl-btn {
    padding: 0 4px;
    font-size: .85rem;
    line-height: 1.4;
    text-decoration: none;
}
.rm-operator {
    font-size: .75rem;
}

/* Toolbar matice (DxToolbar items): label + editor v jednom riadku. DX editor je default
   width:100%, preto mu dáme fixnú šírku cez wrapper (.rm-fld*). */
.rm-tb-fld {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.rm-fld {
    display: inline-block;
}
.rm-fld-year {
    width: 90px;
}
.rm-fld-period {
    width: 160px;
}
.rm-sum {
    white-space: nowrap;
}

/* Filter-row bunka s výberom operátora (lupa) — Zariadenie + VS. Tlačidlo vľavo, editor
   vyplní zvyšok. Lupa = CSS mask (Bootstrap search ikona), bez externého assetu.
   Žiadny padding override na tlačidle → drží default DX výšku zhodnú s inputom. */
.frow-op {
    display: flex;
    align-items: center;
    gap: 4px;
}
.frow-op-editor {
    flex: 1 1 auto;
    min-width: 0;
}
.frow-op-btn {
    flex: 0 0 auto;
}
/* Kompaktné tlačidlo operátora (bez caretu) — min-width preč + tesný padding, aby input
   na zadanie hodnoty dostal max. šírku (inak DX button rezervuje ~64px min-width). */
.frow-op-btn.dxbl-btn {
    min-width: 0;
    padding-left: 8px;
    padding-right: 8px;
}
.frow-op-icon {
    display: inline-block;
    width: 14px;
    height: 14px;
    background-color: currentColor;
    -webkit-mask: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0'/%3E%3C/svg%3E");
    mask: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0'/%3E%3C/svg%3E");
}

/* Aktívny operátor v menu lupy — zvýraznenie cez vlastný class (DxDropDownButtonItem nemá
   natívny selected stav). Akcent témy: Fluent témy majú --dxbl-btn-primary-bg, Bootstrap-based
   témy (Blazing Berry, Purple, Office White, Bootstrap) majú --bs-primary → fallback reťazec
   pokryje obe rodiny. Posledný literál len pre istotu, ak by chýbali obe. */
.frow-op-active.dxbl-btn,
.frow-op-active .dxbl-btn {
    font-weight: 600;
    /* !important: DX má v Bootstrap-based témach špecifickejšie pravidlo na ploské pozadie
       menu-položky (0,4,0 + kombinátor); univerzálne ho prebijeme (docs to odporúčajú). */
    background-color: var(--dxbl-btn-primary-bg, var(--bs-primary, #0d6efd)) !important;
    color: var(--dxbl-btn-primary-color, #fff) !important;
}

/* Grand Total riadok prišpendlený dole pri vertikálnom scrolle. DxPivotTable to natívne
   nevie (sticky sú len Column/Row Field Headers). Trieda `dxbl-pivot-table-grand-total`
   je unikátna pre spodný row-grand-total riadok — per-riadkové stĺpcové totaly používajú
   `-total`. Cielime navyše na posledný <tr>, aby pri viacerých rokoch (Rok→Obdobie) sticky
   nechytil aj prípadný pravý „Grand Total" stĺpec.
   POZOR: DX téma necháva total bunky PRIEHĽADNÉ (`--dxbl-pivot-table-total-bg: unset`) a
   „total" odtieň robí len 5% čierny ::before overlay — overené v 25.2.7 aj 26.1.3, ktoré sú
   v tomto identické (nie je to regresia témy). Pri sticky riadku tak presvitá odscrollovaný
   obsah (priehľadný „sumárny riadok"). Riešenie: doplníme bunke nepriehľadné pozadie z
   premennej celej pivot-tabuľky → 5% overlay ostáva, len už nad nepriehľadným podkladom.
   `var(--dxbl-pivot-table-bg)` je theme-safe (light #fff, dark #37353d, bootstrap = body-bg).
   `!important` je nutné: DX má pravidlo `… table > tbody > tr > td { position: relative }`
   so špecificitou (0,3,4), ktoré inak prebije náš class-selektor (0,3,3). */
.dxbl-pivot-table tbody tr:last-child td.dxbl-pivot-table-grand-total {
    position: sticky !important;
    bottom: 0 !important;
    z-index: 3;
    --dxbl-pivot-table-total-bg: var(--dxbl-pivot-table-bg, #fff);
}

/* Ľavý dolný roh (label „Grand Total") je fixný vľavo aj dole → musí byť nad zvyškom. */
.dxbl-pivot-table tbody tr:last-child td.dxbl-pivot-table-grand-total.dxbl-pivot-table-fixed-cell {
    z-index: 4 !important;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--dxds-color-border-success-default-rest);
}

.invalid {
    outline: 1px solid var(--dxds-color-border-danger-default-rest);
}

.validation-message {
    color: var(--dxds-color-content-danger-default-rest);
}

.button-link {
    text-decoration: unset;
}

.title {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem 0;
}

.title.title-secondary {
    padding: 0.313rem 0 0;
    color: var(--dxds-color-content-secondary-default-rest);
}

.title-header-text {
    font-size: var(--dxds-font-size-headline-lg);
    font-weight: var(--dxds-font-weight-headline-default);
    letter-spacing: var(--dxds-letter-spacing-headline-lg);
    line-height: var(--dxds-line-height-headline-lg);
}

.title-content-text {
    font-size: var(--dxds-font-size-base-lg);
    font-weight: var(--dxds-font-weight-base-default);
    letter-spacing: var(--dxds-letter-spacing-base-lg);
    line-height: var(--dxds-line-height-base-lg);
}

.main-content {
    align-items: center;
    display: flex;
    height: 100%;
    justify-content: center;
    width: 100%;
}

/* Sidebar DxMenu — používa sa v NavMenu (body) aj v MainLayout footer; pravidlá globálne,
   lebo scoped CSS [b-xxx] nepokrýva DxMenu rendrovaný v rôznych komponentoch. */
.menu {
    --dxbl-menu-bottom-left-border-radius: 0;
    --dxbl-menu-bottom-right-border-radius: 0;
    --dxbl-menu-top-left-border-radius: 0;
    --dxbl-menu-top-right-border-radius: 0;
    --dxbl-menu-item-padding-x: 1.125rem;
    --dxbl-menu-item-padding-y: 0.5rem;
    --dxbl-menu-item-color: var(--dxds-color-content-neutral-default-static-dark-rest, var(--bs-white, #fff));
    --dxbl-menu-item-image-color: var(--dxds-color-content-neutral-default-static-dark-rest, var(--bs-white, #fff));
    --dxbl-menu-item-hover-bg: rgb(from var(--dxds-color-surface-neutral-default-static-light-rest, var(--bs-white, #fff)) r g b / 0.15);
    --dxbl-menu-item-hover-color: var(--dxds-color-content-neutral-default-static-dark-hovered, var(--bs-light, #ececec));
    --dxbl-menu-item-hover-image-color: var(--dxds-color-content-neutral-default-static-dark-hovered, var(--bs-light, #ececec));
    background: none;
}

.menu .dxbl-menu-item > .dxbl-btn {
    color: var(--dxds-color-content-neutral-default-static-dark-rest, var(--bs-white, #fff));
}

.menu-item-active {
    background-color: rgb(from var(--dxds-color-surface-neutral-default-static-light-rest, var(--bs-white, #fff)) r g b / 0.05);
}

/* Google Places Autocomplete dropdown sa renderuje do <body> Google API-om.
   DevExpress popup-y majú vysoký z-index — bez tohto by bol dropdown schovaný za DxPopup. */
.pac-container {
    z-index: 100000 !important;
}

/* DxGrid PopupEditForm size override pre adresy.
   DxGrid nemá builder Width/Height parameter ani separátny footer slot — buttons
   (.dxbl-grid-edit-form-buttons) sú interne za EditFormTemplate content (MCP overené).
   Riešenie: žiadny min-height (popup adaptuje na natural content) + flex layout
   v body, aby Save/Cancel držali spodok aj keby content nevyplnil priestor. */
.address-edit-popup {
    min-width: 800px;
}

.address-edit-popup .dxbl-modal-body {
    display: flex;
    flex-direction: column;
}

.address-edit-popup .dxbl-modal-body > .dxbl-grid-popup-edit-form,
.address-edit-popup .dxbl-grid-popup-edit-form > form {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.address-edit-popup .address-edit-form {
    flex: 1; /* form vyplní voľný priestor, buttons držia spodok */
}

.address-edit-popup .dxbl-grid-edit-form-buttons {
    margin-top: auto;
}

/* Úvodná stránka (LandingHome na Default tenante) */
.landing-home { max-width: 720px; margin: 0 auto; padding: 1rem 0 2rem; }
.landing-home h1 { margin-bottom: .5rem; }
.landing-home h2 { margin-top: 1.5rem; font-size: 1.15rem; }
.landing-obce { list-style: none; padding: 0; margin: .5rem 0; }
.landing-obce li { padding: .5rem .75rem; border: 1px solid var(--dxbl-border-color, #dee2e6); border-radius: .375rem; margin-bottom: .5rem; display: flex; align-items: center; gap: .5rem; }
.landing-obce a { font-weight: 600; text-decoration: none; }
.landing-obce a:hover { text-decoration: underline; }
.landing-badge { font-size: .75rem; padding: .1rem .5rem; border-radius: 1rem; background: var(--dxbl-gray-200, #e9ecef); color: var(--dxbl-gray-700, #495057); }
.landing-hint { font-size: .85rem; margin-top: .75rem; }

/* Matica — vizuálna čiara prechodu režimu (F5): prvý stĺpec novej verzie režimu. */
.rm-regime-start {
    border-left: 3px solid var(--dxds-color-border-primary-default-rest, var(--bs-primary, #0d6efd)) !important;
}
.rm-regime-caption { cursor: help; }
.rm-regime-flag {
    color: var(--dxds-color-content-primary-default-rest, var(--bs-primary, #0d6efd));
    margin-right: 0.15rem;
}

/* Popup verzie režimu (Nastavenia → Vykazovanie): DX popup edit form je defaultne úzky a s
   horizontálnymi popiskami stláča editory na 0 — širší popup + popisky nad editormi (vzor
   address-edit-popup). */
.regime-edit-popup {
    min-width: 760px;
}

/* Detail entity na samostatnej stránke (/admin/facilities/{id}, ADR „Detail zariadenia"):
   cesta + odznak stavu navrchu, záložky cez zvyšok výšky (viewport-calc ako .report-tab-content). */
.fd-head {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: .75rem;
}
.fd-crumbs {
    display: flex;
    align-items: baseline;
    gap: .4rem;
    font-size: .95rem;
}
.fd-crumbs .fd-current {
    font-weight: 600;
}
.fd-crumbs a {
    color: inherit;
    opacity: .7;
    text-decoration: none;
}
.fd-crumbs a:hover {
    opacity: 1;
    text-decoration: underline;
}
.fd-badge {
    font-size: .8rem;
    padding: .1rem .5rem;
    border-radius: 999px;
    border: 1px solid currentColor;
}
.fd-badge-active {
    color: var(--bs-success, #198754);
}
.fd-badge-inactive {
    color: var(--bs-secondary, #6c757d);
}
.fd-tab-content {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 230px);
    min-height: 360px;
    padding-top: .75rem;
}
.fd-info {
    overflow-y: auto;
    overflow-x: hidden; /* DxFormLayout má záporné okraje — bez toho vodorovný posuvník */
    max-width: 960px;
}
.fd-actions {
    display: flex;
    gap: .5rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

/* Detail zariadenia — záložka Analýza (graf). */
.fa-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: .75rem;
}
.fa-title {
    font-weight: 600;
    margin-bottom: .25rem;
}
.fa-tooltip-arg {
    font-weight: 600;
    margin-bottom: .15rem;
}
.fd-analytics {
    overflow-y: auto;
    overflow-x: hidden;
}
.fd-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    margin-bottom: .5rem;
}
.fd-month {
    width: 150px;
}
.fd-audit-changes {
    white-space: normal;
}
.fa-years {
    min-width: 220px;
}

/* Analytika obce (/admin/analytika). */
.ma-page {
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}
.ma-tiles-head {
    font-weight: 600;
    margin-bottom: .4rem;
}
.ma-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: .75rem;
    margin-bottom: 1.25rem;
}
.ma-tile {
    border: 1px solid var(--dxbl-border-color, #d6d6d6);
    border-radius: .375rem;
    padding: .6rem .8rem;
}
.ma-tile-label {
    font-size: .8rem;
    opacity: .75;
}
.ma-tile-value {
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1.3;
}
.ma-tile-pct {
    font-size: .9rem;
    font-weight: 400;
    opacity: .8;
}
.ma-tile-sub, .ma-tile-delta {
    font-size: .8rem;
}
.ma-up { color: #2e7d32; }
.ma-down { color: #c62828; }
.ma-topn {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    min-width: 200px;
    font-size: .85rem;
}
.ma-topn input[type=range] {
    accent-color: var(--dxbl-primary, #3b6fb6);
}
.ma-hint {
    font-size: .8rem;
    opacity: .75;
    margin: .25rem 0 .5rem;
}
.ma-grid .dxbl-grid-table tbody tr {
    cursor: pointer;
}

/* Najväčší platitelia — koláč + legenda (popup aj tlač). */
.tp-wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.5rem;
}
.tp-legend {
    border-collapse: collapse;
    font-size: .9rem;
}
.tp-legend td {
    padding: .2rem .4rem;
    vertical-align: middle;
}
.tp-legend tfoot td {
    border-top: 1px solid var(--dxbl-border-color, #d6d6d6);
    font-weight: 600;
}
.tp-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
}
.tp-swatch-others {
    outline: 1px solid #9e9e9e;
}
.tp-rank { font-weight: 600; text-align: right; }
.tp-name { max-width: 320px; }
.tp-num { text-align: right; white-space: nowrap; }
.tp-share { opacity: .75; }
.tp-note {
    margin-top: .75rem;
    font-size: .9rem;
}

.ma-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}
.ma-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem;
}
/* Koláče pre PDF — mimo obrazovky, ale v DOM (DevExtreme ich musí vykresliť). */
.ma-export-host {
    position: fixed;
    left: -10000px;
    top: 0;
    width: 900px;
    pointer-events: none;
}

/* Médiá (/admin/subory) — dxFileManager vypĺňa zvyšok okna. */
.media-manager {
    height: calc(100vh - 240px);
    min-height: 420px;
}
