/* Overlay full-screen documenti IDM obbligatori (MandatoryIdmComplianceOverlay).
   Copre l'intero portale con sfocatura e oscuramento: il contenuto sottostante
   non deve essere leggibile finche' il vendor non e' conforme. */

.vp-idmov-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    /* Fallback per browser senza backdrop-filter: quasi opaco */
    background: rgba(17, 24, 39, 0.96);
}

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
    .vp-idmov-backdrop {
        background: rgba(17, 24, 39, 0.55);
        -webkit-backdrop-filter: blur(26px) saturate(0.5);
        backdrop-filter: blur(26px) saturate(0.5);
    }
}

/* Modalita' gestione ("I Miei Documenti"): nessun oscuramento del portale
   (backdrop trasparente, il contenuto dietro resta visibile) MA modale:
   il backdrop intercetta i click, non si interagisce col portale finche'
   il popup non viene chiuso col pulsante dedicato. */
.vp-idmov-backdrop.vp-idmov-backdrop--light {
    background: transparent !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}

.vp-idmov-backdrop--light .vp-idmov-card {
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
    border: 1px solid #e5e7eb;
}

.vp-idmov-card {
    width: 100%;
    max-width: 820px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
    padding: 32px;
    font-family: inherit;
    color: #1f2937;
    animation: vp-idmov-in 0.25s ease-out;
}

@keyframes vp-idmov-in {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.vp-idmov-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 14px;
    padding: 16px 8px;
}

.vp-idmov-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
}

.vp-idmov-title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 600;
    color: #111827;
}

.vp-idmov-subtitle {
    margin: 6px 0 0;
    font-size: 0.95rem;
    line-height: 1.5;
    color: #4b5563;
}

.vp-idmov-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
}

.vp-idmov-icon--doc {
    background: #eff6ff;
    color: #0078d4;
}

.vp-idmov-icon--error {
    background: #fef2f2;
    color: #dc2626;
    font-size: 1.8rem;
}

.vp-idmov-icon--success {
    background: #ecfdf5;
    color: #059669;
    font-size: 1.8rem;
}

/* --- Righe documento --- */

.vp-idmov-rows {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.vp-idmov-row {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    transition: border-color 0.15s ease;
}

.vp-idmov-row--done {
    border-color: #a7f3d0;
    background: #f0fdf9;
}

.vp-idmov-row-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.vp-idmov-row-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1 1 auto;
    min-width: 0;
}

.vp-idmov-row-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
}

.vp-idmov-doctype {
    font-weight: 600;
    font-size: 1rem;
    color: #111827;
}

.vp-idmov-description {
    font-size: 0.85rem;
    color: #6b7280;
}

.vp-idmov-btn--sm {
    padding: 7px 14px;
    font-size: 0.82rem;
}

.vp-idmov-btn--xs {
    padding: 4px 10px;
    font-size: 0.75rem;
    border-radius: 6px;
}

.vp-idmov-state--valid {
    background: #d1fae5;
    color: #065f46;
}

/* --- Elenco documenti del requisito (scelta documento da visualizzare) --- */

.vp-idmov-doclist {
    margin: 10px 0;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 12px;
    background: #f9fafb;
}

.vp-idmov-doclist-title {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6b7280;
    margin-bottom: 8px;
}

.vp-idmov-doclist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-top: 1px solid #eef0f3;
}

.vp-idmov-doclist-item:first-of-type {
    border-top: none;
}

.vp-idmov-doclist-name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.85rem;
    color: #111827;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vp-idmov-doclist-date {
    font-size: 0.78rem;
    color: #6b7280;
    flex-shrink: 0;
}

/* Pannello upload inline per singolo documento (multi-documento) */

.vp-idmov-docupload {
    display: flex;
    flex-wrap: wrap;
    /* flex-end: il pulsante di conferma resta compatto e allineato alla base
       degli input, invece di stirarsi per tutta l'altezza del pannello. */
    align-items: flex-end;
    gap: 10px;
    padding: 10px 12px 12px 16px;
    border-top: 1px dashed #dbeafe;
    background: #f8fafc;
    border-radius: 8px;
    margin: 4px 0 8px;
}

/* Conferma upload per-documento: verde, distinto dal primario blu di Vedi/Upload globale */

.vp-idmov-btn--confirm {
    background: #059669;
    color: #ffffff;
}

.vp-idmov-btn--confirm:hover:not(:disabled) {
    background: #047857;
}

/* --- Viewer inline documento attuale (iframe: no popup blocker, no Save As) --- */

.vp-idmov-viewer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 31000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(17, 24, 39, 0.7);
}

.vp-idmov-viewer {
    display: flex;
    flex-direction: column;
    width: min(1100px, 96vw);
    height: calc(100vh - 80px);
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.vp-idmov-viewer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid #e5e7eb;
}

.vp-idmov-viewer-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: #111827;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vp-idmov-viewer iframe {
    border: 0;
    width: 100%;
    flex: 1;
}

.vp-idmov-viewer-close {
    border: none;
    background: transparent;
    font-size: 1.1rem;
    cursor: pointer;
    color: #6b7280;
    flex-shrink: 0;
}

.vp-idmov-viewer-close:hover {
    color: #111827;
}

.vp-idmov-row-inputs {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: stretch;
}

/* --- File picker --- */

.vp-idmov-file {
    position: relative;
    flex: 1 1 260px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1.5px dashed #93c5fd;
    border-radius: 10px;
    padding: 12px 14px;
    cursor: pointer;
    background: #f8fafc;
    transition: border-color 0.15s ease, background 0.15s ease;
    min-width: 0;
}

.vp-idmov-file:hover {
    border-color: #0078d4;
    background: #eff6ff;
}

.vp-idmov-file--selected {
    border-style: solid;
    border-color: #0078d4;
    background: #eff6ff;
}

.vp-idmov-file input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.vp-idmov-file-icon {
    font-size: 1.3rem;
    color: #0078d4;
    flex-shrink: 0;
}

.vp-idmov-file-text {
    font-size: 0.9rem;
    color: #374151;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Data scadenza --- */

.vp-idmov-date {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.8rem;
    color: #6b7280;
}

.vp-idmov-date input[type="date"] {
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.9rem;
    color: #111827;
    background: #ffffff;
}

.vp-idmov-date input[type="date"]:focus {
    outline: 2px solid #0078d4;
    outline-offset: -1px;
}

/* --- Stato riga / errori --- */

.vp-idmov-row-status {
    margin-top: 10px;
    font-size: 0.85rem;
}

.vp-idmov-row-status--ok {
    color: #059669;
}

.vp-idmov-row-status--err {
    color: #dc2626;
}

.vp-idmov-error {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    font-size: 0.9rem;
}

.vp-idmov-info {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1d4ed8;
    font-size: 0.9rem;
}

/* --- Stato per riga (ADR-MandatoryIdmDocumentApproval) --- */

.vp-idmov-state {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    /* Il badge non va MAI su due righe: con nomi file lunghi si accorcia
       il nome (ellipsis), non l'etichetta di stato. */
    white-space: nowrap;
    flex-shrink: 0;
}

.vp-idmov-state--missing {
    background: #fef3c7;
    color: #92400e;
}

.vp-idmov-state--pendingapproval {
    background: #e0e7ff;
    color: #3730a3;
}

.vp-idmov-state--rejected {
    background: #fee2e2;
    color: #991b1b;
}

.vp-idmov-state--expired {
    background: #ffedd5;
    color: #9a3412;
}

.vp-idmov-rejection {
    margin: 8px 0;
    padding: 10px 12px;
    border-radius: 8px;
    background: #fef2f2;
    border-left: 3px solid #dc2626;
    color: #7f1d1d;
    font-size: 0.85rem;
}

.vp-idmov-rejection strong {
    display: block;
    margin-bottom: 2px;
}

.vp-idmov-row-pending {
    padding: 8px 0;
    color: #4f46e5;
    font-size: 0.85rem;
    font-style: italic;
}

/* --- Footer --- */

.vp-idmov-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 22px;
}

.vp-idmov-hint {
    font-size: 0.82rem;
    color: #6b7280;
    flex: 1 1 240px;
}

.vp-idmov-btn {
    border: none;
    border-radius: 10px;
    padding: 12px 22px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.vp-idmov-btn--primary {
    background: #0078d4;
    color: #ffffff;
}

.vp-idmov-btn--primary:hover:not(:disabled) {
    background: #106ebe;
}

.vp-idmov-btn--secondary {
    background: #ffffff;
    border: 1px solid #d1d5db;
    color: #374151;
}

.vp-idmov-btn--secondary:hover:not(:disabled) {
    background: #f3f4f6;
}

.vp-idmov-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* --- Spinner --- */

.vp-idmov-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid #dbeafe;
    border-top-color: #0078d4;
    border-radius: 50%;
    animation: vp-idmov-spin 0.9s linear infinite;
}

.vp-idmov-spinner--small {
    width: 26px;
    height: 26px;
    border-width: 3px;
}

.vp-idmov-spinner--inline {
    width: 16px;
    height: 16px;
    border-width: 2px;
    border-color: rgba(255, 255, 255, 0.4);
    border-top-color: #ffffff;
}

@keyframes vp-idmov-spin {
    to { transform: rotate(360deg); }
}

/* --- Mobile --- */

@media (max-width: 560px) {
    .vp-idmov-card {
        padding: 20px;
    }

    .vp-idmov-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .vp-idmov-btn {
        justify-content: center;
    }
}


/* --- Banner preavviso scadenza documenti obbligatori (non bloccante) --- */

.vp-mdexp-banner {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9000;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 720px;
    padding: 10px 14px;
    border-radius: 10px;
    background: #fffbeb;
    border: 1px solid #fcd34d;
    color: #92400e;
    font-size: 0.85rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.vp-mdexp-icon {
    font-size: 1.1rem;
    line-height: 1.2;
}

.vp-mdexp-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.vp-mdexp-close {
    margin-left: auto;
    border: none;
    background: transparent;
    color: #92400e;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0 2px;
}

.vp-mdexp-close:hover {
    color: #451a03;
}

.vp-mdexp-banner--clickable {
    cursor: pointer;
}

.vp-mdexp-banner--clickable:hover {
    background: #fef3c7;
    border-color: #f59e0b;
}


/* --- Vista inline "My Documents" (MyMandatoryDocumentsComponent, dentro lo
   shell XAF: pattern Worker Dashboard). Riusa i badge/pulsanti vp-idmov-*. --- */

.vp-mydocs {
    padding: 8px 4px;
    color: #1f2937;
}

.vp-mydocs-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.vp-mydocs-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #111827;
}

.vp-mydocs-subtitle {
    margin: 6px 0 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #4b5563;
    max-width: 720px;
}

.vp-mydocs-loading {
    display: flex;
    justify-content: center;
    padding: 32px 0;
}

.vp-mydocs-table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    font-size: 0.9rem;
}

.vp-mydocs-table thead th {
    text-align: left;
    padding: 10px 14px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6b7280;
    white-space: nowrap;
}

.vp-mydocs-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f3f5;
    vertical-align: middle;
}

.vp-mydocs-table tbody tr:last-child td {
    border-bottom: none;
}

.vp-mydocs-name {
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
}

.vp-mydocs-desc {
    color: #6b7280;
    max-width: 320px;
}

.vp-mydocs-file {
    color: #374151;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vp-mydocs-expiry {
    white-space: nowrap;
}

.vp-mydocs-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    white-space: nowrap;
}

.vp-mydocs-upload-row td {
    background: #f8fafc;
    padding: 6px 14px 12px;
}

/* Mobile / viewport stretti: la tabella diventa un elenco di CARD impilate.
   L'etichetta di colonna viene dall'attributo data-label di ogni cella
   (gia' bilingue, renderizzato dal componente). */
@media (max-width: 860px) {
    .vp-mydocs-table {
        border: none;
        background: transparent;
    }

    .vp-mydocs-table thead {
        display: none;
    }

    .vp-mydocs-table,
    .vp-mydocs-table tbody,
    .vp-mydocs-table tr,
    .vp-mydocs-table td {
        display: block;
        width: 100%;
    }

    .vp-mydocs-table tbody tr {
        background: #ffffff;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        padding: 12px 14px;
        margin-bottom: 12px;
        box-sizing: border-box;
    }

    .vp-mydocs-table tbody td {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 12px;
        padding: 4px 0;
        border-bottom: none;
        box-sizing: border-box;
    }

    .vp-mydocs-table tbody td[data-label]::before {
        content: attr(data-label);
        flex-shrink: 0;
        font-size: 0.72rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        color: #6b7280;
    }

    .vp-mydocs-name,
    .vp-mydocs-desc,
    .vp-mydocs-file {
        text-align: right;
        max-width: none;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .vp-mydocs-actions {
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 8px;
        padding-top: 10px;
        white-space: normal;
    }

    .vp-mydocs-actions .vp-idmov-btn {
        flex: 1 1 auto;
        justify-content: center;
        padding: 8px 12px;
        font-size: 0.82rem;
    }

    /* Riga del pannello upload inline: card attaccata a quella del documento. */
    .vp-mydocs-upload-row {
        margin-top: -12px;
    }

    .vp-mydocs-upload-row td {
        padding: 0;
    }
}
