/* ============================================================
 * PBI 9320 — poruke u zaglavlju aplikacije (Shared/HeaderMessageBar)
 * Port 1:1 iz design/Main.dc.html, Detalji.dc.html i Nivoi.dc.html.
 * Prefiks hm-. Učitava se globalno (_Host.cshtml) jer je traka na svakom ekranu.
 * Font Inter je globalno učitan u _Host.cshtml (Google Fonts).
 * ============================================================ */

/* ── Traka — redizajn (zahtjev operatera 16.11.2026): kompaktne kartice umjesto širokih traka.
 *    Isto mjesto (ispod gornjeg reda), ~40px po poruci, meke boje + tanak akcent lijevo,
 *    tipografija i radijusi kao ostale V2 stranice. Važno ostaje najuočljivije (crvena oznaka). ── */
.hm-region {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
    padding-top: 10px;
    padding-bottom: 2px;
    font-family: var(--is-font-sans, 'Plus Jakarta Sans', Inter, system-ui, sans-serif);
}
/* Širina = širina sadržaja trenutne stranice. js/header-messages.js izmjeri lijevi/desni rub sadržaja
   stranice nakon svakog renderovanja i upiše --hm-pl / --hm-pr. Dok mjerenje nije gotovo (ili nije moguće)
   koristi se zadani V2 razmak: .main > div 3rem / 1.5rem (site.css) + 28px, desno i skrol traka (--hm-sbw). */
.main > .hm-region {
    padding-left: var(--hm-pl, calc(3rem + 28px)) !important;
    padding-right: var(--hm-pr, calc(1.5rem + 28px + var(--hm-sbw, 0px))) !important;
}

.hm-bar {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    color: var(--is-fg-1, #1a1f2e);
    box-shadow: 0 1px 2px rgba(20, 28, 50, .04);
}
/* Akcent lijevo */
.hm-bar::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; }

.hm-bar--info { background: #F1F8FD; border-color: #D3E8F6; }
.hm-bar--info::before { background: #0494DA; }
.hm-bar--warn { background: #FFF8EC; border-color: #F4E0BC; }
.hm-bar--warn::before { background: #E8A33D; }
.hm-bar--crit { background: #FEF1F1; border-color: #F4CACA; }
.hm-bar--crit::before { background: #D92C2C; }

.hm-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 38px;
    padding: 0 6px 0 14px;
    border: 0;
    background: transparent;
    cursor: pointer;
    text-align: left;
    font: inherit;
    color: inherit;
}
.hm-main:hover .hm-more { text-decoration: underline; text-underline-offset: 3px; }
.hm-main:focus-visible,
.hm-close:focus-visible,
.hm-rest:focus-visible { outline: 2px solid #007BFF; outline-offset: -2px; border-radius: 6px; }

.hm-icon {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.hm-icon svg { width: 16px; height: 16px; }
.hm-bar--info .hm-icon { color: #0494DA; }
.hm-bar--warn .hm-icon { color: #C26A00; }
.hm-bar--crit .hm-icon { color: #D92C2C; }

/* Oznaka nivoa (pill) — ista u traci i u pregledu na ekranu administracije */
.hm-label {
    flex: 0 0 auto;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 999px;
    white-space: nowrap;
}
.hm-bar--info .hm-label { background: rgba(4, 148, 218, .12); color: #066894; }
.hm-bar--warn .hm-label { background: rgba(232, 163, 61, .20); color: #8A5200; }
.hm-bar--crit .hm-label { background: #D92C2C; color: #FFFFFF; }

.hm-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 13.5px;
    line-height: 1.4;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hm-bar--crit .hm-title { font-weight: 600; color: #8E2121; }

.hm-more {
    flex: 0 0 auto;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding-left: 6px;
}
.hm-more svg { width: 13px; height: 13px; }
.hm-bar--info .hm-more { color: #066894; }
.hm-bar--warn .hm-more { color: #8A5200; }
.hm-bar--crit .hm-more { color: #B42F2F; }

.hm-close {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    margin-right: 6px;
    border-radius: 6px;
    border: 0;
    background: transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--is-fg-3, #7a8395);
    padding: 0;
}
.hm-close svg { width: 15px; height: 15px; }
.hm-close:hover { background: rgba(20, 28, 50, .07); color: var(--is-fg-1, #1a1f2e); }

/* Važno nema × — rezerviše isto mjesto da „Detalji ›" ostane poravnat */
.hm-lock { width: 34px; flex: 0 0 34px; }

.hm-rest {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 26px;
    padding: 0 8px;
    margin-left: 4px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--is-brand-blue-700, #066894);
    font: 600 12.5px var(--is-font-sans, 'Plus Jakarta Sans', Inter, system-ui, sans-serif);
    cursor: pointer;
    text-align: left;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hm-rest svg { width: 14px; height: 14px; flex-shrink: 0; }
.hm-rest:hover { background: var(--is-brand-blue-100, #e6f4fb); }

/* ── Ikona poruka u gornjem redu + „+N" na traci (zahtjev operatera 22.11.2026) ──
 *    Na širem ekranu red „Prikaži sve / Još N poruka" ne zauzima mjesto: listu otvara megafon u gornjem
 *    redu (Shared/HeaderMessageTrigger), a višak poruka je „+N" na zadnjoj traci. Ispod 768px je gornji
 *    red sakriven (site.css), pa tamo ostaje stari red, a „+N" se ne prikazuje (bio bi duplikat). ── */
@media (min-width: 768px) {
    .hm-rest { display: none; }
    .main > .hm-region.hm-region--nobars { display: none; }
}
@media (max-width: 767.98px) {
    .hm-plus { display: none; }
}

.hm-plus {
    flex: 0 0 auto;
    align-self: center;
    height: 20px;
    min-width: 28px;
    padding: 0 7px;
    margin-right: 2px;
    border: 0;
    border-radius: 999px;
    background: rgba(20, 28, 50, .07);
    color: var(--is-fg-2, #4a5468);
    font: 700 11px var(--is-font-mono, 'JetBrains Mono', ui-monospace, Consolas, monospace);
    line-height: 20px;
    white-space: nowrap;
    cursor: pointer;
}
.hm-plus:hover { background: var(--is-brand-blue-100, #e6f4fb); color: var(--is-brand-blue-700, #066894); }
.hm-plus:focus-visible { outline: 2px solid #007BFF; outline-offset: 1px; }

/* Megafon: isti izgled kao susjedne ikone (Pomoć / Podrška / Šta je novo — goli <a> sa FA ikonom) */
.hm-trig-container { display: inline-flex; align-items: center; }
.hm-trig { display: inline-block; line-height: 1; }
.hm-trig:focus-visible { outline: 2px solid #007BFF; outline-offset: 3px; border-radius: 4px; }
.hm-trig__badge {
    position: absolute;
    top: -9px;
    right: -11px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border: 2px solid #f7f7f7; /* pozadina gornjeg reda (site.css .main .top-row) */
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: 700 10px var(--is-font-mono, 'JetBrains Mono', ui-monospace, Consolas, monospace);
    line-height: 1;
    color: #FFFFFF;
    box-sizing: content-box;
    pointer-events: none;
}
.hm-trig__badge--info { background: #0494DA; }
.hm-trig__badge--warn { background: #E8A33D; color: #3D2600; }
.hm-trig__badge--crit { background: #D92C2C; }

/* ── Dugme za link na traci i u listi (zahtjev operatera 22.11.2026) ──
 *    Odredište je samo polje Link. Boje su tamnije varijante nivoa, da bijeli tekst ima kontrast ≥ 4.5:1.
 *    Kad poruka ima link, „Detalji ›" na širem ekranu ide kao zasebno dugme IZA dugmeta za link
 *    (.hm-more--wide), a unutrašnji (.hm-more--narrow) se prikazuje samo na uskom ekranu. ── */
.hm-cta {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 220px;
    align-self: center;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 26px;
    padding: 0 10px;
    margin: 0 2px 0 4px;
    border: 0;
    border-radius: 6px;
    font: 600 12.5px var(--is-font-sans, 'Plus Jakarta Sans', Inter, system-ui, sans-serif);
    line-height: 26px;
    white-space: nowrap;
    text-decoration: none;
    color: #FFFFFF;
    cursor: pointer;
}
.hm-cta svg { width: 12px; height: 12px; flex-shrink: 0; }
.hm-cta__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.hm-cta:hover, .hm-cta:focus { color: #FFFFFF; text-decoration: none; }
.hm-cta:focus-visible { outline: 2px solid #1a1f2e; outline-offset: 2px; }
.hm-cta--info { background: #066894; }
.hm-cta--info:hover { background: #04506F; }
.hm-cta--warn { background: #8A5200; }
.hm-cta--warn:hover { background: #6B4000; }
.hm-cta--crit { background: #B42F2F; }
.hm-cta--crit:hover { background: #8E2121; }

button.hm-more--wide {
    align-self: stretch;
    border: 0;
    background: transparent;
    cursor: pointer;
    padding: 0 4px 0 6px;
    font-family: inherit;
}
button.hm-more--wide:hover { text-decoration: underline; text-underline-offset: 3px; }
button.hm-more--wide:focus-visible { outline: 2px solid #007BFF; outline-offset: -2px; border-radius: 6px; }
@media (min-width: 601px) {
    .hm-more--narrow { display: none; }
}

.hm-li-row .hm-cta { max-width: 190px; height: 30px; line-height: 30px; font-size: 13px; }

/* Uski ekran: oznaka + „Detalji ›" + × u prvom redu, naslov ispod (max 2 reda) */
@media (max-width: 600px) {
    .main > .hm-region { padding-left: 16px !important; padding-right: 16px !important; }
    .hm-bar { align-items: flex-start; }
    .hm-main {
        flex-wrap: wrap;
        gap: 4px 8px;
        padding: 8px 4px 8px 12px;
    }
    .hm-icon { display: none; }
    .hm-more { margin-left: auto; height: 28px; }
    .hm-title {
        order: 3;
        flex: 1 1 100%;
        padding-right: 8px;
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    .hm-close { margin: 6px 4px 0 0; }
    .hm-lock { width: 8px; flex: 0 0 8px; }

    /* Dugme za link ide u treći red, ispod naslova */
    .hm-bar:has(.hm-cta) { flex-wrap: wrap; }
    .hm-bar:has(.hm-cta) .hm-main { flex: 1 1 calc(100% - 44px); }
    .hm-bar .hm-cta { order: 10; max-width: calc(100% - 24px); margin: -2px 0 10px 12px; }
    button.hm-more--wide { display: none; }

    .hm-li-row { flex-wrap: wrap; }
    .hm-li-title { order: 3; flex: 1 1 100%; }
    .hm-li-open { margin-left: auto; }
    .hm-li-row .hm-cta { order: 4; max-width: 100%; }
}

/* ── Popup (postojeći InformationPopup, ModalCssClass="hm-dlg hm-dlg--…") ──
   Oznaka nivoa dolazi kroz CSS varijablu --hm-label (ModalContentStyle), meta red je ModalTitle;
   footer InformationPopup-a se skriva, a naš (Zatvori + link) je sticky na dnu sadržaja. */
.icon-info-modal:has(.hm-dlg) + .icon-info-modal-backdrop { background-color: rgba(20, 20, 30, .45); }

/* Uvijek tačno na sredini ekrana (vodoravno i okomito), kao ConfirmDeleteDialog (.cdd-modal). */
html body .custom-modal .modal-dialog.hm-dlg {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
    max-width: 660px; /* +10% (bilo 600px) */
    width: calc(100% - 32px);
    padding-top: 0;
    font-family: Inter, system-ui, sans-serif;
}

/* Lista svih poruka: široka (do 70% ekrana, najmanje kao popup detalja), da red sa naslovom, dugmetom za
   link i „Detalji" stane bez lomljenja (zahtjev operatera 22.11.2026). Na uskom ekranu ostaje 100% - 32px. */
html body .custom-modal .modal-dialog.hm-dlg.hm-dlg--list { max-width: max(660px, 70vw); }
html body .custom-modal .modal-dialog.hm-dlg.hm-dlg--list .modal-body { overflow-y: auto; }
html body .custom-modal .modal-dialog.hm-dlg.hm-dlg--list .hm-li-row .hm-cta { max-width: 280px; }

html body .custom-modal .modal-dialog.hm-dlg .modal-content {
    /* InformationPopup ima inline style="top: 70px" na .modal-content — to je pomjeralo popup 70px ispod
       sredine. Za popupe poruka se poništava (komponenta ostaje nepromijenjena). */
    top: 0 !important;
    border: 0;
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
    overflow: hidden;
    color: #1A1A1F;
}

html body .custom-modal .modal-dialog.hm-dlg .modal-header {
    display: flex !important;
    align-items: center;
    gap: 12px;
    margin: 0 !important;
    width: 100%;
    padding: 14px 14px 14px 20px; /* visina kao standardni popup (ConfirmDeleteDialog: 14px 20px + 32px X) */
    border-radius: 0;
    border-bottom: 1px solid #E5E5EA;
    background: #FFFFFF;
    color: #1A1A1F;
}
html body .custom-modal .modal-dialog.hm-dlg--info .modal-header { background: #E6F2FF; color: #1A1A1F; border-bottom: 2px solid #66B0FF; }
html body .custom-modal .modal-dialog.hm-dlg--warn .modal-header { background: #FDF0DC; color: #1A1A1F; border-bottom: 2px solid #E8A33D; }
html body .custom-modal .modal-dialog.hm-dlg--crit .modal-header { background: #B42F2F; color: #FFFFFF; border-bottom: 2px solid #8E2121; }

html body .custom-modal .modal-dialog.hm-dlg .modal-title {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none !important;
    margin: 0 !important;
    text-align: left !important;
    color: inherit !important;
    display: flex;
    align-items: center;
    gap: 12px;
    font: 600 14px/1.4 Inter, system-ui, sans-serif;
}

/* Detalji poruke: oznaka nivoa ispred meta reda */
html body .custom-modal .modal-dialog.hm-dlg--msg .modal-title::before {
    content: var(--hm-label);
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: 3px 9px;
    border-radius: 999px;
    white-space: nowrap;
}
html body .custom-modal .modal-dialog.hm-dlg--info .modal-title::before { background: #0056B3; color: #FFFFFF; }
html body .custom-modal .modal-dialog.hm-dlg--warn .modal-title::before { background: #C26A00; color: #FFFFFF; }
html body .custom-modal .modal-dialog.hm-dlg--crit .modal-title::before { background: #FFFFFF; color: #8E2121; }

/* Lista svih poruka: naslov u zaglavlju */
html body .custom-modal .modal-dialog.hm-dlg--list .modal-title { font: 700 17px/1.3 Inter, system-ui, sans-serif; }

html body .custom-modal .modal-dialog.hm-dlg .modal-header .modal-close-btn {
    position: static !important;
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    margin: 0 !important;
    padding: 0 !important;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: inherit !important;
    opacity: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-shadow: none;
    box-shadow: none !important;
}
html body .custom-modal .modal-dialog.hm-dlg .modal-header .modal-close-btn:hover { background: rgba(0, 0, 0, .08); }
html body .custom-modal .modal-dialog.hm-dlg .modal-header .modal-close-btn i { font-size: 15px; line-height: 1; color: inherit; }

html body .custom-modal .modal-dialog.hm-dlg .modal-body {
    padding: 0 !important;
    max-height: calc(100vh - 120px) !important;
    /* Tanak plavosivi scroll kao na ostalim V2 ekranima (isto kao drawer na /headermessages). */
    scrollbar-width: thin;
    scrollbar-color: #c3c9d4 transparent;
}
html body .custom-modal .modal-dialog.hm-dlg .modal-body::-webkit-scrollbar { width: 6px; height: 6px; }
html body .custom-modal .modal-dialog.hm-dlg .modal-body::-webkit-scrollbar-track { background: transparent; }
html body .custom-modal .modal-dialog.hm-dlg .modal-body::-webkit-scrollbar-thumb { background: #c3c9d4; border-radius: 999px; }
html body .custom-modal .modal-dialog.hm-dlg .modal-body::-webkit-scrollbar-thumb:hover { background: #9aa3b3; }
html body .custom-modal .modal-dialog.hm-dlg .modal-body::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
html body .custom-modal .modal-dialog.hm-dlg .modal-body > h6:empty { display: none; }
html body .custom-modal .modal-dialog.hm-dlg .modal-footer { display: none; }

.hm-dlg__body {
    padding: 22px 26px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.hm-dlg__title {
    margin: 0;
    font-size: 21px;
    line-height: 1.35;
    font-weight: 700;
    color: #1A1A1F;
    overflow-wrap: anywhere;
}
/* Tekst iz textarea — redovi i nabrajanja ostaju (nikad HTML) */
.hm-dlg__text {
    margin: 0;
    font-size: 16px;
    line-height: 1.6;
    color: #2A2A30;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.hm-dlg__foot {
    position: sticky;
    bottom: 0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px 20px; /* kao ConfirmDeleteDialog footer */
    border-top: 1px solid #E5E5EA;
    background: #FFFFFF;
}
.hm-dlg__foot--plain { border-top: 0; }

.hm-btn-p,
.hm-btn-s {
    height: 36px; /* standardna visina dugmeta u popupu (.cdd-btn) */
    padding: 0 14px;
    border-radius: 6px;
    font: 600 13px Inter, system-ui, sans-serif;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    cursor: pointer;
    text-decoration: none;
}
.hm-btn-p { border: 0; background: #007BFF; color: #FFFFFF; }
.hm-btn-p:hover { background: #0069D9; color: #FFFFFF; text-decoration: none; }
.hm-btn-s { border: 1px solid #B8B8C0; background: #FFFFFF; color: #1A1A1F; }
.hm-btn-s:hover { background: #F5F5F7; }
.hm-btn-p svg { flex-shrink: 0; }
.hm-btn__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* Lista svih poruka */
.hm-li-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    border-bottom: 1px solid #E5E5EA;
}
.hm-li-chip {
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: 3px 9px;
    border-radius: 999px;
    white-space: nowrap;
}
.hm-li-chip--info { background: #E6F2FF; color: #0056B3; }
.hm-li-chip--warn { background: #FDF0DC; color: #7A4200; }
.hm-li-chip--crit { background: #B42F2F; color: #FFFFFF; }
.hm-li-title {
    flex: 1;
    min-width: 0;
    font-size: 15px;
    line-height: 1.45;
    color: #1A1A1F;
    overflow-wrap: anywhere;
}
.hm-li-open {
    border: 0;
    background: none;
    color: #0056B3;
    font: 700 14px Inter, system-ui, sans-serif;
    cursor: pointer;
    white-space: nowrap;
    height: 32px;
    padding: 0 8px;
    border-radius: 6px;
}
.hm-li-open:hover { background: #E6F2FF; }
