/* Thème BCM — Base Commerciale Magasins */
:root {
  --bcm-blue: #00387b;
  --bcm-blue-dark: #002a5c;
  --bcm-blue-light: #0a4d9c;
  --bcm-green: #78be43;
  --bcm-green-hover: #6aad3a;
  --bcm-grey-bg: #f0f2f5;
  --bcm-grey-border: #d8dde6;
  --bcm-grey-tab: #e8eaed;
  --bcm-grey-text: #5f6368;
  --bcm-white: #ffffff;
  --bcm-text: #1a1a1a;
  --bcm-danger: #c62828;
  --bcm-warning: #e65100;
  --bcm-success: #2e7d32;
  --shadow-sm: 0 1px 3px rgba(0, 56, 123, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 56, 123, 0.12);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur: 0.25s;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: Arial, Helvetica, "Segoe UI", sans-serif;
  font-size: 13px;
  color: var(--bcm-text);
  background: var(--bcm-grey-bg);
  min-height: 100vh;
}

[hidden] { display: none !important; }

@keyframes bcm-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes bcm-slide-down {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes bcm-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes bcm-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.animate-in {
  animation: bcm-fade-in 0.45s var(--ease) both;
}

.animate-in-delay-1 { animation-delay: 0.06s; }
.animate-in-delay-2 { animation-delay: 0.12s; }
.animate-in-delay-3 { animation-delay: 0.18s; }

/* ——— Header BCM ——— */
.bcm-header {
  background: var(--bcm-blue);
  color: var(--bcm-white);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  position: sticky;
  top: 0;
  z-index: 100;
  animation: bcm-slide-down 0.4s var(--ease);
}

.bcm-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  min-height: 48px;
  gap: 16px;
}

.bcm-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  transition: opacity var(--dur) var(--ease);
}
.bcm-brand:hover { opacity: 0.92; }

.bcm-logo {
  width: 36px;
  height: 36px;
  background: var(--bcm-white);
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 11px;
  color: var(--bcm-blue);
  letter-spacing: -0.5px;
}

.bcm-brand-text h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}
.bcm-brand-text small {
  font-size: 11px;
  opacity: 0.85;
}

.bcm-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.bcm-nav a {
  color: var(--bcm-white);
  text-decoration: none;
  padding: 8px 14px;
  font-size: 12px;
  border-radius: 2px;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.bcm-nav a:hover { background: rgba(255,255,255,0.12); transform: translateY(-1px); }
.bcm-nav a.active { background: rgba(255,255,255,0.2); font-weight: 700; }

.bcm-user-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
}
.bcm-user-bar img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4);
}
.bcm-logout {
  color: var(--bcm-white);
  background: transparent;
  border: 1px solid rgba(255,255,255,0.35);
  padding: 6px 12px;
  border-radius: 2px;
  cursor: pointer;
  font-size: 12px;
  transition: all var(--dur) var(--ease);
}
.bcm-logout:hover {
  background: rgba(255,255,255,0.15);
  transform: scale(1.02);
}

.bcm-breadcrumb {
  background: var(--bcm-white);
  border-bottom: 1px solid var(--bcm-grey-border);
  padding: 8px 20px;
  font-size: 12px;
  color: var(--bcm-grey-text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.bcm-breadcrumb a { color: var(--bcm-blue); text-decoration: none; }
.bcm-breadcrumb a:hover { text-decoration: underline; }

/* ——— Bandeau test impersonation ——— */
.bcm-impersonate-banner {
  background: linear-gradient(90deg, #fff3e0, #ffe0b2);
  border-bottom: 2px solid var(--bcm-warning);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  animation: bcm-slide-down 0.35s var(--ease);
}
.bcm-impersonate-banner strong { color: #e65100; }

/* ——— Contenu ——— */
.bcm-main {
  padding: 16px 20px 32px;
  max-width: 100%;
}

.bcm-page-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 16px;
  color: var(--bcm-text);
}

/* ——— Onglets type BCM ——— */
.bcm-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 0;
  border-bottom: none;
}
.bcm-tab {
  background: var(--bcm-grey-tab);
  border: 1px solid var(--bcm-grey-border);
  border-bottom: none;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--bcm-grey-text);
  cursor: pointer;
  margin-right: 2px;
  transition: all var(--dur) var(--ease);
  position: relative;
  top: 1px;
}
.bcm-tab:hover {
  background: #dfe3e8;
  color: var(--bcm-text);
}
.bcm-tab.active {
  background: var(--bcm-blue);
  color: var(--bcm-white);
  border-color: var(--bcm-blue);
  z-index: 1;
}

/* ——— Panneau recherche BCM ——— */
.bcm-search-panel {
  background: var(--bcm-white);
  border: 1px solid var(--bcm-grey-border);
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  animation: bcm-fade-in 0.4s var(--ease) 0.1s both;
}

.bcm-search-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 12px;
}
.bcm-search-row input[type="search"],
.bcm-search-row input[type="text"] {
  flex: 1;
  border: 1px solid var(--bcm-grey-border);
  padding: 10px 14px;
  font-size: 14px;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.bcm-search-row input:focus {
  outline: none;
  border-color: var(--bcm-blue);
  box-shadow: 0 0 0 3px rgba(0, 56, 123, 0.15);
}

.btn-bcm-search {
  background: var(--bcm-green);
  color: var(--bcm-white);
  border: none;
  padding: 10px 28px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  white-space: nowrap;
}
.btn-bcm-search:hover {
  background: var(--bcm-green-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(120, 190, 67, 0.4);
}
.btn-bcm-search:active { transform: translateY(0); }

.bcm-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  font-size: 12px;
  color: var(--bcm-grey-text);
}
.bcm-filters label { display: flex; align-items: center; gap: 6px; }
.bcm-filters select {
  border: 1px solid var(--bcm-grey-border);
  padding: 6px 10px;
  min-width: 140px;
  background: var(--bcm-white);
  transition: border-color var(--dur);
}
.bcm-filters select:focus {
  outline: none;
  border-color: var(--bcm-blue);
}

/* ——— KPI ——— */
.bcm-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.bcm-kpi {
  background: var(--bcm-white);
  border: 1px solid var(--bcm-grey-border);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur);
  animation: bcm-fade-in 0.5s var(--ease) both;
}
.bcm-kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.bcm-kpi small {
  display: block;
  color: var(--bcm-grey-text);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.bcm-kpi strong {
  font-size: 24px;
  color: var(--bcm-blue);
  font-weight: 700;
}

/* ——— Tableau BCM ——— */
.bcm-table-wrap {
  background: var(--bcm-white);
  border: 1px solid var(--bcm-grey-border);
  overflow: auto;
  box-shadow: var(--shadow-sm);
  animation: bcm-fade-in 0.5s var(--ease) 0.15s both;
}

.bcm-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1800px;
  font-size: 12px;
}
.bcm-table thead th {
  background: var(--bcm-white);
  color: var(--bcm-grey-text);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 10px 12px;
  border-bottom: 2px solid var(--bcm-grey-border);
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 2;
}
.bcm-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid #eee;
  vertical-align: top;
  transition: background var(--dur);
}
.bcm-table tbody tr {
  animation: bcm-fade-in 0.35s var(--ease) both;
}
.bcm-table tbody tr:hover td {
  background: #f5f8fc;
}
.bcm-table tbody tr:nth-child(even) td {
  background: #fafbfc;
}
.bcm-table tbody tr:nth-child(even):hover td {
  background: #eef3f9;
}

.bcm-cell-muted { color: var(--bcm-grey-text); font-size: 11px; }
.bcm-cell-strong { font-weight: 700; }
.bcm-cell-magasin {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.25;
  max-width: 100%;
}
.bcm-cell-magasin .bcm-cell-strong {
  display: block;
  word-break: break-word;
}
.bcm-cell-magasin .bcm-cell-muted {
  display: block;
  word-break: break-all;
}
.bcm-store-link {
  display: block;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-weight: 700;
  color: var(--bcm-blue);
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-word;
}
.bcm-store-link:hover { color: #002a5c; }

/* ——— Fiche magasin (panneau latéral) ——— */
.bcm-store-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 900;
}
.bcm-store-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(480px, 100vw);
  height: 100vh;
  background: #fff;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
  z-index: 901;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.bcm-store-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 12px;
  border-bottom: 3px solid var(--bcm-blue);
  background: linear-gradient(180deg, #f4f7fb 0%, #fff 100%);
}
.bcm-store-panel-eyebrow {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--bcm-grey-text);
}
.bcm-store-panel-head h2 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.2;
  color: var(--bcm-blue);
}
.bcm-store-panel-sub {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--bcm-grey-text);
}
.bcm-store-panel-close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 4px;
  background: #e8edf4;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--bcm-blue);
}
.bcm-store-panel-close:hover { background: #d0dae8; }
.bcm-store-panel-status {
  min-height: 20px;
  padding: 0 20px;
  font-size: 12px;
  font-weight: 600;
}
.bcm-store-panel-status.ok { color: #2e7d32; }
.bcm-store-panel-status.err { color: #c62828; }
.bcm-store-panel-status.saving { color: var(--bcm-grey-text); }
.bcm-store-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 20px 24px;
}
.bcm-detail-section { margin-bottom: 20px; }
.bcm-detail-section-title {
  margin: 0 0 10px;
  padding-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--bcm-blue);
  border-bottom: 1px solid #e0e6ef;
}
.bcm-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
  margin: 0;
}
.bcm-detail-item { margin: 0; }
.bcm-detail-item dt {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 600;
  color: var(--bcm-grey-text);
}
.bcm-detail-item dd { margin: 0; font-size: 13px; }
.bcm-detail-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--bcm-grey-border);
  border-radius: 2px;
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
}
.bcm-detail-input:focus {
  outline: none;
  border-color: var(--bcm-blue);
  box-shadow: 0 0 0 2px rgba(0, 56, 123, 0.15);
}
.bcm-detail-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.bcm-detail-kpi {
  padding: 10px 12px;
  background: #f4f7fb;
  border-radius: 4px;
  border-left: 3px solid var(--bcm-blue);
}
.bcm-detail-kpi small {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--bcm-grey-text);
  margin-bottom: 4px;
}
.bcm-detail-kpi strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: #1a1a1a;
}
body.bcm-store-panel-open { overflow: hidden; }

/* ——— Badges ——— */
.bcm-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 700;
}
.bcm-badge-prioritaire { background: #ffebee; color: #b71c1c; }
.bcm-badge-surveiller { background: #fff3e0; color: #e65100; }
.bcm-badge-conforme { background: #e8f5e9; color: #2e7d32; }
.bcm-badge-rouge { background: #ffebee; color: #c62828; }
.bcm-badge-orange { background: #fff3e0; color: #ef6c00; }
.bcm-badge-vert { background: #e8f5e9; color: #2e7d32; }

.bcm-classif-edit { display: inline-block; position: relative; }
.bcm-classif-trigger {
  cursor: pointer;
  border: none;
  font: inherit;
  line-height: inherit;
}
.bcm-classif-trigger:hover { filter: brightness(0.97); }
.bcm-classif-select {
  min-width: 7rem;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 4px;
  border: 1px solid var(--bcm-grey-border);
  border-radius: 2px;
}

/* ——— Champs éditables ——— */
.bcm-input, .bcm-textarea, .bcm-select {
  width: 100%;
  min-width: 120px;
  border: 1px solid var(--bcm-grey-border);
  padding: 6px 8px;
  font: inherit;
  font-size: 12px;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.bcm-input:focus, .bcm-textarea:focus, .bcm-select:focus {
  outline: none;
  border-color: var(--bcm-blue);
  box-shadow: 0 0 0 2px rgba(0, 56, 123, 0.12);
}
.bcm-textarea { min-height: 64px; resize: vertical; }

.bcm-input.saved {
  border-color: var(--bcm-green);
  animation: bcm-pulse 0.6s ease;
}

/* ——— Boutons ——— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 2px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--dur) var(--ease);
}
.btn-primary {
  background: var(--bcm-blue);
  color: var(--bcm-white);
}
.btn-primary:hover {
  background: var(--bcm-blue-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-secondary {
  background: var(--bcm-grey-tab);
  color: var(--bcm-text);
  border: 1px solid var(--bcm-grey-border);
}
.btn-secondary:hover {
  background: #dfe3e8;
}
.btn-green {
  background: var(--bcm-green);
  color: var(--bcm-white);
}
.btn-green:hover { background: var(--bcm-green-hover); }

/* ——— Panels admin ——— */
.bcm-panel {
  background: var(--bcm-white);
  border: 1px solid var(--bcm-grey-border);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  animation: bcm-fade-in 0.45s var(--ease) both;
}
.bcm-panel h2 {
  margin: 0 0 16px;
  font-size: 16px;
  color: var(--bcm-blue);
  border-bottom: 2px solid var(--bcm-green);
  padding-bottom: 8px;
}

.bcm-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
.bcm-form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--bcm-grey-text);
}

.bcm-status {
  font-size: 12px;
  color: var(--bcm-grey-text);
}
.bcm-status.ok { color: var(--bcm-success); }
.bcm-status.err { color: var(--bcm-danger); }

.bcm-loading tbody tr td {
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: bcm-shimmer 1.2s infinite;
  height: 36px;
}

/* ——— Bloc KPI Excel ——— */
.bcm-objectives-wrap {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-bottom: 0;
  border: 1px solid var(--bcm-grey-border);
  border-bottom: none;
  background: var(--bcm-white);
  overflow-x: auto;
}
.bcm-objectives-month {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  background: #f5f5f5;
  padding: 8px 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--bcm-grey-text);
  border-right: 1px solid var(--bcm-grey-border);
  white-space: nowrap;
}
.bcm-objectives-table {
  border-collapse: collapse;
  font-size: 11px;
  min-width: 640px;
}
.bcm-objectives-table th,
.bcm-objectives-table td {
  border: 1px solid #ddd;
  padding: 4px 10px;
  text-align: center;
}
.bcm-objectives-table .obj-label {
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  padding-left: 12px;
}

.col-kpi-ca { color: #2e7d32; font-weight: 700; }
.col-kpi-green { color: #2e7d32; }
th.col-kpi-ca, th.col-kpi-green { color: #2e7d32; font-weight: 700; }

th.th-top200 { border-top: 3px solid #1565c0; }
th.th-top300 { border-top: 3px solid #f9a825; }
th.th-topbio { border-top: 3px solid #2e7d32; }
th.th-kpi { border-top: 3px solid var(--bcm-green); }
td.col-top200, td.col-top300, td.col-topbio { background: #fff !important; color: inherit !important; }

.kpi-value { font-variant-numeric: tabular-nums; }
.kpi-ok { color: #2e7d32; font-weight: 700; }
.kpi-ko { color: #c62828; font-weight: 700; }
.kpi-positive { color: #2e7d32; font-weight: 600; }
.kpi-negative { color: #c62828; font-weight: 600; }

.bcm-table td.col-top200:not(:has(.kpi-ok)):not(:has(.kpi-ko)),
.bcm-table td.col-top300:not(:has(.kpi-ok)):not(:has(.kpi-ko)),
.bcm-table td.col-topbio:not(:has(.kpi-ok)):not(:has(.kpi-ko)) {
  color: inherit;
}

.bcm-kpi-block {
  border-top: 3px solid var(--bcm-green);
}

.bcm-table thead tr.kpi-header-row th {
  font-size: 11px;
  padding: 8px 10px;
}

.bcm-table-wrap.sticky-head {
  max-height: calc(100vh - 320px);
}

/* ——— Page login ——— */
.bcm-login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--bcm-blue-dark) 0%, var(--bcm-blue) 50%, var(--bcm-blue-light) 100%);
  padding: 24px;
}
.bcm-login-card {
  width: min(440px, 100%);
  background: var(--bcm-white);
  padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  animation: bcm-fade-in 0.6s var(--ease);
}
.bcm-login-card .bcm-logo {
  margin: 0 auto 16px;
  width: 48px;
  height: 48px;
  font-size: 14px;
}
.bcm-login-card h1 {
  text-align: center;
  color: var(--bcm-blue);
  font-size: 20px;
  margin: 0 0 8px;
}
.bcm-login-card .lead {
  text-align: center;
  color: var(--bcm-grey-text);
  margin-bottom: 24px;
  line-height: 1.5;
}
.bcm-login-card .btn-google {
  width: 100%;
  padding: 14px;
  background: var(--bcm-blue);
  color: white;
  font-size: 14px;
  border: none;
  cursor: pointer;
  font-weight: 700;
  transition: all var(--dur) var(--ease);
}
.bcm-login-card .btn-google:hover {
  background: var(--bcm-blue-light);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 56, 123, 0.35);
}
.bcm-error { color: var(--bcm-danger); margin-top: 14px; text-align: center; font-size: 12px; }

@media (max-width: 768px) {
  .bcm-header-top { flex-wrap: wrap; padding: 10px; }
  .bcm-nav { display: none; }
  .bcm-search-row { flex-direction: column; }
}
