/* WooCommerce Food Information - Frontend Styles */

/* Food Information Tab Content */
.wc-food-information-tab {
    max-width: 800px;
    line-height: 1.6;
    margin: 0 auto;
    /* Center align the tab content */
    text-align: center;
    /* Center align text content */
}

.wc-food-information-tab h3 {
    color: #333;
    border-bottom: 2px solid #4CAF50;
    padding-bottom: 10px;
    margin-bottom: 20px;
    margin-top: 40px;
    /* Increased distance between blocks */
}

.wc-food-information-tab h3:first-child {
    margin-top: 0;
}

.wc-food-information-tab h4 {
    color: #555;
    margin-bottom: 10px;
    margin-top: 20px;
}

/* Center align tables */
.wc-food-information-tab table {
    margin: 0 auto;
    text-align: left;
    /* Keep table content left-aligned for readability */
}

/* Main content sections with increased spacing */
.food-composition,
.food-nutrition,
.food-section {
    margin-bottom: 40px;
    /* Increased spacing between major sections */
}

/* Style the product information box same as nutrition box */
.food-composition {
    background: #fff;
    padding: 20px;
    border-radius: 6px;
    border: 1px solid #ddd;
}

.food-section {
    padding: 15px;
    background: #f9f9f9;
    border-radius: 6px;
    border-left: 4px solid #4CAF50;
}

/* Allergen warning styling */
.allergens-info {
    border-left-color: #ff9800 !important;
    background: #fff8e1;
}

.allergen-warning {
    background: #ffecb3;
    padding: 12px 15px;
    border-radius: 4px;
    border: 1px solid #ffc107;
    color: #e65100;
}

.warning-icon {
    font-size: 18px;
    margin-right: 8px;
}

/* Nutritional values styling */
.nutrition-table {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #e6e6e6;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}

/* Headings inside nutrition box: same green underline but tighter top spacing */
.nutrition-table h3 {
    color: #333;
    border-bottom: 2px solid #4CAF50;
    padding-bottom: 10px;
    margin-bottom: 16px;
    margin-top: 0;
}

/* If multiple h3s appear inside the nutrition box, add spacing above subsequent headings */
.nutrition-table h3:not(:first-of-type) {
    margin-top: 24px;
}

/* EU Nutritional Table Styling */
.eu-nutrition-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 0;
    background: #fff;
    font-family: Arial, sans-serif;
    border: 1px solid #eaeaea;
    border-radius: 10px;
    overflow: hidden;
}

/* EU Product Information Table Styling - Same as nutritional table */
.eu-product-info-table {
    width: 100%;
    table-layout: fixed;
    /* distribute columns evenly */
    border-collapse: separate;
    border-spacing: 0;
    margin: 0;
    background: #fff;
    font-family: Arial, sans-serif;
    border: 1px solid #eaeaea;
    border-radius: 10px;
    overflow: hidden;
}

.eu-nutrition-table th,
.eu-product-info-table th {
    background: linear-gradient(180deg, #fafafa, #f3f3f3);
    padding: 14px 16px;
    width: auto;
    /* shrink to content */
    margin: 0 auto;
    /* center table */
    /* table-layout fixed removed to allow auto sizing */
    border-bottom: 1px solid #e6e6e6;
    font-size: 13px;
    letter-spacing: .3px;
    text-transform: uppercase;
    color: #666;
}

.eu-nutrition-table td,
.eu-product-info-table td {
    background: #fff;
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid #efefef;
    font-size: 15px;
}

.eu-product-info-table td:first-child,
.eu-nutrition-table td:first-child {
    color: #222;
    font-weight: 600;
}

.eu-product-info-table tr:last-child td,
.eu-nutrition-table tr:last-child td {
    border-bottom: none;
}

.eu-product-info-table .allergen-warning {
    background: none;
    padding: 0;
    border: none;
    color: #e65100;
}

.eu-product-info-table .warning-icon {
    font-size: 16px;
    margin-right: 8px;
}

.eu-nutrition-table tr.nutrition-energy {
    background: #f8f9fa;
}

.eu-nutrition-table tr.nutrition-energy td {
    font-weight: 700;
}

.eu-nutrition-table tr.nutrition-sub td {
    padding-left: 28px;
    font-style: normal;
    color: #555;
    background: #fcfcfc;
}

.nutrition-values {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
    white-space: pre-wrap;
    overflow-x: auto;
}

/* Details grid */
.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.detail-item {
    background: #fff;
    padding: 12px 15px;
    border-radius: 4px;
    border: 1px solid #ddd;
    display: flex;
    flex-direction: column;
}

.detail-item strong {
    color: #4CAF50;
    margin-bottom: 5px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-item span {
    color: #333;
    font-weight: 500;
}

/* Quick summary chips for macro values */
.nutrition-summary-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 6px 0 14px;
}

.chip {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 6px 10px;
    background: #f7f7f8;
    border: 1px solid #ececec;
    color: #333;
    border-radius: 999px;
    font-size: 13px;
}

.chip-energy {
    background: #eff8ff;
    border-color: #d6edff;
}

.chip-label {
    color: #666;
    font-weight: 600;
}

.chip-value {
    color: #111;
    font-weight: 600;
}

.chip-sep {
    color: #999;
    padding: 0 4px;
}

/* Summary on product page */
.wc-food-summary {
    margin: 15px 0;
    padding: 12px 15px;
    background: #f0f8f0;
    border-radius: 4px;
    border-left: 4px solid #4CAF50;
}

.wc-food-summary p {
    margin: 5px 0;
    font-size: 14px;
}

/* Allergen warning on product page */
.wc-food-allergen-warning {
    margin: 15px 0;
}

.allergen-notice {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    padding: 12px 15px;
    color: #856404;
    font-size: 14px;
    display: flex;
    align-items: center;
}

.allergen-icon {
    margin-right: 8px;
    font-size: 16px;
}

/* Nutri-Score styling */
.nutri-score {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
    color: white !important;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.3);
}

.nutri-score-a {
    background-color: #038141 !important;
}

.nutri-score-b {
    background-color: #85bb2f !important;
}

.nutri-score-c {
    background-color: #fecb02 !important;
    color: #333 !important;
}

.nutri-score-d {
    background-color: #ee8100 !important;
}

.nutri-score-e {
    background-color: #e73015 !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .details-grid {
        grid-template-columns: 1fr;
    }

    .wc-food-information-tab {
        max-width: none;
    }

    .food-section {
        padding: 12px;
    }

    .nutrition-table {
        padding: 15px;
    }

    .nutrition-values {
        font-size: 12px;
        padding: 12px;
    }

    .eu-nutrition-table {
        font-size: 12px;
    }

    .eu-nutrition-table th,
    .eu-nutrition-table td,
    .eu-product-info-table th,
    .eu-product-info-table td {
        padding: 6px 8px;
    }

    /* Mobile two-column layout: name left, value right */
    .eu-nutrition-table.modern tbody tr,
    .eu-product-info-table tbody tr {
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: center;
        border-bottom: 1px solid #efefef;
    }

    .eu-nutrition-table.modern tbody tr td:first-child,
    .eu-product-info-table tbody tr td:first-child {
        padding-bottom: 4px;
        color: #666;
        font-weight: 600;
    }

    .eu-nutrition-table.modern tbody tr td:last-child,
    .eu-product-info-table tbody tr td:last-child {
        padding-top: 0;
        text-align: right;
        justify-self: end;
        white-space: nowrap;
    }

    /* Remove repeated value labels (e.g., "Per 100g") on mobile */
    .eu-nutrition-table.modern td[data-label]::before,
    .eu-nutrition-table td[data-label]::before {
        content: none !important;
        display: none !important;
    }

    /* Hide nutrition table headers on mobile to avoid redundancy */
    .eu-nutrition-table.modern thead {
        display: none;
    }

    /* Make each nutrition row look like a clean card */
    .eu-nutrition-table.modern tbody tr {
        background: #fff;
        border: 1px solid #eee;
        border-radius: 8px;
        padding: 8px 10px;
        margin: 10px 0;
        border-bottom: none;
    }

    .eu-nutrition-table.modern tbody tr td {
        border-bottom: none;
    }

    .eu-nutrition-table.modern tbody tr td:first-child {
        font-weight: 600;
        color: #333;
        padding-bottom: 6px;
    }

    .eu-nutrition-table.modern tbody tr.nutrition-sub td:first-child {
        padding-left: 10px;
        border-left: 3px solid #f0f0f0;
    }

    /* Product info table: keep two columns on mobile and right-align values */
    .eu-product-info-table {
        overflow: visible;
    }

    .eu-product-info-table tbody tr td:first-child {
        display: block;
    }

    .eu-product-info-table td[data-label]::before {
        content: none !important;
        display: none !important;
    }

    /* Override: stack product info rows as title + full-width content */
    .eu-product-info-table tbody tr {
        grid-template-columns: 1fr !important;
        /* override 1fr auto */
        align-items: start;
        background: #fff;
        border: 1px solid #eee;
        border-radius: 8px;
        padding: 8px 10px;
        margin: 10px 0;
        border-bottom: none;
        gap: 0;
    }

    .eu-product-info-table tbody tr td {
        border-bottom: none;
    }

    .eu-product-info-table tbody tr td:first-child {
        color: #333;
        font-weight: 700;
        padding-bottom: 6px;
    }

    .eu-product-info-table tbody tr td:last-child {
        text-align: left !important;
        justify-self: stretch !important;
        white-space: normal !important;
        /* allow wrapping */
        overflow-wrap: anywhere;
        /* break long strings */
        word-break: break-word;
        /* legacy support */
        padding-top: 4px;
    }

    /* Nice bullets for allergen/ingredient lists */
    .eu-product-info-table .allergens-list,
    .eu-product-info-table .ingredients-list {
        margin: 0;
        padding-left: 20px;
        list-style: disc;
    }
}

/* Print styles */
@media print {
    .wc-food-information-tab {
        max-width: none;
    }

    .food-section {
        background: #fff !important;
        border: 1px solid #ccc !important;
        break-inside: avoid;
    }

    .nutrition-values {
        background: #fff !important;
        border: 1px solid #ccc !important;
    }

    .eu-nutrition-table {
        border: 2px solid #000 !important;
        page-break-inside: avoid;
    }

    .eu-product-info-table {
        border: 2px solid #000 !important;
        page-break-inside: avoid;
    }

    .eu-nutrition-table th,
    .eu-nutrition-table td,
    .eu-product-info-table th,
    .eu-product-info-table td {
        border: 1px solid #000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .eu-nutrition-table tr.nutrition-energy {
        background: #f8f9fa !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .eu-nutrition-table tr.nutrition-sub td {
        background: #fafafa !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}