/**
 * SW Buy Again Select - Styles CSS
 *
 * @package SW_Buy_Again_Select
 * @version 1.0.0
 */

/* ==========================================================================
   Container principal
   ========================================================================== */

.sw-buy-again-select-wrapper {
    margin: 2em 0;
}

.sw-buy-again-select-wrapper h2 {
    margin-bottom: 0.5em;
}

.sw-buy-again-select-description {
    color: #666;
    margin-bottom: 1.5em;
    font-size: 0.95em;
}

/* ==========================================================================
   Tableau des produits
   ========================================================================== */

.sw-buy-again-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5em;
}

.sw-buy-again-table th,
.sw-buy-again-table td {
    padding: 12px 10px;
    text-align: left;
    border-bottom: 1px solid #e5e5e5;
    vertical-align: middle;
}

.sw-buy-again-table thead th {
    background-color: #f8f8f8;
    font-weight: 600;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Colonnes */
.sw-col-select {
    width: 40px;
    text-align: center !important;
}

.sw-col-sku {
    width: 100px;
}

.sw-col-price {
    width: 120px;
}

.sw-col-stock {
    width: 120px;
}

.sw-col-quantity {
    width: 100px;
}

/* ==========================================================================
   Lignes disponibles / indisponibles
   ========================================================================== */

.sw-item-available {
    background-color: #fff;
}

.sw-item-available:hover {
    background-color: #fafafa;
}

/* Ligne grisée pour les produits indisponibles */
.sw-item-unavailable {
    background-color: #f5f5f5;
    opacity: 0.7;
}

.sw-item-unavailable .sw-product-name,
.sw-item-unavailable .sw-col-price,
.sw-item-unavailable .sw-col-sku {
    color: #999;
    text-decoration: line-through;
}

.sw-item-unavailable .sw-col-stock {
    text-decoration: none;
}

/* ==========================================================================
   Éléments de formulaire
   ========================================================================== */

/* Checkbox */
.sw-item-checkbox,
.sw-select-all-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.sw-item-checkbox-disabled {
    width: 18px;
    height: 18px;
    cursor: not-allowed;
    opacity: 0.5;
}

/* Input quantité */
.sw-quantity-input {
    width: 70px;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
    font-size: 0.95em;
}

.sw-quantity-input:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 1px #0073aa;
}

.sw-quantity-input[readonly] {
    background-color: #f5f5f5;
    cursor: not-allowed;
}

/* ==========================================================================
   Statut stock
   ========================================================================== */

.sw-stock-status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 3px;
    font-size: 0.85em;
    font-weight: 500;
}

.sw-stock-status.in-stock {
    background-color: #d4edda;
    color: #155724;
}

.sw-stock-status.out-of-stock {
    background-color: #f8d7da;
    color: #721c24;
}

/* ==========================================================================
   Informations produit
   ========================================================================== */

.sw-product-name {
    font-weight: 500;
    display: block;
    margin-bottom: 4px;
}

.sw-variation-attributes {
    margin: 8px 0 0 0;
    padding: 0;
    list-style: none;
    font-size: 0.85em;
    color: #666;
}

.sw-variation-attributes li {
    margin-bottom: 2px;
}

.sw-unavailable-reason {
    margin: 8px 0 0 0;
    color: #dc3545;
    font-size: 0.85em;
}

.sw-sold-individually-notice {
    margin: 4px 0 0 0;
    color: #6c757d;
}

.sw-sku {
    font-family: monospace;
    font-size: 0.9em;
    color: #666;
}

.sw-no-sku,
.sw-no-price,
.sw-quantity-unavailable {
    color: #999;
}

/* ==========================================================================
   Boutons d'action
   ========================================================================== */

.sw-buy-again-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    padding-top: 1em;
    border-top: 1px solid #e5e5e5;
}

.sw-buy-again-submit {
    background-color: #0073aa !important;
    color: #fff !important;
    border: none !important;
    padding: 12px 24px !important;
    font-size: 1em !important;
    font-weight: 500 !important;
    cursor: pointer;
    border-radius: 4px !important;
    transition: background-color 0.2s ease;
}

.sw-buy-again-submit:hover {
    background-color: #005a87 !important;
}

.sw-buy-again-back {
    background-color: #f5f5f5 !important;
    color: #333 !important;
    border: 1px solid #ddd !important;
    padding: 11px 24px !important;
    font-size: 1em !important;
    text-decoration: none !important;
    border-radius: 4px !important;
    transition: background-color 0.2s ease;
}

.sw-buy-again-back:hover {
    background-color: #e9e9e9 !important;
}

/* ==========================================================================
   Bouton d'action dans la liste des commandes
   ========================================================================== */

.woocommerce-orders-table__cell-order-actions .button.buy-again-select,
.woocommerce-orders-table__cell-order-actions a.buy-again-select {
    white-space: nowrap;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media screen and (max-width: 768px) {
    .sw-buy-again-table thead {
        display: none;
    }

    .sw-buy-again-table,
    .sw-buy-again-table tbody,
    .sw-buy-again-table tr,
    .sw-buy-again-table td {
        display: block;
        width: 100%;
    }

    .sw-buy-again-table tr {
        margin-bottom: 1em;
        border: 1px solid #e5e5e5;
        border-radius: 4px;
        padding: 10px;
    }

    .sw-buy-again-table td {
        border-bottom: none;
        padding: 8px 10px;
        text-align: right;
    }

    .sw-buy-again-table td::before {
        content: attr(data-title);
        float: left;
        font-weight: 600;
        text-transform: uppercase;
        font-size: 0.8em;
        color: #666;
    }

    .sw-col-select {
        text-align: right !important;
    }

    .sw-col-product {
        text-align: left !important;
        padding-top: 0 !important;
    }

    .sw-col-product::before {
        display: none;
    }

    .sw-buy-again-actions {
        flex-direction: column;
    }

    .sw-buy-again-submit,
    .sw-buy-again-back {
        width: 100%;
        text-align: center;
    }

    .sw-variation-attributes {
        text-align: left;
    }

    .sw-quantity-input {
        width: 80px;
    }
}

/* ==========================================================================
   États et animations
   ========================================================================== */

.sw-buy-again-form {
    position: relative;
}

/* Animation au survol des lignes */
.sw-buy-again-table tbody tr {
    transition: background-color 0.15s ease;
}

/* Focus visible pour accessibilité */
.sw-item-checkbox:focus,
.sw-select-all-checkbox:focus,
.sw-quantity-input:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Screen reader only */
.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Champ Honeypot (anti-bot) - Double protection CSS
   ========================================================================== */

.sw-hp-field {
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    height: 0 !important;
    width: 0 !important;
    overflow: hidden !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    z-index: -9999 !important;
}

/* ==========================================================================
   États du bouton de soumission
   ========================================================================== */

.sw-buy-again-submit:disabled,
.sw-buy-again-submit[disabled],
.sw-buy-again-submit[aria-disabled="true"] {
    background-color: #ccc !important;
    color: #666 !important;
    cursor: not-allowed !important;
    opacity: 0.7;
}

.sw-buy-again-submit:disabled:hover,
.sw-buy-again-submit[disabled]:hover {
    background-color: #ccc !important;
}

/* ==========================================================================
   Loading state
   ========================================================================== */

.sw-buy-again-form.sw-loading {
    pointer-events: none;
    opacity: 0.7;
}

.sw-buy-again-form.sw-loading .sw-buy-again-submit {
    position: relative;
}

.sw-buy-again-form.sw-loading .sw-buy-again-submit::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 8px;
    border: 2px solid #fff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: sw-spin 0.8s linear infinite;
    vertical-align: middle;
}

@keyframes sw-spin {
    to {
        transform: rotate(360deg);
    }
}

