/* Couche responsive commune à toutes les vues CRMINUBIL. */
html {
    max-width: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

body {
    max-width: 100%;
}

img, svg, video, canvas {
    max-width: 100%;
    height: auto;
}

input, select, textarea, button {
    max-width: 100%;
    font: inherit;
}

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

.table-responsive > table {
    margin-bottom: 0;
}

.whatsapp-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin-right: 5px;
    border-radius: 50%;
    color: #fff;
    background: #25D366;
    text-decoration: none;
    vertical-align: middle;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.whatsapp-link:hover,
.whatsapp-link:focus-visible {
    color: #fff;
    transform: scale(1.08);
    box-shadow: 0 3px 9px rgba(37, 211, 102, 0.35);
    outline: none;
}

.whatsapp-link.is-disabled {
    color: #fff;
    background: #9ca3af;
    box-shadow: none;
    cursor: not-allowed;
    pointer-events: none;
    opacity: 0.75;
}

.editable-cell.cell-saving {
    border-color: #d69e2e !important;
    box-shadow: 0 0 0 3px rgba(214, 158, 46, 0.16) !important;
}

.editable-cell.cell-saved {
    border-color: #2e7d32 !important;
    background-color: #edf8ee !important;
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.14) !important;
}

.editable-cell.cell-save-error {
    border-color: #c62828 !important;
    background-color: #fff1f1 !important;
    box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.14) !important;
}

/* La sauvegarde des tableaux est entièrement automatique. */
#saveBatchBtn {
    display: none !important;
}

.autosave-success-toast,
.autosave-error-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    width: min(390px, calc(100vw - 30px));
    padding: 14px 18px;
    border-radius: 10px;
    color: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.autosave-success-toast {
    background: #2e7d32;
}

.autosave-error-toast {
    background: #c62828;
}

@media (max-width: 992px) {
    body {
        overflow-x: hidden;
    }

    main {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
    }

    .sidebar:hover ~ main {
        margin-left: 0 !important;
    }

    .table-section,
    .form-section,
    .dashboard-container,
    .content-container,
    .settings-container {
        width: 100% !important;
        max-width: 100% !important;
    }

    .modal-content {
        width: min(94vw, 720px) !important;
        max-width: 94vw !important;
        max-height: 90vh;
        overflow-y: auto;
    }
}

@media (max-width: 768px) {
    main {
        padding-left: 14px !important;
        padding-right: 14px !important;
        padding-bottom: 86px !important;
    }

    .welcome-banner,
    .form-section,
    .table-section,
    .content-container,
    .settings-container {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .form-section,
    .modal-content,
    .content-container,
    .settings-container {
        padding: 20px !important;
    }

    .form-grid,
    .filter-grid-inputs,
    .settings-grid,
    .cards-grid,
    .stats-grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .full-width,
    .btn-submit-form,
    #filterFormation {
        grid-column: 1 / -1 !important;
    }

    .section-header,
    .table-header,
    .actions-bar,
    .search-actions {
        flex-wrap: wrap;
        gap: 10px;
    }

    .search-container,
    .search-box {
        width: 100% !important;
        max-width: none !important;
    }

    button,
    .btn,
    [class*="btn-"] {
        min-height: 42px;
    }

    .editing-hint {
        align-items: flex-start !important;
        line-height: 1.45;
    }

    .whatsapp-link {
        width: 32px;
        height: 32px;
    }
}

@media (max-width: 480px) {
    main {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    .welcome-banner,
    .form-section,
    .modal-content,
    .content-container,
    .settings-container {
        padding: 16px !important;
        border-radius: 12px !important;
    }

    .section-title,
    .page-title,
    h1 {
        overflow-wrap: anywhere;
    }

    .custom-table th,
    .custom-table td {
        padding: 7px 8px;
        font-size: 0.82rem;
    }
}
