/* Basic Styles */
body {
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    color: #333;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: linear-gradient(180deg, #f4f4f4, #e0e0e0);
}

.app-wrapper {
    max-width: 480px;
    margin: 0 auto;
    background: #fff;
    padding: 15px;
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

h1,
h2 {
    color: #2c3e50;
    margin-bottom: 10px;
    text-align: center;
}

/* Search and Target Inputs */
.search-target-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
    justify-content: center;
}

#foodSearch,
.target-input {
    padding: 10px 15px;
    border: none;
    border-radius: 20px;
    background-color: #f0f0f0;
    font-size: 16px;
    flex: 1 1 200px;
    box-sizing: border-box;
}

.target-input {
    max-width: 200px;
}

/* Toggle Buttons (Categories) */
.toggle-buttons {
    display: flex;
    overflow-x: auto;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    justify-content: center;
}

.toggle-button {
    padding: 10px 15px;
    background-color: #f0f0f0;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.3s;
    white-space: nowrap;
    flex-shrink: 0;
}

.toggle-button.active {
    background-color: #3498db;
    color: white;
}

.category-select {
    display: none;
    width: 100%;
    padding: 10px 15px;
    border: none;
    border-radius: 20px;
    background-color: #f0f0f0;
    margin-bottom: 15px;
    font-size: 16px;
}

/* Food Buttons */
#foodButtons {
    display: flex;
    overflow-x: auto;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    justify-content: center;
}

.food-button {
    padding: 10px 15px;
    background-color: #f0f0f0;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.3s;
    white-space: nowrap;
    flex-shrink: 0;
}

.food-button.active {
    background-color: #2ecc71;
    color: white;
}

/* Selected Foods (Vertical Scrollable Portion Controls) */
#selectedFoods {
    max-height: 300px;
    /* Adjust as needed */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.food-item {
    background-color: white;
    padding: 10px 15px;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.food-item-controls {
    display: flex;
    gap: 5px;
    margin-right: 10px;
}
.add-to-custom:hover {
    color: green;
}

.food-item.flagged-for-recipe {
    border: 2px solid #3498db;
}

.flag-food {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2em;
}

.flag-food:hover {
    color: #3498db;
}

.food-item-controls button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2em;
}

.remove-food:hover {
    color: red;
}

.food-item label {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
}

.portion-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.portion-control input[type="range"] {
    width: 150px;
}

.portion-control span {
    font-size: 14px;
    color: #555;
    min-width: 40px;
    text-align: right;
}

/* Dashboard - Macronutrients */
.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.progress-section {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    text-align: center;
    position: relative;
}

.progress-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    position: relative;
    margin: 0 auto 10px;
    background: conic-gradient(#3498db calc(var(--progress) * 1%),
            #e0e0e0 0%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.progress-circle::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background-color: #fff;
}

.progress-circle .progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #555;
    font-size: 18px;
    font-weight: bold;
}

.sub-nutrients {
    margin-top: 10px;
    font-size: 14px;
    color: #555;
    text-align: center;
    white-space: pre-line;
}

.top-contributors {
    margin-top: 10px;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.top-contributors span {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 14px;
}

/* Dashboard - Vitamins and Minerals */
.progress-bars-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 20px;
}

.progress-bar-section {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.progress-bar-section h2 {
    margin-bottom: 15px;
    text-align: center;
}

.progress-bar-row {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.progress-bar-row .nutrient-name {
    width: 100px;
    text-align: left;
    font-weight: 600;
}

.progress-bar-row .progress-bar-container {
    flex: 1;
    position: relative;
    height: 20px;
    background-color: #e0e0e0;
    border-radius: 10px;
    margin: 0 10px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    /* Ensure filling from left */
}

.progress-bar-row .progress-bar-container::before {
    content: attr(data-percentage) "% (" attr(data-current) " / " attr(data-total) ")";
    position: absolute;
    width: 100%;
    text-align: center;
    font-size: 12px;
    color: #333;
    pointer-events: none;
}

.progress-bar-row .progress-bar-fill {
    background-color: #3498db;
    height: 100%;
    border-radius: 10px 0 0 10px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-bar-row .contributors {
    width: 100px;
    font-size: 16px;
    color: #555;
    display: flex;
    gap: 5px;
    justify-content: flex-start;
}

.contributors span {
    display: flex;
    align-items: center;
    gap: 3px;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 40px;
    font-size: 14px;
    color: #777;
}

footer a {
    color: #3498db;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .dashboard {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    .progress-circle {
        width: 100px;
        height: 100px;
    }

    .progress-circle::before {
        width: 80px;
        height: 80px;
    }

    .progress-bar-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .progress-bar-row .progress-bar-container {
        margin: 10px 0;
    }

    .progress-bar-row .contributors {
        width: auto;
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .contributors span {
        flex: 1 1 30%;
    }

    .search-target-container {
        flex-direction: row;
        justify-content: center;
    }

    .food-item {
        flex-direction: row;
        justify-content: space-between;
    }

    .portion-control {
        flex-direction: row;
        gap: 5px;
    }
}
.create-recipe-btn {
    padding: 10px 15px;
    background-color: #f0f0f0;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.3s;
    white-space: nowrap;
    flex-shrink: 0;
    margin: 20px auto;
    display: block;
}

.clear-all-btn {
    padding: 10px 15px;
    background-color: #f0f0f0;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.3s;
    white-space: nowrap;
    flex-shrink: 0;
    margin: 10px auto 20px;
    display: block;
}

.clear-all-btn:hover {
    background-color: #e74c3c;
    color: white;
}

.create-recipe-btn:hover {
    background-color: #3498db;
    color: white;
}
.food-item.recipe-ingredient {
    border: 2px solid #3498db;
}

/* Mobile-specific styles */
@media (max-width: 767px) {
    body {
        padding: 10px;
        font-size: 14px;
    }

    h1 {
        font-size: 24px;
        margin-bottom: 15px;
    }

    .search-target-container {
        flex-direction: column;
        align-items: stretch;
    }

    #foodSearch,
    .target-input {
        max-width: none;
        width: 100%;
        margin-bottom: 10px;
    }

    .toggle-buttons {
        display: none;
    }

    .category-select {
        display: block;
    }

    .toggle-button {
        flex: 0 0 calc(33.33% - 10px);
        font-size: 12px;
        padding: 8px 10px;
        margin-bottom: 10px;
    }

    #foodButtons {
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .food-button {
        flex: 0 0 calc(50% - 10px);
        font-size: 12px;
        padding: 8px 10px;
        margin-bottom: 10px;
    }

    #selectedFoods {
        max-height: none;
    }

    .food-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .food-item-controls {
        width: 100%;
        display: flex;
        justify-content: space-between;
        margin-bottom: 5px;
    }

    .portion-control {
        width: 100%;
    }

    .portion-control input[type="range"] {
        width: calc(100% - 50px);
    }

    .dashboard {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .nutrition-card {
        padding: 8px;
    }

    .nutrition-card h3 {
        font-size: 16px;
    }

    .progress-circle {
        width: 50px;
        height: 50px;
    }

    .progress-text {
        font-size: 12px;
    }

    .nutrition-details {
        font-size: 10px;
    }

    .create-recipe-btn {
        width: 100%;
        margin-top: 15px;
    }
}