* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f7f5;
    color: #1f2937;
    line-height: 1.5;
    min-height: 100vh;
}

a { color: #16a34a; text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    background: #16a34a;
    color: white;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
}
/* Sélecteurs à 2 classes : doivent l'emporter sur « body.mode-enfant a » et les thèmes */
.topbar .topbar-logo { color: white; font-weight: 600; font-size: 18px; }
.topbar-logo:hover { text-decoration: none; }
.topbar-nav { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.topbar .topbar-nav a { color: rgba(255,255,255,.9); font-size: 14px; }
.topbar .topbar-nav a.active { color: white; font-weight: 600; box-shadow: inset 0 -2px 0 white; }
.topbar .topbar-user { color: white; }
body.mode-enfant .topbar { background: #ec4899; }
body.mode-enfant a { color: #ec4899; }

/* Thème Clara — vert amande */
body.theme-clara .topbar { background: #9bb574; }
body.theme-clara a { color: #6b8a47; }
body.theme-clara .btn-pink { background: #9bb574; }
body.theme-clara .btn-pink:hover { background: #7a9a55; }
body.theme-clara .menu-card-titre { color: #6b8a47; }
body.theme-clara .rayon-titre { background: #9bb574; }

/* Thème Ugo — vert canard pétrole */
body.theme-ugo .topbar { background: #157b75; }
body.theme-ugo a { color: #0e5a55; }
body.theme-ugo .btn-pink { background: #157b75; }
body.theme-ugo .btn-pink:hover { background: #0e5a55; }
body.theme-ugo .menu-card-titre { color: #0e5a55; }
body.theme-ugo .rayon-titre { background: #157b75; }

.container { max-width: 900px; margin: 0 auto; padding: 16px; }

h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 20px; margin: 24px 0 12px; }
h3 { font-size: 16px; margin: 16px 0 8px; }

.card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
    margin-bottom: 12px;
}

.btn {
    display: inline-block;
    background: #16a34a;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
}
.btn:hover { background: #15803d; text-decoration: none; color: white; }
.btn-secondary { background: #6b7280; }
.btn-secondary:hover { background: #4b5563; }
.btn-danger { background: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.btn-pink { background: #ec4899; }
.btn-pink:hover { background: #db2777; }
.btn-block { display: block; width: 100%; text-align: center; }
.btn-sm { padding: 6px 10px; font-size: 13px; }

input[type=text], input[type=number], input[type=date], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
}
textarea { resize: vertical; min-height: 120px; }

label { display: block; margin: 8px 0 4px; font-weight: 500; font-size: 14px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form-row > * { flex: 1; min-width: 120px; }

.repas-jour {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 10px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 8px;
    background: white;
}
.repas-jour input[type=checkbox] { width: 20px; height: 20px; flex: 0 0 auto; }
.repas-jour .jour-label { flex: 1; font-weight: 500; }
.repas-jour input[type=number] { width: 70px; flex: 0 0 70px; }

.semaine-list .semaine-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid #f3f4f6;
    text-decoration: none;
    color: inherit;
}
.semaine-list .semaine-item:hover { background: #f9fafb; text-decoration: none; }
.semaine-list .semaine-item:last-child { border-bottom: none; }
.semaine-date { font-weight: 600; font-size: 15px; flex: 1; }
.semaine-statut {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 12px;
    background: #f3f4f6;
    color: #6b7280;
}
.semaine-statut.en_creation   { background: #fef3c7; color: #92400e; }
.semaine-statut.menus_ok      { background: #dbeafe; color: #1e40af; }
.semaine-statut.courses_faites{ background: #d1fae5; color: #065f46; }
.semaine-statut.terminee      { background: #e5e7eb; color: #4b5563; }

.menu-card {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    margin-bottom: 12px;
    overflow: hidden;
    background: white;
}
.menu-card-header {
    background: #f9fafb;
    padding: 10px 14px;
    font-weight: 600;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.menu-card-titre { color: #16a34a; }
.menu-card-body { padding: 10px 14px; font-size: 14px; }
.menu-card-body ul { margin: 4px 0; padding-left: 20px; }
.menu-card-body li { color: #4b5563; }

.rayon-bloc { margin-bottom: 16px; }
.rayon-titre {
    background: #16a34a;
    color: white;
    padding: 8px 12px;
    border-radius: 8px 8px 0 0;
    font-weight: 600;
    font-size: 15px;
}
.rayon-panier .rayon-titre { background: #6b7280; }
.produit-ligne {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-top: none;
    background: white;
    overflow: hidden;
    touch-action: pan-y;
}
.produit-ligne:last-child { border-radius: 0 0 8px 8px; }
.produit-ligne input[type=checkbox] { width: 22px; height: 22px; flex: 0 0 auto; }
.produit-ligne.fait { background: #f9fafb; opacity: .55; }
.produit-ligne.fait .produit-nom { text-decoration: line-through; }
/* Nom tronqué pour garder chaque ingrédient sur une seule ligne */
.produit-nom { flex: 0 1 auto; min-width: 0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Jour estompé (ex : « Dim. midi ») */
.produit-jours { flex: 0 0 auto; color: #9ca3af; font-size: 13px; white-space: nowrap; }
/* Quantité : poussée à droite, couleur visible */
.produit-quantite { flex: 0 0 auto; margin-left: auto; color: #15803d; font-weight: 600; font-size: 14px; white-space: nowrap; }
.produit-source-enfant { flex: 0 0 auto; font-size: 11px; background: #fce7f3; color: #be185d; padding: 2px 6px; border-radius: 10px; white-space: nowrap; }
.produit-ligne .btn { flex: 0 0 auto; }

/* Swipe-pour-supprimer (mobile) : retour visuel pendant le geste */
.produit-ligne.swiping { background: #fee2e2; }
.produit-ligne.swiping::before {
    content: "🗑️";
    position: absolute;
    left: 12px;
    font-size: 18px;
}
.produit-ligne { position: relative; }

.note-stars { display: inline-flex; gap: 2px; }
.note-stars .etoile { font-size: 22px; color: #d1d5db; cursor: pointer; user-select: none; }
.note-stars .etoile.active, .note-stars .etoile.hover { color: #f59e0b; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
.alert-success { background: #d1fae5; color: #065f46; }
.alert-error   { background: #fee2e2; color: #991b1b; }
.alert-info    { background: #dbeafe; color: #1e40af; }

.muted { color: #6b7280; font-size: 13px; }
.spacer { height: 12px; }

details.card > summary { cursor: pointer; font-weight: 600; }
.qui-es-tu select { font-size: 18px; padding: 14px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }

.ajout-article {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
}
.ajout-article .form-row > button { flex: 0 0 auto; min-width: 0; }

.empty {
    text-align: center;
    padding: 32px 16px;
    color: #6b7280;
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }

/* ---------------------------------------------------------------------------
   Mobile (≤ 600px)
--------------------------------------------------------------------------- */
@media (max-width: 600px) {
    .container { padding: 12px; }
    h1 { font-size: 21px; }

    /* Barre d'actions : boutons étirés, plus faciles à toucher */
    .actions > * { flex: 1 1 auto; }
    .actions .btn { width: 100%; text-align: center; }

    /* Formulaire « Ajouter un article » : champs empilés, bouton pleine largeur */
    .ajout-article .form-row { flex-direction: column; align-items: stretch; gap: 8px; }
    .ajout-article .form-row > * { width: 100%; min-width: 0; flex: none; }

    /* Lignes produit : tout sur une seule ligne ; recherche réservée au desktop */
    .produit-ligne { gap: 8px; }
    .produit-search { display: none; }

    /* Cibles tactiles un peu plus grandes */
    .btn-sm { padding: 9px 12px; font-size: 14px; }
}
