/*
 * Operational UI
 * Componenti riusabili per pagine operative, admin, report e aree di lavoro.
 * Le classi op-* sono il nuovo vocabolario; gli alias mantengono coerenti
 * le pagine gia' esistenti senza forzare refactor massivi.
 */

.op-page-header,
.pr-header-row {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    margin-bottom: 1rem;
    padding: 1rem 1.25rem;
}

.op-code,
.pr-code,
.pp-code,
.program-code {
    color: #0d6efd;
    font-size: .85rem;
    font-weight: 800;
}

.op-title,
.pr-title,
.pp-title,
.program-title {
    color: #1f2937;
    font-size: 1.05rem;
    font-weight: 700;
}

.op-meta,
.ob-meta,
.pp-meta {
    color: #6b7280;
    font-size: .8rem;
}

.op-info-box,
.info-box {
    background: #e7f3ff;
    border-left: 4px solid #0d6efd;
    margin-bottom: 1rem;
    padding: 1rem;
}

.op-alert-locked,
.alert-fase-chiusa {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
}

.op-state-badge,
.stato-badge {
    font-size: .875rem;
}

.op-char-counter,
.char-counter {
    background: #f8f9fa;
    border-radius: .25rem;
    font-size: .875rem;
    padding: .5rem;
}

.op-char-counter .text-danger,
.char-counter .text-danger {
    color: #dc3545;
}

.op-char-counter .text-success,
.char-counter .text-success {
    color: #198754;
}

.op-summary-tile,
.summary-tile,
.closure-kpi,
.regional-kpi {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    min-height: 100%;
    padding: .8rem .95rem;
}

.op-summary-value,
.summary-value,
.closure-kpi .value,
.regional-kpi-value {
    color: #1f2937;
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1.12;
}

.op-summary-label,
.summary-label,
.closure-kpi .label,
.regional-kpi-label {
    color: #6b7280;
    display: block;
    font-size: .8rem;
    margin-bottom: .2rem;
}

.op-item,
.ob-item,
.ql-item,
.report-indicator-card {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, .08);
    border-left: 3px solid #0d6efd;
    border-radius: 6px;
    margin-bottom: .6rem;
    padding: .75rem 1rem;
}

.op-item-regionale,
.ob-item.ob-origine-regionale,
.ql-item.ql-origine-regionale,
.ql-origine-regionale,
.report-indicator-card.ql-origine-regionale {
    background: #fffdf4;
    border-left-color: #ffc107;
}

.op-item-success,
.ob-item.ob-tracciante {
    background: #f2fbf7;
    border-left-color: #18a873;
}

.op-inline-code,
.ob-code,
.ql-code,
.indicator-codice,
tr.record .indicator-codice {
    color: #0d6efd;
    font-family: var(--bs-font-monospace);
    font-size: .85rem;
    font-weight: 700;
    margin-right: .5rem;
}

.op-description,
.ob-desc {
    font-size: .95rem;
}

.obiettivo-title-line {
    align-items: flex-start;
    display: flex;
    flex-wrap: wrap;
    gap: .25rem .35rem;
}

.ob-item .form-check-input:disabled {
    cursor: not-allowed;
    opacity: .45;
}

.op-empty,
.ql-empty,
.log-empty {
    color: #6b7280;
    font-style: italic;
    padding: .5rem;
}

.op-pill,
.ind-badge,
.ind-badge-tot,
.ql-badge-tipo,
.tracciante-tag {
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    font-weight: 700;
    line-height: 1.2;
    padding: .15rem .55rem;
}

.ind-badge,
.ind-badge-tot,
.ql-badge-tipo {
    background: #e9ecef;
    color: #495057;
}

.ind-badge.ok,
.ind-badge-tot.ok {
    background: #d1f5e3;
    color: #0f6e4b;
}

.ind-badge.warn,
.ind-badge-tot.warn {
    background: #fff3cd;
    color: #7a5a00;
}

.ind-badge.empty,
.ind-badge-tot.empty {
    background: #f8d7da;
    color: #842029;
}

.tracciante-tag {
    background: #18a873;
    color: #fff;
    margin-left: .5rem;
}

.tracciante-tag.tracciante-invalid {
    background: #dc3545;
}

.tracciante-icon {
    align-items: center;
    color: #0f6e4b;
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 1rem;
    height: 1.35rem;
    justify-content: center;
    width: 1.35rem;
}

.tracciante-icon-invalid {
    color: #842029;
}

.op-section,
.ql-section,
.regional-report-band {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    margin-bottom: 1rem;
    padding: 1rem 1.25rem;
}

.ql-section h5 {
    font-weight: 700;
    margin-bottom: .5rem;
}

.group-header td {
    background: #e7f3ff !important;
    color: #0d47a1;
    padding: .5rem .75rem !important;
}

tr.record {
    border-top: 1px solid rgba(0, 0, 0, .08);
}

tr.record .content-col {
    padding: .75rem;
}

tr.record.origine-regionale .content-col {
    border-left: 3px solid #ffc107;
}

.ind-summary-row {
    border-top: 1px solid #f0f0f0;
    padding: .25rem 0;
}

.ind-summary-row:first-of-type {
    border-top: 0;
}

.val-pill {
    align-items: center;
    background: #f1f3f5;
    border: 1px solid #adb5bd;
    border-radius: 999px;
    color: #212529;
    display: inline-flex;
    font-family: var(--bs-font-monospace);
    font-size: .82rem;
    font-weight: 700;
    justify-content: center;
    line-height: 1.2;
    max-width: 100%;
    min-width: 3.25rem;
    padding: .22rem .58rem;
    text-align: center;
    white-space: normal;
    word-break: break-word;
}

.val-pill.compilato {
    background: #0f5132;
    border-color: #0a3622;
    box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .18);
    color: #fff;
}

.val-pill.vuoto {
    background: #842029;
    border-color: #58151c;
    color: #fff;
}

.val-pill.nazionale {
    background: #084298;
    border-color: #052c65;
    color: #fff;
}

.val-pill.non-monitorato {
    background: #664d03;
    border-color: #533f03;
    color: #fff;
}

.indicatori-valori-page .ind-badge-tot,
.indicatori-specifici-page .ind-badge-tot {
    background: transparent;
    border: 0;
    color: #6b7280;
    font-weight: 700;
    padding: 0;
}

.indicatori-valori-page .val-pill,
.indicatori-valori-page .val-pill.compilato,
.indicatori-valori-page .val-pill.nazionale,
.indicatori-valori-page .val-pill.non-monitorato,
.indicatori-specifici-page .val-pill,
.indicatori-specifici-page .val-pill.compilato,
.indicatori-specifici-page .val-pill.nazionale,
.indicatori-specifici-page .val-pill.non-monitorato {
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    color: #495057;
    font-family: inherit;
    font-size: inherit;
    font-weight: 400;
    line-height: inherit;
    min-width: 0;
    padding: 0;
}

.indicatori-valori-page .val-pill.vuoto,
.indicatori-valori-page .val-pill:empty,
.indicatori-specifici-page .val-pill.vuoto,
.indicatori-specifici-page .val-pill:empty {
    display: none;
}

.indicator-warning {
    background: #fff8e1;
    border-left: 4px solid #ffc107;
}

.op-nav-card,
.pr-card {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, .08);
    border-radius: 6px;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    height: 100%;
    padding: 1rem;
    text-decoration: none;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.op-nav-card:hover,
.pr-card:hover {
    box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .08);
    color: inherit;
    text-decoration: none;
    transform: translateY(-2px);
}

.pr-card-disabled,
.pr-card-disabled:hover {
    box-shadow: none;
    color: #6b7280;
    cursor: not-allowed;
    transform: none;
}

.pr-card-header {
    align-items: center;
    display: flex;
    gap: .5rem;
    justify-content: space-between;
}

.pr-card-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
}

.pr-card-icon {
    font-size: 1.75rem;
    opacity: .85;
}

.pr-card-sub {
    color: #6b7280;
    font-size: .85rem;
}

.pr-badge-rag {
    border: 1px solid rgba(0, 0, 0, .1);
    border-radius: 50%;
    display: inline-block;
    min-height: 12px;
    min-width: 12px;
}

.rag-green {
    background: #18a873;
}

.rag-amber {
    background: #f2b705;
    color: #1b1b1b;
}

.rag-red {
    background: #d52b2b;
}

.rag-pipe {
    align-items: stretch;
    display: flex;
    flex-wrap: nowrap;
    gap: .35rem;
    overflow-x: hidden;
}

.rag-pipe-programmi {
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: .25rem;
}

.rag-step {
    border: 1px solid rgba(0, 0, 0, .08);
    border-radius: 6px;
    box-shadow: none;
    color: #fff;
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    justify-content: center;
    line-height: 1.15;
    min-height: 70px;
    min-width: 0;
    padding: .75rem .9rem;
    position: relative;
}

.rag-pipe-programmi .rag-step {
    min-width: 112px;
    padding: .65rem .72rem;
}

.rag-step::after {
    background: inherit;
    border: 1px solid rgba(0, 0, 0, .08);
    border-radius: 50%;
    content: "";
    height: 20px;
    position: absolute;
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    z-index: 2;
}

.rag-step:not(.first)::before {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, .08);
    border-radius: 50%;
    content: "";
    height: 20px;
    left: -10px;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    z-index: 1;
}

.rag-step:last-child::after {
    content: none;
}

.rag-title {
    align-items: center;
    display: flex;
    font-size: .9rem;
    font-weight: 700;
}

.rag-pipe-programmi .rag-title {
    font-size: .82rem;
}

.rag-sub {
    font-size: .8rem;
    margin-top: .25rem;
    opacity: .95;
}

.rag-pipe-programmi .rag-sub {
    font-size: .74rem;
}

.rag-title,
.rag-sub {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rag-amber .rag-title,
.rag-amber .rag-sub {
    color: #1b1b1b;
}

.rag-icon {
    font-size: 1rem;
    opacity: .95;
}

.pp-row {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, .08);
    border-radius: 6px;
    padding: .8rem 1rem;
}

.pp-row + .pp-row {
    margin-top: .6rem;
}

.anno-card {
    margin-bottom: 1rem;
}

.anno-top {
    align-items: center;
    display: inline-flex;
    gap: .65rem;
}

.anno-header {
    background: #0d6efd;
    border-radius: .5rem .5rem 0 0;
    color: #fff;
    display: inline-block;
    font-size: 1rem;
    font-weight: 700;
    padding: .4rem .75rem;
}

.anno-ref {
    background: #cfe2ff;
    border-radius: 999px;
    color: #0a58ca;
    font-family: var(--bs-font-monospace);
    font-size: .85rem;
    margin-left: .5rem;
    padding: .1rem .5rem;
}

.anno-card .card {
    border-top-left-radius: 0;
}

.format-field[hidden] {
    display: none !important;
}

.closure-summary {
    display: grid;
    gap: .75rem;
    grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
}

.closure-table th {
    white-space: nowrap;
}

.closure-table td {
    vertical-align: top;
}

.closure-notes {
    font-size: .86rem;
    margin: .35rem 0 0;
    padding-left: 1.1rem;
}

.closure-notes li + li {
    margin-top: .15rem;
}

@media (max-width: 991.98px) {
    .rag-pipe {
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: .35rem;
        padding-right: 16px;
    }

    .rag-step {
        min-width: clamp(135px, 45vw, 155px);
    }

    .closure-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 767.98px) {
    .rag-step {
        min-width: clamp(130px, 70vw, 150px);
    }
}

@media (max-width: 575.98px) {
    .closure-summary {
        grid-template-columns: 1fr;
    }
}
