:root {
  --admin-blue: #1f4e79;
  --admin-blue-light: #e8f0fa;
  --admin-grey: #f5f5f5;
  --danger: #c0392b;
  --warning: #f39c12;
  --ok: #27ae60;
  --border-color: #d0d0d0;
  --text-main: #222;
  --text-muted: #666;
  --bg-main: #ffffff;
}

* {
  box-sizing: border-box;
  font-family: "Segoe UI", Roboto, system-ui, sans-serif;
}

body {
  margin: 0;
  background: #eef1f4;
  color: var(--text-main);
}

/* HEADER */

header {
  background: var(--admin-blue);
  color: white;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 4px solid #163a5a;
}

#headerLeft {
  display: flex;
  align-items: center;
  gap: 16px;
}

#siteLogo {
  height: 48px;
  width: auto;
  background: white;
  padding: 6px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.4);
}

.title-block {
  display: flex;
  flex-direction: column;
}

header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

header .subtitle {
  font-size: 12px;
  opacity: 0.9;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

#produitsLink {
  color: white;
  text-decoration: none;
  font-weight: 600;
}

#roleBadge {
  padding: 6px 12px;
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
  font-size: 13px;
  border: 1px solid rgba(255,255,255,0.4);
}

#logoutBtn {
  padding: 6px 10px;
  border-radius: 3px;
  border: 1px solid #fff;
  background: rgba(255,255,255,0.2);
  color: white;
  cursor: pointer;
}

/* MAIN */

main {
  padding: 20px;
  max-width: 1300px;
  margin: 0 auto;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.top-bar-left h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: #1f4e79;
}

.top-bar-left .context {
  font-size: 13px;
  color: var(--text-muted);
}

.top-bar-right button {
  border-radius: 3px;
  border: 1px solid var(--border-color);
  background: #ffffff;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}

.top-bar-right button:hover {
  background: #f0f0f0;
}

/* LAYOUT */

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  align-items: flex-start;
}

.left-column,
.right-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* CARDS */

.card {
  background: var(--bg-main);
  border-radius: 6px;
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  padding: 16px;
}

.card h3 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--admin-blue);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 600;
  color: var(--admin-blue);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* TOGGLE */

.toggle-btn {
  cursor: pointer;
  font-size: 18px;
  user-select: none;
  padding: 2px 6px;
  border-radius: 4px;
}

.toggle-btn:hover {
  background: #e6ecf3;
}

.collapsible {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.25s ease;
}

/* PHARMACIES */

.pharmacy-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pharmacy-item {
  padding: 10px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background: #fafafa;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pharmacy-item.active {
  border-color: var(--admin-blue);
  background: var(--admin-blue-light);
}

.pharmacy-item-title {
  font-weight: 600;
  font-size: 14px;
}

.pharmacy-item-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.badge {
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  color: white;
}

.badge.red { background: var(--danger); }
.badge.orange { background: var(--warning); }
.badge.green { background: var(--ok); }
.badge.grey { background: #7f8c8d; }

/* TABLES */

.table-wrapper {
  border-radius: 4px;
  border: 1px solid var(--border-color);
  overflow: hidden;
  background: white;
  max-height: 320px;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead {
  background: #f0f3f7;
  position: sticky;
  top: 0;
  z-index: 1;
}

th, td {
  padding: 6px 8px;
  border-bottom: 1px solid #e0e0e0;
  text-align: left;
}

tbody tr:nth-child(even) {
  background: #f7faff;
}

tbody tr:nth-child(odd) {
  background: #ffffff;
}

td.muted {
  color: var(--text-muted);
  text-align: center;
  font-style: italic;
}

.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
}

.status-dot.red { background: var(--danger); }
.status-dot.orange { background: var(--warning); }
.status-dot.green { background: var(--ok); }
.status-dot.grey { background: #7f8c8d; }

/* STATUT THÉORIQUE */

.theorique-status-ok {
  background: #e8f5e9;
  color: #2e7d32;
  font-weight: 600;
}

.theorique-status-warn {
  background: #fff8e1;
  color: #f9a825;
  font-weight: 600;
}

.theorique-status-bad {
  background: #ffebee;
  color: #c62828;
  font-weight: 600;
}

/* LOGIN */

#loginScreen {
  position: fixed;
  inset: 0;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

#loginBox {
  background: white;
  padding: 20px;
  border-radius: 8px;
  width: 320px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  border: 2px solid var(--admin-blue);
}

#loginBox h2 {
  margin-top: 0;
  text-align: center;
  color: var(--admin-blue);
}

#loginBox input {
  width: 100%;
  padding: 6px;
  margin-bottom: 10px;
}

#loginError {
  color: var(--danger);
  font-size: 12px;
  margin-top: 6px;
  display: none;
}

/* POPUP ALERTES */

#alertPopupOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

#alertPopup {
  background: white;
  padding: 20px;
  border-radius: 8px;
  width: 380px;
  border: 2px solid #1f4e79;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

#alertPopup h2 {
  margin-top: 0;
  text-align: center;
  color: #1f4e79;
}

.alert-section {
  margin-bottom: 15px;
}

.alert-list {
  padding-left: 0;
}

.alert-item {
  margin: 4px 0;
  padding: 4px 6px;
  background: #f5f5f5;
  border-radius: 3px;
  border: 1px solid #ddd;
}

/* POPUP AJOUT PRODUIT */

#addProductOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

#addProductBox {
  background: white;
  padding: 20px;
  border-radius: 8px;
  width: 350px;
  border: 2px solid #1f4e79;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

#addProductBox h2 {
  margin-top: 0;
  color: #1f4e79;
  text-align: center;
}

#addProductBox input {
  width: 100%;
  margin-bottom: 10px;
}

/* FORM / BOUTONS */

.form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 10px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group input,
.form-group select {
  padding: 4px 6px;
}

.primary {
  background: #1f4e79;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 6px 10px;
  cursor: pointer;
}

.secondary {
  background: #ccc;
  color: black;
  border: none;
  border-radius: 4px;
  padding: 6px 10px;
  cursor: pointer;
}

.primary.full,
.secondary.full {
  width: 100%;
}

.primary:hover {
  background: #163a5a;
}

.secondary:hover {
  background: #b3b3b3;
}

/* THEORIQUE BAR */

.theorique-admin-bar {
  margin-bottom: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.theorique-admin-bar input {
  width: 80px;
}

/* CHART */

.chart-container {
  text-align: center;
  padding: 10px;
}

/* MOBILE */

#mobileMenuBtn {
  display: none;
  margin-bottom: 10px;
  padding: 6px 10px;
  background: var(--admin-blue);
  color: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  border: none;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  #mobileMenuBtn {
    display: inline-block;
  }

  .pharmacy-list {
    display: none;
  }

  .left-column,
  .right-column {
    width: 100%;
  }
/* POPUP FICHE PRODUIT */
.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.popup-box {
  background: white;
  padding: 20px;
  border-radius: 8px;
  width: 420px;
  border: 2px solid #1f4e79;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  position: relative;
}

.popup-close {
  position: absolute;
  top: 8px;
  right: 12px;
  cursor: pointer;
  font-size: 20px;
}

.popup-photo {
  width: 100%;
  height: auto;
  border-radius: 6px;
  margin-bottom: 12px;
}

.photo-preview {
  width: 120px;
  height: 120px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid #ccc;
  margin-top: 6px;
}

}