/**
 * Food System CSS
 * Covers: Pantry, Recipes, Meal Plan, Grocery Lists
 * Version: 1.0.0
 */

/* ============================================================
   LAYOUT & WRAPPER
   ============================================================ */
.food-pantry-wrap {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px;
    font-family: inherit;
}

/* ============================================================
   NAV TABS
   ============================================================ */
.food-nav {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 0;
    overflow-x: auto;
}
.food-nav-btn {
    padding: 10px 16px;
    border: none;
    background: none;
    color: #6c757d;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    transition: color 0.2s, border-color 0.2s;
}
.food-nav-btn:hover {
    color: #212529;
    text-decoration: none;
}
.food-nav-btn.active {
    color: #0d6efd;
    border-bottom-color: #0d6efd;
}
.food-nav-btn i {
    margin-right: 4px;
}

/* ============================================================
   STATS ROW
   ============================================================ */
.food-stats {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}
.food-stat {
    flex: 1;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    border: 1px solid #e9ecef;
}
.food-stat-num {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: #212529;
}
.food-stat-label {
    font-size: 12px;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.food-stat-warn .food-stat-num { color: #fd7e14; }
.food-stat-danger .food-stat-num { color: #dc3545; }

/* ============================================================
   TOOLBAR & FILTERS
   ============================================================ */
.food-toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    align-items: center;
    flex-wrap: wrap;
}
.food-search-wrap {
    flex: 1;
    min-width: 150px;
}
.food-filters {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.food-pill {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid #dee2e6;
    background: #fff;
    color: #495057;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}
.food-pill:hover {
    background: #e9ecef;
}
.food-pill.active {
    background: #0d6efd;
    color: #fff;
    border-color: #0d6efd;
}
.food-pill i {
    margin-right: 3px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.food-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    background: #fff;
    color: #212529;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}
.food-btn:hover {
    background: #e9ecef;
    text-decoration: none;
    color: #212529;
}
.food-btn-primary {
    background: #0d6efd;
    color: #fff;
    border-color: #0d6efd;
}
.food-btn-primary:hover {
    background: #0b5ed7;
    color: #fff;
}
.food-btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.food-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 14px;
    color: #212529;
    background: #fff;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.food-input:focus {
    outline: none;
    border-color: #86b7fe;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}
select.food-input {
    appearance: auto;
}
textarea.food-input {
    resize: vertical;
}
.food-form-group {
    margin-bottom: 12px;
}
.food-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 4px;
}
.food-form-group label small {
    font-weight: 400;
    color: #6c757d;
}
.food-form-row {
    display: flex;
    gap: 12px;
}
.food-form-half { flex: 1; }
.food-form-third { flex: 1; }

/* ============================================================
   PANELS (Add/Edit forms)
   ============================================================ */
.food-panel {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.food-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.food-panel-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}
.food-panel-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.food-panel-close:hover { color: #dc3545; }

/* ============================================================
   AUTOCOMPLETE DROPDOWN
   ============================================================ */
.food-autocomplete {
    position: relative;
    z-index: 100;
}
.food-ac-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f1f3f5;
    background: #fff;
    font-size: 14px;
    border-left: 1px solid #dee2e6;
    border-right: 1px solid #dee2e6;
}
.food-ac-item:first-child {
    border-top: 1px solid #dee2e6;
    border-radius: 6px 6px 0 0;
}
.food-ac-item:last-child {
    border-bottom: 1px solid #dee2e6;
    border-radius: 0 0 6px 6px;
}
.food-ac-item:hover {
    background: #e7f1ff;
}
.food-ac-item small {
    color: #6c757d;
    margin-left: 6px;
}
.food-ac-custom {
    color: #0d6efd;
    font-style: italic;
}
.food-selected-hint {
    color: #198754;
    font-size: 12px;
    margin-top: 4px;
    display: block;
}
.food-exp-auto {
    color: #198754;
    font-style: italic;
}

/* ============================================================
   PANTRY LIST ITEMS
   ============================================================ */
.food-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.food-item {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 12px;
    transition: box-shadow 0.2s;
}
.food-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.food-item-main {
    display: flex;
    align-items: center;
    gap: 12px;
}
.food-item-icon {
    width: 36px;
    height: 36px;
    background: #f8f9fa;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    flex-shrink: 0;
}
.food-item-info {
    flex: 1;
    min-width: 0;
}
.food-item-name {
    font-weight: 600;
    font-size: 14px;
    color: #212529;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.food-item-meta {
    display: flex;
    gap: 10px;
    font-size: 12px;
    color: #6c757d;
    margin-top: 2px;
    flex-wrap: wrap;
}
.food-item-exp {
    font-size: 12px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}
.food-exp-green  { background: #d1e7dd; color: #0f5132; }
.food-exp-orange { background: #fff3cd; color: #664d03; }
.food-exp-yellow { background: #fff3cd; color: #997404; }
.food-exp-red    { background: #f8d7da; color: #842029; }

.food-item-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f1f3f5;
    justify-content: flex-end;
}
.food-act-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    background: #fff;
    color: #495057;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all 0.2s;
}
.food-act-btn:hover { background: #e9ecef; }
.food-act-eat:hover { background: #d1e7dd; color: #0f5132; }
.food-act-waste:hover { background: #fff3cd; color: #664d03; }
.food-act-delete:hover { background: #f8d7da; color: #842029; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.food-empty {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}
.food-empty i {
    font-size: 48px;
    margin-bottom: 12px;
    display: block;
    opacity: 0.4;
}
.food-empty p {
    font-size: 15px;
    margin: 0;
}
.food-empty-small {
    text-align: center;
    padding: 16px;
    color: #6c757d;
    font-size: 13px;
}

/* ============================================================
   RECIPE GRID
   ============================================================ */
.food-recipe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}
.food-recipe-card {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 16px;
    cursor: pointer;
    transition: box-shadow 0.2s, transform 0.1s;
}
.food-recipe-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}
.food-recipe-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}
.food-recipe-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #212529;
}
.food-recipe-fav { color: #dc3545; }
.food-recipe-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 8px;
}
.food-recipe-tag {
    background: #e7f1ff;
    color: #0d6efd;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}
.food-recipe-diff-easy { color: #198754; }
.food-recipe-diff-medium { color: #fd7e14; }
.food-recipe-diff-hard { color: #dc3545; }
.food-recipe-desc {
    font-size: 13px;
    color: #495057;
    margin: 0;
    line-height: 1.4;
}

/* ============================================================
   GROCERY LIST
   ============================================================ */
.food-grocery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}
.food-grocery-card {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 16px;
    cursor: pointer;
    transition: box-shadow 0.2s;
}
.food-grocery-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.food-grocery-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.food-grocery-card-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}
.food-grocery-status {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.food-gl-active .food-grocery-status { background: #d1e7dd; color: #0f5132; }
.food-gl-draft .food-grocery-status { background: #e9ecef; color: #495057; }
.food-gl-completed .food-grocery-status { background: #cfe2ff; color: #084298; }
.food-grocery-card-meta {
    display: flex;
    gap: 10px;
    font-size: 12px;
    color: #6c757d;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.food-grocery-progress {
    height: 4px;
    background: #e9ecef;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 4px;
}
.food-grocery-progress-bar {
    height: 100%;
    background: #198754;
    border-radius: 2px;
    transition: width 0.3s;
}
.food-grocery-meta {
    display: flex;
    gap: 12px;
    font-size: 13px;
    color: #6c757d;
    margin-bottom: 12px;
}

/* Grocery List Detail Items */
.food-grocery-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.food-grocery-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid #f1f3f5;
    border-radius: 6px;
    background: #fff;
    transition: background 0.2s;
}
.food-grocery-item:hover { background: #f8f9fa; }
.food-gi-checked {
    opacity: 0.5;
}
.food-gi-checked .food-gi-name {
    text-decoration: line-through;
}
.food-gi-check {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    cursor: pointer;
    margin: 0;
    font-size: 14px;
}
.food-gi-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}
.food-gi-qty {
    font-size: 12px;
    color: #6c757d;
    white-space: nowrap;
}
.food-gi-cost {
    font-size: 12px;
    color: #495057;
    font-weight: 500;
}

/* ============================================================
   MEAL PLAN
   ============================================================ */
.food-week-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    justify-content: center;
}
.food-week-label {
    font-size: 16px;
    font-weight: 600;
    color: #212529;
    min-width: 200px;
    text-align: center;
}
.food-meal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    margin-bottom: 16px;
}
.food-meal-day {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    min-height: 150px;
    overflow: hidden;
}
.food-meal-today {
    border-color: #0d6efd;
    box-shadow: 0 0 0 1px #0d6efd;
}
.food-meal-day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}
.food-meal-today .food-meal-day-header {
    background: #e7f1ff;
}
.food-meal-day-name {
    font-weight: 600;
    font-size: 13px;
    color: #212529;
}
.food-meal-day-date {
    font-size: 11px;
    color: #6c757d;
}
.food-meal-day-add {
    background: none;
    border: none;
    color: #0d6efd;
    cursor: pointer;
    font-size: 12px;
    padding: 2px;
}
.food-meal-day-add:hover { color: #0b5ed7; }
.food-meal-day-slots {
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.food-meal-slot {
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;
}
.food-meal-slot-breakfast { background: #fff3cd; }
.food-meal-slot-lunch { background: #d1e7dd; }
.food-meal-slot-dinner { background: #cfe2ff; }
.food-meal-slot-snack { background: #f8d7da; }
.food-meal-type-badge {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.7;
    flex-shrink: 0;
}
.food-meal-name {
    flex: 1;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.food-meal-done { color: #198754; }
.food-meal-slot-actions {
    display: none;
    gap: 4px;
}
.food-meal-slot:hover .food-meal-slot-actions {
    display: flex;
}
.food-meal-slot .food-act-btn {
    width: 22px;
    height: 22px;
    font-size: 10px;
    border: none;
}
.food-meal-empty-day {
    text-align: center;
    padding: 20px 4px;
    color: #adb5bd;
}
.food-meal-empty-day small {
    font-size: 11px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .food-meal-grid {
        grid-template-columns: 1fr;
    }
    .food-meal-day {
        min-height: auto;
    }
    .food-recipe-grid {
        grid-template-columns: 1fr;
    }
    .food-grocery-grid {
        grid-template-columns: 1fr;
    }
    .food-form-row {
        flex-direction: column;
        gap: 0;
    }
    .food-stats {
        gap: 6px;
    }
    .food-stat {
        padding: 8px;
    }
    .food-stat-num {
        font-size: 20px;
    }
    .food-nav-btn {
        padding: 8px 12px;
        font-size: 13px;
    }
    .food-week-nav {
        flex-wrap: wrap;
        gap: 8px;
    }
    .food-item-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 480px) {
    .food-pantry-wrap {
        padding: 8px;
    }
    .food-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .food-search-wrap {
        min-width: 100%;
    }
}
