/* Diário Oficial — boletins como documento institucional */

.dio-page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem 1.5rem;
    margin-bottom: 1.15rem;
}

.dio-page-intro {
    flex: 1 1 240px;
    min-width: 0;
}

.dio-page-intro .inst-lead {
    margin-bottom: 0;
}

.dio-search {
    flex: 0 0 auto;
    margin: 0;
    margin-left: auto;
    text-align: right;
}

.dio-search-label {
    display: block;
    margin: 0 0 0.4rem;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #cbd5e1;
}

.dio-search-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: stretch;
    justify-content: flex-end;
}

.dio-search-input {
    flex: 0 1 200px;
    min-width: 0;
    width: 200px;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    border: 1px solid #94a3b8;
    background: #ffffff;
    color: #0f172a;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
}

.dio-search-input::placeholder {
    color: #475569;
    opacity: 1;
}

.dio-search-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.dio-search-btn,
.dio-search-clear {
    padding: 0.55rem 0.95rem;
    border-radius: 8px;
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
}

.dio-search-btn {
    background: #1e3a5f;
    color: #f8fafc;
}

.dio-search-btn:hover {
    background: #274874;
}

.dio-search-clear {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.14);
    color: #e2e8f0;
}

.dio-search-clear:hover {
    background: rgba(255, 255, 255, 0.12);
}

.dio-search-msg {
    margin: 0.45rem 0 0;
    font-size: 0.82rem;
    color: #94a3b8;
    text-align: right;
}

.dio-search-msg.is-err {
    color: #f87171;
}

@media (max-width: 640px) {
    .dio-search {
        width: 100%;
        margin-left: 0;
        text-align: left;
    }

    .dio-search-row {
        justify-content: flex-start;
    }

    .dio-search-input {
        flex: 1 1 auto;
        width: auto;
        max-width: none;
    }

    .dio-search-msg {
        text-align: left;
    }
}

#diario-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.dio-sheet {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    box-sizing: border-box;
    padding: 1.5rem 1.6rem 1.7rem;
    border-radius: 14px;
    background:
        linear-gradient(180deg, rgba(255, 252, 245, 0.97) 0%, rgba(248, 241, 230, 0.98) 100%);
    border: 1px solid rgba(180, 150, 110, 0.35);
    box-shadow:
        0 14px 36px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.55);
    color: #1e293b;
    position: relative;
}

.dio-sheet::before {
    content: "";
    position: absolute;
    inset: 10px;
    border: 1px solid rgba(148, 120, 80, 0.18);
    border-radius: 10px;
    pointer-events: none;
}

.dio-doc-head {
    position: relative;
    margin-bottom: 0;
    padding-bottom: 0.9rem;
    border-bottom: 1.5px solid rgba(100, 80, 50, 0.28);
}

.dio-boletim-num {
    margin: 0.35rem 0 0.85rem;
    text-align: right;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: #64748b;
    line-height: 1;
}

.dio-org {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.dio-org-logo {
    width: 64px;
    height: 74px;
    object-fit: contain;
    flex-shrink: 0;
    background: transparent;
}

.dio-org-text {
    min-width: 0;
}

.dio-org-title {
    margin: 0;
    font-family: "Oswald", "Arial Narrow", sans-serif;
    font-size: clamp(0.82rem, 2vw, 1.05rem);
    font-weight: 600;
    letter-spacing: 0.04em;
    line-height: 1.2;
    color: #0f172a;
    text-transform: uppercase;
}

.dio-org-sub {
    margin: 0.2rem 0 0;
    font-size: 0.82rem;
    font-weight: 500;
    color: #64748b;
}

.dio-parts {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.dio-part-label {
    margin: 0 0 0.25rem;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #0f172a;
}

.dio-part-body {
    margin: 0;
    font-family: "Caveat", "Segoe Script", cursive;
    font-size: 1.35rem;
    font-weight: 500;
    line-height: 1.35;
    color: #1e3a8a;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Assinatura à direita, como no papel */
.dio-sign {
    position: relative;
    margin: 1.75rem 0.5rem 0.35rem auto;
    width: min(100%, 240px);
    text-align: center;
    padding-top: 0.35rem;
    box-sizing: border-box;
}

.dio-sign-label {
    margin: 0 0 0.45rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #64748b;
}

.dio-sign-name {
    margin: 0 0 0.15rem;
    font-family: "Caveat", "Segoe Script", cursive;
    font-size: 1.7rem;
    font-weight: 600;
    line-height: 1.2;
    color: #1e3a8a;
    transform: rotate(-2deg);
    white-space: pre-wrap;
    word-break: break-word;
}

.dio-sign-line {
    display: block;
    width: 100%;
    height: 1px;
    margin-top: 0.15rem;
    background: rgba(100, 80, 50, 0.45);
}

.dio-sign-date {
    margin: 0.4rem 0 0;
    font-size: 0.82rem;
    font-weight: 500;
    color: #475569;
}

/* Paginação — Anterior / páginas / Próxima */
.dio-actions {
    display: flex;
    justify-content: center;
    margin: 1.1rem auto 0;
    max-width: 720px;
}

.dio-pdf-btn {
    padding: 0.55rem 1.15rem;
    border-radius: 8px;
    border: 1px solid rgba(185, 28, 28, 0.45);
    background: rgba(185, 28, 28, 0.9);
    color: #fff;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
}

.dio-pdf-btn:hover:not(:disabled) {
    background: #b91c1c;
}

.dio-pdf-btn:disabled {
    opacity: 0.65;
    cursor: wait;
}

/* Host fora do ecrã para captura limpa do PDF (evita offset do scroll) */
.dio-pdf-export-host {
    position: fixed;
    left: -10000px;
    top: 0;
    width: 680px;
    padding: 0;
    margin: 0;
    z-index: 0;
    pointer-events: none;
    overflow: visible;
    background: #fffaf0;
}

.dio-sheet--export {
    margin: 0 !important;
    max-width: none !important;
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 1.35rem 1.6rem 1.5rem !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
}

.dio-sheet--export::before {
    display: none !important;
}

.dio-sheet--export .dio-sign {
    margin-right: 0.35rem;
    max-width: 220px;
}

.dio-sheet--export .dio-sign-name {
    transform: none !important;
}

.dio-pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    margin: 1rem auto 0;
    max-width: 720px;
}

.dio-pager-nav,
.dio-pager-num {
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
}

.dio-pager-nav {
    padding: 0.55rem 0.95rem;
    border: 1px solid transparent;
    background: #1e3a5f;
    color: #f8fafc;
}

.dio-pager-nav:hover:not(:disabled) {
    background: #274874;
}

.dio-pager-nav:disabled {
    background: #e8e8e8;
    color: #b0b0b0;
    border-color: #e0e0e0;
    cursor: not-allowed;
}

.dio-pager-nums {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

.dio-pager-num {
    min-width: 2.35rem;
    height: 2.35rem;
    padding: 0 0.45rem;
    border: 1px solid #d4d4d4;
    background: #ffffff;
    color: #1e293b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.dio-pager-num:hover:not(.is-active) {
    border-color: #94a3b8;
    background: #f8fafc;
}

.dio-pager-num.is-active {
    background: #1e3a5f;
    border-color: #1e3a5f;
    color: #ffffff;
    cursor: default;
}

@media (max-width: 560px) {
    .dio-sheet {
        padding: 1.15rem 1.05rem 1.35rem;
    }

    .dio-org-logo {
        width: 54px;
        height: 62px;
    }

    .dio-sign {
        width: min(100%, 200px);
        margin-right: 0;
    }

    .dio-pager-nav {
        padding: 0.5rem 0.7rem;
        font-size: 0.82rem;
    }
}

/* Impressão / Salvar como PDF (fallback do browser) */
@media print {
    body[data-page="diario-oficial"] .site-header,
    body[data-page="diario-oficial"] .site-footer,
    body[data-page="diario-oficial"] .site-nav,
    body[data-page="diario-oficial"] .notif-bell,
    body[data-page="diario-oficial"] .dio-page-head,
    body[data-page="diario-oficial"] .dio-actions,
    body[data-page="diario-oficial"] .dio-pager,
    body[data-page="diario-oficial"] .a11y-toolbar,
    body.dio-export-print .site-header,
    body.dio-export-print .site-footer,
    body.dio-export-print .dio-page-head,
    body.dio-export-print .dio-actions,
    body.dio-export-print .dio-pager {
        display: none !important;
    }

    body[data-page="diario-oficial"],
    body[data-page="diario-oficial"] .inst-wrap,
    body[data-page="diario-oficial"] .inst-card,
    body[data-page="diario-oficial"] #diario-list {
        background: #fff !important;
        background-image: none !important;
        box-shadow: none !important;
        border: none !important;
        margin: 0 !important;
        padding: 0 !important;
        max-width: none !important;
        color: #000 !important;
    }

    body[data-page="diario-oficial"] .dio-sheet {
        box-shadow: none !important;
        max-width: none !important;
        margin: 0 !important;
        border-radius: 0 !important;
        break-inside: avoid;
    }

    body[data-page="diario-oficial"] .dio-sheet::before {
        display: none;
    }
}
