/**
 * Modern DataTables Styling
 * 
 * Styles for:
 * - wdm_project_idea_table
 * - wdm_participant_feedback_table
 * - wdm_project_reports_table
 *
 * @package WDM - Event Custom Fields
 * @since 1.0.0
 */

/* ============================================
   Table Container & Wrapper
   ============================================ */

.wdmea-entry-list-wrap {
    margin: 2rem 0;
    padding: 1.5rem;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    -webkit-overflow-scrolling: touch;
    position: relative;
    overflow: hidden;
}

/* ============================================
   Table Display Controls
   ============================================ */

.wdm-display-table-contents {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f0f0f0;
}

.wdm-buttons-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ============================================
   DataTables Base Styles
   ============================================ */

.wdmea-entry-list {
    width: 100% !important;
    border-collapse: separate;
    border-spacing: 0;
    background: #ffffff;
    font-size: 0.9375rem;
    line-height: 1.6;
}

.wdmea-entry-list thead {
    background: var(--ast-global-color-8, #667eea);
    color: #ffffff;
}

.wdmea-entry-list thead th {
    padding: 1rem 1.25rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    white-space: nowrap;
    position: relative;
}

.wdmea-entry-list thead th:first-child {
    border-top-left-radius: 8px;
}

.wdmea-entry-list thead th:last-child {
    border-top-right-radius: 8px;
}

.wdmea-entry-list tbody tr {
    border-bottom: 1px solid #e5e7eb;
    transition: all 0.2s ease;
}

.wdmea-entry-list tbody tr:hover {
    background: #f9fafb;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.wdmea-entry-list tbody tr:last-child {
    border-bottom: none;
}

.wdmea-entry-list tbody td {
    padding: 1rem 1.25rem;
    vertical-align: middle;
    color: #374151;
    border: none;
}

.wdmea-entry-list tbody td:first-child {
    font-weight: 500;
    color: #111827;
}

/* ============================================
   DataTables Sorting Icons
   ============================================ */

.wdmea-entry-list thead th.sorting,
.wdmea-entry-list thead th.sorting_asc,
.wdmea-entry-list thead th.sorting_desc {
    cursor: pointer;
    user-select: none;
    padding-right: 2rem;
}

.wdmea-entry-list thead th.sorting::after,
.wdmea-entry-list thead th.sorting_asc::after,
.wdmea-entry-list thead th.sorting_desc::after {
    content: '';
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
}

.wdmea-entry-list thead th.sorting::after {
    border-top: 5px solid rgba(255, 255, 255, 0.5);
    border-bottom: 5px solid rgba(255, 255, 255, 0.5);
    margin-top: -2px;
}

.wdmea-entry-list thead th.sorting_asc::after {
    border-bottom: 5px solid #ffffff;
    margin-top: -2px;
}

.wdmea-entry-list thead th.sorting_desc::after {
    border-top: 5px solid #ffffff;
}

/* ============================================
   DataTables Processing & Loading
   ============================================ */

/* Processing element styling */
.dt-processing,
.dataTables_processing {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 1.5rem 2.5rem;
    background: rgb(255 255 255 / 52%);
    z-index: 100;
}

div.dt-processing {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    text-align: center;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    max-width: calc(100% - 2rem);
    overflow: hidden;
    padding: 100% !important;
}

/* Hide processing when display is none */
.dt-processing[style*="display: none"],
.dataTables_processing[style*="display: none"] {
    display: none !important;
}

/* Processing animation container - the nested div structure */
.dt-processing>div:last-child,
.dataTables_processing>div:last-child {
    position: relative;
    width: 80px;
    height: 15px;
    margin: 0.5rem auto 0;
}

/* Individual dots in the animation */
.dt-processing>div:last-child>div,
.dataTables_processing>div:last-child>div {
    position: absolute;
    top: 0;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--ast-global-color-8, #667eea);
    animation-timing-function: cubic-bezier(0, 1, 1, 0);
}

/* First dot */
.dt-processing>div:last-child>div:nth-child(1),
.dataTables_processing>div:last-child>div:nth-child(1) {
    left: 8px;
    animation: wdm-datatables-loader-1 0.6s infinite;
}

/* Second dot */
.dt-processing>div:last-child>div:nth-child(2),
.dataTables_processing>div:last-child>div:nth-child(2) {
    left: 8px;
    animation: wdm-datatables-loader-2 0.6s infinite;
}

/* Third dot */
.dt-processing>div:last-child>div:nth-child(3),
.dataTables_processing>div:last-child>div:nth-child(3) {
    left: 32px;
    animation: wdm-datatables-loader-2 0.6s infinite;
}

/* Fourth dot */
.dt-processing>div:last-child>div:nth-child(4),
.dataTables_processing>div:last-child>div:nth-child(4) {
    left: 56px;
    animation: wdm-datatables-loader-3 0.6s infinite;
}

/* Keyframe animations for the dots */
@keyframes wdm-datatables-loader-1 {
    0% {
        transform: scale(0);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes wdm-datatables-loader-3 {
    0% {
        transform: scale(1);
    }

    100% {
        transform: scale(0);
    }
}

@keyframes wdm-datatables-loader-2 {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(24px, 0);
    }
}

/* Fallback spinner for older processing style */
.dataTables_processing::before {
    content: '';
    width: 24px;
    height: 24px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--ast-global-color-8, #667eea);
    border-radius: 50%;
    animation: wdm-spin 0.8s linear infinite;
    flex-shrink: 0;
    display: none;
    /* Hide if using dot animation */
}

.dt-processing:not(:has(> div:last-child))::before,
.dataTables_processing:not(:has(> div:last-child))::before {
    display: block;
}

@keyframes wdm-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   DataTables Pagination
   ============================================ */

.dataTables_wrapper .dataTables_paginate {
    margin-top: 1.5rem;
    text-align: center;
    float: none !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    display: inline-block;
    padding: 0.5rem 0.875rem;
    margin: 0 0.25rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #ffffff;
    color: #374151;
    text-decoration: none !important;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    min-width: 36px;
    text-align: center;
    box-sizing: border-box;
}

/* Fix for project ideas table pagination - ensure consistent styling */
#wdm_project_idea_table_wrapper .dataTables_paginate .paginate_button,
#wdm_participant_feedback_table_wrapper .dataTables_paginate .paginate_button,
#wdm_project_reports_table_wrapper .dataTables_paginate .paginate_button {
    display: inline-block;
    padding: 0.5rem 0.875rem;
    margin: 0 0.25rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #ffffff;
    color: #374151;
    text-decoration: none !important;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    min-width: 36px;
    text-align: center;
    box-sizing: border-box;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--ast-global-color-8, #667eea);
    border-color: var(--ast-global-color-8, #667eea);
    color: #ffffff;
    transform: translateY(-1px);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--ast-global-color-8, #667eea);
    border-color: var(--ast-global-color-8, #667eea);
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.previous,
.dataTables_wrapper .dataTables_paginate .paginate_button.next {
    font-weight: 600;
}

/* ============================================
   DataTables Length Menu
   ============================================ */

.dataTables_wrapper .dataTables_length {
    margin-bottom: 1rem;
}

.dataTables_wrapper .dataTables_length label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
}

.dataTables_wrapper .dataTables_length select {
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #ffffff;
    color: #374151;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 12px;
}

/* Style for select dropdown options */
.dataTables_wrapper .dataTables_length select option {
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    background: #ffffff;
    color: #374151;
}

/* Target the actual length select element with dt-input class */
.dt-length {
    position: relative;
    display: inline-block;
}

.dt-length::after {
    content: '';
    position: absolute;
    left: 45px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #6b7280;
    pointer-events: none;
    transition: transform 0.3s ease;
    z-index: 1;
}

/* Rotate arrow when select is open */
.dt-length.select-open::after {
    transform: translateY(-50%) rotate(180deg);
}

select.dt-input {
    padding: 0.5rem 2rem 0.5rem 0.75rem !important;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #ffffff;
    color: #374151;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: none;
    position: relative;
    z-index: 0;
}

select.dt-input:hover {
    border-color: #9ca3af;
}

select.dt-input:focus {
    outline: none;
    border-color: var(--ast-global-color-8, #667eea);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

/* Style for select dropdown options */
select.dt-input option {
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    background: #ffffff;
    color: #374151;
}

.dataTables_wrapper .dataTables_length select:hover {
    border-color: #9ca3af;
}

.dataTables_wrapper .dataTables_length select:focus {
    outline: none;
    border-color: var(--ast-global-color-8, #667eea);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

/* ============================================
   DataTables Info
   ============================================ */

.dataTables_wrapper .dataTables_info {
    padding-top: 1rem;
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
}

/* ============================================
   DataTables Buttons (Export)
   ============================================ */

.dataTables_wrapper .dt-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.dataTables_wrapper .dt-button {
    padding: 0.625rem 1.25rem;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #374151;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.dataTables_wrapper .dt-button:hover {
    background: var(--ast-global-color-8, #667eea);
    border-color: var(--ast-global-color-8, #667eea);
    color: #ffffff;
    transform: translateY(-1px);
}

.dataTables_wrapper .dt-button:active {
    transform: translateY(0);
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 768px) {
    .wdmea-entry-list-wrap {
        padding: 1rem;
        margin: 1rem 0;
    }

    .wdm-display-table-contents {
        flex-direction: column;
        align-items: stretch;
    }

    .wdm-buttons-wrapper {
        width: 100%;
        justify-content: space-between;
    }

    .wdmea-entry-list {
        font-size: 0.875rem;
    }

    .wdmea-entry-list thead th,
    .wdmea-entry-list tbody td {
        padding: 0.75rem 0.5rem;
    }

    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_info {
        text-align: center;
        width: 100%;
    }

    .dataTables_wrapper .dataTables_paginate {
        margin-top: 1rem;
    }

    .dataTables_wrapper .dt-buttons {
        width: 100%;
        justify-content: center;
    }

    .dataTables_wrapper .dt-button {
        flex: 1;
        min-width: 120px;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .wdmea-entry-list-wrap {
        padding: 0.75rem;
    }

    .wdmea-entry-list thead th,
    .wdmea-entry-list tbody td {
        padding: 0.625rem 0.375rem;
        font-size: 0.8125rem;
    }

    .dataTables_wrapper .dataTables_paginate .paginate_button {
        padding: 0.375rem 0.625rem;
        font-size: 0.8125rem;
        margin: 0.125rem;
    }
}

/* ============================================
   DataTables Responsive Plugin
   ============================================ */

table.dataTable.dtr-inline.collapsed>tbody>tr>td.child,
table.dataTable.dtr-inline.collapsed>tbody>tr>th.child,
table.dataTable.dtr-column.collapsed>tbody>tr>td.child,
table.dataTable.dtr-column.collapsed>tbody>tr>th.child {
    padding: 1rem;
    background: #f9fafb;
}

table.dataTable.dtr-inline.collapsed>tbody>tr>td.child ul,
table.dataTable.dtr-inline.collapsed>tbody>tr>th.child ul,
table.dataTable.dtr-column.collapsed>tbody>tr>td.child ul,
table.dataTable.dtr-column.collapsed>tbody>tr>th.child ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

table.dataTable.dtr-inline.collapsed>tbody>tr>td.child ul li,
table.dataTable.dtr-inline.collapsed>tbody>tr>th.child ul li,
table.dataTable.dtr-column.collapsed>tbody>tr>td.child ul li,
table.dataTable.dtr-column.collapsed>tbody>tr>th.child ul li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
}

table.dataTable.dtr-inline.collapsed>tbody>tr>td.child ul li:last-child,
table.dataTable.dtr-inline.collapsed>tbody>tr>th.child ul li:last-child,
table.dataTable.dtr-column.collapsed>tbody>tr>td.child ul li:last-child,
table.dataTable.dtr-column.collapsed>tbody>tr>th.child ul li:last-child {
    border-bottom: none;
}

table.dataTable.dtr-inline.collapsed>tbody>tr>td.child ul li .dtr-title,
table.dataTable.dtr-inline.collapsed>tbody>tr>th.child ul li .dtr-title,
table.dataTable.dtr-column.collapsed>tbody>tr>td.child ul li .dtr-title,
table.dataTable.dtr-column.collapsed>tbody>tr>th.child ul li .dtr-title {
    font-weight: 600;
    color: #111827;
}

table.dataTable.dtr-inline.collapsed>tbody>tr>td.child ul li .dtr-data,
table.dataTable.dtr-inline.collapsed>tbody>tr>th.child ul li .dtr-data,
table.dataTable.dtr-column.collapsed>tbody>tr>td.child ul li .dtr-data,
table.dataTable.dtr-column.collapsed>tbody>tr>th.child ul li .dtr-data {
    color: #6b7280;
}

/* ============================================
   Empty State
   ============================================ */

.dataTables_empty {
    padding: 3rem 1rem;
    text-align: center;
    color: #9ca3af;
    font-size: 1rem;
    font-weight: 500;
}

/* ============================================
   Link Styling in Tables
   ============================================ */

.wdmea-entry-list tbody td a {
    color: var(--ast-global-color-8, #667eea);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.wdmea-entry-list tbody td a:hover {
    color: var(--ast-global-color-8, #667eea);
    opacity: 0.8;
    text-decoration: underline;
}

/* ============================================
   Status Badges (if used in tables)
   ============================================ */

.wdmea-entry-list tbody td .status-badge {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.pending {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.approved {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.rejected {
    background: #fee2e2;
    color: #991b1b;
}