/* Trikon Free Shipping v1.2 - Optimized */

/* ================================================================
   Product-card free-shipping badge (injected + filled by JS)
   Locks layout so the badge sits at the SAME vertical position on
   every card regardless of whether the card has availability /
   description / other optional rows. This prevents the badge from
   "shifting per product" that some themes exhibit.
   ================================================================ */
.product-miniature .product-freeshipping.trikon-fs-injected,
.product-miniature .product-freeshipping.trikon-fs-filled,
.js-product-miniature .product-freeshipping.trikon-fs-injected,
.js-product-miniature .product-freeshipping.trikon-fs-filled,
.product-container .product-freeshipping.trikon-fs-injected,
.product-container .product-freeshipping.trikon-fs-filled {
    display: block;
    margin: 6px 0 0;
    padding: 0;
    font-size: 12px;
    line-height: 1.4;
    text-align: left;
    background: transparent;
    border: 0;
    color: inherit;
    box-sizing: border-box;
    min-height: 18px;
}

.product-miniature .product-freeshipping.trikon-fs-injected i,
.product-miniature .product-freeshipping.trikon-fs-filled i,
.js-product-miniature .product-freeshipping.trikon-fs-injected i,
.js-product-miniature .product-freeshipping.trikon-fs-filled i,
.product-container .product-freeshipping.trikon-fs-injected i,
.product-container .product-freeshipping.trikon-fs-filled i {
    margin-right: 4px;
}


.trikon-freeshipping-wrapper {
    margin: 15px 0;
    padding: 0;
    contain: content; /* layout isolation for faster paint */
}

/* Main container */
.trikon-fs-banner {
    padding: 14px 18px;
    border-radius: 8px;
    background-color: #f5f5f5;
    border: 1px solid #e0e0e0;
    will-change: opacity; /* GPU hint for transitions */
    animation: trikonFsIn 0.3s ease both;
}

@keyframes trikonFsIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Top row */
.trikon-fs-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

/* Message text */
.trikon-fs-text {
    font-size: 14px;
    font-weight: 400;
    color: #333;
    line-height: 1.4;
}

.trikon-fs-text strong {
    font-weight: 600;
    color: #c0392b;
}

/* Country indicator */
.trikon-fs-country {
    font-size: 12px;
    color: #777;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.trikon-fs-country svg {
    width: 14px;
    height: 14px;
    stroke: #777;
    flex-shrink: 0;
}

/* Progress bar — GPU accelerated */
.trikon-fs-progress {
    height: 6px;
    background-color: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 10px;
}

.trikon-fs-progress-bar {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, #04697e, #2fb5d2);
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 2%;
    will-change: width;
}

/* Meta row */
.trikon-fs-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 11px;
    color: #999;
}

/* ---- Reached state (TRIKON Petrol green) ---- */
.trikon-fs-banner.trikon-fs-reached {
    background-color: #eaf6f8;
    border-color: #b3dce3;
}

.trikon-fs-reached .trikon-fs-text {
    color: #04697e;
    font-weight: 600;
}

.trikon-fs-reached .trikon-fs-text strong {
    color: #04697e;
}

.trikon-fs-reached .trikon-fs-icon {
    stroke: #04697e;
}

.trikon-fs-reached .trikon-fs-progress-bar {
    width: 100% !important;
    background: linear-gradient(90deg, #04697e, #2fb5d2);
}

.trikon-fs-reached .trikon-fs-top {
    justify-content: flex-start;
    gap: 10px;
}

.trikon-fs-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* ---- Modal specific ---- */
#blockcart-modal .trikon-freeshipping-wrapper {
    margin: 10px 15px 5px;
}

#blockcart-modal .trikon-fs-banner {
    padding: 12px 14px;
}

#blockcart-modal .trikon-fs-text {
    font-size: 13px;
}

/* ---- Mobile ---- */
@media (max-width: 480px) {
    .trikon-fs-banner {
        padding: 12px 14px;
    }
    .trikon-fs-text {
        font-size: 13px;
    }
    .trikon-fs-progress {
        height: 5px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .trikon-fs-banner { animation: none; }
    .trikon-fs-progress-bar { transition: none; }
}

/* Print */
@media print {
    .trikon-freeshipping-wrapper, .tfs-overlay, .tfs-overlay-bg { display: none !important; }
}

/* ================================================================
   ADD-TO-CART OVERLAY — Shared Styles
   ================================================================ */
.tfs-overlay-bg {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    z-index: 2147483640;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.tfs-overlay-bg.tfs-visible {
    opacity: 1;
    visibility: visible;
}

.tfs-overlay {
    position: fixed;
    z-index: 2147483641;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    opacity: 0;
    visibility: hidden;
}
.tfs-overlay.tfs-visible {
    opacity: 1;
    visibility: visible;
}

/* Product info */
.tfs-product {
    display: flex;
    gap: 14px;
    align-items: center;
}
.tfs-product-img {
    width: 70px;
    height: 70px;
    object-fit: contain;
    border-radius: 6px;
    background: #f8f8f8;
    flex-shrink: 0;
}
.tfs-product-info { flex: 1; min-width: 0; }
.tfs-product-name {
    font-size: 14px;
    font-weight: 600;
    color: #232323;
    margin: 0 0 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tfs-product-price {
    font-size: 15px;
    font-weight: 700;
    color: #04697e;
    margin: 0;
}
.tfs-product-qty {
    font-size: 12px;
    color: #999;
}

/* Header */
.tfs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.tfs-title {
    font-size: 14px;
    font-weight: 700;
    color: #1a8a5c;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}
.tfs-title svg { stroke: #1a8a5c; flex-shrink: 0; }
.tfs-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: rgba(0,0,0,0.04);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #999;
    transition: all 0.2s;
}
.tfs-close:hover { background: rgba(0,0,0,0.08); color: #333; }

/* Shipping progress inside overlay */
.tfs-shipping {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(0,0,0,0.06);
}
.tfs-shipping-text {
    font-size: 13px;
    color: #555;
    margin-bottom: 8px;
}
.tfs-shipping-text strong { color: #c0392b; font-weight: 600; }
.tfs-shipping-reached {
    font-size: 13px;
    font-weight: 600;
    color: #04697e;
    display: flex;
    align-items: center;
    gap: 6px;
}
.tfs-shipping-reached svg { stroke: #04697e; }

/* Mini progress */
.tfs-mini-progress {
    height: 4px;
    background: #e8e8e8;
    border-radius: 2px;
    overflow: hidden;
    margin: 8px 0;
}
.tfs-mini-progress-bar {
    height: 100%;
    border-radius: 2px;
    background: linear-gradient(90deg, #04697e, #2fb5d2);
    transition: width 0.4s ease;
}
.tfs-mini-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #aaa;
}

/* Buttons */
.tfs-buttons {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}
.tfs-btn {
    flex: 1;
    padding: 11px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    line-height: 1.3;
}
.tfs-btn-secondary {
    background: #f0f0f0;
    color: #333;
}
.tfs-btn-secondary:hover { background: #e4e4e4; color: #333; text-decoration: none; }
.tfs-btn-primary {
    background: #04697e;
    color: #fff;
}
.tfs-btn-primary:hover { background: #035566; color: #fff; text-decoration: none; }

/* ================================================================
   Sidebar Flyout (Mini-Cart)
   ================================================================ */
.tfs-overlay.tfs-sidebar {
    top: 0; right: 0;
    width: 380px; max-width: 90vw;
    height: 100vh; height: 100dvh;
    transform: translateX(102%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease, visibility 0.3s ease;
}
.tfs-overlay.tfs-sidebar.tfs-visible {
    transform: translateX(0);
}
.tfs-sidebar .tfs-inner {
    background: #fff;
    height: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 30px rgba(0,0,0,0.07);
}
.tfs-sidebar .tfs-header {
    padding: 20px 22px 14px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    margin: 0;
}
.tfs-sidebar .tfs-body {
    flex: 1;
    padding: 18px 22px;
    overflow-y: auto;
}
.tfs-sidebar .tfs-buttons {
    padding: 16px 22px;
    border-top: 1px solid rgba(0,0,0,0.06);
    margin: 0;
    flex-direction: column;
}
.tfs-sidebar-bg { background: rgba(0,0,0,0.15); }

@media (max-width: 480px) {
    .tfs-overlay.tfs-sidebar { width: 100vw; max-width: 100vw; }
}

/* ================================================================
   MINI-CART: Cart items list
   ================================================================ */
.tfs-cart-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    position: relative;
}
.tfs-cart-item:last-child { border-bottom: none; }
.tfs-cart-item .tfs-product-img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 6px;
    background: #f8f8f8;
    flex-shrink: 0;
}
.tfs-cart-item .tfs-product-info { flex: 1; min-width: 0; }
.tfs-cart-item .tfs-product-name {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    margin: 0 0 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.tfs-cart-item .tfs-product-price {
    font-size: 13px;
    font-weight: 600;
    color: #04697e;
    margin: 0;
}
.tfs-product-qty {
    font-weight: 400;
    color: #999;
    font-size: 12px;
}
.tfs-product-total {
    font-size: 12px;
    color: #777;
    margin: 2px 0 0;
}
.tfs-item-remove {
    position: absolute;
    top: 12px;
    right: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: #ccc;
    padding: 4px;
    transition: color 0.2s;
}
.tfs-item-remove:hover { color: #c0392b; }
.tfs-cart-count {
    font-weight: 400;
    color: #999;
    font-size: 13px;
}

/* Quantity controls */
.tfs-qty-row {
    display: flex;
    align-items: center;
    gap: 0;
    margin-top: 6px;
}
.tfs-qty-btn {
    width: 26px;
    height: 26px;
    background: #f0f0f0;
    border: 1px solid #e0e0e0;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    line-height: 1;
}
.tfs-qty-btn:hover { background: #e4e4e4; }
.tfs-qty-minus { border-radius: 4px 0 0 4px; }
.tfs-qty-plus { border-radius: 0 4px 4px 0; }
.tfs-qty-value {
    width: 32px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    border-top: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
    height: 26px;
    line-height: 26px;
    background: #fff;
}
.tfs-qty-row .tfs-product-total {
    margin-left: auto;
    font-size: 13px;
    font-weight: 600;
    color: #333;
}

/* Empty cart */
.tfs-empty-cart {
    text-align: center;
    color: #999;
    padding: 40px 0;
    font-size: 14px;
}

/* Cart footer — totals */
.tfs-cart-footer {
    border-top: 1px solid rgba(0,0,0,0.08);
    padding: 14px 22px 18px;
    flex-shrink: 0;
}
.tfs-cart-totals { margin-bottom: 14px; }
.tfs-total-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #777;
    padding: 3px 0;
}
.tfs-total-grand {
    font-size: 15px;
    font-weight: 700;
    color: #232323;
    padding-top: 8px;
    border-top: 1px solid rgba(0,0,0,0.06);
    margin-top: 6px;
}

/* ================================================================
   Mobile optimizations for Mini-Cart Sidebar
   ================================================================ */
@media (max-width: 480px) {
    .tfs-overlay.tfs-sidebar {
        width: 100vw;
        max-width: 100vw;
    }
    .tfs-sidebar .tfs-header {
        padding: 16px 16px 12px;
    }
    .tfs-sidebar .tfs-body {
        padding: 12px 16px;
    }
    .tfs-cart-item .tfs-product-img {
        width: 50px;
        height: 50px;
    }
    .tfs-cart-item .tfs-product-name {
        font-size: 12px;
    }
    .tfs-cart-footer {
        padding: 12px 16px 16px;
    }
    .tfs-btn {
        padding: 12px 14px;
        font-size: 14px;
    }
}

@media (max-width: 768px) {
    .tfs-sidebar .tfs-body {
        -webkit-overflow-scrolling: touch;
    }
    .tfs-btn {
        min-height: 44px;
    }
    .tfs-qty-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    .tfs-qty-value {
        width: 36px;
        height: 32px;
        line-height: 32px;
        font-size: 14px;
    }
}

/* Safe area for notched phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .tfs-cart-footer {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .tfs-overlay { transition: none !important; }
    .tfs-overlay-bg { transition: none !important; }
}
