/* ==================================================
   PRODUCT BADGES - Closed-Loop & Fresh-Grind
   Display prominently below product tip on single product pages
   and in product loop alongside add-to-cart button
   ================================================== */

/* [1] BADGE CONTAINER - Below Product Tip on Single Product */
.eg-product-badges {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0 1.5rem 0;
    flex-wrap: wrap;
}

/* [2] INDIVIDUAL BADGE STYLING */
.eg-badge {
    --eg-badge-size: 2.5rem; /* Match local-only icon size (40px) */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--eg-badge-size);
    height: var(--eg-badge-size);
    border-radius: 999px;
    background: rgba(22, 112, 95, 0.12);
    border: 1px solid rgba(16, 114, 93, 0.25);
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
    text-decoration: none; /* For link badges */
}

.eg-badge img {
    width: 65%;
    height: 65%;
    object-fit: contain;
    display: block;
}

.eg-badge svg {
    width: 65%;
    height: 65%;
    display: block;
    color: #4CAF50;
}

.eg-badge:hover,
.eg-badge:focus-visible {
    background: rgba(22, 112, 95, 0.2);
    border-color: rgba(16, 114, 93, 0.5);
    transform: translateY(-1px);
}

.eg-badge:focus-visible {
    outline: 2px solid rgba(16, 114, 93, 0.5);
    outline-offset: 2px;
}

/* [3] BADGE TOOLTIPS */
.eg-badge::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 100;
    font-family: brandon-grotesque, sans-serif;
}

.eg-badge:hover::after,
.eg-badge:focus-visible::after {
    opacity: 1;
    visibility: visible;
}

/* [3.1] COMPACT INLINE HOUSEMADE ICON NEXT TO PRODUCT TITLE */
.product_title .eg-inline-housemade {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    margin-left: 0.35rem;
    vertical-align: middle;
    position: relative;
    line-height: 1;
}

.product_title .eg-inline-housemade img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.product_title .eg-inline-housemade::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 100;
    font-family: brandon-grotesque, sans-serif;
}

.product_title .eg-inline-housemade:hover::after,
.product_title .eg-inline-housemade:focus-visible::after {
    opacity: 1;
    visibility: visible;
}

/* Caffeinated in title line (single product) – same size as housemade */
.product_title .eg-badge--caffeinated-inline {
    display: inline-flex;
    align-items: center;
    margin-left: 0.35rem;
    vertical-align: middle;
}
.product_title .eg-badge--caffeinated-inline .eg-badge-icon {
    width: 1rem;
    height: 1rem;
    object-fit: contain;
}

/* [4] CLOSED-LOOP BADGE SPECIFIC STYLING */
.eg-badge--closed-loop {
    background: rgba(76, 175, 80, 0.12);
    border-color: rgba(76, 175, 80, 0.25);
}

.eg-badge--closed-loop:hover,
.eg-badge--closed-loop:focus-visible {
    background: rgba(76, 175, 80, 0.2);
    border-color: rgba(76, 175, 80, 0.5);
}

/* [4.1] COLORED SVG VERSION - No background circle needed */
.eg-badge--closed-loop-colored {
    background: transparent !important;
    border: none !important;
    width: var(--eg-badge-size) !important;
    height: var(--eg-badge-size) !important;
    padding: 0 !important;
}

.eg-badge--closed-loop-colored:hover,
.eg-badge--closed-loop-colored:focus-visible {
    background: transparent !important;
    border: none !important;
    transform: translateY(-1px) scale(1.05);
}

.eg-badge--closed-loop-colored img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
}

/* [5] FRESH-GRIND BADGE SPECIFIC STYLING (single product icon button) */
.eg-badge--fresh-grind {
    background: rgba(135, 206, 235, 0.12);
    border-color: rgba(135, 206, 235, 0.25);
}

.eg-badge--fresh-grind:hover,
.eg-badge--fresh-grind:focus-visible {
    background: rgba(135, 206, 235, 0.2);
    border-color: rgba(135, 206, 235, 0.5);
}

/* [5.0] FRESH-GRIND LOOP CHECKBOX */
.eg-fresh-grind-loop-checkbox {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: #334155;
    padding: 0.35rem 0.6rem;
    background: rgba(135, 206, 235, 0.08);
    border: 1px solid rgba(135, 206, 235, 0.25);
    border-radius: 4px;
    transition: background 0.15s ease, border-color 0.15s ease;
    font-family: brandon-grotesque, sans-serif;
    line-height: 1.3;
    width: 100%;
    box-sizing: border-box;
}

.eg-fresh-grind-loop-checkbox:hover {
    background: rgba(135, 206, 235, 0.18);
    border-color: rgba(135, 206, 235, 0.5);
}

.eg-fresh-grind-loop-checkbox .eg-fresh-grind-checkbox-input {
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
    accent-color: #4CAF50;
    margin: 0;
}

.eg-fresh-grind-loop-checkbox .eg-fresh-grind-loop-label {
    flex: 1;
    line-height: 1.3;
}

.eg-fresh-grind-loop-checkbox:has(.eg-fresh-grind-checkbox-input:checked) {
    background: rgba(76, 175, 80, 0.12);
    border-color: rgba(76, 175, 80, 0.5);
}

/* [5.1] CAFFEINATED BADGE SPECIFIC STYLING */
.eg-badge--caffeinated {
    background: transparent; /* No circle background */
    border-color: transparent;
    line-height: 1;
    padding: 0;
}

.eg-badge--caffeinated:hover,
.eg-badge--caffeinated:focus-visible {
    background: transparent;
    border-color: transparent;
}

/* Icon inside caffeinated badge */
.eg-badge--caffeinated .eg-badge-icon {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    vertical-align: middle;
}

/* [6] PRODUCT LOOP BADGES - Display inside card, above product tip */
.woocommerce ul.products li.product .eg-product-badges.eg-product-badges--loop {
    display: flex !important;
    gap: 0.5rem;
    margin: 0.75rem 0 0.5rem 0;
    align-items: center;
    visibility: visible !important;
    opacity: 1 !important;
}

.woocommerce ul.products li.product .eg-badge {
    --eg-badge-size: 3.5rem;
}

.woocommerce ul.products li.product .eg-badge img {
    width: 85%; /* Show more of the icon */
    height: 85%;
}

.woocommerce ul.products li.product .eg-badge--caffeinated .eg-badge-icon {
    width: 70%;
    height: 70%;
}

/* [7] FRESH-GRIND TOGGLE FUNCTIONALITY (single product & cart icon buttons) */
.eg-badge--fresh-grind-toggle-single,
.eg-badge--fresh-grind-toggle-cart {
    position: relative;
    cursor: pointer;
}

.eg-badge--fresh-grind-toggle-single .eg-badge-checkmark,
.eg-badge--fresh-grind-toggle-cart .eg-badge-checkmark {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #4CAF50;
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.eg-badge--fresh-grind-toggle-single.selected,
.eg-badge--fresh-grind-toggle-cart.selected {
    background: rgba(76, 175, 80, 0.25);
    border-color: rgba(76, 175, 80, 0.6);
}

.eg-badge--fresh-grind-toggle-single.selected .eg-badge-checkmark,
.eg-badge--fresh-grind-toggle-cart.selected .eg-badge-checkmark {
    display: flex;
}

.eg-badge--fresh-grind-toggle-single.selected::after,
.eg-badge--fresh-grind-toggle-cart.selected::after {
    content: attr(data-tooltip-selected);
}

/* [8] MOBILE RESPONSIVE */
@media (max-width: 768px) {
    .eg-badge {
        --eg-badge-size: 2.25rem;
    }
    
    .eg-product-badges {
        gap: 0.5rem;
        margin: 0.75rem 0 1rem 0;
    }
    
    .eg-badge--fresh-grind-toggle .eg-badge-checkmark {
        width: 16px;
        height: 16px;
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .eg-badge {
        --eg-badge-size: 2rem;
    }
    
    .eg-badge::after {
        font-size: 11px;
        padding: 4px 8px;
    }
}

/* [8] HIDE OLD INLINE CLOSED-LOOP ICON IN TITLE */
.product_title .closed-loop-icon {
    display: none !important;
}

.product_title .closed-loop-tooltip-wrapper {
    display: none !important;
}

/* [9] HIDE OLD FRESH-GROUND NOTE (replaced by badge) */
.fresh-ground-note {
    display: none !important;
}

/* [10] FRESH GRIND OPTION CHECKBOX STYLING */
.eg-fresh-grind-option {
    margin: 1rem 0 !important;
    padding: 1rem !important;
    background: rgba(135, 206, 235, 0.08) !important;
    border: 2px solid rgba(135, 206, 235, 0.25) !important;
    border-radius: 8px !important;
}

.eg-fresh-grind-option label {
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    margin: 0 !important;
    color: #1f1f1f !important;
    font-family: brandon-grotesque, sans-serif !important;
}

.eg-fresh-grind-option input[type="checkbox"] {
    width: 20px !important;
    height: 20px !important;
    cursor: pointer !important;
    border-radius: 4px !important;
    border: 2px solid rgba(135, 206, 235, 0.5) !important;
    flex-shrink: 0 !important;
}

.eg-fresh-grind-option input[type="checkbox"]:checked {
    accent-color: #87CEEB !important;
}

@media (max-width: 768px) {
    .eg-fresh-grind-option {
        padding: 0.75rem !important;
    }
    
    .eg-fresh-grind-option label {
        font-size: 13px !important;
    }
    
    .eg-fresh-grind-option input[type="checkbox"] {
        width: 18px !important;
        height: 18px !important;
    }
}

/* [11] PRODUCT CATEGORY PILLS - Below product card on single product pages */
.eg-product-categories {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 1rem 0 1.25rem 0;
}

.eg-cat-pill {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    font-size: 12px;
    font-weight: 500;
    font-family: brandon-grotesque, sans-serif;
    color: #2c5e54;
    background: rgba(44, 94, 84, 0.08);
    border: 1px solid rgba(44, 94, 84, 0.2);
    border-radius: 999px;
    text-decoration: none;
    line-height: 1.4;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    white-space: nowrap;
}

.eg-cat-pill:hover,
.eg-cat-pill:focus-visible {
    background: rgba(44, 94, 84, 0.16);
    border-color: rgba(44, 94, 84, 0.4);
    color: #2c5e54;
    text-decoration: none;
}

.eg-cat-pill:focus-visible {
    outline: 2px solid #a5ccbc;
    outline-offset: 2px;
}

/* [11.1] CATEGORY PILLS - Mobile Responsive */
@media (max-width: 768px) {
    .eg-product-categories {
        gap: 0.4rem;
        margin: 0.75rem 0 1rem 0;
    }

    .eg-cat-pill {
        font-size: 11px;
        padding: 0.2rem 0.6rem;
    }
}

@media (max-width: 480px) {
    .eg-cat-pill {
        font-size: 10px;
        padding: 0.2rem 0.5rem;
    }
}
