/* ================================
   WFPL UI – FASE 1
   
Version: 4.3
================================ */

.wfpl-ui {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Categoría */
.wfpl-ui .wfpl-cat {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 20px;
    overflow: hidden;
    background: #fff;
}

/* Header categoría */
.wfpl-ui .wfpl-cat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: #f9fafb;
    cursor: pointer;
}

.wfpl-ui .wfpl-cat-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

/* Botón guardar */


/* Productos */
.wfpl-ui .wfpl-products {
    padding: 12px 16px;
    background: #fff;
}

/* Fila producto */







/* Nombre */
.wfpl-ui .wfpl-name-text {
    font-size: 14px;
    color: #111827;
}

/* Input precio */
.wfpl-ui input.wfpl-price {
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-size: 14px;
    text-align: right;
}

/* Precio modificado */
.wfpl-ui input.wfpl-price.is-dirty {
    border-color: #f59e0b;
    background: #fffbeb;
}

/* Cliente (solo lectura) */
.wfpl-ui .wfpl-price-text {
    font-weight: 600;
    text-align: right;
}
.wfpl-save-cat {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #10b981; /* verde, como feedback de éxito */
    transition: transform 0.1s;
}

.wfpl-save-cat:hover:not(:disabled) {
    transform: scale(1.1);
}

.wfpl-save-cat:disabled svg {
    opacity: 0.4; /* mostrar deshabilitado */
}
.wfpl-button-sutil {
    display: inline-block;   /* clave */
    width: auto;             /* evita 100% */
    background-color: transparent;
    color: #4f46e5;
    border: 2px solid #4f46e5;
    border-radius: 8px;
    padding: 10px 22px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}


.wfpl-button-sutil:hover {
    background-color: #4f46e5;     /* fondo que aparece suavemente */
    color: #ffffff;                 /* texto se vuelve blanco */
    box-shadow: 0 4px 12px rgba(0,0,0,0.1); /* leve elevación */
    transform: translateY(-2px);
}

.wfpl-button-sutil:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.wfpl-shortcode-btn {
    display: flex;
    justify-content: flex-start; /* center si lo querés centrado */
}

.wfpl-shortcode-btn .wfpl-button-sutil {
    width: auto !important;
    display: inline-flex;
}
.wfpl-price-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
}

.wfpl-revert {
    background: none;
    border: none;
    padding: 2px;
    cursor: pointer;
    color: #6b7280;
}

.wfpl-revert:hover {
    color: #dc2626;
}
/* ================================
   WFPL – Quick add to cart
================================ */

.wfpl-quick-cart {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 6px;
}

.wfpl-add-cart {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid #10b981;
    background: #ecfdf5;
    color: #065f46;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.wfpl-add-cart:hover {
    background: #10b981;
    color: #fff;
    transform: scale(1.05);
}
/* ================================
   WFPL – Quick add minimal
================================ */

.wfpl-quick-icons {
        grid-column: 1 / -1;

    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 2px;
}

.wfpl-add-cart-icon {
    background: none;
    border: none;
    padding: 0;
    line-height: 1;
    color: #9ca3af;
    cursor: pointer;
    opacity: 0.5;
}

.wfpl-add-cart-icon:hover {
    opacity: 1;
    color: #10b981;
}
/* Contenedor del precio */
.wfpl-price-cell {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-end; /* mantiene alineación derecha del precio */
}

/* Precio no se mueve */
.wfpl-price-text {
    line-height: 1.2;
}

/* Iconos debajo, sin ocupar altura real */
.wfpl-quick-icons {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 2px;
    height: 0;              /* 🔑 clave */
    overflow: visible;      /* permite verse */
}

/* Iconos ultra chicos */
.wfpl-add-cart-icon {
    transform: translateY(6px); /* baja visualmente sin empujar layout */
}
.wfpl-add-cart-icon {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    padding: 0;
    line-height: 1;
    font-size: 10px;
    color: #9ca3af;
    opacity: 0.45;
    cursor: pointer;
}

.wfpl-add-cart-icon:hover {
    opacity: 1;
    color: #10b981;
}

.wfpl-qty {
    font-size: 10px;
    font-weight: 600;
    transform: translateY(-1px);
}
.wfpl-add-cart-icon.is-adding {
    color: #10b981;
    opacity: 1;
}
.wfpl-add-cart-icon {
    position: relative;
    opacity: 0.55;
    transition: opacity 0.2s ease;
}

.wfpl-add-cart-icon:hover {
    opacity: 0.85;
}

/* estado agregando */
.wfpl-add-cart-icon.is-adding {
    opacity: 1;
    pointer-events: none;
}

/* spinner mínimo */
.wfpl-add-cart-icon.is-adding::after {
    content: '';
    position: absolute;
    inset: 2px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: wfpl-spin 0.8s linear infinite;
}

@keyframes wfpl-spin {
    to { transform: rotate(360deg); }
}
.wfpl-product-link {
    text-decoration: none;
    color: inherit;
}

.wfpl-product-link:hover {
    text-decoration: underline;
}
.wfpl-last-update {
    margin-top: 24px;
    font-size: 12px;
    color: #6b7280;
    text-align: right;
}
/* Toggle costo */
.wfpl-toggle-cost {
    margin: 10px 0 20px;
    font-size: 14px;
}


/* Con costo visible */
.wfpl-show-cost .wfpl-product {
    grid-template-columns: 1fr 160px 250px;
}

/* Input costo */
.wfpl-cost {
    display: none;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-size: 14px;
    text-align: right;
}

/* Mostrar costo */
.wfpl-show-cost .wfpl-cost {
    display: block;
}
/* Fila producto */
.wfpl-ui .wfpl-product {
    display: grid;
    grid-template-columns: 1fr 250px; /* default: sin costo */
    gap: 12px;
    align-items: center;
}

/* Precio (wrap) */
.wfpl-price-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===== CON COSTO ===== */
.wfpl-ui.wfpl-show-cost .wfpl-product {
    grid-template-columns: 1fr 160px 250px;
}

/* Posicionamiento explícito */
.wfpl-name-text {
    grid-column: 1;
}

.wfpl-cost {
    grid-column: 2;
}

.wfpl-price-wrap {
    grid-column: 2; /* default */
}

.wfpl-ui.wfpl-show-cost .wfpl-price-wrap {
    grid-column: 3;
}
.wfpl-cost {
    display: none;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-size: 14px;
    text-align: right;
}

.wfpl-ui.wfpl-show-cost .wfpl-cost {
    display: block;
}
/* ===============================
   WFPL PRODUCT GRID (FINAL)
================================ */

/* Default (cliente o admin sin costo) */
.wfpl-ui .wfpl-product {
    display: grid;
    grid-template-columns: 1fr 250px;
    gap: 12px;
    align-items: center;
}

/* Admin con costos visibles */
.wfpl-ui.wfpl-show-cost .wfpl-product {
    grid-template-columns: 1fr 160px 250px;
}

/* Posicionamiento explícito */
.wfpl-ui .wfpl-name-text {
    grid-column: 1;
}

.wfpl-ui .wfpl-cost {
    grid-column: 2;
    display: none;
}

.wfpl-ui .wfpl-price-wrap {
    grid-column: 2;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Modo costo activo */
.wfpl-ui.wfpl-show-cost .wfpl-cost {
    display: block;
}

.wfpl-ui.wfpl-show-cost .wfpl-price-wrap {
    grid-column: 3;
}

/* === COSTO ACTIVO === */
.wfpl.wfpl-show-cost .wfpl-product {
    grid-template-columns: 1fr 160px 250px;
}

.wfpl.wfpl-show-cost .wfpl-cost {
    display: block;
}

.wfpl.wfpl-show-cost .wfpl-price-wrap {
    grid-column: 3;
}
/* ===============================
   WFPL COST COLUMN – FINAL FIX
================================ */

.wfpl-ui .wfpl-product {
    display: grid;
    grid-template-columns: 1fr 160px 250px;
    gap: 12px;
    align-items: center;
}

/* Nombre */
.wfpl-ui .wfpl-name-text {
    grid-column: 1;
}

/* COSTO */
.wfpl-ui .wfpl-cost {
    grid-column: 2;
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-size: 14px;
    text-align: right;
    background: #fff;
}

/* PRECIO */
.wfpl-ui .wfpl-price-wrap {
    grid-column: 3;
    display: flex;
    align-items: center;
    gap: 6px;
}

.wfpl-ui input.wfpl-price {
    width: 100%;
}
/* ===== BASE (sin costo) ===== */
.wfpl-ui .wfpl-product {
    display: grid;
    grid-template-columns: 1fr 250px; /* nombre | precio */
    gap: 12px;
    align-items: center;
}

.wfpl-ui .wfpl-cost {
    display: none;
}
/* ===== CON COSTO ===== */
.wfpl-ui.wfpl-show-cost .wfpl-product {
    grid-template-columns: 1fr 160px 250px; /* nombre | costo | precio */
}

.wfpl-ui.wfpl-show-cost .wfpl-cost {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-size: 14px;
    text-align: right;
    background: #fff;
}

.wfpl-ui.wfpl-show-cost .wfpl-price-wrap {
    grid-column: 3;
}

.wfpl-ui.wfpl-show-cost input.wfpl-price {
    width: 100%;
}
.wfpl-margin {
    font-size: 11px;
    margin-top: 4px;
    text-align: right;
}

.wfpl-margin.good { color: #16a34a; }
.wfpl-margin.warn { color: #ca8a04; }
.wfpl-margin.bad  { color: #dc2626; }

/* ===============================
   WFPL – Margen (aislado)
================================ */

.wfpl-margin {
    display: block;
    font-size: 11px;
    line-height: 1.3;
    margin-top: 4px;
    text-align: right;
    opacity: 1;
    height: auto;
    visibility: visible;
    pointer-events: none;
}

.wfpl-margin.good { color: #16a34a; }
.wfpl-margin.warn { color: #ca8a04; }
.wfpl-margin.bad  { color: #dc2626; }

.wfpl-ui input.wfpl-cost.is-dirty {
    border-color: #f59e0b;
    background: #fffbeb;
}
.wfpl-ui.wfpl-show-cost input.wfpl-price,
.wfpl-ui.wfpl-show-cost input.wfpl-cost {
    width: 100% !important;
}
/* Categorías cerradas por defecto */
.wfpl-products {
    display: none;
}
.wfpl-cost {
    width: 100%;
    box-sizing: border-box;
}
.wfpl-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #16a34a;
    color: #fff;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.25s ease;
    z-index: 9999;
    pointer-events: none;
}



/* ===============================
   INPUTS PRECIO / COSTO
================================ */

.wfpl-product {
    display: grid;
    grid-template-columns: 1fr 140px 140px 120px;
    gap: 10px;
    align-items: center;
}

.wfpl-price,
.wfpl-cost {
    width: 100% !important;
    max-width: none !important;
    min-width: 0;
    box-sizing: border-box;
    padding: 6px 8px;
    font-size: 14px;
}

/* estado modificado */
.wfpl-price.is-dirty,
.wfpl-cost.is-dirty {
    border-color: #ef4444;
    background: #fff5f5;
}

/* ocultar costo por defecto */
.wfpl-cost {
    display: none;
}

/* mostrar costo cuando toggle activo */
.wfpl-show-cost .wfpl-cost {
    display: block;
}
/* ===============================
   TOAST
================================ */

#wfpl-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #16a34a;
    color: #fff;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    box-shadow: 0 8px 20px rgba(0,0,0,.2);
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: all .3s ease;
    z-index: 9999;
}

#wfpl-toast.show {
    opacity: 1;
    transform: translateY(0);
}

#wfpl-toast.error {
    background: #dc2626;
}
