/* Custom DataTables styling — Suivi Stagiaires plugin
   All tables: fit container width, wrap text, no horizontal scroll, nothing clipped on the right.
*/
:root {
    --ss-dt-bg: #ffffff;
    --ss-dt-border: #e6e9ef;
    --ss-dt-accent: #0d6efd;
    --ss-dt-muted: #6c757d;
    --ss-dt-actions-width: 104px;
    --ss-dt-col-xs: 2.5rem;
    --ss-dt-col-id: 3.25rem;
    --ss-dt-col-narrow: 3.875rem;
    --ss-dt-col-date: 5.5rem;
    --ss-dt-col-status: 6rem;
    --ss-dt-col-phone: 6.75rem;
    --ss-dt-col-action: 3.25rem;
}

/* ── Contain tables inside the card (no overflow past the right edge) ── */
.dataTables_wrapper,
.dataTables_wrapper .dataTables_scroll,
.dataTables_wrapper .dataTables_scrollHead,
.dataTables_wrapper .dataTables_scrollBody,
.table-wrapper-padding,
.ss-dt-table-shell,
.ss-dt-table-shell > .table-wrapper-padding,
.table-responsive,
.ss-gestion-page .ss-gestion-ref-table-card .card-body {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
    overflow-x: hidden !important;
    overflow-y: visible;
}

.dataTables_wrapper table.dataTable,
.dataTables_wrapper table.dataTable.table,
table.dataTable,
table.display {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    border-collapse: separate !important;
    border-spacing: 0;
    background: var(--ss-dt-bg);
    border: 1px solid var(--ss-dt-border);
    box-shadow: 0 1px 2px rgba(13, 110, 253, 0.03);
    font-size: 14px;
    table-layout: fixed !important;
}

/* Default / long text columns — share remaining width */
.dataTables_wrapper table.dataTable thead th.ss-dt-col-flex,
.dataTables_wrapper table.dataTable tbody td.ss-dt-col-flex,
table.dataTable thead th.ss-dt-col-flex,
table.dataTable tbody td.ss-dt-col-flex,
.dataTables_wrapper table.dataTable thead th:not(.table-actions):not([class*="ss-dt-col-"]),
.dataTables_wrapper table.dataTable tbody td:not(.table-actions):not([class*="ss-dt-col-"]) {
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    overflow: hidden !important;
    min-width: 0 !important;
    width: auto !important;
    max-width: none !important;
    box-sizing: border-box !important;
    vertical-align: middle;
}

/* Stagiaires list — auto layout, wrap text, no horizontal overflow */
.ss-stagiaires-page #stagiaires-table,
.ss-stagiaires-page .dataTables_wrapper table.dataTable#stagiaires-table {
    table-layout: auto !important;
}

.ss-stagiaires-page #stagiaires-table thead th,
.ss-stagiaires-page #stagiaires-table tbody td,
.ss-stagiaires-page .dataTables_wrapper #stagiaires-table thead th,
.ss-stagiaires-page .dataTables_wrapper #stagiaires-table tbody td {
    min-width: 0 !important;
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    overflow: hidden !important;
    text-overflow: clip !important;
}

.ss-stagiaires-page #stagiaires-table thead th.table-actions,
.ss-stagiaires-page #stagiaires-table tbody td.table-actions,
.ss-stagiaires-page #stagiaires-table thead th[data-col='cv'],
.ss-stagiaires-page #stagiaires-table tbody td:nth-child(14),
.ss-stagiaires-page #stagiaires-table thead th[data-col='inscrit'],
.ss-stagiaires-page #stagiaires-table thead th[data-col='present'],
.ss-stagiaires-page #stagiaires-table tbody td:nth-child(12),
.ss-stagiaires-page #stagiaires-table tbody td:nth-child(13),
.ss-stagiaires-page .dataTables_wrapper #stagiaires-table thead th.table-actions,
.ss-stagiaires-page .dataTables_wrapper #stagiaires-table tbody td.table-actions,
.ss-stagiaires-page .dataTables_wrapper #stagiaires-table thead th[data-col='cv'],
.ss-stagiaires-page .dataTables_wrapper #stagiaires-table tbody td:nth-child(14),
.ss-stagiaires-page .dataTables_wrapper #stagiaires-table thead th[data-col='inscrit'],
.ss-stagiaires-page .dataTables_wrapper #stagiaires-table thead th[data-col='present'],
.ss-stagiaires-page .dataTables_wrapper #stagiaires-table tbody td:nth-child(12),
.ss-stagiaires-page .dataTables_wrapper #stagiaires-table tbody td:nth-child(13) {
    white-space: nowrap !important;
}

/* Civilité (M. / Mme / Mlle) — smallest */
table.dataTable thead th.ss-dt-col-xs,
table.dataTable tbody td.ss-dt-col-xs {
    width: var(--ss-dt-col-xs) !important;
    min-width: var(--ss-dt-col-xs) !important;
    max-width: var(--ss-dt-col-xs) !important;
    padding: 0.3rem 0.2rem !important;
    white-space: nowrap !important;
    text-align: center !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    font-size: 0.75rem !important;
    line-height: 1.2 !important;
}

table.dataTable thead th.ss-dt-col-xs {
    font-size: 0.65rem !important;
    letter-spacing: -0.02em;
    word-break: break-all;
    white-space: normal !important;
    hyphens: auto;
}

/* ID */
table.dataTable thead th.ss-dt-col-id,
table.dataTable tbody td.ss-dt-col-id {
    width: var(--ss-dt-col-id) !important;
    min-width: var(--ss-dt-col-id) !important;
    max-width: var(--ss-dt-col-id) !important;
    padding: 0.3rem 0.25rem !important;
    white-space: nowrap !important;
    text-align: center !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    font-size: 0.8125rem !important;
}

table.dataTable thead th.ss-dt-col-id {
    font-size: 0.7rem !important;
}

/* Oui/non, zone, traité, etc. */
table.dataTable thead th.ss-dt-col-narrow,
table.dataTable tbody td.ss-dt-col-narrow {
    width: var(--ss-dt-col-narrow) !important;
    min-width: var(--ss-dt-col-narrow) !important;
    max-width: var(--ss-dt-col-narrow) !important;
    padding: 0.35rem 0.25rem !important;
    white-space: normal !important;
    text-align: center !important;
    overflow: hidden !important;
    word-break: break-word !important;
    font-size: 0.8125rem !important;
}

/* Dates */
table.dataTable thead th.ss-dt-col-date,
table.dataTable tbody td.ss-dt-col-date {
    width: var(--ss-dt-col-date) !important;
    max-width: calc(var(--ss-dt-col-date) + 0.5rem) !important;
    white-space: nowrap !important;
    text-align: center !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* Statut / badges */
table.dataTable thead th.ss-dt-col-status,
table.dataTable tbody td.ss-dt-col-status {
    width: var(--ss-dt-col-status) !important;
    max-width: calc(var(--ss-dt-col-status) + 1rem) !important;
    white-space: normal !important;
    text-align: center !important;
    overflow: hidden !important;
    word-break: break-word !important;
}

/* Medium label columns (nom, catégorie, libellé…) — référentiel tables */
table.dataTable thead th.ss-dt-col-wide,
table.dataTable tbody td.ss-dt-col-wide {
    width: 11% !important;
    min-width: 5.5rem !important;
    max-width: 14rem !important;
    white-space: normal !important;
    word-break: break-word !important;
    overflow: hidden !important;
}

/* Commentaire — GF commercial / FDC (editable textarea, must stay visible) */
table.dataTable thead th.ss-dt-col-comment,
table.dataTable tbody td.ss-dt-col-comment,
.dataTables_wrapper table.dataTable td.ss-dt-cell-comment {
    width: 12% !important;
    min-width: 9.5rem !important;
    max-width: 16rem !important;
    white-space: normal !important;
    word-break: break-word !important;
    overflow: visible !important;
    vertical-align: middle !important;
}

table.dataTable tbody td.ss-dt-col-comment textarea,
.dataTables_wrapper table.dataTable td.ss-dt-cell-comment textarea {
    min-width: 8.5rem !important;
    min-height: 2.5rem;
    resize: vertical;
}

.ss-gestion-page .ss-gestion-ref-table-card table.dataTable thead th.ss-dt-col-flex,
.ss-gestion-page .ss-gestion-ref-table-card table.dataTable tbody td.ss-dt-col-flex {
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
}

/* Controls must not expand the column past its share */
.dataTables_wrapper table.dataTable tbody td .btn-group {
    display: inline-flex !important;
    flex-wrap: wrap !important;
    justify-content: center;
    max-width: 100% !important;
    gap: 2px;
}

.dataTables_wrapper table.dataTable tbody td .btn-group-sm > .btn {
    padding: 0.2rem 0.35rem;
    font-size: 0.7rem;
}

.dataTables_wrapper table.dataTable tbody td textarea,
.dataTables_wrapper table.dataTable tbody td select,
.dataTables_wrapper table.dataTable tbody td input:not([type="checkbox"]):not([type="radio"]) {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

table.dataTable thead th {
    background: linear-gradient(180deg, #fbfdff 0%, #f6f9ff 100%);
    color: #111827;
    font-weight: 600;
    border-bottom: 1px solid var(--ss-dt-border);
    padding: 10px 12px;
    line-height: 1.25;
    hyphens: auto;
}

table.dataTable tbody td {
    padding: 10px 12px;
    color: #223;
}

table.dataTable.stripe tbody tr:nth-child(odd) {
    background: #fafbff;
}

table.dataTable tbody tr:hover {
    background: #f1f5ff;
}

.dataTables_wrapper .dt-buttons .dt-button,
.dt-button {
    background: #fff;
    border: 1px solid var(--ss-dt-border);
    color: var(--ss-dt-accent);
    padding: 6px 10px;
    margin-right: 6px;
    border-radius: 6px;
    box-shadow: none;
    cursor: pointer;
    font-weight: 600;
}

.dataTables_wrapper .dt-buttons .dt-button:hover,
.dt-button:hover {
    background: var(--ss-dt-accent);
    color: #fff;
    border-color: var(--ss-dt-accent);
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    margin-bottom: 10px;
}

/* Avoid spurious close-button ring when Bootstrap focus trap refocuses after mouse use */
.modal .btn-close:focus:not(:focus-visible) {
    box-shadow: none;
    outline: none;
}

#modalViewEmotionByStagiaire .modal-dialog {
    max-width: 98vw;
    width: 98vw;
    margin: 1vh auto;
}

#modalViewEmotionByStagiaire .modal-content {
    min-height: 80vh;
}

#modalGfFormEntry .modal-dialog {
    max-width: 96vw !important;
    width: 96vw !important;
    margin: 1vh auto !important;
}

#modalGfFormEntry .modal-content {
    width: 100%;
    max-width: 100%;
}

@media (max-width: 768px) {
    table.dataTable thead th,
    table.dataTable tbody td {
        padding: 8px 6px;
    }

    .dataTables_wrapper .dt-buttons {
        margin-bottom: 8px;
    }
}

/* Actions column — fixed width (tables with manual <colgroup> control their own %) */
table.dataTable thead th.table-actions,
table.dataTable tbody td.table-actions {
    width: var(--ss-dt-actions-width) !important;
    min-width: var(--ss-dt-actions-width) !important;
    max-width: var(--ss-dt-actions-width) !important;
    white-space: nowrap !important;
    text-align: center !important;
    padding: 6px 8px !important;
    box-sizing: border-box;
    overflow: visible !important;
}

table.dataTable.ss-dt-manual-columns thead th.table-actions,
table.dataTable.ss-dt-manual-columns tbody td.table-actions,
.dataTables_wrapper table.dataTable.ss-dt-manual-columns thead th.table-actions,
.dataTables_wrapper table.dataTable.ss-dt-manual-columns tbody td.table-actions {
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
}

td.table-actions .table-actions-inner {
    display: inline-flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

td.table-actions > .btn,
td.table-actions .table-actions-inner > .btn {
    flex: 0 0 auto;
    width: 2.375rem;
    height: 2.375rem;
    min-width: 2.375rem;
    margin: 0;
    padding: 0;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent !important;
    box-shadow: none !important;
    border: 1px solid var(--ss-action-color, #206bc4) !important;
    color: var(--ss-action-color, #206bc4) !important;
}

td.table-actions .table-actions-inner > .btn-group,
td.table-actions .table-actions-inner > .dropdown {
    flex: 0 0 auto;
}

td.table-actions > .btn:hover,
td.table-actions > .btn:focus,
td.table-actions .table-actions-inner > .btn:hover,
td.table-actions .table-actions-inner > .btn:focus {
    color: var(--ss-action-color, #206bc4) !important;
    border-color: var(--ss-action-color, #206bc4) !important;
    box-shadow: none !important;
}

td.table-actions .btn-warning:not(.dropdown-toggle),
td.table-actions .btn[class*="btn-edit"]:not(.dropdown-toggle) {
    --ss-action-color: #f59f00;
}

td.table-actions .btn-danger:not(.dropdown-toggle),
td.table-actions .btn[class*="btn-delete"]:not(.dropdown-toggle) {
    --ss-action-color: #d63939;
}

td.table-actions .btn-primary:not(.dropdown-toggle) {
    --ss-action-color: #206bc4;
}

td.table-actions .btn-success:not(.dropdown-toggle) {
    --ss-action-color: #2fb344;
}

td.table-actions .btn-info:not(.dropdown-toggle) {
    --ss-action-color: #17a2b8;
}

td.table-actions .btn-secondary:not(.dropdown-toggle) {
    --ss-action-color: #64748b;
}

/* Gestion pages — slightly tighter cells */
.ss-gestion-page {
    max-width: 100%;
    min-width: 0;
}

.ss-gestion-page .ss-gestion-ref-table-card table.dataTable,
.ss-gestion-page .ss-gestion-ref-table-card table.table {
    font-size: 0.875rem;
}

.ss-gestion-page .ss-gestion-ref-table-card table.dataTable thead th,
.ss-gestion-page .ss-gestion-ref-table-card table.dataTable tbody td {
    padding: 0.35rem 0.5rem;
}

/* Opt-in ellipsis only */
.ss-gestion-page table.dataTable th.ss-col-truncate,
.ss-gestion-page table.dataTable td.ss-col-truncate {
    max-width: 14rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: normal;
    overflow-wrap: normal;
}

.ss-gestion-page table.dataTable td.ss-col-truncate[title] {
    cursor: help;
}

.ss-gestion-page table.dataTable td.ss-col-no-truncate,
.ss-gestion-page table.dataTable th.ss-col-no-truncate,
.dataTables_wrapper table.dataTable td.ss-dt-cell-comment {
    white-space: normal;
    overflow: hidden;
}

.ss-gestion-page table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control {
    padding-left: 2rem;
}

.ss-gestion-page table.dataTable > tbody > tr.child ul.dtr-details {
    width: 100%;
    margin: 0;
    padding: 0.5rem 0;
}

.ss-gestion-page table.dataTable > tbody > tr.child span.dtr-title {
    font-weight: 600;
    color: #64748b;
}

table.stagiaires-table.dataTable {
    width: 100% !important;
    max-width: 100% !important;
}

/* Téléphone — single line, no digit wrap */
table.dataTable thead th.ss-dt-col-phone,
table.dataTable tbody td.ss-dt-col-phone {
    width: var(--ss-dt-col-phone) !important;
    min-width: var(--ss-dt-col-phone) !important;
    max-width: calc(var(--ss-dt-col-phone) + 0.5rem) !important;
    white-space: nowrap !important;
    text-align: center !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    word-break: normal !important;
    font-size: 0.8125rem !important;
}

/* GF commercial / FDC — widths from <colgroup> only */
.ss-gestion-page table.dataTable.ss-gestion-gf-dt,
.ss-gestion-page .dataTables_wrapper table.dataTable.ss-gestion-gf-dt {
    table-layout: fixed !important;
    width: 100% !important;
}

.ss-gestion-page table.dataTable.ss-gestion-gf-dt thead th,
.ss-gestion-page table.dataTable.ss-gestion-gf-dt tbody td,
.ss-gestion-page .dataTables_wrapper table.dataTable.ss-gestion-gf-dt thead th,
.ss-gestion-page .dataTables_wrapper table.dataTable.ss-gestion-gf-dt tbody td {
    min-width: 0 !important;
}

.ss-gestion-page table.dataTable.ss-gestion-gf-dt th.ss-col-truncate,
.ss-gestion-page table.dataTable.ss-gestion-gf-dt td.ss-col-truncate,
.ss-gestion-page .dataTables_wrapper table.dataTable.ss-gestion-gf-dt th.ss-col-truncate,
.ss-gestion-page .dataTables_wrapper table.dataTable.ss-gestion-gf-dt td.ss-col-truncate {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.ss-gestion-page table.dataTable.ss-gestion-gf-dt tbody td.ss-gf-col-gf .btn,
.ss-gestion-page table.dataTable.ss-gestion-gf-dt tbody td.ss-gf-col-comm .btn {
    width: 1.85rem;
    height: 1.85rem;
    min-width: 1.85rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* GF / Commerciale action cells — compact, not full table-actions width */
table.dataTable thead th.ss-dt-col-action,
table.dataTable tbody td.ss-dt-col-action {
    width: var(--ss-dt-col-action) !important;
    min-width: var(--ss-dt-col-action) !important;
    max-width: var(--ss-dt-col-action) !important;
    white-space: nowrap !important;
    text-align: center !important;
    padding: 0.35rem 0.25rem !important;
    overflow: visible !important;
    vertical-align: middle !important;
}

table.dataTable tbody td.ss-dt-col-action .btn {
    width: 2rem;
    height: 2rem;
    min-width: 2rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

table.dataTable tbody td.ss-dt-col-action .badge {
    font-size: 0.75rem;
    padding: 0.35rem 0.45rem;
}
