/**
 * Frontend styles for WooCommerce Fragile Shipping Notice
 * Optimized for WoodMart theme & custom 2-column grid shipping methods
 */

/* --- Dashicons Fallback for Guest Users --- */
@font-face {
    font-family: "dashicons";
    src: url("/wp-includes/fonts/dashicons.eot");
    src: url("/wp-includes/fonts/dashicons.eot?#iefix") format("embedded-opentype"),
         url("/wp-includes/fonts/dashicons.woff2") format("woff2"),
         url("/wp-includes/fonts/dashicons.woff") format("woff"),
         url("/wp-includes/fonts/dashicons.ttf") format("truetype"),
         url("/wp-includes/fonts/dashicons.svg#dashicons") format("svg");
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

.wc-fragile-badge-recommended .dashicons,
.wc-fragile-badge-warning .dashicons,
.wc-fragile-method-warning-note .dashicons,
.fragile-compact-alert .fca-icon .dashicons,
.wc-fragile-risk-icon .dashicons,
.fragile-modal-box h3 .dashicons {
    font-family: dashicons, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    display: inline-block;
    line-height: 1;
    font-weight: 400;
    font-style: normal;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.dashicons-yes-alt:before { content: "\f147"; }
.dashicons-warning:before { content: "\f534"; }
.dashicons-shield:before { content: "\f332"; }

/* --- 1. Compact Top Alert Banner --- */
.fragile-compact-alert {
    display: flex;
    align-items: center;
    background-color: #fffbeb;
    border: 1px solid #fcd34d;
    color: #78350f;
    padding: 14px 20px;
    margin-bottom: 25px;
    border-radius: var(--wd-brd-radius, 8px);
    font-family: var(--wd-text-font, "Nunito", Arial, sans-serif);
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.fragile-compact-alert .fca-icon {
    margin-right: 14px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.fragile-compact-alert .fca-icon .dashicons {
    font-size: 26px;
    width: 26px;
    height: 26px;
    color: #f59e0b;
}

.fragile-compact-alert .fca-content {
    flex-grow: 1;
}

.fragile-compact-alert .fca-content strong {
    color: #92400e;
    font-size: 14px;
    font-weight: 700;
}

.fragile-more-link {
    color: #d97706;
    font-weight: 700;
    text-decoration: underline;
    margin-left: 8px;
    cursor: pointer;
    white-space: nowrap;
}

.fragile-more-link:hover {
    color: #b45309;
    text-decoration: none;
}

/* --- 2. Modal Explanation Popup --- */
.fragile-modal-overlay {
    display: none;
    position: fixed;
    z-index: 999999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(3, 31, 58, 0.65);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    font-family: var(--wd-text-font, "Nunito", Arial, sans-serif);
}

.fragile-modal-box {
    background-color: #ffffff;
    padding: 30px;
    border-radius: var(--wd-brd-radius, 12px);
    width: 90%;
    max-width: 520px;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.3);
    position: relative;
    animation: fragileFadeIn 0.25s ease-out;
}

.fragile-modal-close {
    color: #8c8f94;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
    transition: color 0.2s;
}

.fragile-modal-close:hover {
    color: #16243c;
}

.fragile-modal-box h3 {
    margin-top: 0;
    color: var(--wd-title-color, #031f3a);
    font-size: 1.3em;
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
    padding-bottom: 12px;
    display: flex;
    align-items: center;
}

.fragile-modal-body p {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 12px;
    color: var(--wd-text-color, #555658);
}

.fragile-modal-btn-ok {
    background-color: #438e44;
    color: #ffffff;
    border: none;
    padding: 12px 20px;
    border-radius: var(--btn-accented-brd-radius, 6px);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: block;
    width: 100%;
    margin-top: 20px;
    text-align: center;
    transition: background-color 0.2s;
}

.fragile-modal-btn-ok:hover {
    background-color: #357336;
}

@keyframes fragileFadeIn {
    from { opacity: 0; transform: translateY(-15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- 3. WoodMart 2-Column Grid Compatibility for Shipping Methods --- */

/* Ensure each <li> is positioned and allows order sorting */
ul#shipping_method li,
.woocommerce-shipping-methods li {
    position: relative;
    box-sizing: border-box;
}

/* Ensure the card label is a flex column so title and badge stack cleanly */
ul#shipping_method li input.shipping_method + label,
.woocommerce-shipping-methods li input.shipping_method + label,
ul#shipping_method li label,
.woocommerce-shipping-methods li label,
.woocommerce form #order_review table.shop_table input.shipping_method + label {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: flex-start !important;
    box-sizing: border-box !important;
    width: 100% !important;
    min-height: 4rem;
}

/* Ensure rpsmdw container is a clean horizontal row for icon + text */
ul#shipping_method li .rpsmdw_shipping_container,
.woocommerce-shipping-methods li .rpsmdw_shipping_container {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

ul#shipping_method li .rpsmdw_shipping_container .rpsmdw_icon,
.woocommerce-shipping-methods li .rpsmdw_shipping_container .rpsmdw_icon {
    flex: 0 0 auto !important;
    margin-right: 10px !important;
    display: flex !important;
    align-items: center !important;
}

ul#shipping_method li .rpsmdw_shipping_container .rpsmdw_title_desc_container,
.woocommerce-shipping-methods li .rpsmdw_shipping_container .rpsmdw_title_desc_container {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
}

ul#shipping_method li .rpsmdw_shipping_title,
.woocommerce-shipping-methods li .rpsmdw_shipping_title {
    display: block !important;
    font-size: 13px !important;
    line-height: 1.35 !important;
    word-break: break-word !important;
}

/* Push recommended method to the very first position in grid/list */
ul#shipping_method li.fragile-method-recommended,
.woocommerce-shipping-methods li.fragile-method-recommended {
    order: -1 !important;
}

/* --- 4. Blurred / Not Recommended Shipping Method UI Effect --- */
ul#shipping_method li.fragile-method-blurred input.shipping_method + label,
.woocommerce-shipping-methods li.fragile-method-blurred input.shipping_method + label,
.woocommerce form #order_review table.shop_table ul#shipping_method li.fragile-method-blurred input.shipping_method + label,
li.fragile-method-blurred label {
    opacity: 0.55 !important;
    filter: grayscale(35%) !important;
    background: #fffcf8 !important;
    border: 1px dashed #e67e22 !important;
    box-shadow: 0 1px 4px rgba(230, 126, 34, 0.12) !important;
    transition: all 0.25s ease-in-out !important;
}

ul#shipping_method li.fragile-method-blurred input.shipping_method + label:hover,
.woocommerce-shipping-methods li.fragile-method-blurred input.shipping_method + label:hover,
.woocommerce form #order_review table.shop_table ul#shipping_method li.fragile-method-blurred input.shipping_method + label:hover,
li.fragile-method-blurred label:hover {
    opacity: 0.88 !important;
    filter: none !important;
    border-color: #d35400 !important;
    box-shadow: 0 3px 8px rgba(230, 126, 34, 0.2) !important;
}

ul#shipping_method li.fragile-method-blurred input.shipping_method:checked + label,
ul#shipping_method li.fragile-method-blurred.is-selected input.shipping_method + label,
.woocommerce-shipping-methods li.fragile-method-blurred input.shipping_method:checked + label,
.woocommerce-shipping-methods li.fragile-method-blurred.is-selected input.shipping_method + label,
.woocommerce form #order_review table.shop_table ul#shipping_method li.fragile-method-blurred input.shipping_method:checked + label,
li.fragile-method-blurred.is-selected label {
    opacity: 1 !important;
    filter: none !important;
    background: #222840 !important;
    color: #ffffff !important;
    border: 2px solid #e74c3c !important;
    box-shadow: 0 0 0 1px #e74c3c, 0 4px 12px rgba(231, 76, 60, 0.28) !important;
}

ul#shipping_method li.fragile-method-blurred input.shipping_method:checked + label .amount,
ul#shipping_method li.fragile-method-blurred.is-selected label .amount,
.woocommerce-shipping-methods li.fragile-method-blurred input.shipping_method:checked + label .amount {
    color: #ffffff !important;
}

/* --- 5. Recommended Shipping Method (PPL) Styling --- */
ul#shipping_method li.fragile-method-recommended input.shipping_method + label,
.woocommerce-shipping-methods li.fragile-method-recommended input.shipping_method + label,
.woocommerce form #order_review table.shop_table ul#shipping_method li.fragile-method-recommended input.shipping_method + label,
li.fragile-method-recommended label {
    border: 1.5px solid #10b981 !important;
    background: #fbfdfc !important;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.08) !important;
}

ul#shipping_method li.fragile-method-recommended input.shipping_method:checked + label,
ul#shipping_method li.fragile-method-recommended.is-selected input.shipping_method + label,
.woocommerce-shipping-methods li.fragile-method-recommended input.shipping_method:checked + label,
.woocommerce-shipping-methods li.fragile-method-recommended.is-selected input.shipping_method + label,
.woocommerce form #order_review table.shop_table ul#shipping_method li.fragile-method-recommended input.shipping_method:checked + label,
li.fragile-method-recommended.is-selected label {
    opacity: 1 !important;
    background: #222840 !important;
    color: #ffffff !important;
    border: 2px solid #10b981 !important;
    box-shadow: 0 0 0 1px #10b981, 0 4px 12px rgba(16, 185, 129, 0.25) !important;
}

/* Recommended badge dedicated row wrapper */
.wc-fragile-badge-recommended-wrap {
    display: block !important;
    margin-top: 6px !important;
    clear: both !important;
    line-height: 1 !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* Recommended badge (PPL) */
.wc-fragile-badge-recommended,
.recommended-label {
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    background-color: #ecfdf5 !important;
    color: #065f46 !important;
    border: 1px solid #a7f3d0 !important;
    border-radius: 4px !important;
    padding: 2px 7px !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    margin: 0 !important;
    vertical-align: middle !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
    max-width: 100% !important;
    font-family: inherit !important;
}

.wc-fragile-badge-recommended .dashicons {
    font-size: 13px !important;
    width: 13px !important;
    height: 13px !important;
    color: #10b981 !important;
    flex-shrink: 0 !important;
}

.wc-badge-full {
    display: inline !important;
}

.wc-badge-short {
    display: none !important;
}

/* Recommended badge when card is active/checked */
ul#shipping_method li.fragile-method-recommended input.shipping_method:checked + label .wc-fragile-badge-recommended,
ul#shipping_method li.fragile-method-recommended.is-selected label .wc-fragile-badge-recommended,
.woocommerce-shipping-methods li.fragile-method-recommended input.shipping_method:checked + label .wc-fragile-badge-recommended,
.woocommerce-shipping-methods li.fragile-method-recommended.is-selected label .wc-fragile-badge-recommended {
    background-color: rgba(16, 185, 129, 0.25) !important;
    color: #6ee7b7 !important;
    border-color: #10b981 !important;
}



/* Warning pill badge */
.wc-fragile-badge-warning {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background-color: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.3;
    align-self: flex-start;
    font-family: var(--wd-text-font, "Nunito", Arial, sans-serif);
}

.wc-fragile-badge-warning .dashicons {
    font-size: 13px;
    width: 13px;
    height: 13px;
    color: #dc2626;
}

/* Custom Warning text note below method */
.wc-fragile-method-warning-note {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 7px 10px;
    background: #fff8f8;
    border: 1px solid #fecaca;
    border-radius: 4px;
    font-size: 11px;
    line-height: 1.4;
    color: #7f1d1d;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
    font-family: var(--wd-text-font, "Nunito", Arial, sans-serif);
}

.wc-fragile-method-warning-note .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    margin-top: 1px;
    color: #dc2626;
    flex-shrink: 0;
}

/* --- 7. Risk Confirmation Box at Checkout --- */
.wc-fragile-risk-box {
    margin: 20px 0;
    padding: 18px 20px;
    background-color: #fffdf7;
    border: 1.5px solid #f59e0b;
    border-radius: var(--wd-brd-radius, 8px);
    box-shadow: 0 2px 10px rgba(245, 158, 11, 0.08);
    font-family: var(--wd-text-font, "Nunito", Arial, sans-serif);
    animation: fragileRiskSlide 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.wc-fragile-risk-box-inner {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.wc-fragile-risk-icon {
    flex-shrink: 0;
    margin-top: 2px;
}

.wc-fragile-risk-icon .dashicons {
    font-size: 26px;
    width: 26px;
    height: 26px;
    color: #d97706;
}

.wc-fragile-risk-content {
    flex-grow: 1;
}

.wc-fragile-risk-label {
    display: flex !important;
    align-items: flex-start !important;
    gap: 12px;
    cursor: pointer;
    margin: 0 !important;
}

.wc-fragile-risk-label input[type="checkbox"] {
    margin-top: 3px !important;
    width: 19px !important;
    height: 19px !important;
    flex-shrink: 0;
    accent-color: #d97706;
}

.wc-fragile-risk-text {
    font-size: 13px;
    line-height: 1.5;
    color: #2d3748;
}

.wc-fragile-risk-text strong {
    color: #b45309;
    display: block;
    margin-bottom: 4px;
    font-size: 14px;
}

.wc-fragile-risk-text .required {
    color: #dc2626;
    text-decoration: none;
    font-weight: bold;
    margin-left: 2px;
}

@keyframes fragileRiskSlide {
    0% { opacity: 0; transform: translateY(-10px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* --- Mobile Responsiveness --- */
@media (max-width: 576px) {
    .fragile-compact-alert {
        padding: 12px 14px;
        font-size: 13px;
    }

    .wc-fragile-method-meta-wrap {
        margin-top: 2px;
        margin-bottom: 8px;
    }

    .wc-fragile-risk-box {
        padding: 14px 15px;
    }

    .wc-fragile-risk-text {
        font-size: 12px;
    }
}
