/* =========================================
   1. VARIABLES & BASE STYLES
   ========================================= */
:root {
    --primary-color: #1a7f8c;
    --primary-dark: #145b66;
    --secondary-color: #6c757d;
    --light-bg: #f8f9fa;
    --card-bg: #ffffff;
    --border-color: #ddd;
    --text-primary: #333;
    --text-secondary: #666;
    
    /* Semantic Colors */
    --low-impact: #27ae60;
    --medium-impact: #f39c12;
    --high-impact: #e74c3c;
    --error-color: #dc3545;
    --success-color: #28a745;
    
    /* UI Elements */
    --highlight-bg: #e7f4f6;
    --border-radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);

    /* Gauge Segments */
    --grade-e-color: #c0392b; 
    --grade-d-color: #e74c3c; 
    --grade-c-color: #f1c40f; 
    --grade-b-color: #90ee90; 
    --grade-a-color: #27ae60; 

    /* Impact Backgrounds (for cards) */
    --high-color-light: rgba(231, 76, 60, 0.2);
    --high-color-dark: rgba(231, 76, 60, 1);
    --medium-color-light: rgba(243, 156, 18, 0.2);
    --medium-color-dark: rgba(243, 156, 18, 1);
    --low-color-light: rgba(39, 174, 96, 0.2);
    --low-color-dark: rgba(39, 174, 96, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; 
    background-color: var(--light-bg); 
    color: var(--text-primary); 
    line-height: 1.5; 
    min-height: 100vh; 
}

/* =========================================
   2. MAIN LAYOUT GRID
   ========================================= */
.dashboard-container { 
    display: grid; 
    grid-template-columns: 300px 1fr 380px; 
    grid-template-rows: auto 1fr auto; 
    min-height: 100vh; 
    gap: 16px; 
    padding: 16px; 
    background-color: var(--light-bg); 
}

/* Header */
.header { 
    grid-column: 1 / -1; 
    grid-row: 1; 
    background-color: var(--card-bg); 
    padding: 16px; 
    border-radius: var(--border-radius); 
    box-shadow: var(--shadow); 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}
.header-title { display: flex; flex-direction: column; }
.header h1 { font-size: 1.5rem; color: var(--primary-color); margin: 0; }
.header p { color: var(--text-secondary); margin: 0; font-size: 0.9rem; }
.creator-link { color: var(--primary-color); text-decoration: none; font-size: 0.9rem; }
.creator-link:hover { text-decoration: underline; }

/* =========================================
   3. PANEL ARCHITECTURE
   ========================================= */
/* Base Panel Style */
.panel { 
    background-color: var(--card-bg); 
    border-radius: var(--border-radius); 
    box-shadow: var(--shadow); 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
    /* CHANGED from 100px to 60px */
    max-height: calc(100vh - 60px); 
}

.panel-header { 
    padding: 12px 16px; 
    background-color: var(--primary-color); 
    color: white; 
    font-weight: 500; 
    font-size: 1.1rem; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    flex-shrink: 0;
}

.panel-content { 
    padding: 16px; 
    overflow-y: auto; 
    flex-grow: 1; 
}

/* --- Left Column: Ingredients --- */
.ingredients-panel { 
    grid-column: 1; 
    grid-row: 2; 
    max-height: calc(100vh - 100px); /* Keeps scrolling internal */
}

/* --- Center Column: Recipe & Visuals --- */
.center-panel { 
    grid-column: 2; 
    grid-row: 2; 
    display: flex; 
    flex-direction: column; 
    gap: 16px; 
    min-width: 0; /* Prevents flex items from overflowing */
}

.recipe-panel { 
    width: 100%; 
    max-height: 50%; /* Upper half of center */
}

.visualization-panel { 
    width: 100%; 
    min-height: 350px; 
    display: grid; 
    /* The 2:1 Ratio Split */
    grid-template-columns: 1.75fr 1fr; 
    gap: 16px; 
}

/* Panels inside the visualization grid */
.recipe-profile-panel, 
.ingredient-impact-panel,
.next-steps-panel { 
    height: 100%; 
    max-height: 100%;
}

/* --- Right Column: Impact Analysis --- */
.right-column-wrapper {
    grid-column: 3;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0; 
}

/* Specific overrides for Right Column to allow full height */
.right-column-wrapper .panel {
    max-height: none;
    height: auto;
    overflow: visible;
    flex: 0 0 auto; 
}

.right-column-wrapper .panel-content {
    overflow: visible;
    height: auto;
    padding-bottom: 24px;
}

/* =========================================
   4. INGREDIENT & SEARCH COMPONENTS
   ========================================= */
.search-container { display: flex; margin-bottom: 16px; }
.search-input { flex: 1; padding: 10px 12px; border: 1px solid var(--border-color); border-radius: var(--border-radius) 0 0 var(--border-radius); font-size: 0.9rem; }
.search-btn { background-color: var(--primary-color); color: white; border: none; padding: 0 15px; border-radius: 0 var(--border-radius) var(--border-radius) 0; cursor: pointer; transition: background-color 0.2s; }
.search-btn:hover { background-color: var(--primary-dark); }
.help-btn { background: none; border: none; color: white; cursor: pointer; font-size: 1.1rem; }
.loading-indicator { display: none; text-align: center; padding: 10px; color: var(--text-secondary); }
.error-message { color: var(--error-color); padding: 8px; margin-bottom: 16px; background-color: rgba(220, 53, 69, 0.1); border-radius: var(--border-radius); text-align: center; display: none; }

/* Tabs */
#ingredient-tabs-wrapper { margin-bottom: 16px; border-bottom: 1px solid var(--border-color); }
.ingredient-tabs { display: flex; border-bottom: none; }
.ingredient-tab { padding: 8px 16px; cursor: pointer; border-bottom: 2px solid transparent; color: var(--text-secondary); transition: all 0.2s; }
.ingredient-tab:hover { color: var(--primary-color); }
.ingredient-tab.active { border-bottom: 2px solid var(--primary-color); color: var(--primary-color); font-weight: 500; }

#saved-tab-container { display: flex; border-top: 1px solid var(--border-color); margin-top: -1px; }
#saved-tab { flex-grow: 1; text-align: center; font-weight: 500; padding: 10px 16px; }
#saved-tab.active { background-color: var(--highlight-bg); color: var(--primary-color); border-bottom: none; }

/* Lists & Grids */
.variants-list { display: none; margin-bottom: 16px; max-height: 400px; overflow-y: auto; }
.variant-item { padding: 12px; border: 1px solid var(--border-color); border-radius: var(--border-radius); margin-bottom: 8px; cursor: pointer; transition: all 0.2s; }
.variant-item:hover { background-color: var(--highlight-bg); border-color: var(--primary-color); }

.category-title { font-weight: 600; margin-bottom: 12px; color: var(--primary-color); }
.ingredient-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 20px;}
.ingredient-box { padding: 10px 8px; background-color: var(--light-bg); border-radius: var(--border-radius); text-align: center; cursor: pointer; transition: all 0.2s ease; font-size: 0.9rem; border: 1px solid transparent; }
.ingredient-box:hover { background-color: var(--highlight-bg); border-color: var(--primary-color); transform: translateY(-2px); box-shadow: 0 2px 4px rgba(0,0,0,0.1); }

/* Example Recipes */
.example-recipe-item { padding: 8px 12px; border: 1px solid var(--border-color); border-radius: var(--border-radius); margin-bottom: 8px; cursor: pointer; transition: all 0.2s; }
.example-recipe-item:hover { background-color: var(--highlight-bg); border-color: var(--primary-color); transform: translateY(-2px); box-shadow: 0 2px 4px rgba(0,0,0,0.08); }
.example-recipe-item h4 { margin: 0; color: var(--primary-color); font-size: 0.9rem; font-weight: 400; }

/* =========================================
   5. RECIPE BUILDER & TABLES
   ========================================= */
.recipe-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.recipe-table th, .recipe-table td { padding: 10px; text-align: left; border-bottom: 1px solid var(--border-color); }
.recipe-table th { background-color: var(--light-bg); font-weight: 500; }
.total-row { background-color: var(--light-bg); font-weight: 600; }
.edit-weight-input { width: 60px; padding: 4px; text-align: center; border: 1px solid var(--border-color); border-radius: 4px; }
.recipe-header-actions { display: flex; gap: 8px; }

/* Click-to-swap styling */
.editable-ingredient { cursor: pointer; color: var(--primary-color); border-bottom: 1px dotted var(--primary-color); padding-bottom: 1px; font-weight: 500; position: relative; padding-right: 20px; transition: all 0.2s; display: inline-block; }
.editable-ingredient::after { content: '\f303'; font-family: "Font Awesome 6 Free"; font-weight: 900; position: absolute; right: 0; top: 2px; font-size: 0.75em; opacity: 0.5; color: var(--text-secondary); }
.editable-ingredient:hover { color: var(--primary-dark); border-bottom-style: solid; }
.editable-ingredient:hover::after { opacity: 1; color: var(--primary-color); }

.impact-indicator { width: 12px; height: 12px; border-radius: 50%; display: inline-block; margin-right: 6px; border: 1px solid rgba(0, 0, 0, 0.1); }
.impact-indicator.impact-low { background-color: #27ae60; }
.impact-indicator.impact-medium { background-color: #f39c12; }
.impact-indicator.impact-high { background-color: #e74c3c; }

.intensity-note { margin-top: 16px; padding: 12px; background-color: var(--highlight-bg); border: 1px solid rgba(26, 127, 140, 0.2); border-radius: var(--border-radius); display: flex; align-items: center; gap: 10px; font-size: 0.9rem; color: var(--text-secondary); }
.intensity-note .icon { font-size: 1.2rem; color: var(--primary-color); flex-shrink: 0; }

.serving-calculator { padding: 16px; border-radius: var(--border-radius); background-color: var(--highlight-bg); margin-top: 16px; }
.serving-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* =========================================
   6. IMPACT ANALYSIS & VISUALIZATION
   ========================================= */
/* Impact Cards (Right Panel) */
.impact-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 0; }
.impact-card { background-color: var(--card-bg); box-shadow: 0 4px 12px rgba(0,0,0,0.05); border: 1px solid #eef; border-radius: var(--border-radius); padding: 16px; text-align: center; display: flex; flex-direction: column; position: relative; min-height: 150px; }

.impact-title { font-weight: 500; margin-bottom: 8px; font-size: 0.9rem; }
.impact-value { font-size: 2.2rem; font-weight: 700; line-height: 1.1; margin: 8px 0; }
.impact-unit { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 8px; }

.impact-level { padding: 6px; border-radius: 0 0 var(--border-radius) var(--border-radius); font-size: 0.85rem; font-weight: 500; margin: auto -16px -16px -16px; }
.impact-level.impact-low { background-color: var(--low-color-light); color: var(--low-color-dark); }
.impact-level.impact-medium { background-color: var(--medium-color-light); color: var(--medium-color-dark); }
.impact-level.impact-high { background-color: var(--high-color-light); color: var(--high-color-dark); }

.impact-bar-container { height: 8px; background-color: var(--light-bg); border-radius: 4px; margin: 8px 0; overflow: hidden; border: 1px solid var(--border-color); }
.impact-bar { height: 100%; width: 0%; border-radius: 4px; transition: width 0.5s ease-in-out, background-color 0.5s ease-in-out; }
.impact-bar.impact-low { background-color: var(--low-impact); }
.impact-bar.impact-medium { background-color: var(--medium-impact); }
.impact-bar.impact-high { background-color: var(--high-impact); }

.info-icon { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; background-color: var(--primary-color); color: white; border-radius: 50%; font-size: 10px; cursor: pointer; margin-left: 4px; position: absolute; top: 10px; right: 10px; }

/* Final Rating Gauge */
#final-rating-section { border: 1px solid var(--border-color); border-radius: var(--border-radius); padding: 20px; margin-bottom: 16px; }
.rating-gauge { width: 200px; height: 100px; margin: 0 auto 10px auto; }
.gauge-svg { width: 100%; height: 100%; }
.gauge-segment { stroke-width: 2; stroke: white; }
#grade-e-segment { fill: var(--grade-e-color); }
#grade-d-segment { fill: var(--grade-d-color); }
#grade-c-segment { fill: var(--grade-c-color); }
#grade-b-segment { fill: var(--grade-b-color); }
#grade-a-segment { fill: var(--grade-a-color); }
.gauge-needle { transform-origin: 100px 100px; transition: transform 0.5s ease-in-out; }
.needle-shape, .needle-pivot { fill: var(--text-primary); }

.final-grade { font-size: 2.5rem; font-weight: 700; line-height: 1; margin-bottom: 4px; }
.final-grade.grade-a { color: var(--low-impact); }
.final-grade.grade-b { color: var(--primary-color); }
.final-grade.grade-c { color: var(--medium-impact); }
.final-grade.grade-d, .final-grade.grade-e { color: var(--high-impact); }
.final-title { font-size: 1.2rem; font-weight: 500; margin-bottom: 8px; color: var(--text-secondary); }
.final-description { font-size: 0.9rem; color: var(--text-secondary); max-width: 80%; margin: 0 auto; }

/* Charts */
.chart-container { height: 250px; position: relative; margin-bottom: 16px; background-color: var(--light-bg); border-radius: var(--border-radius); padding: 16px; }

/* =========================================
   7. PROMO & SUGGESTIONS (NEXT STEPS)
   ========================================= */
.suggestion-item { display: flex; align-items: center; gap: 12px; padding: 12px; }
.suggestion-icon { font-size: 1.1rem; color: var(--primary-color); flex-shrink: 0; }
.suggestion-text-content { flex-grow: 1; }

.next-steps-panel .panel-content { padding: 12px; }
.promo-section { margin-top: 0; padding-top: 0; border-top: none; } /* Reset from old styles */
.promo-content { display: flex; align-items: flex-start; gap: 15px; }
.promo-icon { font-size: 1.1rem; color: var(--primary-color); flex-shrink: 0; padding-top: 2px; }
.promo-text { flex-grow: 1; }
.promo-text ol { list-style-type: decimal; list-style-position: outside; margin: 0; padding-left: 15px; color: var(--text-secondary); font-size: 0.9rem; }
.promo-text li { margin-bottom: 8px; }

/* Button inside suggestions */
.btn-swap { background-color: #27ae60; color: white; border: none; padding: 8px 12px; border-radius: 4px; cursor: pointer; font-size: 0.9rem; font-weight: 600; margin-top: 10px; display: inline-flex; align-items: center; gap: 8px; transition: background 0.2s; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.btn-swap:hover { background-color: #219150; transform: translateY(-1px); }

/* =========================================
   8. UI ELEMENTS (Buttons, Inputs, Modals)
   ========================================= */
/* Buttons */
.btn { padding: 8px 16px; border: none; border-radius: var(--border-radius); cursor: pointer; font-size: 0.9rem; transition: background-color 0.2s; font-weight: 500; }
.btn-primary { background-color: var(--primary-color); color: white; }
.btn-primary:hover { background-color: var(--primary-dark); }
.btn-secondary { background-color: var(--secondary-color); color: white; }
.btn-secondary:hover { background-color: #5a6268; }
.btn-warning { background-color: var(--high-impact); color: white; }
.btn-warning:hover { background-color: #c0392b; }
.btn-small { padding: 5px 10px; font-size: 0.8rem; }
.action-btn { background: none; border: none; cursor: pointer; color: var(--secondary-color); padding: 4px; transition: color 0.2s; }
.action-btn:hover { color: var(--primary-color); }
.delete-btn:hover { color: var(--high-impact); }

/* Modals */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0, 0, 0, 0.5); }
.modal-content { background-color: var(--card-bg); margin: 10% auto; padding: 24px; border-radius: var(--border-radius); box-shadow: var(--shadow); max-width: 500px; width: 90%; position: relative; }
.modal-title { font-size: 1.2rem; font-weight: 600; margin: 0 0 16px; }
.close-modal { position: absolute; top: 15px; right: 20px; font-size: 24px; font-weight: bold; cursor: pointer; color: var(--text-secondary); }
.close-modal:hover { color: var(--text-primary); }

/* Swap Results inside Modal */
.swap-results { max-height: 300px; overflow-y: auto; margin-top: 10px; border: 1px solid #eee; display: none; }
.swap-item { padding: 10px; border-bottom: 1px solid #eee; cursor: pointer; }
.swap-item:hover { background-color: #f9f9f9; color: var(--primary-color); }

/* Staging Table (Smart Paste) */
.staging-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.staging-table th { background-color: #f8f9fa; position: sticky; top: 0; z-index: 10; padding: 10px; text-align: left; border-bottom: 2px solid #ddd; color: var(--primary-color); }
.staging-table td { padding: 8px 10px; border-bottom: 1px solid #eee; vertical-align: middle; }
.staging-row:hover { background-color: #f0fbff; }
.staging-select { width: 100%; padding: 6px; border: 1px solid #ccc; border-radius: 4px; background-color: white; }
.weight-input-small { width: 70px; padding: 5px; border: 1px solid #ccc; border-radius: 4px; text-align: center; }
.no-match-text { color: var(--high-impact); font-style: italic; font-size: 0.85rem; }

/* Ingredient Detail Form */
.ingredient-detail { background-color: var(--highlight-bg); padding: 16px; border-radius: var(--border-radius); margin-top: 16px; display: none; }
.weight-btn { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border-color); background-color: white; cursor: pointer; transition: all 0.2s; }

/* Empty States */
.empty-recipe-message, .empty-impact-message { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 20px; text-align: center; color: var(--text-secondary); background-color: var(--light-bg); border-radius: var(--border-radius); }
.icon-large { font-size: 3rem; margin-bottom: 16px; opacity: 0.6; }
.empty-saved-message { padding: 30px; text-align: center; color: var(--text-secondary); }

/* =========================================
   9. EXPORT & PRINT STYLES
   ========================================= */
/* =========================================
   9. EXPORT & PRINT STYLES (FIXED LAYOUT)
   ========================================= */
.spec-sheet-content { 
    background-color: white; 
    border: 1px solid #dee2e6; 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; 
    color: #212529; 
    padding: 25px; 
    box-shadow: 0 0 15px rgba(0,0,0,0.1); 
    box-sizing: border-box; 
}

/* Update existing .spec-sheet-header */
.spec-sheet-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; /* Center vertically */
    border-bottom: 2px solid #adb5bd; 
    padding-bottom: 20px; 
    margin-bottom: 20px; 
    gap: 20px;
}

/* New Layout Containers */
.header-logo-left, 
.header-logo-right {
    flex: 0 0 100px; /* Fixed width for logos to prevent crushing */
    display: flex;
    justify-content: center;
    align-items: center;
}

.header-center {
    flex: 1; /* Takes up remaining space */
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* Image styling */
.cert-logo {
    max-width: 100px; /* Adjust based on your actual image size */
    max-height: 100px;
    height: auto;
    object-fit: contain;
}

/* Tweak title section to center align text */
.spec-sheet-title-section {
    text-align: center;
    margin-bottom: 10px;
}

/* --- RATING SECTION (Top Right) --- */
.spec-sheet-rating { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    padding: 10px 15px; 
    border-radius: 8px; 
    background-color: #f8f9fa; 
    border: 1px solid #dee2e6; 
    min-width: 200px; 
}

/* This was missing: Forces A-B-C-D-E to be horizontal */
.spec-sheet-rating-scale {
    display: flex;         
    flex-direction: row;   
    justify-content: center;
    gap: 5px;              
    width: 100%;
    margin-bottom: 8px;    
}

.rating-item { 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    width: 32px; 
    height: 32px; 
    color: white; 
    font-weight: bold; 
    font-size: 16px; 
    border-radius: 4px; 
    opacity: 0.3; 
    border: 2px solid transparent; 
}

.rating-a { background-color: var(--grade-a-color); }
.rating-b { background-color: var(--grade-b-color); }
.rating-c { background-color: var(--grade-c-color); }
.rating-d { background-color: var(--grade-d-color); }
.rating-e { background-color: var(--grade-e-color); }

.rating-item.active { 
    opacity: 1; 
    transform: scale(1.1); 
    box-shadow: 0 2px 5px rgba(0,0,0,0.2); 
    border-color: #34495e; 
    z-index: 1; 
}

.spec-sheet-rating-title {
    font-size: 18px; 
    font-weight: 700;
    color: #212529;
    margin-bottom: 2px;
}

.spec-sheet-rating-descriptor {
    font-size: 11px;
    text-transform: uppercase;
    color: #6c757d;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* --- MAIN LAYOUT (Side-by-Side Tables) --- */
.spec-sheet-main {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important; /* Prevents vertical stacking */
    gap: 30px;
    align-items: flex-start;
}

.spec-sheet-column {
    flex: 1;
    width: 50%; 
    min-width: 0; 
}

.spec-sheet-column h3 {
    font-size: 18px;
    font-weight: 700;
    color: #1a7f8c; 
    margin-bottom: 12px;
    margin-top: 0;
}

/* --- TABLES --- */
.spec-sheet-table { 
    width: 100%; 
    border-collapse: collapse; 
    background-color: white;
}

.spec-sheet-table th, 
.spec-sheet-table td { 
    border: 1px solid #dee2e6; 
    padding: 10px 12px; 
    text-align: left; 
    font-size: 14px; 
    vertical-align: middle;
}

.spec-sheet-table th { 
    background-color: #f8f9fa; 
    font-weight: 600; 
    color: #495057;
}

/* Center Align numbers and ratings */
.spec-sheet-table td:nth-child(2), 
.spec-sheet-table th:nth-child(2) {
    text-align: center;
}
.spec-sheet-table td:last-child, 
.spec-sheet-table th:last-child {
    text-align: center;
}

.impact-rating-pill { 
    display: inline-block; 
    width: 80px; 
    padding: 4px 0; 
    border-radius: 12px; 
    font-size: 12px; 
    font-weight: 600; 
    line-height: 1; 
    text-align: center; 
    color: white; 
}
.pill-low { background-color: var(--low-impact); }
.pill-medium { background-color: var(--medium-impact); }
.pill-high { background-color: var(--high-impact); }

.spec-sheet-footer {
    margin-top: 25px;
    border-top: 1px solid #dee2e6;
    padding-top: 15px;
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #6c757d;
}

.footer-cta {
    color: #1a7f8c;
    font-weight: 600;
}

/* Link to Gallery */
.view-gallery-link { display: flex; align-items: center; justify-content: center; padding: 12px; margin-bottom: 16px; background-color: var(--highlight-bg); border: 1px solid rgba(26, 127, 140, 0.2); border-radius: var(--border-radius); text-decoration: none; color: var(--primary-color); font-weight: 500; text-align: center; transition: all 0.2s ease; }
.view-gallery-link:hover { background-color: var(--primary-color); color: white; box-shadow: 0 4px 8px rgba(0,0,0,0.1); transform: translateY(-2px); }
.view-gallery-link .fas { margin-right: 10px; font-size: 1.1rem; }

/* =========================================
   10. FOOTER
   ========================================= */
#footer { background: #252525; color: rgba(255, 255, 255, 0.3); padding: 0; font-size: 13px; margin-top: 16px; }
#footer .copyright { padding: 20px 0; background: #1c1c1c; }
#footer .copyright .container { max-width: 1170px; padding-right: 15px; padding-left: 15px; margin-right: auto; margin-left: auto; }
#footer .list-inline { padding-left: 0; list-style: none; margin-left: -5px; }
#footer .list-inline > li { display: inline-block; padding-left: 5px; padding-right: 5px; }
#footer .inline-links a { color: rgba(255, 255, 255, 0.3); text-decoration: none; }
#footer .inline-links a:hover { color: #fff; }

/* =========================================
   11. MOBILE & RESPONSIVE DESIGN (CONSOLIDATED)
   ========================================= */
/* Menu Toggle */
.menu-toggle { position: relative; display: inline-block; }
#menu-toggle-checkbox { display: none; }
.menu-toggle-label { cursor: pointer; }
.menu-toggle-label .fas.fa-bars { color: var(--primary-color); font-size: 1.2rem; }
.menu-dropdown { display: none; position: absolute; top: 100%; right: 0; background-color: var(--card-bg); min-width: 220px; box-shadow: 0 8px 16px rgba(0,0,0,0.2); border-radius: var(--border-radius); border: 1px solid var(--border-color); z-index: 10001; }
.menu-toggle:hover .menu-dropdown, #menu-toggle-checkbox:checked ~ .menu-dropdown { display: block; }
.menu-dropdown a { color: var(--text-primary); padding: 12px 16px; text-decoration: none; display: block; border-bottom: 1px solid var(--border-color); }
.menu-dropdown a:last-child { border-bottom: none; }
.menu-dropdown a:hover { background-color: var(--light-bg); color: var(--primary-color); }

/* Tablet and below (max 992px) */
@media (max-width: 992px) {
    .dashboard-container { 
        display: block; /* Stacks everything vertically */
    }
    
    .panel { 
        max-height: none; 
        margin-bottom: 16px; 
    }
    
    .visualization-panel { 
        display: block; /* Stacks charts vertically */
    }
    
    .recipe-profile-panel, .ingredient-impact-panel { 
        margin-bottom: 16px; 
    }
    
    .impact-grid, .serving-impact-grid { 
        grid-template-columns: repeat(2, 1fr); 
    }
    
    /* Reset Right Column specific styles for mobile so it flows normally */
    .right-column-wrapper {
        grid-column: 1 / -1;
    }
    
    .ingredients-panel {
        max-height: 500px; /* Give it a limit on mobile so it doesn't take over */
    }
}

/* Mobile (max 768px) */
/* Mobile (max 768px) */
/* =========================================
   11. MOBILE & RESPONSIVE DESIGN (CONSOLIDATED)
   ========================================= */
/* Menu Toggle */
.menu-toggle { position: relative; display: inline-block; }
#menu-toggle-checkbox { display: none; }
.menu-toggle-label { cursor: pointer; }
.menu-toggle-label .fas.fa-bars { color: var(--primary-color); font-size: 1.2rem; }
.menu-dropdown { display: none; position: absolute; top: 100%; right: 0; background-color: var(--card-bg); min-width: 220px; box-shadow: 0 8px 16px rgba(0,0,0,0.2); border-radius: var(--border-radius); border: 1px solid var(--border-color); z-index: 10001; }
.menu-toggle:hover .menu-dropdown, #menu-toggle-checkbox:checked ~ .menu-dropdown { display: block; }
.menu-dropdown a { color: var(--text-primary); padding: 12px 16px; text-decoration: none; display: block; border-bottom: 1px solid var(--border-color); }
.menu-dropdown a:last-child { border-bottom: none; }
.menu-dropdown a:hover { background-color: var(--light-bg); color: var(--primary-color); }

/* Tablet and below (max 992px) */
@media (max-width: 992px) {
    .dashboard-container { display: block; }
    /* Edge Fix: Ensure panels don't clip touch events */
    .panel { max-height: none !important; margin-bottom: 16px; overflow: visible !important; }
    .visualization-panel { display: block; }
    .recipe-profile-panel, .ingredient-impact-panel { margin-bottom: 16px; }
    .impact-grid, .serving-impact-grid { grid-template-columns: repeat(2, 1fr); }
    .right-column-wrapper { grid-column: 1 / -1; }
    .ingredients-panel { max-height: 500px; }
}

/* Mobile (max 768px) */
@media (max-width: 768px) {
    /* 1. Prevent Header Collision */
    .header { flex-direction: column !important; align-items: flex-start !important; }
    .header h1 { font-size: 1.2rem; }
    .header-actions { width: 100%; justify-content: space-between; font-size: 0; margin-top: 10px; }
    .creator-link { font-size: 0.85rem; display: inline-block; }

    /* 2. Edge Mobile Button Fixes (Lite/Pro and Export) */
    .impact-panel .panel-header {
        flex-direction: column !important;
        height: auto !important;
        gap: 12px !important;
        padding: 15px !important;
        display: flex !important;
    }
    .mode-toggle { margin: 5px 0 !important; z-index: 100; }
    .toggle-btn { touch-action: manipulation; padding: 8px 12px !important; }
    
    #exportLabelButton {
        width: 100% !important;
        text-align: center;
        white-space: normal; 
        padding: 12px !important;
        z-index: 100; /* Keeps it above the chart layers */
        touch-action: manipulation; /* Removes 300ms delay in Edge */
    }

    /* 3. Recipe Table Scrolling (Original Styles Preserved) */
    .recipe-table { display: block; overflow-x: auto; white-space: nowrap; }
    .recipe-table th, .recipe-table td { padding: 8px 4px; font-size: 0.75rem; }
    .recipe-table th:first-child, .recipe-table td:first-child { 
        min-width: 90px; 
        white-space: normal; 
    }
    
    /* 4. General Mobile Utility (Original Styles Preserved) */
    .mobile-block { display: block; float: none !important; margin-bottom: 10px !important; }
    
    /* 5. Chart Visibility (Original Styles Preserved) */
    .ingredient-impact-panel .chart-container { height: 450px !important; }
    
    /* 6. Smart Paste Staging Table (Original Styles Preserved) */
    .staging-table th, .staging-table td { padding: 5px; font-size: 0.8rem; }
}

/* Small Mobile (max 600px) */
@media (max-width: 600px) {
    .col-original { display: none; }
    .impact-grid { grid-template-columns: 1fr; } /* Stack impact cards */
}

/* Toast Notification */
#toast-notification {
    visibility: hidden;
    min-width: 250px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 4px;
    padding: 16px;
    position: fixed;
    z-index: 9999;
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    font-size: 1rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    opacity: 0;
    transition: opacity 0.3s, bottom 0.3s;
}

#toast-notification.show {
    visibility: visible;
    opacity: 1;
    bottom: 50px; /* Slide up effect */
}

/* --- High-Emphasis Style for Export Button --- */
#exportLabelButton {
    background-color: #ffffff !important;   /* White background pops against Teal header */
    color: var(--primary-color) !important; /* Teal text */
    font-weight: 800 !important;            /* Extra bold text */
    font-size: 0.9rem !important;           /* Slightly larger text */
    text-transform: uppercase;              /* Make it shout a little */
    letter-spacing: 0.5px;
    border: none !important;
    box-shadow: 0 3px 6px rgba(0,0,0,0.2) !important; /* Drop shadow for depth */
    padding: 8px 16px !important;           /* Larger clickable area */
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

/* Hover Effect: Lifts up and glows slightly */
#exportLabelButton:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.3) !important;
    background-color: #fff !important;
}

/* Disabled State (when recipe is empty) */
#exportLabelButton:disabled {
    background-color: rgba(255, 255, 255, 0.3) !important;
    color: rgba(255, 255, 255, 0.6) !important;
    box-shadow: none !important;
    cursor: not-allowed;
    transform: none !important;
}
/* =========================================
   MOBILE HEADER FIX (Paste at bottom of styles.css)
   ========================================= */

/* 1. Desktop Layout: Align Link and Menu in a row */
.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0; /* Prevents this section from being squashed by the title */
}

/* 2. Mobile Layout: Stack Title on top, Link/Menu below */
@media (max-width: 768px) {
    .header {
        flex-direction: column !important; /* Forces vertical stacking */
        align-items: flex-start !important;
        padding-bottom: 16px;
    }

    .header-title {
        width: 100%;
        margin-bottom: 15px; /* Adds space between Title and Link/Menu */
        padding-right: 0;
    }

    .header-actions {
        width: 100%; /* Spans full width of the card */
        justify-content: space-between; /* Pushes Link to Left, Menu to Right */
        
        /* THE TRICK: This hides the loose pipe '|' text node */
        font-size: 0; 
    }

    /* Make the 'Created by' link visible again and position it */
    .creator-link {
        font-size: 0.85rem; /* Restore text size */
        display: inline-block;
        white-space: normal; /* Allow wrapping if needed */
        text-align: left;
        color: var(--primary-color);
    }

    /* Restore Menu size */
    .menu-toggle {
        font-size: 1rem;
    }
    
    /* Ensure the icon is large enough to tap */
    .menu-toggle-label .fas {
        font-size: 1.4rem;
    }
}
@media (max-width: 768px) {
    /* 
       Increase the height of the "Impact by Ingredient" chart on mobile.
       This gives enough room for the Legend to wrap multiple lines 
       without crushing the bars below it.
    */
    .ingredient-impact-panel .chart-container {
        height: 450px !important; 
        min-height: 450px !important;
    }
    
    /* Ensure the canvas fills this new larger space */
    .ingredient-impact-panel canvas {
        max-height: 100% !important;
    }
}
/* Add to styles.css */

/* Blurs the specific data values until export */
.blur-data {
    filter: blur(4px);
    user-select: none;
}

/* Watermark for Lite Label Export - Final Corrected Version */
.watermark-overlay {
    /* Anchors to the 'position: relative' parent we just fixed */
    position: absolute;
    top: 0;
    left: 0;
    width: 850px; /* Matches your HTML width exactly */
    height: 100%;
    
    /* Centering logic */
    display: flex;
    align-items: center;
    justify-content: center;
    
    z-index: 99;
    pointer-events: none;
}

.watermark-text {
    /* No absolute positioning here, let Flexbox handle it */
    transform: rotate(-30deg);
    
    /* Font Styling */
    font-size: 3.2rem;
    font-weight: 900;
    color: rgba(26, 127, 140, 0.15); 
    white-space: nowrap;
    text-transform: uppercase;
    text-align: center;
    font-family: sans-serif;
    letter-spacing: 2px;
}


/* Add this to the bottom of styles.css to fix mobile layout */
@media (max-width: 768px) {
    /* Stack the Impact Analysis header vertically */
    .impact-panel .panel-header {
        flex-direction: column;
        height: auto;
        gap: 15px; /* Add space between title and button */
        padding: 15px;
    }

    /* Ensure the title stands out */
    .impact-panel .panel-header span {
        width: 100%;
        text-align: center;
        font-weight: 700;
    }

    /* Make the button full width and allow text wrapping */
    #exportLabelButton {
        width: 100%;
        text-align: center;
        white-space: normal; /* Allow text wrapping */
    }
}

/* Mode Toggle Styling */
.mode-toggle {
    display: flex;
    background: rgba(0,0,0,0.2);
    padding: 2px;
    border-radius: 20px;
    margin: 0 10px;
}
.toggle-btn {
    background: none;
    border: none;
    color: white;
    padding: 4px 12px;
    border-radius: 18px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.2s;
}
.toggle-btn.active {
    background: white;
    color: var(--primary-color);
}

/* Pro Table Styling */
.pro-section-header {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 15px 0 8px 0;
    border-bottom: 2px solid var(--highlight-bg);
}
.pro-table-wrapper {
    background: white;
    border-radius: 4px;
    border: 1px solid #eee;
    margin-bottom: 10px;
}
.pro-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid #f9f9f9;
    font-size: 0.85rem;
}
.pro-row:last-child { border-bottom: none; }
.pro-label { color: #666; }
.pro-value { font-weight: 600; color: #333; }

.pro-accordion {
    margin-bottom: 10px;
    border: 1px solid #eee;
    border-radius: 4px;
    overflow: hidden;
}
.pro-accordion summary {
    background: var(--highlight-bg);
    padding: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-color);
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.pro-accordion summary::-webkit-details-marker { display: none; }
.pro-accordion summary::after {
    content: '\f078'; /* FontAwesome Down Arrow */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 0.7rem;
    transition: transform 0.2s;
}
.pro-accordion[open] summary::after {
    transform: rotate(180deg);
}
.pro-accordion-content {
    background: white;
    border-top: 1px solid #eee;
}
/* Styling for the 16-indicator Pro View */
.pro-accordion {
    margin-bottom: 8px;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
}

.pro-accordion summary {
    padding: 12px;
    background: #f6f8fa;
    font-weight: bold;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    border-bottom: 1px solid transparent;
}

.pro-accordion[open] summary {
    border-bottom: 1px solid #e1e4e8;
}

.pro-accordion summary i {
    margin-right: 10px;
    color: #1a7f8c;
    width: 20px;
    text-align: center;
}

.pro-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    font-size: 0.85rem;
    border-bottom: 1px solid #f1f1f1;
}

.pro-row:last-child {
    border-bottom: none;
}

.pro-label {
    color: #586069;
}

.pro-value {
    font-family: monospace;
    font-weight: bold;
    color: #24292e;
}
.pro-cert-paper {
    background: white;
    padding: 40px;
    border: 1px solid #eee;
    color: #333;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    position: relative;
}

.cert-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 3px solid #1a7f8c;
    padding-bottom: 20px;
}

.cert-logo { height: 60px; }
.cert-verify-tag {
    background: #1a7f8c;
    color: white;
    font-size: 10px;
    text-transform: uppercase;
    padding: 4px 8px;
    border-radius: 4px;
    margin-top: 8px;
    display: inline-block;
}

.header-right { text-align: right; }
.header-right h1 { color: #1a7f8c; margin: 0; font-size: 28px; }

.cert-summary-bar {
    display: flex;
    background: #f8f9fa;
    margin: 20px 0;
    padding: 15px;
    border-radius: 8px;
    justify-content: space-around;
    border: 1px solid #eee;
}

.summary-item { text-align: center; }
.summary-item .label { display: block; font-size: 11px; text-transform: uppercase; color: #666; margin-bottom: 5px; }

.grade-badge {
    width: 40px;
    height: 40px;
    line-height: 40px;
    border-radius: 50%;
    color: white;
    font-weight: bold;
    font-size: 20px;
    margin: 0 auto;
}

.cert-body { display: flex; gap: 30px; margin-top: 20px; }
.cert-col { flex: 1; }
.col-title {
    font-size: 14px;
    color: #1a7f8c;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
    margin-bottom: 10px;
}

/* PEF Data Styling */
.pef-category-title {
    font-size: 11px;
    font-weight: bold;
    background: #e7f4f6;
    padding: 4px 8px;
    margin: 10px 0 5px 0;
}

.pef-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    padding: 3px 8px;
    border-bottom: 1px solid #f9f9f9;
}

.pef-val { font-weight: 600; }

/* Nutri Table */
.nutri-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.nutri-table th { text-align: left; background: #f1f1f1; padding: 8px; }
.nutri-table td { padding: 8px; border-bottom: 1px solid #eee; }

.ingredient-tag-container { display: flex; flex-wrap: wrap; gap: 5px; }
.ing-tag {
    background: #eee;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 10px;
}

.cert-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #999;
}
/* Environmental Grade Colors */
.grade-badge.grade-a { background-color: #27ae60; }
.grade-badge.grade-b { background-color: #90ee90; color: #333; }
.grade-badge.grade-c { background-color: #f1c40f; color: #333; }
.grade-badge.grade-d { background-color: #e67e22; }
.grade-badge.grade-e { background-color: #e74c3c; }

/* Nutri-Score Colors */
.grade-badge.nutri-a { background-color: #008b4c; }
.grade-badge.nutri-b { background-color: #80bc29; }
.grade-badge.nutri-c { background-color: #fccb00; color: #333; }
.grade-badge.nutri-d { background-color: #ef8200; }
.grade-badge.nutri-e { background-color: #e63d11; }
/* Certificate Traffic Lights */
.cert-badge-row {
    display: flex;
    gap: 5px;
    justify-content: space-between;
    margin-bottom: 15px;
}

.cert-tl-badge {
    flex: 1;
    text-align: center;
    border-radius: 4px;
    padding: 5px 2px;
    color: white;
    font-family: sans-serif;
}

.cert-tl-badge .tl-label { font-size: 9px; text-transform: uppercase; opacity: 0.9; border-bottom: 1px solid rgba(255,255,255,0.3); margin-bottom: 3px; }
.cert-tl-badge .tl-val { font-size: 12px; font-weight: bold; }
.cert-tl-badge .tl-ri { font-size: 10px; font-weight: bold; }

/* Visual Nutri-Score Bar on Cert */
.cert-nutriscore-container {
    background: #fff;
    border: 1px solid #eee;
    padding: 10px;
    border-radius: 6px;
    text-align: center;
}
.cert-nutriscore-container .ns-label { font-size: 10px; font-weight: bold; color: #666; margin-bottom: 5px; }
.ns-bar { display: inline-flex; border-radius: 4px; overflow: hidden; }
.ns-item { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; color: white; font-weight: bold; font-size: 14px; opacity: 0.2; }
.ns-item.a { background: #008b4c; }
.ns-item.b { background: #80bc29; }
.ns-item.c { background: #fccb00; }
.ns-item.d { background: #ef8200; }
.ns-item.e { background: #e63d11; }
.ns-item.active { opacity: 1; transform: scale(1.1); box-shadow: 0 0 5px rgba(0,0,0,0.3); z-index: 2; }
/* Prevent column squashing */
.cert-body {
    display: flex !important;
    flex-direction: row !important;
    gap: 40px !important; /* Increased gap */
    align-items: flex-start;
}

.cert-col {
    flex: 1; /* Allow equal sharing of space */
    min-width: 0; /* Critical for flexbox math */
}

/* Force specific widths for the Nutrition table columns */
.nutri-table {
    width: 100%;
    table-layout: fixed; /* Prevents cell expansion */
}

.nutri-table th, .nutri-table td {
    padding: 6px 4px !important;
    font-size: 11px !important; /* Slightly smaller for fit */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Prevent PEF rows from looking too tight */
.pef-row {
    padding: 4px 8px !important;
    font-size: 10.5px !important;
}

/* Make the overall paper a bit wider for the new data */
#exportableLabelContainer {
    width: 1000px !important; 
}

.pro-cert-paper {
    width: 100%;
    box-sizing: border-box;
}

/* Compliance Badges - ensure they don't wrap awkwardly */
.cert-badge-row {
    flex-wrap: nowrap !important;
    justify-content: space-between;
}

.cert-tl-badge {
    min-width: 65px;
}
/* Optimize PEF row spacing for full 16-list cert */
.pef-category-title {
    font-size: 10px !important;
    padding: 3px 8px !important;
    margin: 6px 0 3px 0 !important;
}

.pef-row {
    padding: 2px 8px !important; /* Tighter rows */
    font-size: 10px !important;
}

.pef-val {
    font-family: monospace; /* Easier to read decimals */
    font-size: 10px;
}

.col-title {
    font-size: 13px !important;
    margin-bottom: 8px !important;
}
/* --- LITE EXPORT LABEL STYLING --- */
#exportableLiteLabel {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #333;
    border: 8px solid #1a7f8c; /* Branding teal border */
}

.lite-dish-name {
    font-size: 32px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.lite-metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 20px 0;
}

.lite-metric {
    background: #f4f9f9;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid #e0eef0;
}

.lite-metric strong {
    display: block;
    font-size: 14px;
    color: #666;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.lite-metric span {
    font-size: 24px;
    font-weight: 700;
    color: #1a7f8c;
}

.lite-footer-tag {
    margin-top: 20px;
    font-size: 14px;
    color: #1a7f8c;
    font-weight: 600;
    text-align: center;
}
/* Blurs only the specific numeric values */
.blur-number {
    user-select: none;
    padding: 0 4px;
    border-radius: 4px;
    display: inline-block;
}

/* Make the overlay less obstructive so the labels are readable */
.unlock-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 12px;
    border: 2px solid #1a7f8c;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    width: 80%;
    max-width: 320px;
}
/* --- RESTORED LITE LABEL STYLING --- */
.lite-rating-item {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    border-radius: 4px;
    opacity: 0.3;
    font-size: 18px;
}

.lite-rating-item.active {
    opacity: 1;
    transform: scale(1.15);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    border: 2px solid #333;
}

/* Old Color Mappings */
.l-a { background-color: #27ae60; }
.l-b { background-color: #90ee90; color: #333; }
.l-c { background-color: #f1c40f; color: #333; }
.l-d { background-color: #e67e22; }
.l-e { background-color: #e74c3c; }

/* Impact Pills for Tables */
.lite-pill {
    display: inline-block;
    padding: 2px 8px;      /* Reduced vertical and horizontal padding */
    border-radius: 10px;    /* Smoother radius for the smaller size */
    font-size: 9px;        /* Smaller font to match table context */
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    min-width: 48px;       /* Reduced minimum width */
    line-height: 1.1;
    text-align: center;
}

.pill-low { background-color: #27ae60; }
.pill-medium { background-color: #f39c12; }
.pill-high { background-color: #e74c3c; }

.lite-table th {
    font-size: 11px;
    text-transform: uppercase;
    color: #1a7f8c;
    letter-spacing: 0.5px;
}
/* --- PRO CERTIFICATE SNAPSHOT STYLING --- */
/* --- PRO CERTIFICATE SNAPSHOT (ENVIRONMENT SNAPSHOT) --- */

/* Wrapper for the bar to handle centering and labeling */
.pro-rating-bar-container {
    background: #fff; 
    border: 1px solid #eee; 
    padding: 10px; 
    border-radius: 6px; 
    text-align: center; 
    margin-bottom: 20px;
}

.pro-rating-bar-label {
    font-size: 10px; 
    font-weight: bold; 
    color: #666; 
    margin-bottom: 5px;
    text-transform: uppercase;
}

/* The bar itself - matches Nutri-Score block style */
.pro-rating-bar {
    display: inline-flex; 
    border-radius: 4px; 
    overflow: hidden;
    gap: 0px !important; /* Forces blocks to touch like Nutri-Score */
}

.pro-rate-item {
    width: 30px;  /* Matches Nutri-Score block width */
    height: 30px; /* Matches Nutri-Score block height */
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 14px;
    opacity: 0.2; /* Dimmed for non-active */
    transition: all 0.2s ease;
}

/* Color Palette - Matched to standard PEF/Nutri-Score spectrum */
.p-a { background-color: #008b4c; } 
.p-b { background-color: #80bc29; }
.p-c { background-color: #fccb00; }
.p-d { background-color: #ef8200; }
.p-e { background-color: #e63d11; }

/* Active State: Pops out exactly like the Nutri-Score indicator */
.pro-rate-item.active {
    opacity: 1;
    transform: scale(1.15); 
    box-shadow: 0 0 5px rgba(0,0,0,0.3);
    z-index: 2;
    border-radius: 2px;
}

/* Snapshot Table: Narrower and Left-Justified */
.pro-snapshot-table {
    width: 80%; /* Makes the table narrower */
    border-collapse: collapse; 
    font-size: 11px;
    margin-top: 10px;
}

.pro-snapshot-table td {
    color: #444;
    padding: 5px 10px;
    border: 1px solid #eee;
}

.pro-snapshot-table th {
    background: #f8f9fa;
    padding: 6px 10px;
    border: 1px solid #eee;
    text-align: left;
}

/* Smaller pills for the technical document look */
.pro-snapshot-table .lite-pill {
    padding: 2px 6px;
    font-size: 9px;
    min-width: 50px;
    border-radius: 10px;
    text-transform: uppercase;
    font-weight: 700;
}
.disclosure-list {
    margin-bottom: 20px;
}

/* Reusing your existing row styles for consistency */
.disclosure-list .pef-row {
    padding: 6px 8px !important;
    font-size: 11px !important;
}

.disclosure-list .pef-val {
    color: #1a7f8c;
    font-weight: bold;
}
/* =========================================
   NEW: INLINE PREVIEW SECTIONS
   ========================================= */

/* Shared section header for nutrition and PEF preview */
.preview-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #1a7f8c;
    background: #e7f4f6;
    padding: 6px 10px;
    border-radius: 4px;
    margin-bottom: 6px;
}

.pro-preview-header {
    background: #1a7f8c;
    color: #fff;
}

.pro-badge-pill {
    font-size: 9px;
    font-weight: 700;
    background: #fff;
    color: #1a7f8c;
    padding: 2px 7px;
    border-radius: 10px;
    letter-spacing: 0.5px;
}

/* Nutrition preview table */
.preview-nutri-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.preview-nutri-table th {
    text-align: left;
    background: #f8f9fa;
    padding: 5px 8px;
    border-bottom: 2px solid #1a7f8c;
    color: #444;
    font-weight: 700;
}

.preview-nutri-table td {
    padding: 4px 8px;
    border-bottom: 1px solid #f0f0f0;
    color: #333;
}

.preview-nutri-table th:not(:first-child),
.preview-nutri-table td:not(:first-child) {
    text-align: right;
}

.nutri-indent-row td:first-child {
    padding-left: 18px;
    color: #666;
    font-size: 10.5px;
}

/* PEF locked preview rows */
.pef-preview-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 11px;
}

.pef-row-locked {
    opacity: 0.5;
}

.pef-preview-label {
    color: #555;
    flex: 1;
}

.pef-preview-val {
    font-weight: 600;
    color: #1a7f8c;
    font-family: monospace;
    font-size: 11px;
}

.pef-preview-val small {
    font-weight: 400;
    color: #888;
    font-family: inherit;
}

.pef-preview-blur {
    filter: blur(4px);
    user-select: none;
    color: #555;
    font-family: monospace;
    font-size: 11px;
    font-weight: 600;
}

.pef-preview-unit {
    font-size: 10px;
    color: #888;
}

.pef-preview-locked {
    color: #aaa;
    font-size: 12px;
}

.pef-preview-more {
    font-size: 10px;
    color: #888;
    font-style: italic;
    padding: 6px 8px 2px;
}

/* Pro unlock banner inside the panel */
.pro-unlock-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #e8f4f5;
    border: 1px solid #1a7f8c;
    border-radius: 6px;
    padding: 10px 12px;
    margin-top: 10px;
}

.pro-unlock-text {
    flex: 1;
    font-size: 11px;
    color: #145b66;
    line-height: 1.4;
}

.pro-unlock-btn {
    white-space: nowrap;
    font-size: 11px;
    padding: 7px 12px;
}

/* =========================================
   NEW: CONTEXTUAL NEXT STEPS
   ========================================= */

.next-steps-empty {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
}

.next-steps-empty .promo-icon {
    font-size: 2rem;
    color: #1a7f8c;
    margin-bottom: 10px;
}

.next-steps-empty p {
    font-size: 13px;
}

.next-steps-grade-card {
    background: #fafafa;
    border-radius: 6px;
    padding: 12px 14px;
    margin-bottom: 12px;
}

.next-steps-grade-header {
    font-size: 13px;
    margin-bottom: 6px;
}

.next-steps-grade-body {
    font-size: 12px;
    color: #555;
    line-height: 1.5;
    margin: 0;
}

.next-steps-cta {
    background: #fff;
    border: 1px solid #1a7f8c;
    border-radius: 6px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.next-steps-cta-text {
    font-size: 12px;
    color: #333;
    line-height: 1.5;
}

.next-steps-unlock-btn {
    width: 100%;
    text-align: center;
    font-size: 12px;
    padding: 9px 12px;
}

.next-steps-cta-paid {
    background: #e8f9ef;
    border: 1px solid #27ae60;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 12px;
    color: #1e8449;
    line-height: 1.5;
}
/* =========================================
   PRO ACTIVE STATE - Dashboard Panel
   ========================================= */

/* Pro Active pill (replaces PRO teaser pill when pass is valid) */
.pro-active-pill {
    font-size: 9px;
    font-weight: 700;
    background: #27ae60;
    color: #fff;
    padding: 2px 7px;
    border-radius: 10px;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

/* PEF group header (shown in pro full view) */
.pef-preview-group-header {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
    background: #1a7f8c;
    padding: 3px 8px;
    margin-top: 6px;
}

.pef-preview-group-header:first-child {
    margin-top: 0;
}

/* Compliance badges inside the dashboard preview panel */
.preview-compliance-badges {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 6px;
    margin-bottom: 8px;
}

.preview-compliance-badges .cert-tl-badge {
    flex: 1;
    min-width: 45px;
    padding: 5px 4px;
    border-radius: 4px;
    text-align: center;
    color: white;
}

.preview-compliance-badges .tl-label {
    font-size: 8px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 1.2;
}

.preview-compliance-badges .tl-val {
    font-size: 11px;
    font-weight: 700;
    line-height: 1.3;
}

.preview-compliance-badges .tl-ri {
    font-size: 9px;
    opacity: 0.9;
    line-height: 1.2;
}

/* Nutri-Score bar inside preview panel */
.preview-nutriscore {
    margin-top: 6px;
    margin-bottom: 4px;
}

.preview-nutriscore .ns-label {
    font-size: 9px;
}

.preview-nutriscore .ns-bar {
    gap: 2px;
    margin-top: 4px;
}

.preview-nutriscore .ns-item {
    font-size: 11px;
    padding: 4px 6px;
    min-width: 26px;
}

/* =========================================
   VIEW TOGGLE (Lite / Full Pro) — paid users
   ========================================= */
.view-toggle-group {
    display: flex;
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 6px;
    overflow: hidden;
    gap: 0;
}

.view-toggle-btn {
    background: transparent;
    color: rgba(255,255,255,0.75);
    border: none;
    padding: 5px 13px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.view-toggle-btn:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

.view-toggle-btn.active {
    background: rgba(255,255,255,0.25);
    color: #fff;
}

/* =========================================
   STICKY UNLOCK BAR — free users
   ========================================= */
.sticky-unlock-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: linear-gradient(135deg, #145b66 0%, #1a7f8c 100%);
    color: #fff;
    border-radius: 7px;
    padding: 9px 14px;
    margin-bottom: 14px;
    font-size: 12px;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(26,127,140,0.3);
    flex-wrap: wrap;
    gap: 8px;
}

.sticky-unlock-btn {
    white-space: nowrap;
    font-size: 11px;
    padding: 6px 13px;
    background: #fff;
    color: #1a7f8c;
    border: none;
    font-weight: 700;
    flex-shrink: 0;
}

.sticky-unlock-btn:hover {
    background: #e8f4f5;
}

/* Lite mode nutrition footnote */
.lite-nutri-footnote {
    font-size: 11px;
    color: #1a7f8c;
    background: #e8f4f5;
    border-left: 3px solid #1a7f8c;
    border-radius: 0 4px 4px 0;
    padding: 7px 10px;
    margin-top: 10px;
    line-height: 1.4;
}

/* Simple unlock link in PEF teaser (replaces full banner) */
.pef-simple-unlock {
    font-size: 11px;
    color: #555;
    padding: 8px 8px 4px;
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: wrap;
}

.pef-unlock-link {
    color: #1a7f8c;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
}

.pef-unlock-link:hover {
    color: #145b66;
}

/* Swap Impact Alert */
.swap-impact-alert, .swap-preview-card {
    animation: fadeInUp 0.4s ease;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Swap confirm/cancel buttons */
.btn-swap-cancel {
    padding: 8px 16px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    color: #666;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-swap-cancel:hover {
    background: #f5f5f5;
    border-color: #999;
}

/* Undo last swap button */
.btn-swap-undo {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px dashed #1a7f8c;
    border-radius: 5px;
    background: #f0f9fa;
    color: #1a7f8c;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-swap-undo:hover {
    background: #d7f0f3;
    border-style: solid;
}

/* Portion reduction buttons */
.btn-portion {
    padding: 8px 18px;
    border: 1px solid #1a7f8c;
    border-radius: 6px;
    background: #fff;
    color: #1a7f8c;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-portion:hover {
    background: #1a7f8c;
    color: #fff;
}

/* Optimization section labels */
.opt-section-label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Optimisation summary box */
.optimisation-summary {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px 15px;
    margin-bottom: 12px;
    font-size: 13px;
    line-height: 1.6;
}
.opt-summary-header {
    font-weight: 700;
    color: #1a7f8c;
    margin-bottom: 6px;
    font-size: 13px;
}
.opt-summary-row {
    color: #444;
}
.opt-good {
    color: #4caf50;
    font-weight: 600;
}
.opt-warn {
    color: #ff9800;
    font-weight: 600;
}

/* Categorised swap select with optgroups */
.swap-select optgroup {
    font-weight: 700;
    color: #333;
    font-size: 13px;
}
.swap-select option {
    font-weight: 400;
    padding: 4px 8px;
}

/* RI column in nutrition preview */
.preview-nutri-table th.ri-header {
    font-size: 11px;
    white-space: nowrap;
}