/* ===== WinMall APF Theme — Layout ===== */

/* ---- Field Group Container ---- */

.wapf .wapf-field-group {
    display: flex;
    flex-direction: column;
    gap: var(--wm-gap-field);
    background: var(--wm-bg);
    padding: 24px;
}

/* ---- Section Dividers ---- */

.wapf .wapf-field-container:not(:last-child)::after {
    content: '';
    display: block;
    margin-top: var(--wm-gap-field);
    border-bottom: 1px solid var(--wm-border);
}

/* ---- Field Labels ---- */

.wapf .wapf-field-label span {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: var(--wm-text);
    margin-bottom: 12px;
}

/* ---- Field Description ---- */

.wapf .wapf-field-description {
    font-size: 13px;
    color: var(--wm-text-secondary);
    margin-top: 8px;
}

/* ---- Grand Total Area ---- */

.wapf .wapf-product-totals {
    margin-top: var(--wm-gap-field);
    padding: 16px 24px;
    background: var(--wm-bg-card);
    border-radius: var(--wm-card-radius);
    border: 1px solid var(--wm-border);
}

.wapf .wapf-product-totals .wapf--inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.wapf .wapf-grand-total {
    font-size: 24px;
    font-weight: 700;
    color: var(--wm-primary);
}

/* ---- Add to Cart Button ---- */

.wapf ~ .e-atc-qty-button-holder .single_add_to_cart_button {
    background: var(--wm-primary) !important;
    border-color: var(--wm-primary) !important;
    color: #ffffff !important;
    border-radius: var(--wm-card-radius);
    font-weight: 600;
    padding: 12px 32px;
    transition: background var(--wm-transition);
}

.wapf ~ .e-atc-qty-button-holder .single_add_to_cart_button:hover {
    background: var(--wm-primary-hover) !important;
}

/* ---- Matrix Container ---- */

.wm-apf-matrix {
    display: flex;
    flex-direction: column;
    gap: var(--wm-gap-option);
}

/* ---- Matrix Rows ---- */

.wm-apf-matrix-header-row,
.wm-apf-matrix-row {
    display: grid;
    gap: var(--wm-gap-option);
}

/* Top-left corner: axis labels */
.wm-apf-matrix-corner {
    position: relative;
    font-size: 12px;
    color: var(--wm-text-secondary);
    min-height: 48px;
}

.wm-apf-matrix-corner-label {
    position: absolute;
    line-height: 1.2;
}

.wm-apf-matrix-corner-label:first-child {
    /* Quantità — bottom-center */
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
}

.wm-apf-matrix-corner-label:last-child {
    /* Data — right-center */
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
}

/* ---- Shared Card Style (matches Grammatura VCard) ---- */

.wm-apf-matrix .wm-apf-card {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--wm-padding-card);
    background: var(--wm-bg-card);
    border: 1px solid var(--wm-border);
    border-radius: var(--wm-card-radius);
    font-size: 14px;
    font-weight: 600;
    color: var(--wm-text);
    cursor: pointer;
    transition: border-color var(--wm-transition),
                box-shadow var(--wm-transition),
                background var(--wm-transition),
                color var(--wm-transition);
    min-height: 48px;
    text-align: center;
}

.wm-apf-matrix .wm-apf-card:hover {
    border-color: var(--wm-primary);
    box-shadow: var(--wm-card-shadow-hover);
}

/* ---- Selected State ---- */

.wm-apf-matrix .wm-apf-card.wm-apf-matrix-selected,
.wm-apf-matrix .wm-apf-card.wm-apf-matrix-header-selected {
    border: 2px solid var(--wm-border-active);
    background: var(--wm-primary-light);
    box-shadow: var(--wm-card-shadow);
}

/* ---- Spinner ---- */

.wm-apf-matrix .wm-apf-spinner {
    display: inline-block;
    width: var(--wm-spinner-size);
    height: var(--wm-spinner-size);
    border: 2px solid var(--wm-border);
    border-top-color: var(--wm-spinner-color);
    border-radius: 50%;
    animation: wm-apf-spin 0.6s linear infinite;
    vertical-align: middle;
}

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

/* ---- Hide matrix source fields ---- */

.wm-apf-matrix-source {
    display: none !important;
}
