/**
 * WC Category Product Table
 * Responsive Card Layout Version with Pagination
 */

/* ===========================
   CONTENEDOR Y TABLA BASE
=========================== */

.wcpt-wrapper {
    width: 100%;
    margin: 20px 0;
}

.wcpt-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #ddd;
    font-size: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
}

.wcpt-table thead {
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
}

.wcpt-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-right: 1px solid #dee2e6;
}

.wcpt-table th:last-child {
    border-right: none;
}

.wcpt-table td {
    padding: 12px 15px;
    vertical-align: middle;
    border-right: 1px solid #dee2e6;
}

.wcpt-table td:last-child {
    border-right: none;
}

.wcpt-table tbody tr {
    border-bottom: 1px solid #e9ecef;
    transition: background-color .2s ease;
}

.wcpt-table tbody tr:hover {
    background: #fafafa;
}

.wcpt-table tbody tr:nth-child(even) {
    background: #fcfcfc;
}

/* ===========================
   COLUMNAS DESKTOP
=========================== */

.wcpt-table th:nth-child(1),
.wcpt-table td:nth-child(1) {
    width: 100px;
    text-align: center;
}

.wcpt-table th:nth-child(2),
.wcpt-table td:nth-child(2) {
    min-width: 250px;
}

.wcpt-table th:nth-child(3),
.wcpt-table td:nth-child(3) {
    min-width: 220px;
}

.wcpt-table th:nth-child(4),
.wcpt-table td:nth-child(4) {
    width: 90px;
    text-align: center;
}

.wcpt-table th:nth-child(5),
.wcpt-table td:nth-child(5) {
    width: 130px;
}

.wcpt-table th:nth-child(6),
.wcpt-table td:nth-child(6) {
    width: 160px;
    text-align: center;
}

/* ===========================
   IMÁGENES Y ENLACES
=========================== */

.wcpt-table img {
    max-width: 80px;
    height: auto;
    display: block;
    margin: 0 auto;
    border-radius: 4px;
}

.wcpt-table td a {
    text-decoration: none;
    color: inherit;
    display: inline-block;
}

.wcpt-table td a.wcpt-product-title {
    color: #333;
    font-weight: 600;
    transition: color 0.2s ease;
}

.wcpt-table td a.wcpt-product-title:hover {
    color: #0073aa;
}

/* ===========================
   PRECIOS Y CONTROLES
=========================== */

.wcpt-price {
    font-weight: 700;
    font-size: 16px;
    color: #27ae60;
    text-align: right;
    white-space: nowrap;
}

.woocommerce-Price-amount {
    font-weight: 700;
}

.woocommerce-Price-currencySymbol {
    margin-right: 2px;
}

.wcpt-variation-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #bbb;
    border-radius: 4px;
    background: #fff;
    font-size: 13px;
    cursor: pointer;
    transition: border-color .2s ease;
}

.wcpt-variation-select:hover {
    border-color: #666;
}

.wcpt-variation-select:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0,115,170,.12);
}

.wcpt-qty {
    width: 80px;
    min-width: 80px;
    padding: 8px 10px;
    border: 1px solid #bbb;
    border-radius: 4px;
    background: #fff;
    font-size: 14px;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 18px;
    padding-right: 30px;
}

.wcpt-add-to-cart {
    display: inline-block;
    width: 100%;
    padding: 10px 18px;
    border: none;
    border-radius: 4px;
    background: #0073aa;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all .25s ease;
}

.wcpt-add-to-cart:hover {
    background: #005a87;
    box-shadow: 0 2px 8px rgba(0,115,170,.25);
}

.wcpt-add-to-cart:disabled {
    opacity: .6;
    cursor: not-allowed;
}

.wcpt-add-to-cart.loading {
    opacity: .6;
    position: relative;
}

.wcpt-add-to-cart.loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: 6px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: wcpt-spin 0.6s linear infinite;
    vertical-align: middle;
}

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

/* ===========================
   BARRA DE FILTROS
=========================== */

.wcpt-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 15px;
    background: #f8f9fa;
    padding: 15px 20px;
    border: 1px solid #dee2e6;
    border-radius: 6px 6px 0 0;
    margin-bottom: -1px;
}

.wcpt-filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.wcpt-filter-group label {
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    text-transform: uppercase;
}

.wcpt-filter-input {
    width: 140px;
    padding: 8px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    background-color: #fff;
    transition: border-color 0.2s;
}

.wcpt-filter-input:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.15);
}

.wcpt-filter-actions {
    margin-left: auto;
}

.wcpt-reset-btn {
    padding: 8px 16px;
    background: #e9ecef;
    color: #495057;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.wcpt-reset-btn:hover {
    background: #dc3545;
    color: #fff;
    border-color: #dc3545;
}

/* ===========================
   NOTIFICACIONES
=========================== */

.wcpt-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    padding: 0;
    border-radius: 6px;
    font-weight: 500;
    background: #fff;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    transform: translateX(400px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.wcpt-notification.wcpt-notification-show {
    transform: translateX(0);
}

.wcpt-notification-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
}

.wcpt-notification-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.wcpt-notification-success .wcpt-notification-icon {
    background: #27ae60;
    color: #fff;
}

.wcpt-notification-error .wcpt-notification-icon {
    background: #dc3545;
    color: #fff;
}

.wcpt-notification-message {
    color: #333;
    font-size: 14px;
    max-width: 300px;
    word-wrap: break-word;
}

/* ===========================
   PAGINACIÓN DESKTOP
=========================== */

.wcpt-pagination {
    margin: 15px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.wcpt-pagination ul.page-numbers {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
    gap: 6px;
    align-items: center;
}

.wcpt-pagination ul.page-numbers li {
    margin: 0;
    padding: 0;
}

.wcpt-pagination ul.page-numbers .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background: #fff;
    color: #0073aa;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}

.wcpt-pagination ul.page-numbers a.page-numbers:hover {
    background: #0073aa;
    color: #fff;
    border-color: #0073aa;
}

.wcpt-pagination ul.page-numbers .page-numbers.current {
    background: #0073aa;
    color: #fff;
    border-color: #0073aa;
    cursor: default;
}

.wcpt-pagination ul.page-numbers .page-numbers.dots {
    border: none;
    background: transparent;
    color: #6c757d;
}

/* ======================================================
   RESPONSIVE LAYOUT (TABLET & MOBILE CARD MODE)
====================================================== */

@media (max-width: 768px) {

    .wcpt-filter-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
    }

    .wcpt-filter-input {
        width: 100%;
    }

    .wcpt-filter-actions {
        margin-left: 0;
    }

    .wcpt-reset-btn {
        width: 100%;
    }

    /* Ocultar encabezados nativos */
    .wcpt-table thead {
        display: none;
    }

    .wcpt-table,
    .wcpt-table tbody,
    .wcpt-table tfoot,
    .wcpt-table tr,
    .wcpt-table td {
        display: block;
        width: 100% !important;
        box-sizing: border-box;
    }

    .wcpt-table {
        border: none;
        background: transparent;
        box-shadow: none;
    }

    /* Transformar cada fila en una tarjeta */
    .wcpt-table tbody tr {
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 8px;
        margin-bottom: 15px;
        padding: 15px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.04);
    }

    .wcpt-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border-right: none;
        border-bottom: 1px solid #f1f5f9;
        text-align: right;
    }

    .wcpt-table td:last-child {
        border-bottom: none;
        padding-top: 12px;
    }

    /* Inyectar etiquetas de encabezado desde data-label */
    .wcpt-table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 12px;
        color: #64748b;
        text-transform: uppercase;
        text-align: left;
        padding-right: 10px;
    }

    /* Ajustes específicos de celdas en modo Tarjeta */
    .wcpt-table td[data-label="Image"] {
        justify-content: center;
        border-bottom: 1px solid #e2e8f0;
        padding-bottom: 12px;
    }

    .wcpt-table td[data-label="Image"]::before {
        display: none;
    }

    .wcpt-table td[data-label="Description"] {
        text-align: right;
    }

    .wcpt-table td[data-label="Description"] a {
        font-size: 15px;
    }

    .wcpt-table td[data-label="Add to Cart"]::before {
        display: none;
    }

    .wcpt-table td[data-label="Add to Cart"] {
        justify-content: stretch;
    }

    .wcpt-variation-select {
        max-width: 60%;
    }

    .wcpt-notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }

    /* ======================================================
       REGISTRO DE EXCEPCIONES PARA PAGINACIÓN EN MÓVIL
    ====================================================== */

    .wcpt-table tfoot tr.wcpt-pagination-row {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin-top: 15px;
    }

    .wcpt-table td.wcpt-pagination-cell {
        display: block !important;
        border: none !important;
        padding: 0 !important;
        text-align: center !important;
    }

    .wcpt-table td.wcpt-pagination-cell::before {
        display: none !important;
    }

    /* Organización por bloques flexibles para evitar saltos verticales inesperados */
    .wcpt-pagination ul.page-numbers {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        gap: 6px;
        width: 100%;
    }

    /* Números visibles horizontalmente con flexbox */
    .wcpt-pagination ul.page-numbers li {
        display: inline-flex;
    }

    .wcpt-pagination ul.page-numbers .page-numbers {
        min-width: 32px;
        height: 34px;
        padding: 0 8px;
        font-size: 13px;
    }

    /* Mover Previous / Next debajo de los números y expandirlos al 100% */
    .wcpt-pagination ul.page-numbers li:has(.prev),
    .wcpt-pagination ul.page-numbers li:has(.next),
    .wcpt-pagination ul.page-numbers a.prev,
    .wcpt-pagination ul.page-numbers a.next {
        width: 100% !important;
        display: flex !important;
        justify-content: center;
        align-items: center;
        order: 99;
        margin-top: 4px;
        background: #f8f9fa;
        border-color: #ced4da;
    }
}

/* ===========================
   OCULTAR PAGINACIÓN (< 50 ÍTEMS / 1 PÁGINA)
=========================== */

/* Oculta la paginación si el contenedor tiene la clase condicional */
.wcpt-wrapper.has-single-page .wcpt-pagination,
.wcpt-wrapper.wcpt-no-pagination .wcpt-pagination,
.wcpt-pagination.is-hidden {
    display: none !important;
}
