/* ═══════════════════════════════════════════════════
   Factory Price CRM — Styles principaux (mobile-first)
   ═══════════════════════════════════════════════════ */

:root {
  --gold:        #B8932A;
  --gold-light:  #D4AA4A;
  --gold-pale:   #FBF5E6;
  --gold-line:   #E8D49A;
  --bg:          #F8F7F4;
  --white:       #FFFFFF;
  --border:      #E5E2DB;
  --text:        #1A1A1A;
  --text-sub:    #6B6560;
  --text-dim:    #A8A39C;
  --green:       #1A7A4A;
  --green-bg:    #EDF7F2;
  --red:         #C0392B;
  --red-bg:      #FDF2F0;
  --orange:      #C25A1A;
  --orange-bg:   #FDF4EE;
  --blue:        #1A5FAA;
  --blue-bg:     #EEF4FB;
  --nav-h:       64px;   /* hauteur barre nav mobile */
  --top-h:       56px;   /* hauteur topbar */
}

/* ── Reset & base ────────────────────────────────── */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--text);
  margin: 0;
  padding: 0;
  overscroll-behavior: none;
}

/* ── Topbar ──────────────────────────────────────── */
.app-topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  height: var(--top-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 16px; gap: 12px;
}
.app-topbar .brand { font-size: 15px; font-weight: 800; color: var(--text); letter-spacing: .04em; }
.app-topbar .brand span { color: var(--gold); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ── Content wrapper ─────────────────────────────── */
.app-content {
  padding-top: calc(var(--top-h) + 12px);
  padding-bottom: calc(var(--nav-h) + 12px);
  padding-left: 14px;
  padding-right: 14px;
  min-height: 100vh;
}

/* ── Bottom Nav (mobile) ─────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  height: var(--nav-h);
  background: var(--white);
  border-top: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px;
  color: var(--text-dim); text-decoration: none;
  font-size: 10px; font-weight: 600; letter-spacing: .02em;
  padding: 6px 4px; border-radius: 12px;
  transition: all .15s; position: relative;
}
.bottom-nav a i { font-size: 20px; }
.bottom-nav a.active { color: var(--gold); }
.bottom-nav a.active i { color: var(--gold); }
.bottom-nav a:hover { color: var(--text); }
.bottom-nav .nav-badge {
  position: absolute; top: 4px; right: calc(50% - 16px);
  min-width: 16px; height: 16px; border-radius: 8px;
  background: var(--red); color: #fff;
  font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px; border: 2px solid var(--white);
}

/* ── Cards ───────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border) !important;
  border-radius: 16px !important;
  box-shadow: 0 2px 8px rgba(26,20,10,.06) !important;
}
.card-body { padding: 16px; }
.card-header-fp {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header-fp .card-title {
  font-size: 14px; font-weight: 700; color: var(--text); margin: 0;
}

/* ── KPI Cards ───────────────────────────────────── */
.kpi-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  transition: all .2s;
}
.kpi-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; margin-bottom: 12px;
}
.kpi-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .1em; font-weight: 700; margin-bottom: 4px; }
.kpi-value { font-size: 22px; font-weight: 800; color: var(--text); line-height: 1; margin-bottom: 3px; }
.kpi-sub   { font-size: 11px; color: var(--text-sub); }

/* Objectif journalier */
.goal-progress { position: relative; }
.goal-bar-wrap { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin: 8px 0; }
.goal-bar-fill { height: 100%; border-radius: 4px; transition: width 1s ease; }

/* ── Avatars ─────────────────────────────────────── */
.avatar {
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0;
  border: 1.5px solid currentColor;
}
.avatar-sm { width: 32px; height: 32px; font-size: 11px; }
.avatar-md { width: 40px; height: 40px; font-size: 14px; }
.avatar-lg { width: 52px; height: 52px; font-size: 18px; }

/* ── Badges / Pills ──────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; padding: 3px 10px;
  border-radius: 20px; white-space: nowrap;
}
.pill-dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }

/* ── Buttons ─────────────────────────────────────── */
.btn-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: #fff !important; border: none; font-weight: 700;
  border-radius: 12px; padding: 12px 20px; font-size: 14px;
  box-shadow: 0 4px 14px rgba(184,147,42,.3);
  transition: opacity .18s; width: 100%; display: block; text-align: center; text-decoration: none;
  cursor: pointer;
}
.btn-gold:hover { opacity: .88; }
.btn-gold-sm {
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: #fff !important; border: none; font-weight: 700;
  border-radius: 8px; padding: 7px 14px; font-size: 12px;
  box-shadow: 0 2px 8px rgba(184,147,42,.25); cursor: pointer;
}
.btn-outline {
  background: transparent; border: 1px solid var(--border); color: var(--text-sub);
  border-radius: 10px; padding: 9px 16px; font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all .15s;
}
.btn-outline:hover { border-color: var(--gold); color: var(--gold); }

/* ── Forms ───────────────────────────────────────── */
.form-label-fp {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-sub); display: block; margin-bottom: 6px;
}
.input-fp {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg);
  font-size: 14px; color: var(--text); outline: none;
  transition: border-color .18s, background .18s;
  -webkit-appearance: none;
}
.input-fp:focus { border-color: var(--gold); background: var(--white); }
.input-fp.error { border-color: var(--red); background: var(--red-bg); }
.form-group { margin-bottom: 16px; }

/* ── Tables ──────────────────────────────────────── */
.table-fp { width: 100%; border-collapse: collapse; }
.table-fp thead th {
  background: var(--bg); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em; color: var(--text-dim);
  border-bottom: 1px solid var(--border); padding: 10px 12px;
  white-space: nowrap; text-align: left;
}
.table-fp tbody td {
  padding: 12px; font-size: 13px;
  border-bottom: 1px solid #f0ede7; vertical-align: middle;
}
.table-fp tbody tr { transition: background .1s; }
.table-fp tbody tr:hover { background: var(--bg); }
.table-fp tbody tr:last-child td { border-bottom: none; }

/* ── Sale card (mobile list) ─────────────────────── */
.sale-item {
  background: var(--white); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px;
  margin-bottom: 10px; transition: all .15s;
}
.sale-item:active { background: var(--bg); transform: scale(.99); }

/* ── Filter pills ────────────────────────────────── */
.filter-wrap { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.filter-wrap::-webkit-scrollbar { display: none; }
.filter-pill {
  flex-shrink: 0; padding: 7px 14px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--white);
  font-size: 12px; font-weight: 500; color: var(--text-sub);
  cursor: pointer; transition: all .15s; white-space: nowrap;
  text-decoration: none; display: inline-block;
}
.filter-pill.active, .filter-pill:hover { border-color: var(--gold); color: var(--gold); background: var(--gold-pale); font-weight: 700; }

/* ── Section header ──────────────────────────────── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-title  { font-size: 15px; font-weight: 700; color: var(--text); margin: 0; }

/* ── Empty state ─────────────────────────────────── */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-dim); }
.empty-state i { font-size: 40px; margin-bottom: 12px; opacity: .3; display: block; }
.empty-state p { font-size: 13px; margin: 0; }

/* ── Alert ───────────────────────────────────────── */
.alert-fp {
  padding: 12px 14px; border-radius: 12px;
  font-size: 13px; font-weight: 500; margin-bottom: 14px;
  border: 1px solid transparent;
}
.alert-error   { background: var(--red-bg);    color: var(--red);    border-color: rgba(192,57,43,.2);  }
.alert-success { background: var(--green-bg);  color: var(--green);  border-color: rgba(26,122,74,.2);  }
.alert-info    { background: var(--blue-bg);   color: var(--blue);   border-color: rgba(26,95,170,.2);  }

/* ── Auth page ───────────────────────────────────── */
.auth-page {
  min-height: 100vh; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.auth-card { background: var(--white); border-radius: 20px; border: 1px solid var(--border); padding: 28px 24px; width: 100%; max-width: 400px; box-shadow: 0 12px 40px rgba(26,20,10,.08); }
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo-icon {
  width: 56px; height: 56px; border-radius: 14px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #fff; margin: 0 auto 12px;
  box-shadow: 0 6px 20px rgba(184,147,42,.3);
}
.auth-title { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.auth-sub   { font-size: 12px; color: var(--text-sub); margin-bottom: 22px; }

/* ── Progress bar ────────────────────────────────── */
.progress-fp { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-fp-bar { height: 100%; border-radius: 2px; transition: width .8s ease; }

/* ── Spinner ─────────────────────────────────────── */
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modal bottom sheet ──────────────────────────── */
.sheet-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 500; opacity: 0; pointer-events: none; transition: opacity .25s;
}
.sheet-overlay.open { opacity: 1; pointer-events: all; }
.sheet {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 501;
  background: var(--white); border-radius: 24px 24px 0 0;
  padding: 8px 20px 32px;
  transform: translateY(100%); transition: transform .3s cubic-bezier(.25,.8,.25,1);
  max-height: 90vh; overflow-y: auto;
}
.sheet.open { transform: translateY(0); }
.sheet-handle { width: 40px; height: 4px; background: var(--border); border-radius: 2px; margin: 8px auto 16px; }
.sheet-title { font-size: 17px; font-weight: 700; color: var(--text); margin-bottom: 18px; }

/* ── Responsive desktop ──────────────────────────── */
@media (min-width: 768px) {
  .app-content { padding-left: 20px; padding-right: 20px; }

  /* Sidebar desktop */
  .bottom-nav { display: none; }
  .app-sidebar {
    display: flex !important;
    flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 230px; background: var(--white);
    border-right: 1px solid var(--border); z-index: 100;
  }
  .app-content { margin-left: 230px; padding-top: calc(var(--top-h) + 20px); padding-bottom: 20px; }
  .app-topbar  { left: 230px; }

  .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
  .grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; }
}

@media (max-width: 767px) {
  .app-sidebar { display: none; }
  .grid-2, .grid-3, .grid-4 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 18px; }
}

/* ── Sidebar nav desktop ─────────────────────────── */
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; border-radius: 10px; border: none;
  color: var(--text-sub); text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  transition: all .15s; position: relative; margin-bottom: 2px;
}
.sidebar-nav a:hover { background: var(--bg); color: var(--text); }
.sidebar-nav a.active { background: var(--gold-pale); color: var(--gold); font-weight: 700; }
.sidebar-nav a.active::after {
  content: ""; position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 2px; background: var(--gold);
}
.sidebar-nav a i { font-size: 16px; width: 20px; text-align: center; }

/* ── Misc ─────────────────────────────────────────── */
.text-gold  { color: var(--gold); }
.text-green { color: var(--green); }
.text-red   { color: var(--red); }
.text-muted-fp { color: var(--text-dim); }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.divider { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.rounded-fp { border-radius: 12px; }
.mono { font-family: 'SF Mono', 'Fira Code', monospace; }
