/* ===== MediCIV Mobile - Theme medical ===== */
:root {
  --bleu: #0077B6;
  --bleu-fonce: #005f8e;
  --vert: #2E8B57;
  --rouge: #DC143C;
  --orange: #E67E22;
  --fond: #F8FAFB;
  --carte: #ffffff;
  --texte: #1d2b36;
  --muted: #6b7c8a;
  --bordure: #e3eaf0;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--fond);
  color: var(--texte);
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  font-size: 16px;
}

/* ===== Barre du haut ===== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 10px;
  background: var(--bleu); color: #fff;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.topbar h1 { font-size: 18px; margin: 0; flex: 1; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back-btn {
  color: #fff; text-decoration: none; font-size: 28px; line-height: 1;
  padding: 0 8px; margin-left: -8px; font-weight: bold;
}
.user-chip {
  color: #fff; text-decoration: none; font-size: 13px;
  background: rgba(255,255,255,.18); padding: 6px 10px; border-radius: 20px;
  white-space: nowrap;
}

/* ===== Contenu ===== */
.content {
  padding: 14px;
  padding-bottom: calc(86px + env(safe-area-inset-bottom));
  max-width: 640px; margin: 0 auto;
}

/* ===== Navigation du bas ===== */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; justify-content: space-around;
  background: var(--carte); border-top: 1px solid var(--bordure);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 10px rgba(0,0,0,.06);
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: 11px;
  padding: 4px 10px; border-radius: 10px; min-width: 56px;
}
.bottomnav a span { font-size: 22px; }
.bottomnav a.active { color: var(--bleu); font-weight: 600; }

/* ===== Cartes ===== */
.card {
  background: var(--carte); border: 1px solid var(--bordure);
  border-radius: 14px; padding: 14px; margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.card h3 { margin: 0 0 10px; font-size: 16px; color: var(--bleu-fonce); }
.card h4 { margin: 12px 0 6px; font-size: 14px; color: var(--muted); }
.alert-title { color: var(--rouge) !important; }

/* ===== Stats ===== */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat-card {
  background: var(--carte); border: 1px solid var(--bordure); border-radius: 14px;
  padding: 14px; text-decoration: none; color: var(--texte);
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.stat-value { font-size: 22px; font-weight: 700; color: var(--bleu); }
.stat-green .stat-value { color: var(--vert); }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ===== Boutons ===== */
.btn {
  display: inline-block; padding: 12px 16px; border-radius: 12px;
  border: none; font-size: 15px; font-weight: 600; text-decoration: none;
  cursor: pointer; text-align: center;
}
.btn-primary { background: var(--bleu); color: #fff; }
.btn-green { background: var(--vert); color: #fff; }
.btn-danger { background: var(--rouge); color: #fff; }
.btn-outline { background: var(--carte); color: var(--bleu); border: 1.5px solid var(--bleu); }
.btn-block { display: block; width: 100%; }
.btn-big { padding: 16px; font-size: 17px; }
.btn:active { opacity: .85; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.quick-actions .btn { flex: 1; min-width: 130px; }
.quick-actions form { flex: 1; min-width: 130px; }
.quick-actions form .btn { width: 100%; }

/* ===== Listes ===== */
.searchbar { display: flex; gap: 8px; margin-bottom: 8px; }
.searchbar input { flex: 1; }
.item-card {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--texte);
}
.item-main { flex: 1; min-width: 0; }
.item-sub { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag {
  font-size: 12px; background: #eef4f8; color: #41586b;
  border-radius: 6px; padding: 2px 7px;
}
.chevron { color: var(--muted); font-size: 24px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.pager { display: flex; justify-content: space-between; gap: 8px; margin: 10px 0; }
.row-line {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--bordure); font-size: 14px;
}
.row-line:last-child { border-bottom: none; }
.total-line { font-size: 17px; color: var(--bleu-fonce); }
.badge {
  font-size: 12px; background: #eef4f8; border-radius: 12px; padding: 3px 9px;
  white-space: nowrap;
}
.badge-red { background: #fde8ec; color: var(--rouge); font-weight: 600; }
.badge-orange { background: #fdf0e3; color: var(--orange); font-weight: 600; }

/* ===== FAB ===== */
.fab {
  position: fixed; right: 18px; bottom: calc(86px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--vert); color: #fff; font-size: 32px; line-height: 56px;
  text-align: center; text-decoration: none;
  box-shadow: 0 4px 14px rgba(46,139,87,.4); z-index: 40;
}

/* ===== Formulaires ===== */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; font-weight: 600; }
input, select, textarea {
  display: block; width: 100%; margin-top: 4px;
  padding: 12px; font-size: 16px;
  border: 1.5px solid var(--bordure); border-radius: 10px;
  background: #fff; color: var(--texte); font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--bleu); }
input[disabled] { background: #f1f4f6; color: var(--muted); }
.check-line { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--texte); }
.check-line input { width: 22px; height: 22px; margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-card label:last-of-type { margin-bottom: 16px; }

/* ===== Messages flash ===== */
.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 10px; font-size: 14px; }
.flash-success { background: #e6f4ec; color: #1e6b41; border: 1px solid #bfe3cf; }
.flash-error { background: #fde8ec; color: #a01030; border: 1px solid #f5c2cd; }

/* ===== Detail ===== */
.detail-list { margin: 0; }
.detail-row { padding: 8px 0; border-bottom: 1px solid var(--bordure); }
.detail-row:last-child { border-bottom: none; }
.detail-row dt { font-size: 12px; color: var(--muted); font-weight: 600; }
.detail-row dd { margin: 2px 0 0; font-size: 15px; white-space: pre-wrap; }
.detail-alert { background: #fde8ec; margin: 0 -14px; padding: 8px 14px; border-radius: 8px; }
.detail-alert dd { color: var(--rouge); font-weight: 700; }
.child-row { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 0; border-bottom: 1px solid var(--bordure); }
.child-row:last-child { border-bottom: none; }

/* ===== Menu ===== */
.group-title { font-size: 13px; text-transform: uppercase; color: var(--muted); margin: 18px 4px 8px; }
.menu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.menu-tile {
  background: var(--carte); border: 1px solid var(--bordure); border-radius: 14px;
  padding: 14px 6px; text-align: center; text-decoration: none; color: var(--texte);
  font-size: 12.5px; display: flex; flex-direction: column; gap: 6px; align-items: center;
}
.menu-icon { font-size: 26px; }
.user-card { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 48px; height: 48px; border-radius: 50%; background: var(--bleu);
  color: #fff; font-size: 22px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* ===== Connexion ===== */
.login-box { max-width: 380px; margin: 30px auto; }
.login-logo { text-align: center; }
.login-logo img { border-radius: 22px; box-shadow: 0 6px 20px rgba(0,119,182,.3); }
.login-box h2 { text-align: center; margin: 14px 0 2px; color: var(--bleu-fonce); }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ===== Caisse / POS ===== */
.med-result {
  display: block; width: 100%; text-align: left;
  background: #f3f8fb; border: 1px solid var(--bordure); border-radius: 10px;
  padding: 10px; margin-top: 6px; font-size: 14px; cursor: pointer; font-family: inherit;
}
.med-result strong { color: var(--bleu-fonce); }
.med-out { opacity: .5; }
.cart-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--bordure);
}
.cart-name { font-size: 14px; flex: 1; }
.cart-qty { display: flex; align-items: center; gap: 8px; }
.qty-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1.5px solid var(--bordure);
  background: #fff; font-size: 18px; cursor: pointer;
}
.qty-del { color: var(--rouge); border-color: #f5c2cd; }
.totals { margin-top: 10px; }
.pay-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.pay-btn {
  padding: 10px 4px; border-radius: 10px; border: 1.5px solid var(--bordure);
  background: #fff; font-size: 12px; cursor: pointer; font-family: inherit;
}
.pay-btn.active { border-color: var(--bleu); background: #e7f3fa; font-weight: 700; }
details summary { font-size: 14px; color: var(--bleu); cursor: pointer; margin: 8px 0; }

/* ===== Lignes ordonnance / commande ===== */
.ligne-card {
  position: relative; border: 1.5px dashed var(--bordure); border-radius: 12px;
  padding: 12px; padding-top: 16px; margin-bottom: 10px;
}
.ligne-del {
  position: absolute; top: 8px; right: 8px;
  width: 30px; height: 30px; border-radius: 8px; border: none;
  background: #fde8ec; color: var(--rouge); font-size: 14px; cursor: pointer;
}
