/* ---- Base ---- */
html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Poppins', system-ui, -apple-system, sans-serif;
}

[data-bs-theme="dark"] body {
    background-color: #1c1c1e;
}

[data-bs-theme="light"] body {
    background-color: #f2f2f7;
}

* {
    scrollbar-width: thin;
}

[data-bs-theme="dark"] * {
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

[data-bs-theme="light"] * {
    scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

::-webkit-scrollbar {
    width: 0.375rem;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    border-radius: 0.25rem;
}

[data-bs-theme="dark"] ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

[data-bs-theme="light"] ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
}

/* ---- Utilities ---- */
.text-gradient {
    background: linear-gradient(45deg, #9200eb, #ff037b, #ff5b0d);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ---- Site header ---- */
.site-header {
    z-index: 1030;
}

[data-bs-theme="dark"] .site-header {
    background-color: #111113;
}

[data-bs-theme="light"] .site-header {
    background-color: #e2e2e9;
}

/* ---- Navbar ---- */
[data-bs-theme="dark"] .navbar {
    background-color: #111113;
}

[data-bs-theme="light"] .navbar {
    background-color: #e2e2e9;
}


.brand-text {
    font-weight: 700;
    font-size: 1.5rem;
}

/* ---- Theme toggle ---- */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.4375rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}

.theme-toggle i {
    font-size: 1.5rem;
    color: var(--bs-secondary-color);
    opacity: 0.35;
    transition: all 0.2s;
}

[data-bs-theme="dark"] .theme-toggle .bi-moon-stars-fill,
[data-bs-theme="light"] .theme-toggle .bi-sun-fill {
    opacity: 1;
}

.theme-track {
    width: 2.375rem;
    height: 1.375rem;
    background: rgba(128, 128, 128, 0.35);
    border-radius: 0.6875rem;
    position: relative;
    flex-shrink: 0;
    transition: background 0.25s;
}

[data-bs-theme="light"] .theme-track {
    background: linear-gradient(45deg, #9200eb, #ff037b, #ff5b0d);
}

.theme-thumb {
    width: 1.125rem;
    height: 1.125rem;
    background: #fff;
    border-radius: 50%;
    position: absolute;
    top: 0.125rem;
    left: 0.125rem;
    transition: transform 0.25s;
    box-shadow: 0 0.0625rem 0.1875rem rgba(0, 0, 0, 0.3);
}

[data-bs-theme="light"] .theme-thumb {
    transform: translateX(1rem);
}

/* ---- Meal panel ---- */
[data-bs-theme="dark"] .meal-panel {
    background-color: #1c1c1e;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-bs-theme="light"] .meal-panel {
    background-color: #f2f2f7;
    border-bottom: 1px solid rgba(0, 0, 0, 0.07);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* ---- Search (TomSelect) ---- */

.ts-opt {
    padding: 0.0625rem 0;
}

.ts-opt-main {
    font-weight: 600;
}

.ts-opt-details {
    font-size: 0.82rem;
    color: var(--bs-secondary-color);
    margin-left: 0.125rem;
}

/* ---- Food list ---- */
main.container-lg {
    display: flex;
    flex-direction: column;
}

#food-list {
    flex: 1;
}

#food-list:has(> p) {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---- Food card ---- */
[data-bs-theme="dark"] .card:not(.totals-card) {
    background-color: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.09);
}

[data-bs-theme="light"] .card:not(.totals-card) {
    background-color: rgba(255, 255, 255, 0.85);
    border-color: rgba(0, 0, 0, 0.1);
}

.food-card {
    position: relative;
}

.food-row {
    align-items: center;
    row-gap: 0.375rem;
}

.food-name {
    order: 1;
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.9rem;
}

.food-main {
    font-weight: 600;
}

.food-details {
    font-size: 0.82rem;
    color: var(--bs-secondary-color);
}

.food-values {
    order: 3;
    flex: 0 0 100%;
    align-items: center;
    justify-content: center;
}

.food-footer {
    align-items: center;
    border-top: 1px solid var(--bs-border-color);
}

.food-remove {
    position: absolute;
    top: 0.25rem;
    right: 0.375rem;
    background: none;
    border: none;
    padding: 0;
    line-height: 1;
    font-size: 0.9rem;
    opacity: 0.4;
    cursor: pointer;
    color: currentColor;
    transition: opacity 0.15s, color 0.15s;
}

.food-remove:hover {
    opacity: 1;
    color: var(--bs-danger);
}

/* ---- Nutrients ---- */
.nutrient-col {
    min-width: 3.25rem;
}

.food-values .nutrient-col {
    flex: 1;
}

.nutrient-value {
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.3;
    white-space: nowrap;
}

.nutrient-unit {
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
}

.nutrient-label {
    font-size: 0.7rem;
    color: var(--bs-secondary-color);
    line-height: 1.4;
}

.nutrient-sep {
    width: 1px;
    height: 1.75rem;
    background-color: var(--bs-border-color);
    flex-shrink: 0;
}

/* ---- Portion ---- */
.portion-group {
    max-width: 6.875rem;
}

.portion-add {
    padding-inline: 0.5rem;
}

/* ---- Footer ---- */
.footer {
    border-top: 1px solid var(--bs-border-color);
}

.social-link {
    color: var(--bs-secondary-color);
    font-size: 2rem;
    text-decoration: none;
    display: inline-flex;
    transition: all 0.2s;
}

.social-link:hover {
    background: linear-gradient(45deg, #9200eb, #ff037b, #ff5b0d);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ---- Responsive (≥ 768px) ---- */
@media (min-width: 768px) {

    /* Meal totals */
    #meal-totals .nutrient-value {
        font-size: 1.75rem;
    }

    #meal-totals .nutrient-unit {
        font-size: 1rem;
    }

    #meal-totals .nutrient-label {
        font-size: 0.85rem;
    }

    /* Food card */
    .food-card {
        flex-direction: row;
    }

    .food-card>.card-body {
        flex: 1 1 auto;
        min-width: 0;
    }

    .food-row {
        flex-direction: column;
        align-items: stretch;
        row-gap: 0;
    }

    .food-values {
        flex: 1;
        align-items: flex-end;
    }

    .food-footer {
        flex: 0 0 auto;
        align-items: flex-end;
        border-top: none;
        border-left: 1px solid var(--bs-border-color);
        justify-content: center;
        min-width: 10rem;
    }

    /* Nutrients */
    .food-values .nutrient-value>span:first-child {
        font-size: 1.25rem;
    }

    .nutrient-col {
        min-width: 4.25rem;
    }

    .nutrient-sep {
        height: 3rem;
    }
}
