/* ============================================================================
   DATATABLES CRM THEME - VizCo Design System
   Drop this AFTER dataTables.bootstrap4.css
   
   FIX: Added higher specificity selectors and explicit card wrappers
   ============================================================================ */

/* ── CSS Variables ── */
:root {
    --dt-card-radius: 12px;
    --dt-card-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --dt-spacing-sm: 0.5rem;
    --dt-spacing-md: 1rem;
    --dt-spacing-lg: 1.5rem;
}

/* ============================================================================
   1. WRAPPER - The main container needs explicit styling
   ============================================================================ */

.dt-container {
    font-family: var(--font-montserrat, 'Montserrat', system-ui, sans-serif);
    padding: 0;
}


/* ============================================================================
   2. TOP TOOLBAR (Length + Buttons + Search)
   Wrap in a card - need HIGH specificity to beat Bootstrap .row
   ============================================================================ */

div.dt-container {
    width: 100% !important;
    background: white !important;
    border-radius: var(--dt-card-radius) !important;
    box-shadow: var(--dt-card-shadow) !important;
    overflow: hidden !important;
}

div.dt-container div.row:first-child {
    padding: var(--dt-spacing-md) !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    align-items: center !important;
    border-bottom: 1px solid #f1f5f9 !important;
}

/* Length selector container */
div.dt-container div.dt-length {
    font-size: 0.875rem;
    color: #64748b;
    padding: 0;
}

div.dt-container div.dt-length label {
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

div.dt-container div.dt-length select {
    border: 1px solid var(--color-vz-border-light, #ccd9eb) !important;
    border-radius: 8px !important;
    padding: 0.5rem 2rem 0.5rem 0.75rem !important;
    font-size: 0.875rem !important;
    background-color: white !important;
    color: var(--color-vz-blue, #00348e) !important;
    font-weight: 500 !important;
    min-width: 70px;
    height: auto !important;
}

div.dt-container div.dt-length select:focus {
    outline: none !important;
    border-color: var(--color-vz-blue, #00348e) !important;
    box-shadow: 0 0 0 3px rgba(0, 52, 142, 0.1) !important;
}

/* Search box container */
div.dt-container div.dt-search {
    font-size: 0.875rem;
    color: #64748b;
    padding: 0;
}

div.dt-container div.dt-search label {
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

div.dt-container div.dt-search input {
    border: 1px solid var(--color-vz-border-light, #ccd9eb) !important;
    border-radius: 8px !important;
    padding: 0.5rem 1rem !important;
    font-size: 0.875rem !important;
    min-width: 200px;
    height: auto !important;
    transition: border-color 0.2s, box-shadow 0.2s;
}

div.dt-container div.dt-search input:focus {
    outline: none !important;
    border-color: var(--color-vz-blue, #00348e) !important;
    box-shadow: 0 0 0 3px rgba(0, 52, 142, 0.1) !important;
}

/* ============================================================================
3. EXPORT BUTTONS (PDF / Excel)
============================================================================ */

div.dt-container div.dt-buttons {
    display: flex;
    gap: 0.5rem;
}

/* PDF Button - Solid */
div.dt-container div.dt-buttons button.dt-button,
div.dt-container div.dt-buttons .btn {
    background-color: var(--color-vz-blue, #00348e) !important;
    color: white !important;
    border: 2px solid var(--color-vz-blue, #00348e) !important;
    border-radius: 8px !important;
    padding: 0.5rem 1.5rem !important;
    font-size: 0.875rem !important;
    font-weight: 600 !important;
    transition: background-color 0.2s, transform 0.1s !important;
    box-shadow: none !important;
    background-image: none !important;
    text-transform: none !important;
}

div.dt-container div.dt-buttons button.dt-button:hover,
div.dt-container div.dt-buttons .btn:hover {
    background-color: var(--color-vz-blue-dark, #00286e) !important;
    border-color: var(--color-vz-blue-dark, #00286e) !important;
    transform: translateY(-1px);
}

/* Excel Button - Outline style */
div.dt-container div.dt-buttons button.buttons-excel,
div.dt-container div.dt-buttons .btn.buttons-excel {
    background-color: white !important;
    color: var(--color-vz-blue, #00348e) !important;
    border: 2px solid var(--color-vz-blue, #00348e) !important;
}

div.dt-container div.dt-buttons button.buttons-excel:hover,
div.dt-container div.dt-buttons .btn.buttons-excel:hover {
    background-color: var(--color-vz-bg-light, #e6ecf5) !important;
    color: var(--color-vz-blue, #00348e) !important;
    border-color: var(--color-vz-blue, #00348e) !important;
}

/* ============================================================================
4. TABLE CONTAINER - Wrap in card
============================================================================ */

div.dt-container div.row:nth-child(2) {
    overflow: hidden !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding: 0 !important;
}

/* Table itself */
table.dataTable {
    border-collapse: separate !important;
    border-spacing: 0 !important;
    margin: 0 !important;
    width: 100% !important;
}

/* Remove all Bootstrap table borders */
table.dataTable.table-bordered,
table.dataTable.table-bordered td,
table.dataTable.table-bordered th {
    border: none !important;
}

/* Header styling */
table.dataTable thead th,
table.dataTable thead td {
    background-color: var(--color-vz-bg-light, #e6ecf5) !important;
    color: var(--color-vz-blue, #00348e) !important;
    font-weight: 600 !important;
    font-size: 0.8125rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.025em !important;
    padding: 1rem !important;
    border-bottom: 2px solid var(--color-vz-blue, #00348e) !important;
    border-top: none !important;
    white-space: nowrap;
}

table.dataTable th.dt-type-numeric div.dt-column-header {
    flex-direction: row;
}

table.dataTable th.dt-type-numeric {
    text-align: left;
}

table.dataTable td.dt-type-numeric{
    text-align: left;
}

/* Body rows */
table.dataTable tbody tr {
    background-color: white !important;
    transition: background-color 0.15s;
}

table.dataTable tbody tr:hover {
    background-color: var(--color-vz-bg-light, #e6ecf5) !important;
}

table.dataTable tbody tr.selected {
    background-color: rgba(0, 52, 142, 0.08) !important;
}

/* Remove alternating row colors */
table.dataTable.table-striped tbody tr:nth-of-type(odd),
table.dataTable.table-striped tbody tr:nth-of-type(even) {
    background-color: white !important;
}

table.dataTable.table-striped tbody tr:nth-of-type(odd):hover,
table.dataTable.table-striped tbody tr:nth-of-type(even):hover {
    background-color: var(--color-vz-bg-light, #e6ecf5) !important;
}

/* Body cells */
table.dataTable tbody td {
    padding: 1rem !important;
    vertical-align: middle !important;
    font-size: 0.9375rem;
    color: #334155;
    border-bottom: 1px solid #f1f5f9 !important;
    border-top: none !important;
}

/* Links in table */
table.dataTable tbody td a {
    color: var(--color-vz-blue-light, #347cb2);
    text-decoration: none;
    font-weight: 500;
}

table.dataTable tbody td a:hover {
    color: var(--color-vz-blue, #00348e);
    text-decoration: underline;
}

/* ============================================================================
5. RESPONSIVE - Child rows (Mobile expanded cards)
============================================================================ */

/* Control column expand/collapse button - collapsed (+ icon) */
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control::before,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control::before {
    font-family: "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
    content: "\f055" !important;
    background-color: transparent !important;
    background-image: none !important;
    border: none !important;
    box-shadow: none !important;
    color: var(--color-vz-blue, #00348e) !important;
    font-size: 18px !important;
    width: auto !important;
    height: auto !important;
    display: inline-block !important;
}

/* Control column expand/collapse button - expanded (- icon) */
table.dataTable.dtr-inline.collapsed > tbody > tr.dtr-expanded > td.dtr-control::before,
table.dataTable.dtr-inline.collapsed > tbody > tr.dtr-expanded > th.dtr-control::before {
    content: "\f056" !important;
    color: var(--color-vz-blue, #00348e) !important;
}

/* Child row background */
table.dataTable > tbody > tr.child {
    background-color: #f8fafc !important;
    padding: 0 !important;
}

table.dataTable > tbody > tr.child:hover {
    background-color: #f8fafc !important;
}

table.dataTable > tbody > tr.child td {
    padding: 1rem !important;
    border: none !important;
}

/* The child row details list - make it a card */
    table.dataTable > tbody > tr.child ul.dtr-details,
    table.dataTable > tbody > tr.child span.dtr-data ul,
    tr.child ul.dtr-details {
        display: flex !important;
        flex-direction: column !important;
        gap: 0 !important;
        padding: var(--dt-spacing-md) !important;
        margin: 0 !important;
        background: white !important;
        border-radius: 8px !important;
        border: 1px solid var(--color-vz-border-light, #ccd9eb) !important;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
        list-style: none !important;
    }

/* Each detail row */
table.dataTable > tbody > tr.child ul.dtr-details > li,
tr.child ul.dtr-details > li {
    display: flex !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    padding: 0.75rem 0 !important;
    border-bottom: 1px solid #f1f5f9 !important;
    margin: 0 !important;
    list-style: none !important;
}

table.dataTable > tbody > tr.child ul.dtr-details > li:last-child,
tr.child ul.dtr-details > li:last-child {
    border-bottom: none !important;
}

/* Label (column header) in child row */
table.dataTable > tbody > tr.child ul.dtr-details > li .dtr-title,
tr.child ul.dtr-details > li .dtr-title,
table.dataTable > tbody > tr.child span.dtr-title {
    font-weight: 600 !important;
    color: var(--color-vz-blue, #00348e) !important;
    font-size: 0.75rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.025em !important;
    flex-shrink: 0;
    margin-right: 1rem;
}

/* Value in child row */
table.dataTable > tbody > tr.child ul.dtr-details > li .dtr-data,
tr.child ul.dtr-details > li .dtr-data,
table.dataTable > tbody > tr.child span.dtr-data {
    color: #334155 !important;
    font-size: 0.9375rem !important;
    text-align: right;
    word-break: break-word;
}

/* ============================================================================
   6. BOTTOM TOOLBAR (Info + Pagination)
   ============================================================================ */

div.dt-container div.row:last-child {
    padding: var(--dt-spacing-md) !important;
    margin-top: var(--dt-spacing-md) !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    align-items: center !important;
}

div.dt-container div.dt-info {
    font-size: 0.875rem;
    color: #64748b;
    padding: 0 !important;
}

div.dt-container div.dt-paging {
    padding: 0 !important;
}

div.dt-container div.dt-paging ul.pagination {
    margin: 0 !important;
    gap: 0.25rem;
}

div.dt-container div.dt-paging .dt-paging-button,
div.dt-container div.dt-paging .page-item .page-link {
    border: none !important;
    background: transparent !important;
    color: #64748b !important;
    padding: 0.5rem 0.875rem !important;
    border-radius: 8px !important;
    font-weight: 500 !important;
    font-size: 0.875rem !important;
    transition: all 0.15s !important;
    margin: 0 !important;
}

div.dt-container div.dt-paging .dt-paging-button:hover,
div.dt-container div.dt-paging .page-item .page-link:hover {
    background: var(--color-vz-bg-light, #e6ecf5) !important;
    color: var(--color-vz-blue, #00348e) !important;
}

div.dt-container div.dt-paging .dt-paging-button.current,
div.dt-container div.dt-paging .page-item.active .page-link {
    background: var(--color-vz-blue, #00348e) !important;
    color: white !important;
}

div.dt-container div.dt-paging .dt-paging-button.current:hover,
div.dt-container div.dt-paging .page-item.active .page-link:hover {
    background: var(--color-vz-blue-dark, #00286e) !important;
    color: white !important;
}

div.dt-container div.dt-paging .dt-paging-button.disabled,
div.dt-container div.dt-paging .page-item.disabled .page-link {
    color: #cbd5e1 !important;
    background: transparent !important;
    cursor: not-allowed;
}

/* ============================================================================
   7. STATUS PILLS
   ============================================================================ */

.vz-status-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    white-space: nowrap;
}

.vz-status-pill--initial,
.vz-status-pill--new {
    background-color: #dbeafe;
    color: #1e40af;
}

.vz-status-pill--en-cours,
.vz-status-pill--in-progress {
    background-color: #fef3c7;
    color: #92400e;
}

.vz-status-pill--completed,
.vz-status-pill--complete,
.vz-status-pill--complété {
    background-color: #d1fae5;
    color: #065f46;
}

.vz-status-pill--canceled,
.vz-status-pill--cancelled,
.vz-status-pill--annulé {
    background-color: #fee2e2;
    color: #991b1b;
}

/* ============================================================================
   8. EXPAND/COLLAPSE BUTTONS
   ============================================================================ */

.responsive-btns-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: var(--dt-spacing-md);
}

.input-group .responsive-btns,
button.responsive-btns {
    background-color: white !important;
    color: var(--color-vz-blue, #00348e) !important;
    border: 1px solid var(--color-vz-border-light, #ccd9eb) !important;
    border-radius: 8px !important;
    padding: 0.5rem 0.75rem !important;
    font-size: 0.875rem !important;
    transition: all 0.15s !important;
}

.input-group .responsive-btns:hover,
button.responsive-btns:hover {
    background-color: var(--color-vz-bg-light, #e6ecf5) !important;
    border-color: var(--color-vz-blue, #00348e) !important;
}

.input-group .responsive-btns i,
button.responsive-btns i {
    color: var(--color-vz-blue, #00348e);
}

.vz-btn-images {
    background-color: white;
    color: var(--color-vz-blue, #00348e);
    border: 1px solid var(--color-vz-border-light, #ccd9eb);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    transition: all 0.15s;
    cursor: pointer;
}

.vz-btn-images:hover {
    background-color: var(--color-vz-bg-light, #e6ecf5);
    border-color: var(--color-vz-blue, #00348e);
}

/* ============================================================================
   9. MOBILE OPTIMIZATIONS
   ============================================================================ */

@media (max-width: 767.98px) {
    
    /* Reduce Bootstrap grid padding injected by DataTables bs4 on mobile */
    div.dt-container [class*="col-"] {
        padding-left: 5px !important;
        padding-right: 5px !important;
    }

    /* Expand/collapse button - collapsed */
    table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control::before,
    table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control::before {
        font-size: 16px !important;
    }

    /* Expand/collapse button - expanded */
    table.dataTable.dtr-inline.collapsed > tbody > tr.dtr-expanded > td.dtr-control::before,
    table.dataTable.dtr-inline.collapsed > tbody > tr.dtr-expanded > th.dtr-control::before {
        font-size: 16px !important;
    }

    /* Child row background */
    table.dataTable > tbody > tr.child {
        background-color: #f8fafc !important;
    }

    /* Child row details - the card */
    table.dataTable > tbody > tr.child ul.dtr-details,
    tr.child ul.dtr-details {
        background: white;
        border-radius: 8px;
        border: 1px solid #ccd9eb;
        padding: 0.75rem 1rem;
        margin: 0.5rem;
        width: 100%;
        list-style: none;
    }

    /* Each row in the card */
    table.dataTable > tbody > tr.child ul.dtr-details > li,
    tr.child ul.dtr-details > li {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: 0.6rem 0;
        border-bottom: 1px solid #f1f5f9;
        list-style: none;
    }

    table.dataTable > tbody > tr.child ul.dtr-details > li:last-child,
    tr.child ul.dtr-details > li:last-child {
        border-bottom: none;
    }

    /* Label (left side) */
    table.dataTable > tbody > tr.child .dtr-title,
    tr.child .dtr-title {
        font-weight: 600;
        color: #00348e;
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.025em;
        flex-shrink: 0;
        margin-right: 1rem;
    }

    /* Value (right side) */
    table.dataTable > tbody > tr.child .dtr-data,
    tr.child .dtr-data {
        color: #334155;
        font-size: 0.9rem;
        text-align: right;
        word-break: break-word;
    }

    table.dataTable > tbody > tr.child ul.dtr-details,
    tr.child ul.dtr-details {
        margin: 0.5rem;
    }

    .dt-container .dt-buttons .dt-button,
    .dt-container .dt-buttons .btn {
        padding: 0.35rem 0.75rem !important;
        font-size: 0.8rem !important;
    }

    .dt-container .dt-paging {
        width: 100%;
        overflow-x: auto;
        display: flex;
        justify-content: center;
    }

    .dt-container .dt-paging .pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.25rem;
    }

    .dt-container .dt-paging .dt-paging-button {
        padding: 0.4rem 0.6rem !important;
        font-size: 0.8rem !important;
    }
}


/* ============================================================================
   10. LOADING & EMPTY STATES
   ============================================================================ */

.dt-processing {
    background: white !important;
    border: none !important;
    border-radius: var(--dt-card-radius) !important;
    box-shadow: var(--dt-card-shadow) !important;
    padding: 1.5rem 2rem !important;
    color: var(--color-vz-blue, #00348e) !important;
    font-weight: 500 !important;
}

.dt-empty {
    padding: 3rem !important;
    text-align: center !important;
    color: #64748b !important;
    font-size: 1rem !important;
}
