/* ==========================================================================
   Papelarte AD Color Palette & Bulk Matrix Styles
   ========================================================================== */

/* Ocultar formulario nativo de variaciones de WooCommerce cuando la paleta AD está activa */
body.has-ad-palette .variations_form,
body.has-ad-palette .woocommerce-variation-add-to-cart,
body.has-ad-palette .ppa-volume-quick-add {
    display: none !important;
}

/* Asegurar visibilidad inmediata del gallery en productos con paleta */
body.has-ad-palette .woocommerce-product-gallery,
body.has-ad-palette .woocommerce-product-gallery .woocommerce-product-gallery__wrapper,
body.has-ad-palette .woocommerce-product-gallery img {
    opacity: 1 !important;
    visibility: visible !important;
}

/* ==========================================================================
   Summary Callout Note (Toned-down editorial note)
   ========================================================================== */
.ppa-ad-summary-callout {
    background: #FAFAFA;
    border: 1px solid #E5E7EB;
    border-left: 3px solid #0F172A;
    border-radius: 4px;
    padding: 14px 16px;
    margin: 16px 0 20px 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ppa-ad-callout-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ppa-ad-callout-icon {
    font-size: 1rem;
    line-height: 1;
}

.ppa-ad-callout-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: #0F172A;
}

.ppa-ad-callout-desc {
    font-size: 0.8125rem;
    color: #64748B;
    line-height: 1.45;
    margin: 0;
}

.ppa-ad-callout-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #0F172A !important;
    text-decoration: underline !important;
    text-underline-offset: 3px;
    font-size: 0.8125rem;
    font-weight: 600;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin-top: 2px;
    cursor: pointer;
    transition: color 0.15s ease;
}

.ppa-ad-callout-btn:hover {
    color: #2563EB !important;
}

.ppa-ad-palette-wrap {
    width: 100%;
    max-width: 1320px;
    margin: 32px auto 40px auto;
    padding: 32px 0 24px 0;
    background: transparent;
    border-top: 1px solid #E5E7EB;
    border-bottom: 1px solid #E5E7EB;
    border-left: none;
    border-right: none;
    border-radius: 0;
    box-shadow: none;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .ppa-ad-palette-wrap {
        margin: 20px 0 28px 0;
        padding: 20px 0 16px 0;
    }
}

/* Header */
.ppa-ad-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 16px;
    padding-bottom: 20px;
    border-bottom: 1px solid #F1F5F9;
    margin-bottom: 20px;
}

.ppa-ad-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0F172A;
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ppa-ad-title-icon {
    font-size: 1.35rem;
}

.ppa-ad-subtitle {
    font-size: 0.875rem;
    color: #64748B;
    margin: 0;
}

.ppa-ad-carta-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #FFFFFF;
    color: #334155;
    border: 1px solid #CBD5E1;
    border-radius: 4px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ppa-ad-carta-btn:hover {
    background: #F8FAFC;
    border-color: #0F172A;
    color: #0F172A;
}

/* Toolbar: Search and Filters */
.ppa-ad-toolbar {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 22px;
}

@media (min-width: 900px) {
    .ppa-ad-toolbar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 20px;
    }

    .ppa-ad-search-box {
        max-width: 340px;
        flex: 0 0 340px;
    }

    .ppa-ad-family-pills {
        flex: 1;
        justify-content: flex-end;
    }
}

.ppa-ad-search-box {
    position: relative;
    width: 100%;
}

.ppa-ad-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #94A3B8;
    pointer-events: none;
}

.ppa-ad-search-input {
    width: 100%;
    height: 40px;
    padding: 0 36px 0 38px;
    background: #FFFFFF;
    border: 1px solid #CBD5E1;
    border-radius: 4px;
    font-size: 0.875rem;
    color: #0F172A;
    transition: border-color 0.15s ease;
}

.ppa-ad-search-input:focus {
    background: #FFFFFF;
    border-color: #0F172A;
    outline: none;
    box-shadow: none;
}

.ppa-ad-search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #94A3B8;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.ppa-ad-search-clear:hover {
    color: #0F172A;
}

/* Family Pills */
.ppa-ad-family-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ppa-ad-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 11px;
    background: transparent;
    color: #475569;
    border: 1px solid #E2E8F0;
    border-radius: 4px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ppa-ad-pill:hover {
    background: #F8FAFC;
    border-color: #94A3B8;
    color: #0F172A;
}

.ppa-ad-pill.is-active {
    background: #0F172A;
    color: #FFFFFF;
    border-color: #0F172A;
    font-weight: 600;
}

.ppa-pill-count {
    font-size: 0.75rem;
    color: inherit;
    opacity: 0.75;
    background: transparent;
    padding: 0;
}

.ppa-ad-pill.is-active .ppa-pill-count {
    background: transparent;
    color: inherit;
    opacity: 0.85;
}

/* Grid of Cards */
.ppa-ad-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    max-height: 720px;
    overflow-y: auto;
    padding: 6px 4px;
    scrollbar-width: thin;
    scrollbar-color: #CBD5E1 #F1F5F9;
}

.ppa-ad-grid::-webkit-scrollbar {
    width: 8px;
}

.ppa-ad-grid::-webkit-scrollbar-track {
    background: #F8FAFC;
    border-radius: 4px;
}

.ppa-ad-grid::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 4px;
}

.ppa-ad-grid::-webkit-scrollbar-thumb:hover {
    background: #94A3B8;
}

@media (min-width: 520px) {
    .ppa-ad-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 14px;
    }
}

@media (min-width: 768px) {
    .ppa-ad-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }
}

@media (min-width: 1024px) {
    .ppa-ad-grid {
        grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
        gap: 16px;
    }
}

/* Color Card (Clean, editorial, no rounded AI bubbles) */
.ppa-ad-card {
    display: flex;
    flex-direction: column;
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 6px;
    padding: 10px;
    transition: border-color 0.15s ease;
    position: relative;
    box-sizing: border-box;
}

.ppa-ad-card:hover {
    border-color: #9CA3AF;
}

.ppa-ad-card.is-selected {
    border-color: #0F172A;
    background: #FAFAFA;
    box-shadow: inset 0 0 0 1px #0F172A;
}

.ppa-ad-card-thumb {
    width: 100%;
    aspect-ratio: 1.15;
    background: #F9FAFB;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    border: 1px solid #F3F4F6;
}

.ppa-ad-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ppa-ad-card-meta {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-bottom: 8px;
}

.ppa-ad-card-top-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 4px;
}

.ppa-ad-code-badge {
    font-size: 0.8125rem;
    font-weight: 700;
    color: #0F172A;
    background: transparent !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    letter-spacing: 0.02em;
    font-family: inherit;
    flex-shrink: 0;
}

.ppa-ad-family-badge {
    font-size: 0.6875rem;
    font-weight: 500;
    color: #94A3B8;
    background: transparent !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 95px;
}

.ppa-ad-color-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #1E293B;
    margin: 0 0 6px 0;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2rem;
}

.ppa-ad-card-price {
    font-size: 0.875rem;
    font-weight: 700;
    color: #059669;
    margin-top: auto;
}

/* Stepper inside Card (Simple, sharp, utilitarian) */
.ppa-ad-stepper {
    display: flex;
    align-items: center;
    background: #FFFFFF;
    border: 1px solid #D1D5DB;
    border-radius: 4px;
    overflow: hidden;
    height: 32px;
    margin-top: 8px;
    transition: border-color 0.15s ease;
}

.ppa-ad-card.is-selected .ppa-ad-stepper {
    border-color: #0F172A;
}

.ppa-ad-step-btn {
    width: 32px;
    height: 100%;
    background: transparent;
    border: none;
    font-size: 1.125rem;
    font-weight: 600;
    color: #4B5563;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
    user-select: none;
    padding: 0;
}

.ppa-ad-step-btn:hover {
    background: #F3F4F6;
    color: #111827;
}

.ppa-ad-card.is-selected .ppa-ad-step-btn {
    color: #0F172A;
}

.ppa-ad-qty-input {
    flex: 1;
    width: 100%;
    height: 100%;
    border: none;
    border-left: 1px solid #F3F4F6;
    border-right: 1px solid #F3F4F6;
    background: transparent;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 700;
    color: #111827;
    padding: 0;
    outline: none;
    -moz-appearance: textfield;
}

.ppa-ad-qty-input::-webkit-outer-spin-button,
.ppa-ad-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* No results state */
.ppa-ad-no-results {
    padding: 32px 16px;
    text-align: center;
    color: #64748B;
    font-size: 0.9375rem;
}

/* Floating Sticky Bar (Sleek, sharp, sober) */
.ppa-ad-sticky-bar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    width: calc(100% - 32px);
    max-width: 820px;
    background: #0F172A;
    color: #FFFFFF;
    border-radius: 8px;
    padding: 12px 18px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
    z-index: 99999;
    transition: transform 0.25s ease, opacity 0.25s ease;
    opacity: 0;
    pointer-events: none;
}

.ppa-ad-sticky-bar.is-visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.ppa-ad-sticky-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.ppa-ad-sticky-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.ppa-ad-sticky-icon-wrap {
    font-size: 1.15rem;
    line-height: 1;
}

.ppa-ad-sticky-count {
    font-size: 0.875rem;
    color: #E2E8F0;
}

.ppa-ad-sticky-count strong {
    color: #FFFFFF;
}

.ppa-ad-sticky-units {
    color: #94A3B8;
}

.ppa-ad-sticky-total {
    font-size: 0.9375rem;
    font-weight: 500;
    color: #F8FAFC;
}

.ppa-ad-sticky-total strong {
    color: #FFFFFF;
    font-size: 1.0625rem;
    font-weight: 700;
}

.ppa-ad-sticky-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ppa-ad-clear-btn {
    background: none;
    border: none;
    color: #94A3B8;
    font-size: 0.8125rem;
    cursor: pointer;
    padding: 8px 12px;
    transition: color 0.15s ease;
}

.ppa-ad-clear-btn:hover {
    color: #F87171;
}

.ppa-ad-submit-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    background: #FFFFFF;
    color: #0F172A;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.ppa-ad-submit-btn:hover:not(:disabled) {
    background: #F1F5F9;
}

.ppa-ad-submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ppa-btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #FFFFFF;
    border-radius: 50%;
    animation: ppa-spin 0.6s linear infinite;
}

@keyframes ppa-spin {
    to { transform: rotate(360deg); }
}

/* Modal Lightbox */
.ppa-ad-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.ppa-ad-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
}

.ppa-ad-modal-content {
    position: relative;
    background: #FFFFFF;
    border-radius: 16px;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    z-index: 10;
}

.ppa-ad-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #E2E8F0;
}

.ppa-ad-modal-header h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #0F172A;
}

.ppa-ad-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #64748B;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}

.ppa-ad-modal-close:hover {
    color: #0F172A;
}

.ppa-ad-modal-body {
    padding: 16px;
    overflow-y: auto;
    text-align: center;
}

.ppa-ad-carta-img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    cursor: zoom-in;
}

/* Mobile adjustments */
@media (max-width: 640px) {
    .ppa-ad-palette-wrap {
        padding: 16px;
    }
    
    .ppa-ad-sticky-bar {
        bottom: 12px;
        width: calc(100% - 24px);
        padding: 12px 14px;
    }
    
    .ppa-ad-sticky-inner {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .ppa-ad-sticky-actions {
        display: flex;
        width: 100%;
    }
    
    .ppa-ad-submit-btn {
        flex: 1;
        justify-content: center;
    }
}
