/* ============================================================================
 * Moduli Digitali - Layout Responsive, Mobile Review & Dialog Firma Digitale
 * ============================================================================ */

.btn:focus,
.btn:active,
.btn:focus-visible,
button:focus,
button:active,
button:focus-visible,
.nav-link:focus,
.nav-link:active,
.nav-link:focus-visible,
.btn-close:focus,
.btn-close:active,
.btn-close:focus-visible,
dialog.df-sig-dialog:focus,
dialog.df-sig-dialog:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

.df-sr-only {
    position: absolute;
    clip-path: inset(50%);
    overflow: hidden;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    white-space: nowrap;
}

.digital-forms-shell {
    --df-primary: #1e3c72;
    --df-accent: #2a5298;
}

/* Auto-sizing textareas per modern-web-guidance */
.df-auto-textarea {
    field-sizing: content;
    height: auto;
    width: 100%;
    min-block-size: 3lh;
    max-block-size: 12lh;
}

/* Responsive table wrapper con sticky header e angoli superiori arrotondati */
.table-wrapper {
    overflow: auto;
    max-inline-size: 100%;
    max-block-size: min(620px, 80vh);
    container-type: inline-size;
}

.table-wrapper table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}

.table-wrapper thead {
    position: sticky;
    inset-block-start: 0;
    z-index: 2;
}

.df-table-header {
    background: linear-gradient(135deg, #6f42c1 0%, #4a238b 100%);
}

.df-table-header th {
    background: transparent !important;
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.14) !important;
}

.df-table-rounded > table > thead > tr:first-child > th:first-child {
    border-top-left-radius: calc(1rem - 1px);
}

.df-table-rounded > table > thead > tr:first-child > th:last-child {
    border-top-right-radius: calc(1rem - 1px);
}

/* Anteprima firma nelle card */
.signature-preview-card {
    min-height: 110px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
}

[data-bs-theme="dark"] .signature-preview-card {
    background: #14161a;
    border-color: #495057;
}

[data-bs-theme="dark"] .signature-preview-card img {
    background: #ffffff;
    border-radius: 0.5rem;
    padding: 0.25rem;
}

/* Card sezione con titolo largo quanto il testo posizionato metà fuori e metà dentro su desktop */
.df-fieldset-card {
    position: relative;
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 1rem;
    padding: 1.25rem;
    margin-top: 1.15rem;
    margin-bottom: 1.85rem;
    box-shadow: 0 0.125rem 0.35rem rgba(15, 23, 42, 0.05);
}

.df-fieldset-card > legend.df-inner-legend {
    float: left;
    width: auto;
    max-width: 100%;
    padding: 0.65rem 1rem;
    margin-top: -1.25rem;
    margin-bottom: -0.35rem;
    transform: translateY(-50%);
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    box-shadow: 0 3px 8px rgba(15, 23, 42, 0.06);
    font-size: 0.98rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.df-fieldset-card > legend.df-inner-legend + * {
    clear: both;
}

.df-fieldset-card.df-reserved-card {
    border: 2px solid rgba(108, 117, 125, 0.35);
}

.df-fieldset-card.df-reserved-card > legend.df-inner-legend {
    background: #334155;
    border-color: #1e293b;
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.14);
}

[data-bs-theme="dark"] .df-fieldset-card {
    background: #1d2127;
    border-color: #30363d;
    box-shadow: 0 0.125rem 0.35rem rgba(0, 0, 0, 0.35);
}

[data-bs-theme="dark"] .df-fieldset-card > legend.df-inner-legend {
    background: #252a31;
    border-color: #3b424c;
    color: #e9ecef;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
}

[data-bs-theme="dark"] .df-fieldset-card.df-reserved-card {
    border-color: rgba(148, 163, 184, 0.35);
}

[data-bs-theme="dark"] .df-fieldset-card.df-reserved-card > legend.df-inner-legend {
    background: #0f172a;
    border-color: #334155;
    color: #f8fafc;
}

/* Accordion nativo (<details>/<summary>) per sezione (RISERVATO ZANCANER) */
.df-reserved-accordion {
    border: 2px solid rgba(108, 117, 125, 0.35);
    border-radius: 1rem;
    background-color: var(--bs-body-bg);
    overflow: hidden;
    box-shadow: 0 0.125rem 0.35rem rgba(15, 23, 42, 0.05);
}

[data-bs-theme="dark"] .df-reserved-accordion {
    background-color: #1d2127;
    border-color: rgba(148, 163, 184, 0.35);
    box-shadow: 0 0.125rem 0.35rem rgba(0, 0, 0, 0.35);
}

.df-reserved-summary {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    padding: 0.85rem 1.15rem;
    background-color: #334155;
    color: #ffffff;
    cursor: pointer;
    user-select: none;
    font-weight: 700;
    font-size: 0.94rem;
    transition: background-color 0.15s ease;
    outline: none !important;
    box-shadow: none !important;
}

.df-reserved-summary:hover {
    background-color: #273446;
}

[data-bs-theme="dark"] .df-reserved-summary {
    background-color: #0f172a;
    color: #f8fafc;
}

[data-bs-theme="dark"] .df-reserved-summary:hover {
    background-color: #172033;
}

.df-reserved-summary::-webkit-details-marker {
    display: none;
}

.df-reserved-summary-title {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.df-reserved-summary-title::before {
    content: "";
    inline-size: 0.95em;
    block-size: 0.95em;
    flex-shrink: 0;
    background-color: currentColor;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='black' fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708'/%3E%3C/svg%3E") no-repeat center / contain;
    rotate: -90deg;
}

details.df-reserved-accordion[open] > .df-reserved-summary .df-reserved-summary-title::before {
    rotate: 0deg;
}

@media (prefers-reduced-motion: no-preference) {
    .df-reserved-summary-title::before {
        transition: rotate 0.2s ease;
    }
}

details.df-reserved-accordion::details-content {
    interpolate-size: allow-keywords;
    overflow: clip;
    contain: layout;
}

details.df-reserved-accordion:not([open])::details-content {
    block-size: 0;
}

@media (prefers-reduced-motion: no-preference) {
    details.df-reserved-accordion::details-content {
        transition: block-size 0.28s ease-in-out, content-visibility 0.28s ease-in-out;
        transition-behavior: allow-discrete;
    }
}

.df-reserved-body {
    padding: 1.15rem;
    border-top: 1px solid rgba(108, 117, 125, 0.25);
}

@media (max-width: 767.98px) {
    .df-reserved-summary {
        padding: 0.75rem 0.95rem;
        font-size: 0.88rem;
    }

    .df-reserved-body {
        padding: 0.9rem;
    }
}

/* Griglia allegati Foto, Video e File MD_24 */
.df-att-dropzone {
    background-color: var(--bs-tertiary-bg);
    border: 1.5px dashed var(--bs-border-color);
    border-radius: 0.85rem;
    padding: 0.9rem 1rem;
}

.df-att-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
}

.df-att-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.85rem;
    background-color: var(--bs-body-bg);
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.05);
}

.df-att-thumb {
    height: 118px;
    background-color: var(--bs-tertiary-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 1px solid var(--bs-border-color);
}

.df-att-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Su smartphone evita leggende flottanti tagliate o sovrapposte su titoli lunghi */
@media (max-width: 767.98px) {
    .df-fieldset-card {
        padding: 0.9rem;
        margin-top: 0.5rem;
        margin-bottom: 1.15rem;
    }

    .df-fieldset-card > legend.df-inner-legend {
        float: none;
        display: flex;
        width: 100%;
        transform: none;
        margin-top: 0;
        margin-bottom: 0.85rem;
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
        line-height: 1.3;
        box-shadow: none;
    }
}

/* Tap targets ottimizzati per dispositivi touch (preservando i controlli filtro a 38px) */
@media (pointer: coarse) {
    .digital-forms-shell .df-form-editor input.form-control:not(.df-filter-control),
    .digital-forms-shell .df-form-editor select.form-select:not(.df-filter-control),
    .digital-forms-shell .btn-touch,
    dialog.df-sig-dialog input.form-control,
    dialog.df-sig-dialog .btn-touch {
        min-height: 46px;
        font-size: 0.95rem;
    }
}

.df-filter-control {
    height: 38px !important;
    min-height: 38px !important;
}

.df-filter-reset-btn {
    width: 100%;
}

@media (min-width: 1200px) {
    .df-filter-reset-btn {
        width: auto;
    }
}

.df-filter-search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

/* Badge interattivi riepilogo firme su Mobile Review (coerenti con le card elenco) */
.df-sig-badge-btn {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    transition: transform 0.12s ease, opacity 0.12s ease;
}

.df-sig-badge-btn:active {
    transform: scale(0.97);
}

/* Pulsanti e campi in attesa di traduzione AI */
.df-btn-ai-translate {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.df-btn-ai-translate:disabled {
    opacity: 0.55;
    pointer-events: auto;
    cursor: not-allowed;
}

.df-btn-ai-translating,
.df-btn-ai-translating:disabled {
    opacity: 0.85 !important;
    pointer-events: auto !important;
    cursor: wait !important;
}

@keyframes dfAiWaitPulse {
    0%, 100% { opacity: 0.78; }
    50% { opacity: 0.48; }
}

.df-field-translating {
    cursor: wait !important;
    animation: dfAiWaitPulse 1.2s ease-in-out infinite;
}

/* Popover azioni riga nello Storico Globale e nei menu compatti mobile */
[popover].df-actions-popover {
    min-width: 220px;
    max-width: min(290px, 92vw);
}

@supports (position-area: block-end) {
    [popover].df-actions-popover {
        inset: auto;
        margin: 0;
        margin-block-start: 4px;
        position-area: block-end span-inline-start;
        position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline;
    }
}

.df-popover-action-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.df-popover-action-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    min-height: 40px;
    padding: 0.45rem 0.75rem;
    border: 0;
    border-radius: 0.55rem;
    background: transparent;
    color: var(--bs-body-color);
    font-size: 0.88rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.12s ease;
}

.df-popover-action-item:hover {
    background-color: var(--bs-tertiary-bg);
}

.df-popover-action-item.text-danger:hover {
    background-color: rgba(220, 53, 69, 0.1);
}

/* ============================================================================
 * BARRA MOBILE A PILLOLE SCORREVOLI (Sostituisce le 5 KPI card su smartphone)
 * ============================================================================ */

@property --df-fade-start {
    syntax: "<length>";
    inherits: false;
    initial-value: 0px;
}

@property --df-fade-end {
    syntax: "<length>";
    inherits: false;
    initial-value: 0px;
}

.df-mobile-pillbar {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.5rem;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.15rem 0.1rem 0.35rem;
    scroll-snap-type: inline proximity;
    scroll-padding-inline: 1rem;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.df-mobile-pillbar::-webkit-scrollbar {
    display: none;
}

@supports (animation-timeline: scroll()) {
    .df-mobile-pillbar {
        --df-fade-size: 1.75rem;
        mask:
            linear-gradient(black, black) no-clip subtract,
            linear-gradient(to right, black, transparent) 0 0 / var(--df-fade-start) 100% no-repeat no-clip,
            linear-gradient(to right, transparent, black) 100% 0 / var(--df-fade-end) 100% no-repeat no-clip;
        animation: df-pillbar-fade-start linear both, df-pillbar-fade-end linear both;
        animation-timeline: scroll(self inline);
        animation-range: 0 var(--df-fade-size), calc(100% - var(--df-fade-size)) 100%;
    }

    @keyframes df-pillbar-fade-start {
        to { --df-fade-start: var(--df-fade-size); }
    }

    @keyframes df-pillbar-fade-end {
        from { --df-fade-end: var(--df-fade-size); }
    }
}

.df-mobile-pill {
    flex: none;
    scroll-snap-align: start;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-block-size: 40px;
    padding: 0.42rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--bs-border-color);
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.df-mobile-pill-compact {
    padding: 0.42rem 0.68rem;
    gap: 0.35rem;
}

.df-mobile-pill .df-pill-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4rem;
    height: 1.35rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    background-color: var(--bs-tertiary-bg);
    color: var(--bs-secondary-color);
}

.df-mobile-pill.df-pill-active {
    border-bottom-width: 3px;
    font-weight: 700;
}

.df-mobile-pill.df-pill-active.df-pill-purple {
    background-color: rgba(111, 66, 193, 0.14);
    border-color: rgba(111, 66, 193, 0.7);
    color: #59359a;
}

.df-mobile-pill.df-pill-active.df-pill-purple .df-pill-count {
    background-color: #6f42c1;
    color: #ffffff;
}

.df-mobile-pill.df-pill-active.df-pill-primary {
    background-color: rgba(13, 110, 253, 0.12);
    border-color: rgba(13, 110, 253, 0.7);
    color: #0a58ca;
}

.df-mobile-pill.df-pill-active.df-pill-primary .df-pill-count {
    background-color: #0d6efd;
    color: #ffffff;
}

.df-mobile-pill.df-pill-active.df-pill-success {
    background-color: rgba(25, 135, 84, 0.12);
    border-color: rgba(25, 135, 84, 0.7);
    color: #146c43;
}

.df-mobile-pill.df-pill-active.df-pill-success .df-pill-count {
    background-color: #198754;
    color: #ffffff;
}

.df-mobile-pill.df-pill-active.df-pill-info {
    background-color: rgba(13, 202, 240, 0.16);
    border-color: rgba(13, 202, 240, 0.75);
    color: #087990;
}

.df-mobile-pill.df-pill-active.df-pill-info .df-pill-count {
    background-color: #0dcaf0;
    color: #0f172a;
}

.df-mobile-pill.df-pill-active.df-pill-warning {
    background-color: rgba(255, 193, 7, 0.2);
    border-color: rgba(255, 193, 7, 0.85);
    color: #856404;
}

.df-mobile-pill.df-pill-active.df-pill-warning .df-pill-count {
    background-color: #ffc107;
    color: #0f172a;
}

[data-bs-theme="dark"] .df-mobile-pill.df-pill-active.df-pill-purple {
    color: #c29ffa;
}
[data-bs-theme="dark"] .df-mobile-pill.df-pill-active.df-pill-primary {
    color: #6ea8fe;
}
[data-bs-theme="dark"] .df-mobile-pill.df-pill-active.df-pill-success {
    color: #75b798;
}
[data-bs-theme="dark"] .df-mobile-pill.df-pill-active.df-pill-info {
    color: #6edff6;
}
[data-bs-theme="dark"] .df-mobile-pill.df-pill-active.df-pill-warning {
    color: #ffda6a;
}

/* ============================================================================
 * MOBILE REVIEW MODE, STORICO CARDS & STICKY BOTTOM BAR
 * ============================================================================ */

.df-review-shell,
.df-review-shell p,
.df-review-shell div,
.df-mobile-card {
    overflow-wrap: break-word;
}

.df-review-kv-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem 1rem;
}

@media (max-width: 399.98px) {
    .df-review-kv-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

.df-review-kv-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--bs-secondary-color);
    margin-bottom: 0.1rem;
}

.df-review-kv-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--bs-emphasis-color);
    line-height: 1.3;
}

.df-review-text-block {
    white-space: pre-line;
    font-size: 0.9rem;
    line-height: 1.48;
    color: var(--bs-body-color);
}

.df-sig-anchor {
    scroll-margin-top: 76px;
}

@media (max-width: 991.98px) {
    .df-has-sticky-bar {
        padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px)) !important;
    }

    html:has(.df-mobile-sticky-bar) {
        scroll-padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
    }
}

.df-mobile-sticky-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    background-color: var(--bs-body-bg);
    border-top: 1px solid var(--bs-border-color);
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.1);
    padding-top: 0.55rem;
    padding-bottom: max(0.6rem, env(safe-area-inset-bottom, 0px));
    padding-left: max(0.75rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.75rem, env(safe-area-inset-right, 0px));
}

[data-bs-theme="dark"] .df-mobile-sticky-bar {
    box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.45);
}

/* ============================================================================
 * DIALOG NATIVO FIRMA DIGITALE (<dialog>) & FOGLIO A TUTTO SCHERMO LANDSCAPE
 * ============================================================================ */

dialog.df-sig-dialog {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--bs-body-color);
    overflow: visible;
    width: min(92vw, 820px);
    max-width: 820px;
    max-height: 92dvh;
    margin: auto;
    border-radius: 1rem;
    box-shadow: 0 1.25rem 3rem rgba(15, 23, 42, 0.35);
}

/* Scope flex layout solo quando aperto (per guida dialog: mai display incondizionato) */
dialog.df-sig-dialog[open] {
    display: flex;
    flex-direction: column;
}

/* Regole obbligatorie scroll containment per prevent-page-scroll-under-modal-dialog */
dialog.df-sig-dialog:modal {
    overscroll-behavior: contain;
}

dialog.df-sig-dialog::backdrop {
    background: rgba(15, 23, 42, 0.72);
    overflow: hidden;
    overscroll-behavior: contain;
}

.df-sig-shell {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    border-radius: inherit;
    overflow: hidden;
}

.df-sig-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1.15rem;
    background-color: #111827;
    color: #ffffff;
    flex-shrink: 0;
}

.df-sig-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 1.15rem;
    background-color: var(--bs-tertiary-bg);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.df-sig-stage {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 220px;
}

.df-sig-canvas-box {
    position: relative;
    width: 100%;
    height: 240px;
    background-color: #ffffff !important;
    border: 2px dashed #64748b;
    border-radius: 0.85rem;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    overflow: hidden;
}

.df-sig-canvas-box canvas {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: block;
    background: transparent;
    touch-action: none;
    cursor: crosshair;
}

/* Guida visiva non esportata nel PNG */
.df-sig-guide {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    user-select: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 0 1.25rem 2.1rem;
}

.df-sig-watermark {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    color: rgba(100, 116, 139, 0.45);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-align: center;
    padding: 0 1rem;
}

.df-sig-baseline {
    width: 100%;
    border-bottom: 1.5px dashed rgba(100, 116, 139, 0.42);
    position: relative;
}

.df-sig-baseline::before {
    content: "×";
    position: absolute;
    left: 0.1rem;
    bottom: 0.15rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: rgba(100, 116, 139, 0.55);
    line-height: 1;
}

.df-sig-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.8rem 1.15rem;
    background-color: var(--bs-body-bg);
    border-top: 1px solid var(--bs-border-color);
    flex-shrink: 0;
}

.df-sig-rotate-hint {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.75rem;
    border-radius: 0.65rem;
    background-color: rgba(13, 110, 253, 0.08);
    border: 1px solid rgba(13, 110, 253, 0.22);
    color: var(--bs-emphasis-color);
    font-size: 0.78rem;
    font-weight: 500;
}

.df-sig-landscape-bar {
    display: none;
}

.df-sig-details-drawer {
    display: none;
}

/* Smartphone Verticale (Portrait): Sheet a pieno schermo con canvas elastico */
@media (max-width: 991.98px) and (orientation: portrait) {
    dialog.df-sig-dialog {
        width: 100dvw;
        height: 100dvh;
        max-width: 100dvw;
        max-height: 100dvh;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .df-sig-header {
        padding-top: max(0.75rem, env(safe-area-inset-top, 0px));
        padding-left: max(0.9rem, env(safe-area-inset-left, 0px));
        padding-right: max(0.9rem, env(safe-area-inset-right, 0px));
    }

    .df-sig-body {
        padding: 0.85rem max(0.85rem, env(safe-area-inset-right, 0px)) 0.85rem max(0.85rem, env(safe-area-inset-left, 0px));
        gap: 0.7rem;
    }

    .df-sig-rotate-hint {
        display: flex;
    }

    .df-sig-stage {
        flex: 1 1 auto;
        min-height: 220px;
    }

    .df-sig-canvas-box {
        flex: 1 1 auto;
        height: auto;
        min-height: 220px;
    }

    .df-sig-footer {
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
        padding-left: max(0.85rem, env(safe-area-inset-left, 0px));
        padding-right: max(0.85rem, env(safe-area-inset-right, 0px));
    }
}

/* Smartphone Orizzontale (Landscape): Modalità "Foglio a Tutto Schermo" (85-90% area di firma) */
@media (orientation: landscape) and (max-height: 560px) {
    dialog.df-sig-dialog {
        width: 100dvw;
        height: 100dvh;
        max-width: 100dvw;
        max-height: 100dvh;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .df-sig-portrait-only,
    .df-sig-rotate-hint {
        display: none !important;
    }

    .df-sig-landscape-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        min-height: 48px;
        padding: 0.35rem max(0.75rem, env(safe-area-inset-right, 0px)) 0.35rem max(0.75rem, env(safe-area-inset-left, 0px));
        background-color: #111827;
        color: #ffffff;
        flex-shrink: 0;
    }

    .df-sig-landscape-bar .btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 38px !important;
        padding-top: 0.25rem;
        padding-bottom: 0.25rem;
        white-space: nowrap;
    }

    .df-sig-landscape-bar .btn.df-sig-icon-btn {
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        flex-shrink: 0;
    }

    .df-sig-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
        padding: 0;
        gap: 0;
    }

    .df-sig-stage {
        flex: 1 1 auto;
        position: relative;
        min-height: 0;
        padding: 0.45rem max(0.65rem, env(safe-area-inset-right, 0px)) max(0.5rem, env(safe-area-inset-bottom, 0px)) max(0.65rem, env(safe-area-inset-left, 0px));
        background-color: var(--bs-tertiary-bg);
    }

    .df-sig-canvas-box {
        flex: 1 1 auto;
        height: auto;
        min-height: 0;
        width: 100%;
        border-radius: 0.65rem;
    }

    .df-sig-details-drawer {
        display: block;
        position: absolute;
        inset: 0;
        z-index: 12;
        overflow-y: auto;
        background-color: var(--bs-body-bg);
        padding: 0.85rem max(1rem, env(safe-area-inset-right, 0px)) max(0.85rem, env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-left, 0px));
    }
}

@media (orientation: landscape) and (max-height: 560px) and (max-width: 767.98px) {
    .df-sig-landscape-bar .btn.df-sig-icon-btn-sm {
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        flex-shrink: 0;
    }
}
