/* ============================================================
   AkaGestSoft — Gestion Avicole
   Design tokens (validés sur les maquettes) + styles de base
   ============================================================ */

:root {
  /* Palette */
  --vert-profond: #2F4A3D;
  --vert-clair: #E4EEE6;
  --vert-texte: #3D6B4E;
  --ambre: #D9A441;
  --ambre-clair: #FBF2DE;
  --coquille: #F7F4EC;
  --charbon: #2B2620;
  --rouille: #B5502F;
  --rouille-clair: #FBEAE1;
  --gris-texte: #8A8071;
  --gris-clair: #B0A890;
  --bordure: #E8E1CE;

  /* Typographie */
  --font-display: 'Fraunces', serif;
  --font-body: 'Archivo', sans-serif;

  /* Rayons */
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

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

html, body {
  height: 100%;
  font-family: var(--font-body);
  background: var(--coquille);
  color: var(--charbon);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--coquille);
  position: relative;
  display: flex;
  flex-direction: column;
}

/* ---- Barre supérieure commune ---- */
.topbar {
  background: var(--vert-profond);
  color: var(--coquille);
  padding: 20px 20px 18px;
  padding-top: max(20px, env(safe-area-inset-top));
  flex-shrink: 0;
}
.topbar .backrow { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.topbar .backrow-left { display: flex; align-items: center; gap: 12px; }
.topbar .back-btn, .topbar .icon-btn {
  width: 34px; height: 34px; border-radius: 11px;
  background: rgba(247,244,236,.14);
  display: flex; align-items: center; justify-content: center;
  border: none; cursor: pointer;
}
.topbar .back-btn svg, .topbar .icon-btn svg { width: 18px; height: 18px; stroke: var(--coquille); }
.topbar h1 { font-family: var(--font-display); font-weight: 700; font-size: 19px; }
.topbar .sub { font-size: 12px; color: #B9C9BC; margin-top: 3px; }

/* ---- Contenu scrollable ---- */
.content { flex: 1; overflow-y: auto; padding: 18px 20px; padding-bottom: 100px; }

/* ---- Navigation basse ---- */
.bottomnav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  height: 78px; padding-bottom: max(14px, env(safe-area-inset-bottom));
  background: #fff; border-top: 1px solid var(--bordure);
  display: flex; align-items: center; justify-content: space-around;
  z-index: 50;
}
.navitem { display: flex; flex-direction: column; align-items: center; gap: 4px; background: none; border: none; cursor: pointer; }
.navitem svg { width: 21px; height: 21px; stroke: var(--gris-clair); }
.navitem span { font-size: 10px; color: var(--gris-clair); font-weight: 500; }
.navitem.active svg { stroke: var(--vert-profond); }
.navitem.active span { color: var(--vert-profond); font-weight: 700; }

/* ---- Composants communs ---- */
.section-title {
  font-family: var(--font-display); font-weight: 700; font-size: 14.5px;
  color: var(--charbon); margin: 18px 0 10px;
}
.section-title:first-child { margin-top: 0; }

.card {
  background: #fff; border: 1px solid var(--bordure); border-radius: var(--radius-lg);
  padding: 15px; margin-bottom: 10px;
}

.btn-primary {
  background: var(--ambre); color: var(--vert-profond);
  font-family: var(--font-body); font-weight: 700; font-size: 15px;
  text-align: center; padding: 16px; border-radius: var(--radius-md);
  border: none; width: 100%; cursor: pointer;
}
.btn-primary:active { opacity: .85; }

.tag { font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 6px; display: inline-block; }
.tag-ok { background: var(--vert-clair); color: var(--vert-profond); }
.tag-warn { background: var(--rouille-clair); color: var(--rouille); }

.fab {
  position: fixed; bottom: 96px; left: 50%;
  transform: translateX(calc(-50% + 155px));
  width: 56px; height: 56px; border-radius: 18px;
  background: var(--ambre); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 24px rgba(217,164,65,.45);
  z-index: 40;
}
.fab svg { width: 24px; height: 24px; stroke: var(--vert-profond); stroke-width: 2.4; }

/* ---- États vides / chargement ---- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--gris-texte); }
.empty-state svg { width: 48px; height: 48px; stroke: var(--gris-clair); margin-bottom: 14px; }
.empty-state p { font-size: 13px; line-height: 1.5; }

.skeleton {
  background: linear-gradient(90deg, #F0EBDD 25%, #F7F4EC 50%, #F0EBDD 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.4s ease infinite;
  border-radius: var(--radius-md);
}
@keyframes skeleton-loading { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---- Bandeau offline ---- */
.offline-banner {
  background: var(--ambre-clair); color: #7A5A14;
  font-size: 11.5px; font-weight: 600; text-align: center;
  padding: 8px; display: none;
}
.offline-banner.visible { display: block; }

/* ---- Toast de confirmation ---- */
.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--vert-profond); color: var(--coquille);
  font-size: 13px; font-weight: 600; padding: 12px 20px; border-radius: 14px;
  opacity: 0; transition: opacity .25s ease, transform .25s ease;
  z-index: 100; pointer-events: none; white-space: nowrap;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================
   Styles d'impression — pour l'export PDF du rapport
   Le contenu .print-only est invisible à l'écran, affiché
   uniquement quand le navigateur imprime (Ctrl+P → Enregistrer en PDF).
   ============================================================ */
.print-only { display: none; }

@media print {
  body * { visibility: hidden; }
  #rapport-print, #rapport-print * { visibility: visible; }
  #rapport-print { display: block !important; position: absolute; top: 0; left: 0; width: 100%; }
  .topbar, .bottomnav, #rapport-apercu, .fab { display: none !important; }

  @page { size: A4; margin: 0; }
  .print-page {
    width: 210mm; min-height: 297mm; padding: 16mm; position: relative;
    page-break-after: always; box-sizing: border-box;
    font-family: var(--font-body); color: var(--charbon);
  }
  .print-page:last-child { page-break-after: avoid; }

  .print-cover {
    background: var(--vert-profond) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact;
    color: var(--coquille); display: flex; flex-direction: column; justify-content: space-between;
  }
  .print-cover-top { display: flex; justify-content: space-between; align-items: flex-start; }
  .print-logo { font-family: var(--font-display); font-weight: 700; font-size: 15px; }
  .print-tag { font-size: 10px; color: #B9C9BC; border: 1px solid rgba(247,244,236,.3); padding: 5px 11px; border-radius: 20px; }
  .print-eyebrow { color: var(--ambre); font-weight: 700; font-size: 12px; letter-spacing: .04em; margin-bottom: 14px; }
  .print-title { font-family: var(--font-display); font-weight: 700; font-size: 38px; line-height: 1.15; max-width: 440px; }
  .print-sub { font-size: 13px; color: #B9C9BC; margin-top: 16px; max-width: 400px; line-height: 1.5; }
  .print-meta { display: flex; gap: 36px; margin-top: 36px; }
  .print-meta-num { font-family: var(--font-display); font-weight: 700; font-size: 24px; }
  .print-meta-lbl { font-size: 10px; color: #9FB3A4; margin-top: 2px; }
  .print-cover-bottom { display: flex; justify-content: space-between; align-items: flex-end; border-top: 1px solid rgba(247,244,236,.15); padding-top: 14px; font-size: 12px; }

  .print-header { font-family: var(--font-display); font-weight: 700; font-size: 17px; color: var(--vert-profond); border-bottom: 2px solid var(--vert-profond); padding-bottom: 8px; margin-bottom: 16px; }
  .print-table { width: 100%; border-collapse: collapse; font-size: 10.5px; }
  .print-table th { text-align: left; font-size: 8.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--gris-texte); padding: 6px 7px; border-bottom: 1.5px solid var(--bordure); font-weight: 700; }
  .print-table td { padding: 7px; border-bottom: 1px solid #EEE8D8; }

  .print-finance-row { display: flex; gap: 12px; }
  .print-fin-box { flex: 1; text-align: center; padding: 14px 10px; border-radius: 10px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-fin-box.rev { background: var(--vert-clair); }
  .print-fin-box.exp { background: var(--rouille-clair); }
  .print-fin-box.net { background: var(--vert-profond); color: var(--coquille); }
  .print-fin-val { font-family: var(--font-display); font-weight: 700; font-size: 17px; }
  .print-fin-lbl { font-size: 9px; margin-top: 3px; opacity: .85; }

  .print-signature { margin-top: 26px; display: flex; gap: 36px; }
  .print-signature > div { flex: 1; }
  .print-sig-line { border-bottom: 1px solid var(--charbon); height: 36px; }
  .print-sig-lbl { font-size: 9px; color: var(--gris-texte); margin-top: 6px; }

  .print-footer { position: absolute; bottom: 12mm; left: 16mm; right: 16mm; display: flex; justify-content: space-between; font-size: 8px; color: var(--gris-clair); border-top: 1px solid var(--bordure); padding-top: 8px; }
}
