/* Users admin page */

/* Full width like detail_compte.php — pages users et changelog. La page
   des news (qui charge aussi ce fichier) garde la largeur de 900 px
   d'index.php, pour laisser voir son fond animé sur les côtés. */
body:not(.page-news) .main-content .dashboard-container {
    max-width: none !important;
}

/* Scroll horizontal de la table dans son propre conteneur,
   sans faire déborder la page (ce qui cacherait les colonnes de gauche
   derrière la sidebar fixe sur mobile). */
.u-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    align-self: stretch;
}

/* Supprimer les effets de survol/clic sur les blocs (account-box, account-block) */
.account-box:hover,
.account-box:active,
.account-link:hover,
.account-link:active {
    background: var(--color-surface) !important;
    border-color: var(--color-border) !important;
    transform: none !important;
    box-shadow: none !important;
    text-decoration: none;
}

/* Prevent cell content from wrapping */
.users-table td,
.users-table th {
    white-space: nowrap;
}

/* Email column can shrink gracefully if very long */
.users-table td.u-col-email {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mini-lignes secondaires (email sous pseudo, activité sous inscription) —
   affichées uniquement en mode responsive quand les colonnes correspondantes
   sont masquées. Évite la duplication visuelle en desktop. */
.u-inline {
    display: none;
    margin-top: 2px;
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--color-text-secondary);
}

@media (max-width: 1100px) {
    .users-table th.u-col-email,
    .users-table td.u-col-email,
    .users-table th.u-col-activity,
    .users-table td.u-col-activity {
        display: none;
    }
    .u-inline { display: block; }
    /* La cellule Pseudo/Inscription contient désormais deux lignes : autoriser wrap */
    .users-table td:first-child,
    .users-table td:nth-child(3) {
        white-space: normal;
    }
}

/* ==================== ACCORDION ROWS ==================== */

.u-user-row {
    cursor: pointer;
    transition: background 0.15s;
}

.u-user-row:hover {
    background: var(--color-surface-hover, rgba(0,0,0,0.04));
}

.u-user-row.u-row-expanded {
    background: var(--color-surface-hover, rgba(0,0,0,0.04));
}

.u-user-row td:first-child {
    text-align: left;
}

.u-user-row td:first-child::before {
    content: '▶';
    display: inline-block;
    margin-right: 6px;
    font-size: 0.6rem;
    opacity: 0.4;
    transition: transform 0.2s;
    vertical-align: middle;
}

.u-user-row.u-row-expanded td:first-child::before {
    transform: rotate(90deg);
    opacity: 0.7;
}

/* Detail row — pas de bordure colorée */
.u-detail-row td {
    padding: 0 !important;
    border-bottom: 1px solid var(--color-border) !important;
}

/* Animation fluide via grid-template-rows (supporte hauteur inconnue) */
.u-detail-wrapper {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.28s ease;
}

.u-detail-wrapper.open {
    grid-template-rows: 1fr;
}

.u-detail-inner {
    overflow: hidden;
}

.u-accounts-container {
    padding: 0;
    background: transparent;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Largeur minimale pour que toutes les colonnes restent accessibles */
.u-accounts-table {
    min-width: 600px;
}

/* Première colonne : largeur fixe pour éviter le retour à la ligne sur le label */
.u-accounts-table .u-col-account {
    min-width: 140px;
    max-width: 180px;
}

/* Serveur en ligne secondaire sous le portefeuille */
.u-accounts-table .u-col-server-inline {
    color: var(--color-text-secondary);
    font-size: 0.72rem;
    display: block;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0 auto;
}

/* Solde : jamais coupé en plein milieu d'un nombre */
.u-accounts-table .u-col-balance {
    white-space: nowrap;
}

.u-accounts-loading,
.u-accounts-empty {
    padding: 10px 12px;
    color: var(--color-text-secondary);
    font-style: italic;
    font-size: 0.85rem;
}

/* Accounts sub-table — même style que open-table / closed-table */
.u-accounts-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    font-size: 0.82rem;
    border: none;
}

.u-accounts-table thead th {
    background: var(--color-bg-secondary);
    color: var(--color-text);
    padding: 5px 8px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.u-accounts-table tbody td {
    padding: 5px 8px;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
    white-space: nowrap;
    word-break: normal;  /* neutralise l'héritage de .metrics-table td { word-break: break-all } */
}

.u-accounts-table tbody tr:nth-child(even) {
    background: var(--color-bg);
}

.u-accounts-table tbody tr:last-child td {
    border-bottom: none;
}

.u-accounts-table tbody tr:hover {
    background: var(--color-bg-hover);
}

/* ==================== SORT INDICATORS ==================== */

.u-sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.u-sortable::after {
    content: ' ⇅';
    opacity: 0.3;
    font-size: 0.75em;
}

.u-sort-asc::after {
    content: ' ▲';
    opacity: 0.7;
    color: var(--color-primary);
}

.u-sort-desc::after {
    content: ' ▼';
    opacity: 0.7;
    color: var(--color-primary);
}

/* Activity badges */
.u-badge--yellow {
    background: rgba(234,179,8,0.12);
    color: #a16207;
}

.u-badge--red {
    background: rgba(239,68,68,0.12);
    color: #b91c1c;
}

/* ==================== PLEINE LARGEUR + ÉCART ENTRE BLOCS ====================
   Applique aux pages changelog et users la même mise en page que
   metrics.php : conteneurs qui remplissent la largeur (au lieu du max
   --container-max-width = 900 px hérité d'index.css) + petit gap entre
   les .account-header-row d'un même .account-block (news compris).
   La page des news garde, elle, la largeur de 900 px d'index.php : les
   côtés libérés laissent voir son fond animé.
   Duplique la logique de metrics.css volontairement — ces trois pages ne
   chargent pas metrics.css. */
body.page-changelog .main-content .dashboard-container,
body.page-changelog .main-content > *,
body.page-users .main-content .dashboard-container,
body.page-users .main-content > * {
  max-width: none;
}

body.page-news #main-content .account-block,
body.page-changelog #main-content .account-block,
body.page-users #main-content .account-block {
  display: flex;
  flex-direction: column;
  gap: var(--section-gap, 8px);
}

body.page-news #main-content .account-header-row,
body.page-changelog #main-content .account-header-row,
body.page-users #main-content .account-header-row {
  margin-bottom: 0;
}

/* ==================== NEWS ====================
   Une carte par annonce, dépliable en accordéon (voir news.php +
   dashboard.js pour la logique .toggle-block / .accordion-group). Le
   fond, la bordure et le padding viennent maintenant du .account-box
   interne, on ne les duplique plus sur .news-card. */
.news-card {
  width: 100%;
  box-sizing: border-box;
  text-align: left;
}
/* Le bloc .news-card hérite du cadre des .account-block (fond, bordure,
   padding) : combiné à celui du .account-box interne, il dessinait une
   bordure en double autour de chaque news. On ne garde que le cadre
   interne ; seul l'espacement entre deux news est conservé. */
#block-news .news-card.account-block {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  margin: 0;
  /* Ni rognage ni arrondi : hérités des .account-block, ils coupaient les
     coins de la case interne (et son soulèvement au survol). */
  overflow: visible;
  border-radius: 0;
}
/* Écart entre deux news : un seul espacement de 6 px, au lieu du gap de
   8 px des .account-block de la page (règle « PLEINE LARGEUR » plus haut)
   cumulé à la marge basse de 8 px de chaque bloc. */
body.page-news #main-content #block-news {
  gap: 6px;
}

/* Le header (label) porte le titre + la date. On ne coupe pas la
   marge basse quand replié (accordion collapse), sinon on garde un
   petit espace sous le titre visible. */
.news-card .account-label {
  padding: 0;
  margin: 0;
  font-weight: normal;
  line-height: 1.35;
  /* .account-label impose nowrap + overflow:hidden : le titre était coupé
     au lieu de passer à la ligne, et la bordure du bouton Partager rognée. */
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}
.news-card-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.news-card-date {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.news-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
  line-height: 1.35;
}

.news-card-body {
  color: var(--color-text);
  font-size: 0.9rem;
  line-height: 1.55;
}
.news-card-body p { margin: 0 0 10px; }
.news-card-body p:last-child { margin-bottom: 0; }
.news-card-body ul,
.news-card-body ol { margin: 0 0 10px; padding-left: 20px; }
.news-card-body li { margin-bottom: 4px; }
.news-card-body em { font-style: italic; }
.news-card-body strong { font-weight: 700; }

/* Groupe d'images (captures) — deux ou plus, côte à côte sur desktop,
   empilées sur mobile. Border + fond thème pour se démarquer du corps.
   margin-bottom > 0 pour ne pas coller au texte qui suit (h3, p…). */
.news-figures {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin: 12px 0 20px;
  padding: 0;
}
.news-figures img,
.news-figures .news-video {
  max-width: 600px;
  width: 100%;
  height: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-lg, 8px);
  background: var(--color-bg-secondary);
  padding: 4px;
  display: block;
}
/* Bouton « Partager » d'une news, à droite du titre ; « Lien copié »
   s'affiche en vert après la copie. Libellé masqué sur petit écran. */
.news-share {
  margin-left: auto;
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: transparent;
  color: var(--color-text-secondary);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.news-share:hover,
.news-share.copied {
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.news-share.copied { background: var(--color-primary-light, transparent); }
@media (max-width: 480px) {
  .news-share-lbl { display: none; }
  .news-share { padding: 4px 7px; }
}
/* Mobile : date et bouton Partager sur la première ligne, titre en dessous
   sur toute la largeur, plus petit et libre de passer sur deux lignes. */
@media (max-width: 600px) {
  .news-card-head { row-gap: 4px; }
  .news-card-date { order: 1; }
  .news-share { order: 2; }
  .news-card-title { order: 3; flex-basis: 100%; font-size: 0.92rem; }
}
/* News ouverte depuis un lien de partage : défile sous la topbar fixe et
   se distingue d'un liseré vert. */
.news-card { scroll-margin-top: 64px; }
.news-card--target > .account-header-row > .account-box {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 25%, transparent);
}

/* Captures et vidéos agrandissables (classe posée par news.php) : loupe au
   survol, léger soulèvement — même effet que les captures de landing.php. */
.news-figures .news-zoomable {
  cursor: zoom-in;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.news-figures .news-zoomable:hover {
  transform: translateY(-3px) scale(1.01);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  border-color: var(--color-primary);
}

/* Lightbox des news (copie de celle de landing.css, ids propres). */
#news-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.84);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  padding: 24px;
}
#news-lightbox.active { display: flex; }
#news-lightbox [hidden] { display: none; }
#news-lightbox__img,
#news-lightbox__video {
  max-width: min(94vw, 1600px);
  max-height: 90vh;
  width: auto;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.6);
  cursor: default;
  object-fit: contain;
  animation: news-lightbox-in 0.18s ease;
}
@keyframes news-lightbox-in {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}
#news-lightbox__close {
  position: fixed;
  top: 16px;
  right: 20px;
  width: 38px;
  height: 38px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  color: #fff;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  z-index: 9001;
}
#news-lightbox__close:hover { background: rgba(255, 255, 255, 0.22); }

/* Logo d'un outil en tête de news : centré, sans le cadre des captures.
   Classe news-logo aussi sur l'<img> : les balises Open Graph du lien de
   partage (php/news_share.php) lui préfèrent la première capture. */
.news-logo {
  margin: 4px 0 18px;
  padding: 0;
  text-align: center;
}
.news-logo img {
  display: inline-block;
  max-width: 300px;
  width: 100%;
  height: auto;
}
/* Logo carré (EA Stats Export) : plus petit qu'un logo en longueur. */
.news-logo--square img {
  max-width: 200px;
  border-radius: 12px;
}
/* Vidéo de démo — autoplay muted loop, sert de remplacement au GIF.
   preload=metadata suffit pour afficher le poster instantanément sans
   télécharger le flux tant que la page n'est pas visitée. */
.news-figures .news-video { max-width: 720px; width: 100%; }
@media (max-width: 768px) {
  .news-figures { flex-direction: column; }
  .news-figures img { max-width: 100%; }
}

.news-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--color-text-secondary);
  font-style: italic;
}

/* ==================== CHANGELOG ==================== */

.changelog-month {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-lg, 8px);
  background: var(--color-surface);
  margin-bottom: var(--box-gap, 6px);
  text-align: left;
}
.changelog-month:last-child { margin-bottom: 0; }

/* Le conteneur parent doit prendre toute la largeur */
.account-box.span-6 > .changelog-month { display: block; }

.changelog-month-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 8px;
}

.changelog-month-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
}

.changelog-count {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--color-text-secondary);
}

.changelog-entries {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.changelog-day-group {
  padding: 4px 16px 10px 28px;
}

.changelog-day-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  margin-left: -12px;
}

.changelog-entry {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 0.85rem;
  line-height: 1.5;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.changelog-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.changelog-text {
  color: var(--color-text);
  flex: 1;
  min-width: 0;
}

/* ==================== PLAN BADGE ==================== */
.u-plan-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: var(--font-size-xs);
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.u-plan-badge--retail {
  background: #22c55e;
  color: #fff;
}
.u-plan-badge--pro {
  background: #3b82f6;
  color: #fff;
}
.u-plan-badge--fund {
  background: #f59e0b;
  color: #fff;
}

/* ==================== ADMIN PANEL ==================== */
.u-admin-panel {
  background: var(--color-surface-alt, rgba(0,0,0,0.03));
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 8px 12px;
  margin-bottom: 14px;
}

.u-admin-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
}

.u-admin-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 80px;
  flex-shrink: 0;
}
.u-admin-field--action {
  width: auto;
}

.u-admin-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  font-weight: 500;
  white-space: nowrap;
}
.u-admin-label small {
  font-weight: 400;
  opacity: 0.7;
}

.u-admin-panel select,
.u-admin-panel input[type="text"],
.u-admin-panel input[type="date"],
.u-admin-panel input[type="number"] {
  padding: 4px 6px;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--font-size-xs);
  width: 100%;
  box-sizing: border-box;
}
.u-admin-panel select:focus,
.u-admin-panel input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.u-admin-save {
  padding: 4px 12px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  border: none;
  border-radius: var(--border-radius-sm);
  background: var(--color-primary);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity var(--transition-fast);
}
.u-admin-save:hover { opacity: 0.85; }
.u-admin-save:disabled { opacity: 0.5; cursor: not-allowed; }

.u-admin-status {
  font-size: var(--font-size-xs);
  font-weight: 500;
  align-self: flex-end;
  padding-bottom: 5px;
}

/* ================================================================
   Badges D-W-M par portefeuille et cloche d'alerte par compte
   Ajoutés à la sous-table des comptes de la page admin Utilisateurs.
================================================================ */
.u-pf-freq-group {
  display: inline-flex;
  gap: 3px;
  margin-left: 6px;
  vertical-align: middle;
}
.u-pf-freq-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 5px;
  min-width: 14px;
  text-align: center;
  line-height: 1.5;
}

.u-alert-bell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
}
.u-alert-bell--on  { color: var(--color-success, #22c55e); }
.u-alert-bell--off { color: var(--color-text-secondary); opacity: 0.5; }
