/* ============================================================
   CSS principal — Repas à domicile
   ============================================================ */

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

:root {
  --blue:        #3A6428;
  --blue-light:  #E8F3DD;
  --blue-dark:   #284D1B;
  --teal:        #6B9E25;
  --teal-light:  #EEF6DC;
  --green:       #27500A;
  --green-light: #EAF3DE;
  --amber-light: #FAEEDA;
  --amber-dark:  #633806;
  --red:         #8B1F1F;
  --red-light:   #FCEBEB;
  --gray-50:     #F8F8F6;
  --gray-100:    #F1EFE8;
  --gray-200:    #D3D1C7;
  --gray-400:    #888780;
  --gray-600:    #5F5E5A;
  --gray-900:    #1A1A18;
  --white:       #FFFFFF;
  --radius-sm:   6px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08);
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--gray-900);
  background: var(--gray-50);
  min-height: 100vh;
}

/* --- Layout principal --- */
.app-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  grid-row: 1 / -1;
  background: var(--white);
  border-right: 0.5px solid var(--gray-200);
  padding: 1.5rem 0;
  display: flex;
  flex-direction: column;
}

.sidebar-logo {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 0 1.25rem 1.5rem;
  border-bottom: 0.5px solid var(--gray-100);
  margin-bottom: 1rem;
}

.sidebar-logo .logo-img {
  width: 100%;
  height: auto;
  max-height: 56px;
  object-fit: contain;
  object-position: left center;
}

.sidebar-logo span {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-900);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 1.25rem;
  font-size: 13px;
  color: var(--gray-600);
  text-decoration: none;
  border-radius: 0;
  transition: background .1s, color .1s;
}

.nav-item:hover { background: var(--gray-50); color: var(--gray-900); }

.nav-item.active {
  background: var(--blue-light);
  color: var(--blue-dark);
  font-weight: 500;
  border-right: 2px solid var(--blue);
}

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.nav-section {
  font-size: 10px;
  font-weight: 500;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 1rem 1.25rem .4rem;
}

.sidebar-footer {
  margin-top: auto;
  padding: 1rem 1.25rem 0;
  border-top: 0.5px solid var(--gray-100);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--gray-600);
}

.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--blue-light);
  color: var(--blue-dark);
  font-size: 11px;
  font-weight: 500;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* --- Contenu principal --- */
.main-content {
  padding: 1.75rem 2rem;
  overflow-x: auto;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 8px;
}

.page-title {
  font-size: 18px;
  font-weight: 500;
  color: var(--gray-900);
}

/* --- Boutons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  border: 0.5px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-900);
  transition: background .1s;
  text-decoration: none;
}

.btn:hover { background: var(--gray-50); }
.btn:active { transform: scale(.98); }

.btn-primary {
  background: var(--blue-light);
  color: var(--blue-dark);
  border-color: transparent;
  font-weight: 500;
}

.btn-primary:hover { background: #cfe6b8; }

.btn-danger {
  background: var(--red);
  color: #fff;
  border-color: transparent;
}

.btn-danger:hover { background: #721919; }

/* --- Cards --- */
.card {
  background: var(--white);
  border: 0.5px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

/* --- Badges --- */
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 10px;
  font-weight: 500;
}

.badge-ok     { background: var(--green-light); color: var(--green); }
.badge-due    { background: var(--amber-light); color: var(--amber-dark); }
.badge-late   { background: var(--red-light);   color: var(--red); }
.badge-info   { background: var(--blue-light);  color: var(--blue-dark); }

/* --- Formulaires --- */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.field label { font-size: 12px; color: var(--gray-600); }

input[type=text], input[type=email], input[type=password],
input[type=number], input[type=date], select, textarea {
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  border: 0.5px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: var(--white);
  color: var(--gray-900);
  transition: border-color .15s;
}

input:hover, select:hover { border-color: var(--gray-400); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(24,95,165,.15);
}

input.field-error, select.field-error, textarea.field-error {
  border-color: var(--red) !important;
  box-shadow: 0 0 0 2px rgba(139,31,31,.15);
}
.field-error-msg {
  font-size: 11px;
  color: var(--red);
  margin-top: -8px;
  display: none;
}
.field-error-msg.visible { display: block; }

/* --- Toast notification --- */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--green-light);
  color: var(--green);
  border: 0.5px solid #C0DD97;
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  z-index: 1000;
  display: none;
}

/* --- Responsive mobile (livreur smartphone) --- */
@media (max-width: 640px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    grid-row: auto;
    flex-direction: row;
    flex-wrap: wrap;
    padding: .5rem;
    border-right: none;
    border-bottom: 0.5px solid var(--gray-200);
  }

  .sidebar-logo { padding: .5rem; border: none; margin: 0; }
  .sidebar-footer { display: none; }
  .nav-section { display: none; }

  .nav-item {
    padding: 8px 10px;
    font-size: 12px;
    flex-direction: column;
    gap: 3px;
    border-right: none;
  }

  .nav-item.active {
    border-right: none;
    border-bottom: 2px solid var(--blue);
  }

  .main-content { padding: 1rem; }
}
