/**
 * Administration - Whisp It
 * En-tete, bandeau de chiffres, demandes d acces, recherche et tableau des comptes.
 * Style plat, memes couleurs et arrondis que le reste de l application (variables.css).
 */

/* ---------- En-tete et onglets ---------- */
.adm-head {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.admin-segmented-switcher {
  display: flex;
  grid-template-columns: none;
  gap: 2px;
  padding: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.admin-segmented-switcher::-webkit-scrollbar {
  display: none;
}

.admin-segmented-switcher .admin-switcher-btn {
  flex: 1 0 auto;
  white-space: nowrap;
}

/* ---------- Bandeau de chiffres ---------- */
.adm-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 18px;
  overflow: hidden;
}

.adm-stats div {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border-subtle);
  min-width: 0;
}

.adm-stats div:nth-child(odd) {
  border-right: 1px solid var(--border-subtle);
}

.adm-stats div:last-child {
  grid-column: 1 / -1;
  border: 0;
}

.adm-stats b {
  display: block;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text-primary);
}

.adm-stats span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ---------- Demandes d acces en attente ---------- */
.adm-pending-list {
  display: grid;
  gap: 10px;
}

.adm-pending-list:empty {
  display: none;
}

.adm-pending {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #0f172a;
  color: #ffffff;
  border-radius: 18px;
}

.adm-pending-body {
  flex: 1;
  min-width: 180px;
}

.adm-pending-body strong {
  display: block;
  font-size: 14.5px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.adm-pending-body small {
  display: block;
  font-size: 12.5px;
  color: #94a3b8;
  overflow-wrap: anywhere;
}

.adm-pending-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* ---------- Boutons ---------- */
.adm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.adm-btn svg {
  flex-shrink: 0;
}

.adm-btn-dark {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
}

.adm-btn-dark:hover {
  background: var(--btn-primary-hover);
}

.adm-btn-light {
  background: #ffffff;
  color: #0f172a;
}

.adm-btn-light:hover {
  background: #e2e8f0;
}

.adm-btn-ghost {
  background: transparent;
  border-color: #334155;
  color: #e2e8f0;
}

.adm-btn-ghost:hover {
  border-color: #64748b;
}

.adm-btn:focus-visible,
.adm-icon-btn:focus-visible,
.adm-switch:focus-visible,
.admin-filter-chip:focus-visible {
  outline: 2px solid #0f172a;
  outline-offset: 2px;
}

.adm-pending .adm-btn:focus-visible {
  outline-color: #ffffff;
}

/* ---------- Recherche, ajout, filtres ---------- */
.adm-tools {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.adm-tools-row {
  display: flex;
  gap: 10px;
}

.adm-search {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 40px;
  padding: 0 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  transition: border-color var(--transition-fast);
}

.adm-search:focus-within {
  border-color: #0f172a;
}

.adm-search svg {
  flex-shrink: 0;
}

.adm-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 16px; /* 16px minimum : pas de zoom automatique sur iPhone */
  color: var(--text-primary);
}

.adm-search input::placeholder {
  color: var(--text-muted);
}

.adm-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.adm-chips::-webkit-scrollbar {
  display: none;
}

.admin-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 13px;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  color: var(--text-secondary);
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.admin-filter-chip span {
  font-weight: 800;
  opacity: 0.6;
}

.admin-filter-chip:hover {
  color: var(--text-primary);
}

.admin-filter-chip.active {
  background: #0f172a;
  border-color: #0f172a;
  color: #ffffff;
}

/* ---------- Tableau des comptes ---------- */
.adm-table {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 18px;
  overflow: hidden;
}

.adm-tr {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px 14px;
  padding: 15px 16px;
  align-items: center;
}

.adm-tr + .adm-tr {
  border-top: 1px solid var(--border-subtle);
}

.adm-th {
  display: none;
}

.adm-who {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  grid-column: 1 / -1;
}

.adm-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--bg-app);
  border: 1px solid var(--border-card);
  display: grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--text-primary);
  flex-shrink: 0;
}

.adm-pending .adm-avatar {
  background: #1e293b;
  border-color: #334155;
  color: #ffffff;
}

.adm-who-text {
  min-width: 0;
}

.adm-who strong {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.adm-who small {
  display: block;
  font-size: 12.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.adm-tag {
  display: inline-flex;
  align-items: center;
  height: 19px;
  padding: 0 7px;
  border: 1px solid var(--border-card);
  border-radius: 6px;
  background: var(--bg-app);
  font-size: 10.5px;
  font-weight: 800;
  font-style: normal;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.adm-tag-dark {
  background: #0f172a;
  border-color: #0f172a;
  color: #ffffff;
}

.adm-use b {
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.adm-use small {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
}

.adm-muted {
  font-size: 13px;
  color: var(--text-secondary);
}

.adm-tr [data-label]::before {
  content: attr(data-label);
  display: block;
  margin-bottom: 3px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.adm-acts {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  align-self: end;
}

.adm-icon-btn {
  width: 44px;
  height: 44px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.adm-icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.adm-icon-btn.is-danger:hover {
  color: #ef4444;
}

/* Interrupteur d acces */
.adm-switch {
  position: relative;
  display: block;
  width: 44px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--border-input);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.adm-switch i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform var(--transition-fast);
}

.adm-switch.is-on {
  background: #16a34a;
}

.adm-switch.is-on i {
  transform: translateX(18px);
}

.adm-empty {
  margin: 0;
  padding: 34px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ---------- Tablette et plus ---------- */
@media (min-width: 640px) {
  .adm-stats {
    grid-template-columns: repeat(5, 1fr);
  }

  .adm-stats div,
  .adm-stats div:nth-child(odd) {
    border-bottom: 0;
    border-right: 1px solid var(--border-subtle);
  }

  .adm-stats div:last-child {
    grid-column: auto;
    border-right: 0;
  }
}

@media (min-width: 900px) {
  .adm-tr {
    grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.1fr) 124px minmax(0, 1fr) 70px 92px;
    gap: 16px;
    padding: 13px 18px;
  }

  .adm-th {
    display: grid;
    padding-top: 11px;
    padding-bottom: 11px;
    background: var(--bg-input);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
  }

  .adm-who {
    grid-column: auto;
  }

  .adm-tr [data-label]::before {
    display: none;
  }

  .adm-acts {
    align-self: center;
  }

  .adm-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }
}

/* ---------- Ordinateur : la page occupe tout l espace de travail ---------- */
@media (min-width: 1024px) {
  .admin-view.active {
    left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 28px max(0px, calc((100% - 1120px) / 2)) 40px !important;
    border-left: 0 !important;
    background: var(--bg-app) !important;
    flex-direction: column !important;
    gap: 18px !important;
  }

  .adm-head {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
  }

  .admin-header-card {
    padding: 0;
  }

  .admin-header-card .btn-back-to-home {
    display: none;
  }

  .admin-view-title {
    font-size: 26px;
  }

  .admin-segmented-switcher {
    flex-shrink: 0;
  }

  .admin-segmented-switcher .admin-switcher-btn {
    padding-left: 16px;
    padding-right: 16px;
  }

  .adm-tools {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .adm-tools-row {
    grid-column: 2;
    grid-row: 1;
    width: 440px;
  }

  .adm-chips {
    grid-column: 1;
    grid-row: 1;
  }
}

/* ---------- Telephone ---------- */
.adm-tools {
  grid-template-columns: minmax(0, 1fr);
}

.adm-stats b,
.adm-use b {
  letter-spacing: -0.02em;
  word-spacing: 0.08em;
}

@media (max-width: 479px) {
  .admin-segmented-switcher .admin-switcher-btn {
    padding-left: 8px;
    padding-right: 8px;
    gap: 5px;
    font-size: 12px;
  }

  .admin-segmented-switcher .admin-switcher-btn > svg {
    display: none;
  }

  .adm-pending-actions {
    width: 100%;
  }

  .adm-pending-actions .adm-btn {
    flex: 1;
  }
}

@media (min-width: 1024px) {
  .adm-tools {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}

/* Sur telephone et tablette, les cellules d une ligne s alignent en haut */
@media (max-width: 899px) {
  .adm-tr {
    align-items: start;
  }

  /* Le nom et les boutons partagent la premiere ligne : les cases du dessous vont par deux */
  .adm-who {
    grid-column: 1;
    grid-row: 1;
  }

  .adm-acts {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
  }

  /* L etiquette (En attente, Bloque) passe sous le nom plutot que d etre coupee */
  .adm-who strong {
    flex-wrap: wrap;
    gap: 4px 8px;
  }
}

/* Formule du compte : liste deroulante dans la ligne */
.adm-plan-wrapper {
  display: inline-block;
  width: 124px;
  max-width: 100%;
  vertical-align: top;
}

.adm-plan-wrapper .adm-plan-select {
  height: 36px;
  padding: 0 30px 0 12px;
  border-radius: 10px;
  font-size: 13px;
}

.adm-plan-wrapper .admin-select-arrow {
  right: 10px;
}
