* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.product-sheet-add-portion-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.product-sheet-add-portion-actions .secondary-btn.small[disabled] {
    opacity: 0.4;
    cursor: default;
}

/* Vue Aliments pleine page (recouvre le header, sous la bottom-nav) */

#view-foods.view-section {
    position: fixed;
    inset: 0; /* top:0; right:0; bottom:0; left:0; */
    z-index: 15; /* > header (10), < bottom-nav (20) */
    display: flex;
    flex-direction: column;
    background: #111;
    padding-bottom: 56px; /* pour la bottom-nav */
}

.food-browser-page {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #111;
}

.food-browser-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: #202020;
    border-bottom: 1px solid #303030;
}

.food-browser-title {
    flex: 1;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
}

.food-browser-actions {
    display: flex;
    gap: 4px;
}

.icon-btn {
    border: none;
    background: transparent;
    color: #f5f5f5;
    font-size: 18px;
    padding: 4px 6px;
    cursor: pointer;
}

.food-browser-tabs {
    display: flex;
    padding: 4px 8px;
    gap: 4px;
    background: #181818;
}

.food-browser-tab-btn {
    flex: 1;
    border: none;
    background: #202020;
    color: #bbb;
    padding: 6px 4px;
    border-radius: 999px;
    font-size: 13px;
}

.food-browser-tab-btn.food-browser-tab-active {
    background: #36c275;
    color: #111;
}

.food-browser-body {
    flex: 1;
    padding: 8px 12px 12px;
    overflow-y: auto;
}

.food-browser-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.food-browser-item {
    padding: 8px 10px;
    border-radius: 8px;
    background: #202020;
}

.food-browser-item-title {
    font-size: 14px;
    margin-bottom: 4px;
}

.food-browser-item-macros {
    font-size: 11px;
    color: #aaa;
}

.chooser-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.chooser-btn .chooser-icon {
    font-size: 18px;
    line-height: 1;
}

.chooser-btn .chooser-label {
    font-size: 14px;
}

/* Barre de navigation basse */

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: flex;
    justify-content: stretch;
    gap: 0;
    padding: 0;
    background: #111;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.8);
}

.bottom-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    border-radius: 0;
    border: none;
    background: #181818;
    color: #ddd;
    font-size: 11px;
}

.bottom-nav-btn .bottom-nav-icon {
    font-size: 18px;
    line-height: 1;
    margin-bottom: 2px;
}

.bottom-nav-btn .bottom-nav-label {
    font-size: 11px;
}

.bottom-nav-btn:active,
.bottom-nav-btn:focus-visible {
    background: #36c275;
    color: #111;
    outline: none;
}

/* Menu contextuel pour les éléments de repas */

.context-menu {
    position: fixed;
    z-index: 2000;
    min-width: 150px;
    background: #222;
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.7);
    padding: 4px 0;
}

.context-menu.hidden {
    display: none;
}

.context-menu-item {
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: #eee;
    text-align: left;
    font-size: 13px;
    cursor: pointer;
}

.context-menu-item:hover {
    background: #333;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #111;
    color: #f5f5f5;
    /* background: red; */
}

h1,
h2,
h3 {
    margin-bottom: 12px;
}

.hidden {
    display: none !important;
}

#app-root {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-bar {
    padding: 0 12px 0;
    position: sticky;
    top: 0;
    z-index: 10;
    background: #111;
    box-shadow: 0px 10px 46px rgb(17 17 17);
}

.top-bar-content {
    padding: 12px;
    background: #272727;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
    border-radius: 0 0 12px 12px;
    margin-bottom: 12px;
}

.week-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.week-nav-btn {
    width: 32px;
    height: 32px;
    border-radius: 16px;
    border: none;
    background: #262626;
    color: #fff;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.week-days {
    flex: 1;
    display: flex;
    justify-content: space-between;
    margin: 0 8px;
}

.week-day {
    flex: 1;
    text-align: center;
    font-size: 11px;
    color: #aaa;
    background-color: #272727;
    border: 0;
}

.week-day-name {
    text-transform: lowercase;
    margin-bottom: 4px;
}

.week-day-number {
    width: 26px;
    height: 26px;
    line-height: 26px;
    margin: 0 auto;
    border-radius: 13px;
    border: 1px solid #444;
    font-size: 14px;
    color: #f5f5f5;
    background: #111; /* fond sombre pour que le chiffre reste visible */
}

.week-day-active .week-day-number {
    background: #36c275;
    border-color: #36c275;
    color: #111;
}

.selected-date {
    text-align: center;
    font-size: 13px;
    color: #ccc;
    margin: 16px;
}

.main-tabs {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.tab-btn {
    flex: 1;
    padding: 6px 0;
    border-radius: 999px;
    border: none;
    background: #111;
    color: #bbb;
    font-size: 13px;
}

.tab-btn.tab-active {
    background: #36c275;
    color: #111;
}

.main-content {
    flex: 1;
    margin: 0 12px;
    padding-bottom: 70px; /* espace pour la barre de navigation basse */
}

.view-section {

}

.card-content {
    background: #272727;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);   
    padding: 12px 16px;
    margin-bottom: 12px;
}

.kcal-card {
    display: flex;
    gap: 0;
    padding-bottom: 12px;
}

.kcal-circle-wrapper {
    flex: 0 0 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kcal-circle {
    width: 90px;
    height: 90px;
    border-radius: 60px;
    /* 0 -> var(--kcal-progress) : kcal consommées (rouge)
       var(--kcal-progress) -> 360 : kcal restantes (vert) */
    background: conic-gradient(#9b0b0b 0deg, #9b0b0b var(--kcal-progress, 160deg), #444 var(--kcal-progress, 160deg));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    /* inversion horizontale pour rendre la progression anti-horaire */
    transform: scaleX(-1);
}

.kcal-circle::after {
    content: '';
    position: absolute;
    inset: 6px;
    border-radius: 999px;
    background: #272727;
    z-index: 0;
}

.kcal-main {
    position: relative;
    z-index: 1;
    font-size: 20px;
    font-weight: 700;
    /* remettre le texte à l'endroit */
    transform: scaleX(-1);
}

.kcal-label {
    position: relative;
    z-index: 1;
    font-size: 7px;
    text-transform: uppercase;
    color: #aaa;
    margin-top: 4px;
    text-align: center;
    transform: scaleX(-1);
}

.kcal-side {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.kcal-side-block {
    margin-bottom: 10px;
    text-align: center;
}

.kcal-side-label {
    font-size: 9px;
    color: #999;
    text-transform: uppercase;
}

.kcal-side-label::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    margin-right: 6px;
    vertical-align: middle;
    background: transparent;
}

.kcal-label-consumed::before {
    background: #9b0b0b; /* rouge pour les kcal consommées */
}

.kcal-label-remaining::before {
    background: #444; /* vert pour les kcal restantes (cercle) */
}

.kcal-side-value {
    font-size: 20px;
    font-weight: 600;
}

.macros-cols {
    display: flex;
    gap: 12px;
}

.macro-col {
    flex: 1;
}

.macro-label {
    font-size: 11px;
    color: #ccc;
    margin-bottom: 4px;
}

.macro-bar {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: #444;
    overflow: hidden;
}

.macro-bar-fill {
    height: 100%;
    width: 0;
    background: #9b0b0b;
    border-radius: 999px;
    transition: width 0.25s ease-out;
}

.macro-values {
    font-size: 11px;
    color: #f5f5f5;
    margin-top: 4px;
}

/* Cartes repas */

.meal-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.meal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.meal-title {
    font-size: 14px;
    font-weight: 600;
}

.meal-add-btn {
    width: 28px;
    height: 28px;
    border-radius: 14px;
    border: none;
    background: #36c275;
    color: #111;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.meal-body {
    font-size: 13px;
    color: #ccc;
}

.meal-body.empty {
    font-style: italic;
}

/* Lignes d'éléments dans un repas (aliment / recette) */

.meal-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 0;
    border-top: 1px solid #222;
}

.meal-item:first-child {
    border-top: none;
}

.meal-item-main {
    flex: 1;
    min-width: 0;
}

.meal-item-name {
    font-size: 13px;
    font-weight: 600;
    color: #f5f5f5;
    display: flex;
    align-items: center;
    gap: 6px;
}

.meal-item-meta {
    font-size: 9px;
    color: #999;
    margin-top: 2px;
}

.meal-item-portion {
    position: relative;
    padding-left: 20px;
}

.meal-item-portion::before {
    content: '🍽';
    position: absolute;
    left: 4px;
    top: -3px;
    font-size: 12px;
    color: #777;
}

.meal-item-kcal {
    font-size: 14px;
    font-weight: 600;
    align-self: center;
    display: flex;
    align-items: center;
    gap: 4px;
}

.meal-item-menu-btn {
    border: none;
    background: transparent;
    color: #aaa;
    cursor: pointer;
    padding: 2px 4px;
    font-size: 16px;
}

.meal-item-menu-btn:hover {
    color: #fff;
}

.meal-item-badge {
    font-size: 10px;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 999px;
    background: #333;
    color: #ddd;
}

.meal-item-recipe .meal-item-badge {
    background: #36c275;
    color: #111;
}

.settings-card h2 {
    font-size: 16px;
    margin-bottom: 8px;
}

.field-label {
    font-size: 13px;
    margin-bottom: 6px;
    display: block;
}

.field-input {
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #333;
    background: #111;
    color: #f5f5f5;
    margin-bottom: 6px;
}

.hint-text {
    font-size: 12px;
    color: #888;
}

.primary-btn {
    margin-top: 10px;
    width: 100%;
    padding: 10px 0;
    border-radius: 999px;
    border: none;
    background: #36c275;
    color: #111;
    font-weight: 600;
    font-size: 14px;
}

.primary-btn.small {
    width: auto;
    padding-inline: 18px;
}

.secondary-btn {
    padding: 10px 18px;
    border-radius: 999px;
    border: none;
    background: transparent;
    color: #ccc;
    font-size: 14px;
}

/* Overlay calendrier */

.overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.overlay-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 0;
}

.calendar-modal {
    position: relative;
    width: 90%;
    max-width: 360px;
    border-radius: 16px;
    overflow: hidden;
    background: #f5f5f5;
    color: #111;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    z-index: 1;
}

.calendar-header {
    background: #36c275;
    color: #111;
    padding: 12px 16px 16px;
}

.calendar-year {
    font-size: 14px;
    margin-bottom: 4px;
}

.calendar-title {
    font-size: 20px;
    font-weight: 600;
}

.calendar-nav-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px 0;
}

.calendar-month-label {
    font-size: 15px;
    font-weight: 500;
}

.calendar-nav-btn {
    width: 32px;
    height: 32px;
    border-radius: 16px;
    border: none;
    background: #e0e0e0;
    color: #111;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    padding: 8px 16px 0;
    font-size: 11px;
    color: #777;
    text-align: center;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    padding: 4px 12px 0;
    margin-bottom: 8px;
}

.calendar-day {
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: #111;
}

.calendar-day button {
    width: 28px;
    height: 28px;
    border-radius: 14px;
    border: none;
    background: transparent;
    color: inherit;
}

.calendar-day.disabled {
    opacity: 0;
}

.calendar-day-current button {
    border: 1px solid #36c275;
}

.calendar-day-selected button {
    background: #36c275;
    color: #111;
}

.calendar-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 16px 14px;
}

/* Overlay choix repas (aliment / recette) */

.meal-chooser-modal {
    position: relative;
    width: 90%;
    max-width: 360px;
    border-radius: 16px;
    overflow: hidden;
    background: #272727;
    color: #f5f5f5;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}

.meal-chooser-header {
    padding: 14px 16px 8px;
}

.meal-chooser-title {
    font-size: 16px;
    font-weight: 600;
}

.meal-chooser-body {
    padding: 8px 16px 4px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chooser-btn {
    width: 100%;
    padding: 10px 0;
    border-radius: 10px;
    border: 1px solid #444;
    background: #111;
    color: #f5f5f5;
    font-size: 14px;
    text-align: left;
    padding-inline: 12px;
}

/* Overlay recherche aliment */

.food-search-modal {
    position: relative;
    width: 90%;
    max-width: 420px;
    border-radius: 16px;
    overflow: hidden;
    background: #272727;
    color: #f5f5f5;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}

.food-search-header {
    padding: 14px 16px 6px;
}

.food-search-title {
    font-size: 16px;
    font-weight: 600;
}

.food-search-sub {
    font-size: 12px;
    color: #aaa;
}

.food-search-tabs {
    display: flex;
    padding: 6px 8px 0;
    gap: 6px;
}

.food-tab-btn {
    flex: 1;
    padding: 6px 0;
    border-radius: 999px;
    border: none;
    background: #111;
    color: #bbb;
    font-size: 13px;
}

.food-tab-btn.food-tab-active {
    background: #36c275;
    color: #111;
}

.food-search-body {
    padding: 10px 16px 4px;
}

.food-tab-panel {
    margin-bottom: 8px;
}

.food-search-results {
    max-height: 220px;
    overflow-y: auto;
    border-top: 1px solid #222;
    margin-top: 8px;
    padding-top: 4px;
}

.food-result {
    width: 100%;
    border: none;
    background: #1b1b1b;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 10px;
    margin-bottom: 6px;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
    text-align: left;
}

.food-result:active {
    background: #111;
}

.food-result-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.food-result-name {
    font-size: 14px;
    font-weight: 600;
}

.food-result-meta {
    font-size: 11px;
    color: #b0b0b0;
}

.food-result-portion {
    font-size: 11px;
    color: #888;
}

.food-result-kcal {
    margin-left: 8px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.food-result-left {
    margin-right: 8px;
}

.food-result-thumb {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    color: #f5f5f5;
    overflow: hidden;
}

.food-result-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Fiche produit */

.product-sheet-modal {
    position: relative;
    width: 90%;
    max-width: 420px;
    max-height: 90vh;
    border-radius: 16px;
    overflow: hidden;
    background: #272727;
    color: #f5f5f5;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
}

.product-sheet-header {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 14px 16px 10px;
    background: linear-gradient(135deg, #1f1f1f, #333);
}

.product-sheet-image {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    background: #111;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 600;
}

.product-sheet-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-sheet-title-block {
    flex: 1;
    min-width: 0;
}

.product-sheet-name {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
}

.product-sheet-macros {
    font-size: 11px;
    color: #ccc;
}

.product-sheet-body {
    padding: 10px 16px 4px;
    overflow-y: auto;
}

.product-sheet-section-title {
    font-size: 13px;
    font-weight: 600;
    margin: 10px 0 6px;
}

.product-sheet-portions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.product-portion-chip {
    border: none;
    border-radius: 999px;
    padding: 4px 10px;
    background: #1b1b1b;
    color: #f5f5f5;
    font-size: 11px;
}

.product-sheet-add-portion {
    margin-top: 8px;
}

.product-sheet-add-to-meal {
    margin-top: 8px;
}

/* Bouton favori dans la fiche produit */

.favorite-btn {
    border: none;
    background: transparent;
    color: #f5a623;
    font-size: 22px;
    cursor: pointer;
    padding: 2px 0;
    margin-top: 4px;
    line-height: 1;
}

/* Icône recette dans la fiche overlay */

.recipe-icon {
    font-size: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Vue Recettes (même structure que vue Aliments) */

#view-recipes.view-section {
    position: fixed;
    inset: 0;
    z-index: 15;
    display: flex;
    flex-direction: column;
    background: #111;
    padding-bottom: 56px;
}

/* États génériques loading / empty / error */

.loading {
    text-align: center;
    color: #888;
    padding: 16px;
    font-size: 13px;
}

.empty {
    text-align: center;
    color: #666;
    padding: 16px;
    font-size: 13px;
    font-style: italic;
}

.error {
    text-align: center;
    color: #e55;
    padding: 16px;
    font-size: 13px;
}

/* inline fields groupés (2 colonnes) */

.field-inline-group {
    display: flex;
    gap: 10px;
}

.field-inline {
    flex: 1;
    min-width: 0;
}

/* Dictée */

.dictation-modal {
    max-width: 440px;
}

.dictation-textarea {
    resize: vertical;
    min-height: 60px;
    font-family: inherit;
}

.dictation-results {
    max-height: 55vh;
    overflow-y: auto;
    margin-top: 10px;
}

.dictation-item {
    background: #1b1b1b;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
}

.dictation-item-match-label {
    font-size: 13px;
    margin: 8px 0 6px;
    color: #ccc;
}

.dictation-item-results {
    max-height: 140px;
    border-top: none;
    margin-top: 6px;
    padding-top: 0;
}

.dictation-match-selected {
    outline: 2px solid #36c275;
}

.dictation-item-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.dictation-item-actions .primary-btn.small {
    margin-top: 0;
}

.dictation-item-status {
    font-size: 12px;
    color: #aaa;
}

.dictation-item-added {
    opacity: 0.7;
}

/* Scanner de code-barres */

.barcode-scanner-modal {
    max-width: 420px;
}

.barcode-scanner-video {
    width: 100%;
    max-height: 320px;
    object-fit: cover;
    background: #000;
    border-radius: 10px;
    display: block;
}

.barcode-scanner-status {
    text-align: center;
    margin-top: 10px;
}
