/**
 * My Custom Elements — style widgetu "Dodaj do koszyka" (shortcode [mce_simple_cart]).
 *
 * W wersji 1.0.0 wtyczki CSS był drukowany inline w HTML przy każdym renderze
 * przez render_styles() / render_ppom_styles() (~500 linii CSS w HTML produktu).
 * Od 1.1.0 przenieśliśmy go tutaj — plik jest cachowany przez przeglądarkę
 * i CDN-y, a HTML produktu jest ~15 KB lżejszy.
 */

/* ========================================================================
 *  Widget główny (cena / wysyłka / stock / qty / CTA)
 * ======================================================================== */

/* Style widgetu */
.mce-simple-widget {
    background: linear-gradient(145deg, #ffffff, #fcfaff);
    border: 1px solid #e8d5ff;
    border-radius: 16px;
    padding: 25px;
    margin: 20px 0;
    box-shadow: 0 10px 30px rgba(94, 42, 132, 0.05);
    position: relative;
    overflow: hidden;
}

.mce-trust-badges {
    margin-top: 15px;
    font-size: 0.85em;
    color: #555;
    display: grid;
    grid-template-columns: 1fr 1fr; /* Dwie kolumny */
    gap: 8px;
}

.mce-badge-item {
    display: flex;
    align-items: center;
    gap: 5px;
    line-height: 1.2;
}

.mce-simple-widget::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #5e2a84, #c0392b, #5e2a84);
    background-size: 200% auto;
    animation: mceGradientMove 3s linear infinite;
}
@keyframes mceGradientMove {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

.mce-simple-price-section {
    text-align: center;
    margin-bottom: 20px;
    padding: 20px;
    background: linear-gradient(135deg, rgba(94, 42, 132, 0.03) 0%, rgba(192, 57, 43, 0.03) 100%);
    border-radius: 12px;
    position: relative;
}
.mce-simple-price-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #8e44ad;
    margin-bottom: 8px;
    opacity: 0.8;
}
.mce-simple-price-box {
    text-align: center;
    margin-bottom: 10px;
    font-size: 36px !important;
    font-weight: 900 !important;
    line-height: 1.2;
}
/* Główna cena - wszystkie możliwe selektory */
.mce-simple-price-box,
.mce-simple-price-box .price,
.mce-simple-price-box .amount,
.mce-simple-price-box .woocommerce-Price-amount,
.mce-simple-price-box bdi {
    background: linear-gradient(135deg, #5e2a84 0%, #8e44ad 50%, #c0392b 100%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
}
/* Stara cena (przekreślona) */
.mce-simple-price-box del,
.mce-simple-price-box del .amount,
.mce-simple-price-box del .woocommerce-Price-amount,
.mce-simple-price-box del bdi {
    font-size: 0.5em !important;
    font-weight: 400 !important;
    opacity: 0.7 !important;
    text-decoration: line-through !important;
    background: none !important;
    -webkit-text-fill-color: #aaa !important;
    color: #aaa !important;
}
/* Nowa cena (promocyjna) */
.mce-simple-price-box ins,
.mce-simple-price-box ins .amount,
.mce-simple-price-box ins .woocommerce-Price-amount,
.mce-simple-price-box ins bdi {
    text-decoration: none !important;
    background: linear-gradient(135deg, #5e2a84 0%, #8e44ad 50%, #c0392b 100%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
    font-weight: 900 !important;
}
.mce-simple-price-footer {
    font-size: 11px;
    color: #666;
    font-style: italic;
}
.mce-shipping-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #f8f4ff 0%, #fff5f5 100%);
    border-radius: 25px;
    margin-bottom: 20px;
    border: 1px solid #e8d5ff;
}
.mce-shipping-icon {
    font-size: 18px;
    animation: mceFloat 3s ease-in-out infinite;
}
@keyframes mceFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-3px); }
}
.mce-shipping-text {
    font-size: 13px;
    font-weight: 600;
    color: #5e2a84;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mce-simple-stock {
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 25px;
    padding: 5px 15px;
    border-radius: 20px;
}
.mce-stock-ok {
    color: #27ae60;
    background: #f0fff4;
    border: 1px solid #c3e6cb;
}
.mce-stock-low {
    color: #c0392b;
    background: #fff5f5;
    border: 1px solid #f5c6cb;
    animation: mcePulse 2s infinite;
}
.mce-stock-out {
    color: #777;
    background: #eee;
}
.mce-stock-back {
    color: #d35400;
    background: #fffbf0;
}
@keyframes mcePulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

.mce-simple-actions {
    display: flex;
    gap: 15px;
    align-items: stretch;
}

.mce-simple-qty-wrapper {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 50px;
    width: 120px;
    flex-shrink: 0;
    transition: border-color 0.3s;
    position: relative;
    z-index: 10;
}
.mce-simple-qty-wrapper:hover {
    border-color: #8e44ad;
}

.mce-simple-btn-qty {
    width: 40px;
    height: 50px;
    background: none;
    border: none;
    font-size: 18px;
    color: #5e2a84;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    touch-action: manipulation;
}
.mce-simple-btn-qty:hover {
    color: #c0392b;
    background: rgba(0,0,0,0.02);
    border-radius: 50%;
}

.mce-simple-qty-input {
    width: 40px !important;
    height: 100% !important;
    border: none !important;
    background: transparent !important;
    text-align: center;
    font-size: 16px !important;
    font-weight: 700 !important;
    color: #333 !important;
    padding: 0 !important;
    margin: 0 !important;
    -moz-appearance: textfield;
}
.mce-simple-qty-input::-webkit-outer-spin-button,
.mce-simple-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.mce-simple-qty-input:focus {
    outline: none !important;
    box-shadow: none !important;
}

.mce-simple-submit {
    flex-grow: 1;
    min-width: 200px;
    min-height: 50px;
    padding: 12px 30px;
    background: linear-gradient(135deg, #5e2a84 0%, #8e44ad 100%);
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(94, 42, 132, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.mce-simple-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(94, 42, 132, 0.35);
    background: linear-gradient(135deg, #4b2c68 0%, #c0392b 100%);
}

@media (max-width: 480px) {
    .mce-simple-actions {
        flex-direction: column;
    }
    .mce-simple-qty-wrapper {
        width: 100%;
        justify-content: space-between;
    }
}

/* ========================================================================
 *  Integracja z PPOM (Product Addons)
 * ======================================================================== */

.mce-ppom-wrapper {
    margin-bottom: 20px;
    background: linear-gradient(145deg, #fefeff, #f9f5ff);
    border: 1px solid #e8d5ff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(94, 42, 132, 0.05);
    transition: all 0.3s ease;
}
.mce-ppom-wrapper.mce-ppom-expanded {
    box-shadow: 0 4px 20px rgba(94, 42, 132, 0.12);
}
.mce-ppom-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
    background: linear-gradient(135deg, rgba(94, 42, 132, 0.03) 0%, rgba(192, 57, 43, 0.03) 100%);
}
.mce-ppom-header:hover {
    background: linear-gradient(135deg, rgba(94, 42, 132, 0.08) 0%, rgba(192, 57, 43, 0.08) 100%);
}
.mce-ppom-header > div:first-child {
    display: flex;
    align-items: center;
    gap: 10px;
}
.mce-ppom-icon {
    font-size: 20px;
    animation: mceSparkle 2s ease-in-out infinite;
}
@keyframes mceSparkle {
    0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
    50% { transform: scale(1.1) rotate(10deg); opacity: 0.8; }
}
.mce-ppom-title {
    font-size: 14px;
    font-weight: 700;
    color: #5e2a84;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.mce-ppom-arrow {
    font-size: 12px;
    color: #8e44ad;
    transition: transform 0.3s ease;
}
.mce-ppom-fields {
    padding: 20px;
    animation: mceSlideDown 0.3s ease;
}
@keyframes mceSlideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Ukrywanie domyślnego pytania o intencję */
.mce-ppom-fields .ppom-field-wrapper[data-data_name="intencja"] {
    display: none !important;
}

/* Style dla checkboxów jako buttonów */
.mce-ppom-fields .ppom-field-wrapper[data-data_name="czy_doda__intencje_"] {
    width: 100%;
}
.mce-ppom-fields .ppom-field-wrapper[data-data_name="czy_doda__intencje_"] label.form-control-label {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
    display: block;
}
.mce-ppom-fields .ppom-field-wrapper[data-data_name="czy_doda__intencje_"] .show_description {
    display: block;
    font-size: 12px;
    color: #666;
    font-weight: 400;
    font-style: italic;
    margin-top: 5px;
    line-height: 1.4;
}

/* Kontener buttonów */
.mce-ppom-fields .form-group.ppom-input-czy_doda__intencje_ {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    margin-top: 15px;
}

/* Pojedyncza opcja jako button */
.mce-ppom-fields .form-check-inline {
    margin: 0;
    width: 100%;
}
.mce-ppom-fields .form-check-inline .form-check-label {
    display: block;
    width: 100%;
    margin: 0;
    cursor: pointer;
}

/* Ukrywamy domyślny checkbox */
.mce-ppom-fields input[type="checkbox"].ppom-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* Button style dla label */
.mce-ppom-fields .ppom-label-checkbox {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: white;
    border: 2px solid #e8d5ff;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}
.mce-ppom-fields .ppom-label-checkbox::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 100%;
    background: linear-gradient(135deg, rgba(94, 42, 132, 0.1) 0%, rgba(192, 57, 43, 0.1) 100%);
    transition: width 0.3s ease;
    z-index: 0;
}
.mce-ppom-fields .ppom-label-checkbox > * {
    position: relative;
    z-index: 1;
}

/* Hover */
.mce-ppom-fields .ppom-label-checkbox:hover {
    border-color: #8e44ad;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(94, 42, 132, 0.15);
}
.mce-ppom-fields .ppom-label-checkbox:hover::before {
    width: 100%;
}

/* Zaznaczony checkbox */
.mce-ppom-fields input[type="checkbox"]:checked + .ppom-label-checkbox {
    background: linear-gradient(135deg, #5e2a84 0%, #8e44ad 50%, #c0392b 100%);
    border-color: #5e2a84;
    color: white;
    box-shadow: 0 6px 20px rgba(94, 42, 132, 0.3);
    transform: translateY(-2px);
}
.mce-ppom-fields input[type="checkbox"]:checked + .ppom-label-checkbox::before {
    width: 0;
}

/* Cena opcji */
.mce-ppom-fields .ppom-option-label-price {
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    white-space: nowrap;
}
.mce-ppom-fields input[type="checkbox"]:checked + .ppom-label-checkbox .ppom-option-label-price {
    background: rgba(255, 255, 255, 0.3);
}

/* Ukrywanie tabel cenowych PPOM */
.mce-ppom-fields #ppom-price-container,
.mce-ppom-fields #ppom-price-cloner-wrapper {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .mce-ppom-fields .form-group.ppom-input-czy_doda__intencje_ {
        grid-template-columns: 1fr;
    }
}

/* =========================================================================
   UX FEEDBACK — stan "dodawanie do koszyka" (v1.2.0)
   Po kliknieciu "Do koszyka" przycisk disable'uje sie i pokazuje spinner,
   zeby user nie klikal drugi raz zanim strona sie przeladuje.
   ========================================================================= */
.mce-simple-submit.is-loading {
    opacity: 0.85;
    cursor: wait;
    pointer-events: none;
}

.mce-simple-submit[disabled],
.mce-simple-submit[aria-busy="true"] {
    cursor: wait;
}

.mce-simple-submit .mce-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 6px;
    vertical-align: -3px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: mce-spin 0.8s linear infinite;
}

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