/* =========================================================
   COMMON — variables, base, layout, header, buttons, badges,
   shells, tables, modals, bottom nav, mobile compact
   ========================================================= */

:root{
  --rp-bg: #e2f0dd;         /* vert pastel fond */
  --rp-surface: #ffffff;    /* cartes */
  --rp-surface-2: #f7f8f2;  /* champs / surfaces light */
  --rp-border: rgba(70, 90, 70, .12);

  --rp-text: #55625F;
  --rp-muted: rgba(47,58,47,.65);

  --rp-green: #9cc96b;
  --rp-green-2: #86b95a;

  --rp-radius-lg: 26px;
  --rp-radius-md: 16px;

  --rp-shadow-soft: 0 18px 45px rgba(40, 70, 40, .10);
  --rp-shadow-inset: inset 0 1px 0 rgba(255,255,255,.75);

  --rp-green-start: #a6d27b;
  --rp-green-end: #8fbf61;
  --rp-green-text: #ffffff;

  --rp-soft-start: #F9FBF1;
  --rp-soft-end: #EFF5DA;

  --rp-danger-text: #9a4a4a;
  --rp-danger-border: rgba(170,90,90,.45);
  --rp-danger-bg: linear-gradient(180deg, #FBECEC, #F4DADA);

  /* Layout vars (utilisées par chat + padding mobile) */
  --rp-header-h: 56px;
  --rp-main-gap-top: 15px;
  --rp-page-pad: 2rem;
  --rp-page-pad-mobile: 1.1rem;
  --rp-bottom-nav-h: 92px;
}

body{
  font-family: "Nunito", system-ui, -apple-system, sans-serif;
  color: var(--rp-text);
  background-color: var(--rp-bg);
  background-image: url("/img/background.png");
  background-repeat: no-repeat;
  background-position: center top;
  background-size: 100% auto;
  background-attachment: fixed;
  min-height: 100vh;
}

.container{ max-width: 1220px !important; }

/* Titles */
h1{
  color: var(--rp-text);
  font-weight: 800;
  font-size: 28px;
}
h2{
  color: var(--rp-text);
  font-weight: 800;
  font-size: 24px;
}

/* =========================================================
   BUTTONS (bootstrap overrides)
   ========================================================= */

.btn-outline-primary{
  border-radius: 999px;
  padding: .45rem 1rem;
  font-weight: 600;
  font-size: .9rem;

  color: #5b6f55;
  border: 1px solid rgba(120,150,120,.35);
  background: linear-gradient(180deg, var(--rp-soft-start), var(--rp-soft-end));

  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.8),
    0 2px 6px rgba(90,120,60,.18);

  transition: all .2s ease;
}
.btn-outline-primary:hover{
  color: #3f5f36;
  border-color: rgba(120,150,120,.55);
  background: linear-gradient(180deg, #ffffff, #f2f7df);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.9),
    0 3px 8px rgba(90,120,60,.22);
}

.btn-primary{
  border-radius: 999px;
  padding: .5rem 1.1rem;
  font-weight: 700;
  font-size: .95rem;

  color: var(--rp-green-text);
  border: none;
  background: linear-gradient(180deg, var(--rp-green-start), var(--rp-green-end));

  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.6),
    0 6px 16px rgba(120,170,80,.45);

  text-shadow: 0 1px 0 rgba(0,0,0,.25);
  transition: all .2s ease;
}
.btn-primary:hover{
  background: linear-gradient(180deg, #b4dc8a, #96c86b);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.7),
    0 8px 18px rgba(120,170,80,.5);
}

.btn-primary:active,
.btn-outline-primary:active{
  transform: translateY(1px);
  box-shadow: inset 0 2px 4px rgba(0,0,0,.2);
}
.btn-primary:focus-visible,
.btn-outline-primary:focus-visible{
  outline: none;
  box-shadow:
    0 0 0 3px rgba(150,200,100,.35),
    0 6px 16px rgba(120,170,80,.35);
}

.btn-outline-danger{
  border-radius: 999px;
  padding: .45rem .7rem;
  color: var(--rp-danger-text);
  border-color: var(--rp-danger-border);
  background: var(--rp-danger-bg);

  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.85),
    0 2px 6px rgba(120,60,60,.18);

  transition: all .2s ease;
}
.btn-outline-danger:hover{
  color: #7f3b3b;
  border-color: rgba(150,70,70,.65);
  background: linear-gradient(180deg, #ffffff, #f6dede);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.9),
    0 3px 8px rgba(120,60,60,.25);
}
.btn-outline-danger:active{
  transform: translateY(1px);
  box-shadow: inset 0 2px 4px rgba(120,60,60,.25);
}
.btn-outline-danger:focus-visible{
  outline: none;
  box-shadow:
    0 0 0 3px rgba(220,150,150,.45),
    0 3px 8px rgba(120,60,60,.25);
}

.bt-action-thumb{ width: 30px; height: 30px; }
@media (max-width: 576px){
    .bt-action-thumb{
        margin-right: -5px;
    }
}  

/* =========================================================
   BADGES / CARD HEADER
   ========================================================= */

.card-header{
  background: linear-gradient(180deg, var(--rp-green-start), var(--rp-green-end));
  color: #ffffff;
  text-shadow: 0 1px 0 rgba(0,0,0,.25);
}

.badge.bg-primary{
  border-radius: 999px;
  padding: .4em .75em;
  font-weight: 700;
  font-size: .75rem;
  color: #ffffff;
  background: linear-gradient(180deg, var(--rp-green-start), var(--rp-green-end));
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.6),
    0 3px 8px rgba(120,170,80,.45);
  text-shadow: 0 1px 0 rgba(0,0,0,.25);
}

.badge-outline-primary{
  border-radius: 999px;
  padding: .35em .7em;
  font-weight: 600;
  font-size: .75rem;
  color: #5b6f55;
  border: 1px solid rgba(120,150,120,.35);
  background: linear-gradient(180deg, var(--rp-soft-start), var(--rp-soft-end));
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.8),
    0 2px 5px rgba(90,120,60,.18);
}

.badge.bg-light.text-primary{
  border-radius: 999px;
  font-weight: 600;
  color: #5b6f55 !important;
  border: 1px solid rgba(120,150,120,.35);
  background: linear-gradient(180deg, var(--rp-soft-start), var(--rp-soft-end));
}

.badge.bg-primary:hover,
.badge-outline-primary:hover{
  filter: brightness(1.05);
}

/* =========================================================
   HEADER / NAV
   ========================================================= */

.rp-header{
  background: rgba(255,255,255,.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(120,150,120,.18);
}

.rp-brand-name{
  font-weight: 800;
  font-size: 2rem;
  color: #3b5a32;
}

.rp-brand-mark{ width: 80px; height: 80px; }
.rp-title-thumb{ width: 45px; height: 45px; }
.rp-top-nav-action-thumb{ width: 30px; height: 30px; }

.rp-topnav-link{
  display: inline-flex;
  align-items: center;
  gap: .25rem;

  padding: .45rem .95rem;
  border-radius: 999px;

  font-weight: 600;
  font-size: .95rem;

  color: #5b6f55;
  text-decoration: none;

  transition: background-color .2s ease, box-shadow .2s ease, color .2s ease;
}
.rp-topnav-link.is-active{
  background: linear-gradient(180deg, var(--rp-green-start), var(--rp-green-end));
  color: #ffffff;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.6),
    0 6px 16px rgba(120,170,80,.45);
  font-weight: 700;
  text-shadow: 0 1px 0 rgba(0,0,0,.25);
}

.rp-header-cta{
  border-radius: 999px;
  padding: .45rem 1rem;
  font-weight: 600;
  font-size: .9rem;
  color: #5b6f55;

  border: 1px solid rgba(120,150,120,.35);
  background: linear-gradient(180deg, var(--rp-soft-start), var(--rp-soft-end));

  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.8),
    0 2px 6px rgba(90,120,60,.18);

  backdrop-filter: blur(4px);
  transition: all .2s ease;
}
.rp-header-cta:hover{
  background: rgba(255,255,255,.9);
  color: #3f5f36;
  border-color: rgba(120,150,120,.55);
}

/* =========================================================
   PAGE / SHELL / FIELDS
   ========================================================= */

.rp-page{
  background: #FEFCFB;
  margin-top: 15px;
  border-radius: 28px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.85),
    0 10px 18px rgba(60,90,60,.22);
  padding: 2rem;
}

.rp-shell{
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(255,255,255,.55);
  border-radius: var(--rp-radius-lg);
  box-shadow: var(--rp-shadow-soft);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.rp-title{
  font-weight: 700;
  letter-spacing: -.02em;
  color: rgba(35,45,35,.80);
}

.rp-field{
  background: var(--rp-surface-2);
  border: 1px solid var(--rp-border);
  border-radius: var(--rp-radius-md);
  box-shadow: var(--rp-shadow-inset);
}

.rp-section-title{
  display: inline-flex;
  align-items: center;
  gap: .6rem;
}
.rp-section-title h2{
  font-weight: 700;
  letter-spacing: -.02em;
  color: rgba(47,58,47,.85);
}
.rp-count-badge{
  font-size: .75rem;
  padding: .35em .7em;
  transform: translateY(-2px);
}

/* =========================================================
   TABLES (within rp-page)
   ========================================================= */

.rp-page .table-responsive{
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid rgba(120,150,120,.20);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.85),
    0 10px 18px rgba(60,90,60,.14);
}

.rp-page .table{
  margin-bottom: 0;
  --bs-table-bg: transparent;
  --bs-table-striped-bg: rgba(239,245,218,.35);
  --bs-table-hover-bg: rgba(166,210,123,.16);
}

.rp-page .table thead th{
  background: linear-gradient(180deg, rgba(231,243,219,.85), rgba(217,238,200,.75));
  color: rgba(47,58,47,.75);
  font-weight: 700;
  letter-spacing: -.01em;
  border-bottom: 1px solid rgba(120,150,120,.18);
}

.rp-page .table tbody{ --bs-table-bg: #ffffff; }

.rp-page .table > :not(caption) > * > *{
  padding: 0.5rem 1.1rem;
  border-bottom-color: rgba(120,150,120,.14);
}

.rp-page .table tbody tr{ background: #ffffff; }
.rp-page .table tbody tr:hover{ background: #fcfdf9; }

/* =========================================================
   MODAL (shared)
   ========================================================= */

.rp-modal{
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(231,243,219,.92), rgba(217,238,200,.86));
  border: 1px solid rgba(120,150,120,.18);
  box-shadow: 0 18px 40px rgba(60,90,60,.18);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.rp-modal .modal-title{
  font-weight: 900;
  letter-spacing: -.01em;
  color: var(--rp-text);
}
.rp-modal-text{
  font-weight: 700;
  color: var(--rp-text);
}

/* Quantité editable (shared stock/shopping/recipes) */
.rp-qty{
  cursor: pointer;
  position: relative;
  display: inline-block;
}
.rp-qty-input{
  display: none;
  width: 88px;
  text-align: right;
  border: none !important;
  outline: none !important;
  background: transparent !important;
  box-shadow: none !important;
  font-weight: 800;
  color: inherit;
}
.rp-qty.is-editing .rp-qty-input{ display: inline-block; }

.rp-qty-btn{
  border: 0;
  background: transparent;
  padding: 6px 8px;
  border-radius: 10px;
}
.rp-qty-btn:active{ background: rgba(0,0,0,.05); }

/* =========================================================
   BOOTSTRAP SWITCH OVERRIDE
   ========================================================= */

.form-switch .form-check-input{
  width: 2.8rem;
  height: 1.55rem;
  appearance: none;
  -webkit-appearance: none;

  border-radius: 999px;
  border: 1px solid rgba(35,48,82,0.25);
  background-color: rgba(35,48,82,0.15);

  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-2 -2 36 36'%3E%3Ccircle cx='16' cy='16' r='14' fill='white'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 1.15rem 1.15rem;
  background-position: left 0.2rem center;

  cursor: pointer;
  transition: background-color .2s ease, border-color .2s ease, background-position .2s ease;
  box-shadow: inset 0 2px 4px rgba(0,0,0,.08);
}
.form-switch .form-check-input:checked{
  background-color: var(--rp-brand, #8ECF9E);
  border-color: rgba(142,207,158,0.85);
  background-position: right 0.2rem center;
}
.form-switch .form-check-input:focus{
  outline: 0;
  box-shadow: var(--rp-focus, 0 0 0 .25rem rgba(167,228,210,.55));
}
.form-switch .form-check-input:disabled{
  opacity: .5;
  cursor: not-allowed;
}
.form-switch .form-check-label{
  margin-left: .55rem;
  font-weight: 700;
  color: var(--rp-ink, #233052);
}

/* =========================================================
   MOBILE BOTTOM NAV
   ========================================================= */

.rp-bottom-nav{
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(0px + env(safe-area-inset-bottom));
  z-index: 1030;

  width: min(560px, calc(100% - 24px));
  padding: 0px;

  display: flex;
  align-items: stretch;
  gap: 0;

  border-radius: 22px;
  background: linear-gradient(180deg, var(--rp-soft-start), var(--rp-soft-end));

  border: 2px solid transparent;
  background-clip: padding-box;

  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.85),
    0 14px 28px rgba(60,90,60,.20);

  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.rp-bottom-nav .rp-tab{
  flex: 1 1 0;
  min-width: 0;

  text-decoration: none;
  color: rgba(47,58,47,.72);

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;

  padding: 3px 6px;
  border-radius: 22px;

  position: relative;
  transition: transform .12s ease, filter .12s ease, background .12s ease, box-shadow .12s ease;
}

.rp-bottom-nav .rp-tab + .rp-tab::before{
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 1px;
  background: rgba(120,150,120,.18);
}

.rp-bottom-nav .rp-tab:active{ transform: translateY(1px); }

.rp-bottom-nav .rp-tab.is-active{
  color: var(--rp-green-text);
  background: linear-gradient(180deg, var(--rp-green-start), var(--rp-green-end));
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.6),
    0 6px 16px rgba(120,170,80,.45);
  text-shadow: 0 1px 0 rgba(0,0,0,.25);
  border: 1px solid rgba(255,255,255,.20);
  transform: translateY(-1px);
}

.rp-bottom-nav .rp-tab.is-active i,
.rp-bottom-nav .rp-tab.is-active span{
  color: var(--rp-green-text);
}

.rp-bottom-nav .rp-tab.is-active::before{ opacity: 0; }
.rp-bottom-nav .rp-tab.is-active + .rp-tab::before{ opacity: 0; }

.rp-bottom-nav .rp-tab:focus-visible{
  outline: none;
  box-shadow: 0 0 0 3px rgba(150,200,100,.35);
  border-radius: 999px;
}

.rp-bottom-nav .rp-nav-action-thumb{
  width: 50px;
  margin-bottom: -8px;
}

/* Eviter que le menu fixe recouvre le contenu sur mobile */
@media (max-width: 991.98px){
  body{ padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
}

/* =========================================================
   MOBILE COMPACT (<= 576px)
   ========================================================= */

@media (max-width: 576px){
  body{ background-image: url("/img/background_mobile.png"); }

  .container{
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .rp-page{
    padding: 0.7rem !important;
    margin-top: 10px !important;
    border-radius: 22px !important;
  }

  .rp-header{
    background: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    position: relative !important;
    top: inherit !important;
  }

  h1{
    font-size: 22px !important;
    line-height: 1.15;
    margin-bottom: .35rem;
  }
  h2{
    font-size: 18px !important;
    line-height: 1.2;
    margin-bottom: .35rem;
  }

  .rp-title{ font-size: 1.05rem; }

  /* Réduire gros espacements bootstrap */
  .mt-5{ margin-top: 1.5rem !important; }
  .mb-5{ margin-bottom: 1.5rem !important; }
  .py-5{ padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }

  .rp-page .card-body{ padding: 1rem !important; }

  .btn-primary,
  .btn-outline-primary,
  .btn-outline-danger{
    padding: .42rem .70rem !important;
    font-size: .9rem !important;
  }

  .rp-topnav-link{
    padding: .38rem .75rem !important;
    font-size: .9rem !important;
  }

  .rp-brand-name{ font-size: 1.6rem !important; }
  .rp-brand-mark{ width: 60px; height: 60px; }

  .rp-section-title{ gap: .45rem !important; }
  .rp-count-badge{
    transform: none !important;
    padding: .30em .60em !important;
  }

  .rp-page .table > :not(caption) > * > *{
    padding: 0.42rem 0.65rem !important;
  }
  .rp-page .table thead th{ font-size: .85rem; }
  .rp-page .table-responsive{ border-radius: 18px !important; }

  .swipe-content{ padding: 1px; }
  .rp-accordion{ margin: 0 -11px; }
  .rp-recipe-grid{ margin: 0px -0.4rem; }
  .rp-recipe-main{ padding: 10px; }
}

.ts-no-results { padding: 10px; }


.rp-unit-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 0;
  cursor: pointer;
  box-shadow: none;
}

.rp-unit-select::-ms-expand {
  display: none;
}

.rp-unit-select:focus {
  outline: none;
  box-shadow: none;
}

@media (min-width: 768px) {
  .rp-unit-select {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    width: auto;
    min-width: 0;
  }
}

.rp-unit-select-mobile {
  width: 44px;
  max-width: 44px;
  min-width: 44px;
  flex: 0 0 44px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .85rem;
}