/* DL3Support — correzioni responsive desktop, tablet e smartphone */
html {
    max-width: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

body.dl3-responsive {
    max-width: 100%;
    overflow-x: hidden;
}

body.dl3-responsive *,
body.dl3-responsive *::before,
body.dl3-responsive *::after {
    box-sizing: border-box;
}

body.dl3-responsive img,
body.dl3-responsive video,
body.dl3-responsive canvas,
body.dl3-responsive svg {
    max-width: 100%;
}

body.dl3-responsive .table-wrap {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
}

body.dl3-responsive input,
body.dl3-responsive select,
body.dl3-responsive textarea,
body.dl3-responsive button {
    max-width: 100%;
}

/* Dashboard */
@media (max-width: 820px) {
    body.dl3-dashboard-page .dashboard-header {
        position: relative;
        padding: 12px 14px;
        gap: 10px;
    }

    body.dl3-dashboard-page .brand-area {
        flex: 1 1 auto;
        min-width: 52px;
    }

    body.dl3-dashboard-page .user-info {
        flex: 0 1 auto;
        gap: 7px;
    }

    body.dl3-dashboard-page .main-container {
        width: 100%;
        padding: 18px 10px 38px;
    }

    body.dl3-dashboard-page .page-intro,
    body.dl3-dashboard-page .card {
        width: 100%;
        max-width: 100%;
    }

    body.dl3-dashboard-page .card-header,
    body.dl3-dashboard-page .card-body {
        padding-left: 14px;
        padding-right: 14px;
    }

    body.dl3-dashboard-page .form-grid,
    body.dl3-dashboard-page .delivery-fields,
    body.dl3-dashboard-page .implant-fields {
        grid-template-columns: 1fr !important;
    }

    body.dl3-dashboard-page input,
    body.dl3-dashboard-page select,
    body.dl3-dashboard-page textarea {
        font-size: 16px !important;
    }

    body.dl3-dashboard-page .orders-filter {
        padding: 14px;
        grid-template-columns: 1fr !important;
    }

    body.dl3-dashboard-page .filter-actions {
        grid-column: 1;
        justify-content: stretch;
    }

    body.dl3-dashboard-page .filter-button {
        flex: 1 1 135px;
        justify-content: center;
        min-height: 44px;
    }

    body.dl3-dashboard-page .orders-table-wrap {
        overflow: visible;
        padding: 10px;
        border-radius: 0 0 17px 17px;
    }

    body.dl3-dashboard-page .responsive-orders-table,
    body.dl3-dashboard-page .responsive-orders-table tbody,
    body.dl3-dashboard-page .responsive-orders-table tr,
    body.dl3-dashboard-page .responsive-orders-table td {
        display: block;
        width: 100%;
        min-width: 0;
    }

    body.dl3-dashboard-page .responsive-orders-table thead {
        display: none;
    }

    body.dl3-dashboard-page .responsive-orders-table tbody {
        padding: 0;
    }

    body.dl3-dashboard-page .responsive-orders-table tr {
        margin: 0 0 14px;
        overflow: hidden;
        background: #fff;
        border: 1px solid #dde6f0;
        border-radius: 15px;
        box-shadow: 0 8px 22px rgba(21, 37, 61, 0.07);
    }

    body.dl3-dashboard-page .responsive-orders-table tr:last-child {
        margin-bottom: 0;
    }

    body.dl3-dashboard-page .responsive-orders-table td {
        min-height: 45px;
        padding: 11px 13px;
        display: grid;
        grid-template-columns: minmax(90px, 32%) minmax(0, 1fr);
        align-items: start;
        gap: 10px;
        border-bottom: 1px solid #edf1f5;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    body.dl3-dashboard-page .responsive-orders-table td:last-child {
        border-bottom: 0;
    }

    body.dl3-dashboard-page .responsive-orders-table td::before {
        content: attr(data-label);
        color: #667085;
        font-size: 10px;
        font-weight: 850;
        line-height: 1.35;
        text-transform: uppercase;
        letter-spacing: .045em;
    }

    body.dl3-dashboard-page .responsive-orders-table td.col-qr {
        display: none;
    }

    body.dl3-dashboard-page .responsive-orders-table .actions {
        justify-content: flex-start;
        gap: 8px;
    }

    body.dl3-dashboard-page .responsive-orders-table .action-label {
        display: inline;
    }

    body.dl3-dashboard-page .responsive-orders-table .btn-azione {
        min-height: 42px;
        padding: 0 11px;
    }

    body.dl3-dashboard-page .modal-content,
    body.dl3-dashboard-page .modal-content.project-modal-content {
        width: calc(100vw - 24px) !important;
        max-width: calc(100vw - 24px) !important;
        max-height: calc(100vh - 24px);
        overflow-y: auto;
    }

    body.dl3-dashboard-page .odontogramma-wrapper {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 480px) {
    body.dl3-dashboard-page .logo-container {
        width: 52px;
        height: 52px;
        flex-basis: 52px;
        border-radius: 14px;
    }

    body.dl3-dashboard-page .logo-container img {
        width: 43px;
        height: 43px;
    }

    body.dl3-dashboard-page .admin-nav-link,
    body.dl3-dashboard-page .logout-link {
        width: 42px;
        min-width: 42px;
        height: 42px;
    }

    body.dl3-dashboard-page .user-profile {
        display: none;
    }

    body.dl3-dashboard-page .responsive-orders-table td {
        grid-template-columns: 82px minmax(0, 1fr);
        padding: 10px 11px;
    }
}

/* Studi e attività */
@media (max-width: 820px) {
    body.dl3-studi-page main,
    body.dl3-activity-page main,
    body.dl3-profile-page main {
        width: 100%;
        max-width: 100%;
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    body.dl3-studi-page header,
    body.dl3-activity-page header,
    body.dl3-profile-page header {
        gap: 10px;
        flex-wrap: wrap;
    }

    body.dl3-studi-page .stats-grid,
    body.dl3-studi-page .charts-grid,
    body.dl3-studi-page .form-grid,
    body.dl3-profile-page .form-grid,
    body.dl3-profile-page .grid {
        grid-template-columns: 1fr !important;
    }

    body.dl3-studi-page .card-header,
    body.dl3-profile-page .card-head,
    body.dl3-activity-page .intro {
        align-items: flex-start;
        flex-direction: column;
    }

    body.dl3-studi-page .card-actions,
    body.dl3-studi-page .actions,
    body.dl3-profile-page .header-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    body.dl3-studi-page .button,
    body.dl3-studi-page .action-button,
    body.dl3-profile-page .button,
    body.dl3-activity-page .action {
        min-height: 44px;
    }

    body.dl3-studi-page table {
        min-width: 760px;
    }

    body.dl3-studi-page input,
    body.dl3-studi-page select,
    body.dl3-studi-page textarea,
    body.dl3-profile-page input,
    body.dl3-profile-page select,
    body.dl3-profile-page textarea,
    body.dl3-activity-page input,
    body.dl3-activity-page select {
        font-size: 16px !important;
    }
}

/* Login, registrazione, recupero password */
@media (max-width: 780px) {
    body.dl3-login-page,
    body.dl3-registration-page,
    body.dl3-auth-page {
        min-height: 100svh;
        padding: 10px !important;
        align-items: flex-start !important;
    }

    body.dl3-login-page .login-shell,
    body.dl3-registration-page .auth-shell,
    body.dl3-auth-page .card {
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
        border-radius: 16px;
    }

    body.dl3-registration-page .form-grid {
        grid-template-columns: 1fr !important;
    }

    body.dl3-login-page input,
    body.dl3-registration-page input,
    body.dl3-registration-page select,
    body.dl3-registration-page textarea,
    body.dl3-auth-page input,
    body.dl3-auth-page select,
    body.dl3-auth-page textarea {
        font-size: 16px !important;
    }

    body.dl3-registration-page .form-panel,
    body.dl3-login-page .form-panel,
    body.dl3-auth-page .body {
        padding-left: 18px !important;
        padding-right: 18px !important;
    }
}

/* Informative e stato pubblico */
@media (max-width: 720px) {
    body.dl3-legal-page main,
    body.dl3-status-page main,
    body.dl3-status-page .card {
        width: 100%;
        max-width: 100%;
        margin-left: auto;
        margin-right: auto;
    }

    body.dl3-legal-page {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    body.dl3-legal-page .actions,
    body.dl3-status-page .meta {
        grid-template-columns: 1fr !important;
    }

    body.dl3-legal-page .button {
        width: 100%;
        justify-content: center;
    }
}


/* ============================================================
   CORREZIONE DEFINITIVA MARGINI DASHBOARD
   ============================================================ */

body.dl3-dashboard-page {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body.dl3-dashboard-page .dashboard-header,
body.dl3-dashboard-page .main-container,
body.dl3-dashboard-page .card,
body.dl3-dashboard-page .card-body,
body.dl3-dashboard-page .table-wrap {
    min-width: 0;
    max-width: 100%;
}

body.dl3-dashboard-page .main-container {
    width: min(100%, 1760px);
    padding-left: clamp(14px, 2vw, 34px);
    padding-right: clamp(14px, 2vw, 34px);
}

body.dl3-dashboard-page .table-card {
    overflow: hidden;
}

body.dl3-dashboard-page .orders-table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body.dl3-dashboard-page .responsive-orders-table {
    width: 100% !important;
    min-width: 0 !important;
    table-layout: fixed;
}

body.dl3-dashboard-page .responsive-orders-table th,
body.dl3-dashboard-page .responsive-orders-table td {
    min-width: 0;
    padding-left: 9px;
    padding-right: 9px;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
}

body.dl3-dashboard-page .responsive-orders-table th:nth-child(1),
body.dl3-dashboard-page .responsive-orders-table td:nth-child(1) {
    width: 7%;
}

body.dl3-dashboard-page .responsive-orders-table th:nth-child(2),
body.dl3-dashboard-page .responsive-orders-table td:nth-child(2) {
    width: 8%;
}

body.dl3-dashboard-page .responsive-orders-table th:nth-child(3),
body.dl3-dashboard-page .responsive-orders-table td:nth-child(3) {
    width: 8%;
}

body.dl3-dashboard-page .responsive-orders-table th:nth-child(4),
body.dl3-dashboard-page .responsive-orders-table td:nth-child(4) {
    width: 16%;
}

body.dl3-dashboard-page .responsive-orders-table th:nth-child(5),
body.dl3-dashboard-page .responsive-orders-table td:nth-child(5) {
    width: 4%;
    text-align: center;
}

body.dl3-dashboard-page .responsive-orders-table th:nth-child(6),
body.dl3-dashboard-page .responsive-orders-table td:nth-child(6),
body.dl3-dashboard-page .responsive-orders-table th:nth-child(7),
body.dl3-dashboard-page .responsive-orders-table td:nth-child(7) {
    width: 7%;
}

body.dl3-dashboard-page .responsive-orders-table th:nth-child(8),
body.dl3-dashboard-page .responsive-orders-table td:nth-child(8) {
    width: 8%;
}

body.dl3-dashboard-page .responsive-orders-table th:nth-child(9),
body.dl3-dashboard-page .responsive-orders-table td:nth-child(9) {
    width: 9%;
    min-width: 0;
}

body.dl3-dashboard-page .responsive-orders-table th:nth-child(10),
body.dl3-dashboard-page .responsive-orders-table td:nth-child(10) {
    width: 26%;
}

body.dl3-dashboard-page .qr-static {
    width: 86px;
    height: 86px;
    padding: 6px;
}

body.dl3-dashboard-page .qr-static img {
    width: 72px;
    height: 72px;
}

body.dl3-dashboard-page .responsive-orders-table .actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
    gap: 6px;
    white-space: normal;
}

body.dl3-dashboard-page .responsive-orders-table .actions form {
    width: 100%;
    min-width: 0;
    display: block;
}

body.dl3-dashboard-page .responsive-orders-table .btn-azione {
    width: 100%;
    min-width: 0;
    height: 36px;
    padding: 0 7px;
    gap: 5px;
    font-size: 10.5px;
    white-space: nowrap;
}

body.dl3-dashboard-page .responsive-orders-table .work-name,
body.dl3-dashboard-page .responsive-orders-table .studio-name,
body.dl3-dashboard-page .responsive-orders-table .patient-name,
body.dl3-dashboard-page .responsive-orders-table .order-id {
    overflow-wrap: anywhere;
}

body.dl3-dashboard-page .responsive-orders-table .work-color {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
}

body.dl3-dashboard-page .user-info {
    min-width: 0;
}

body.dl3-dashboard-page .user-profile {
    min-width: 0;
}

body.dl3-dashboard-page .user-profile strong {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Su laptop e tablet la tabella diventa una serie di schede.
   In questo modo non compare mai la barra orizzontale. */
@media (max-width: 1100px) {
    body.dl3-dashboard-page .dashboard-header {
        flex-wrap: wrap;
    }

    body.dl3-dashboard-page .orders-table-wrap {
        overflow: visible;
        padding: 10px;
    }

    body.dl3-dashboard-page .responsive-orders-table,
    body.dl3-dashboard-page .responsive-orders-table tbody,
    body.dl3-dashboard-page .responsive-orders-table tr,
    body.dl3-dashboard-page .responsive-orders-table td {
        display: block;
        width: 100%;
        min-width: 0;
    }

    body.dl3-dashboard-page .responsive-orders-table {
        table-layout: auto;
    }

    body.dl3-dashboard-page .responsive-orders-table thead {
        display: none;
    }

    body.dl3-dashboard-page .responsive-orders-table tbody {
        padding: 0;
    }

    body.dl3-dashboard-page .responsive-orders-table tr {
        margin: 0 0 14px;
        overflow: hidden;
        background: #fff;
        border: 1px solid #dde6f0;
        border-radius: 15px;
        box-shadow: 0 8px 22px rgba(21, 37, 61, 0.07);
    }

    body.dl3-dashboard-page .responsive-orders-table td {
        min-height: 45px;
        padding: 11px 13px;
        display: grid;
        grid-template-columns: minmax(105px, 30%) minmax(0, 1fr);
        align-items: start;
        gap: 10px;
        text-align: left;
        border-bottom: 1px solid #edf1f5;
    }

    body.dl3-dashboard-page .responsive-orders-table td::before {
        content: attr(data-label);
        color: #667085;
        font-size: 10px;
        font-weight: 850;
        line-height: 1.35;
        text-transform: uppercase;
        letter-spacing: .045em;
    }

    body.dl3-dashboard-page .responsive-orders-table td:last-child {
        border-bottom: 0;
    }

    body.dl3-dashboard-page .responsive-orders-table td.col-qr {
        display: none;
    }

    body.dl3-dashboard-page .responsive-orders-table .actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    body.dl3-dashboard-page .responsive-orders-table .btn-azione {
        min-height: 42px;
        font-size: 11px;
    }
}

@media (max-width: 560px) {
    body.dl3-dashboard-page .responsive-orders-table td {
        grid-template-columns: 88px minmax(0, 1fr);
        padding: 10px 11px;
    }

    body.dl3-dashboard-page .responsive-orders-table .actions {
        grid-template-columns: 1fr;
    }

    body.dl3-dashboard-page .responsive-orders-table .btn-azione {
        justify-content: flex-start;
        padding-left: 13px;
    }
}


/* ============================================================
   STATO DA STAMPARE - SFONDO ROSSO TENUE
   ============================================================ */

body.dl3-dashboard-page
.responsive-orders-table
tr.row-da-stampare {
    background: #fff1f0 !important;
    border-color: #f3c3bf !important;
    box-shadow:
        inset 5px 0 0 #d92d20,
        0 8px 22px rgba(180, 35, 24, 0.10) !important;
}

body.dl3-dashboard-page
.responsive-orders-table
tr.row-da-stampare
td {
    background: #fff1f0 !important;
}

body.dl3-dashboard-page
.responsive-orders-table
tr.row-da-stampare:hover
td {
    background: #ffe7e5 !important;
}

@media (max-width: 1100px) {
    body.dl3-dashboard-page
    .responsive-orders-table
    tr.row-da-stampare {
        background: #fff1f0 !important;
        border: 1px solid #f0aaa4 !important;
        box-shadow:
            inset 5px 0 0 #d92d20,
            0 8px 22px rgba(180, 35, 24, 0.11) !important;
    }

    body.dl3-dashboard-page
    .responsive-orders-table
    tr.row-da-stampare
    td {
        background: transparent !important;
    }
}

/* ============================================================
   CORREZIONE SMARTPHONE — CELLE DASHBOARD A LARGHEZZA COMPLETA
   Evita che le larghezze percentuali desktop comprimano i valori
   e facciano andare il testo a capo una lettera alla volta.
   ============================================================ */
@media (max-width: 1100px) {
    body.dl3-dashboard-page .responsive-orders-table th,
    body.dl3-dashboard-page .responsive-orders-table td,
    body.dl3-dashboard-page .responsive-orders-table th:nth-child(n),
    body.dl3-dashboard-page .responsive-orders-table td:nth-child(n) {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }

    body.dl3-dashboard-page .responsive-orders-table td {
        grid-template-columns: minmax(105px, 30%) minmax(0, 1fr);
        overflow-wrap: normal !important;
        word-break: normal !important;
    }

    body.dl3-dashboard-page .responsive-orders-table td > * {
        min-width: 0;
        max-width: 100%;
        overflow-wrap: break-word;
        word-break: normal;
    }

    body.dl3-dashboard-page .responsive-orders-table .order-id {
        white-space: nowrap;
        overflow-wrap: normal !important;
        word-break: keep-all !important;
    }

    body.dl3-dashboard-page .responsive-orders-table .studio-name,
    body.dl3-dashboard-page .responsive-orders-table .patient-name,
    body.dl3-dashboard-page .responsive-orders-table .work-name,
    body.dl3-dashboard-page .responsive-orders-table .work-color,
    body.dl3-dashboard-page .responsive-orders-table .teeth-value {
        max-width: 100%;
        overflow-wrap: break-word !important;
        word-break: normal !important;
    }

    body.dl3-dashboard-page .responsive-orders-table td:not([data-label]) {
        display: block;
    }

    body.dl3-dashboard-page .responsive-orders-table td:not([data-label])::before {
        display: none;
    }
}

@media (max-width: 560px) {
    body.dl3-dashboard-page .responsive-orders-table td {
        grid-template-columns: 92px minmax(0, 1fr);
        column-gap: 12px;
    }

    body.dl3-dashboard-page .responsive-orders-table .order-id {
        font-size: 13px;
    }
}


/* ============================================================
   RIFINITURA SMARTPHONE — DETTAGLI LAVORAZIONE LEGGIBILI
   Mantiene colore, fase e note nella colonna dei valori e usa
   tutta la larghezza disponibile senza spezzare le parole.
   ============================================================ */
@media (max-width: 560px) {
    body.dl3-dashboard-page
    .responsive-orders-table
    td[data-label="Lavorazione"] > .work-name,
    body.dl3-dashboard-page
    .responsive-orders-table
    td[data-label="Lavorazione"] > .work-color {
        grid-column: 2;
        width: 100%;
        max-width: none;
        min-width: 0;
        overflow-wrap: break-word !important;
        word-break: normal !important;
    }

    body.dl3-dashboard-page
    .responsive-orders-table
    td[data-label="Lavorazione"] > .work-color {
        display: flex;
    }
}
