/* =========================================================
   🎮 KissBooK Games — Styles hub fusionné (v3.20 Dark Neon+)
   ========================================================= */

/* === Variables globales === */
:root {
  --kbg-bg: #000;
  --kbg-card: #0f172a;
  --kbg-border: #233047;
  --kbg-text: #e5e7eb;
  --kbg-muted: #94a3b8;
  --kbg-accent: #38bdf8;
  --kbg-green: #10b981;
  --kbg-red: #ef4444;
  --kbg-warning: #f59e0b;
  /* Pour le badge dev */
}

/* === Container & Topbar === */
#kbg-container {
  background: var(--kbg-bg);
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--kbg-border);
  box-shadow: 0 0 35px rgba(56, 189, 248, 0.25);
  color: var(--kbg-text);
  overflow: hidden;
}

#kbg-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  animation: fadeDown .6s ease-in-out;
}

@keyframes fadeDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

#kbg-game-title {
  font-weight: 700;
  font-size: 18px;
  color: var(--kbg-accent);
  letter-spacing: .5px;
}

#kbg-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

#kbg-controls button {
  border: 1px solid var(--kbg-border);
  background: #0b1320;
  border-radius: 10px;
  padding: 6px 10px;
  color: var(--kbg-accent);
  cursor: pointer;
  transition: all .25s ease;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.15);
}

#kbg-controls button:hover {
  background: var(--kbg-accent);
  color: #041015;
  transform: scale(1.15);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.4);
}

/* === Info bar === */
#kbg-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0;
  padding: 8px 12px;
  border: 1px solid var(--kbg-border);
  border-radius: 12px;
  background: #0b1220;
  color: var(--kbg-text);
  box-shadow: inset 0 0 10px rgba(56, 189, 248, 0.15);
}

#kbg-info .label {
  color: var(--kbg-muted);
  margin-right: 6px;
}

#kbg-info .sep {
  margin: 0 8px;
  color: var(--kbg-muted);
}

/* === Status message === */
#kbg-status {
  display: none;
  margin: 8px 0;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--kbg-border);
  background: #0b1220;
  color: var(--kbg-text);
  transition: all .3s ease;
}

#kbg-status.ok {
  border-color: var(--kbg-green);
  color: var(--kbg-green);
}

#kbg-status.err {
  border-color: var(--kbg-red);
  color: var(--kbg-red);
}

#kbg-status .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--kbg-green);
  margin-right: 8px;
}

#kbg-status.err .dot {
  background: var(--kbg-red);
}

/* === Stage / iframe === */
#kbg-stage {
  position: relative;
  border: 1px solid var(--kbg-border);
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 40px rgba(56, 189, 248, 0.2);
  animation: fadeInStage .8s ease-in-out;
}

@keyframes fadeInStage {
  from {
    opacity: 0;
    transform: scale(.98);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

#kbg-iframe {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  min-height: 900px;
  /* ✅ plus haute pour éviter le contenu tronqué */
  border: 0;
  background: #000;
  transition: height .4s ease;
}

#kbg-iframe.is-background {
  opacity: 1 !important;
  pointer-events: auto !important;
  filter: none !important;
}

#kbg-placeholder {
  position: absolute;
  inset: 0;
  z-index: 10;
  /* Ensure it covers everything when visible */
  background-size: cover;
  background-position: center;
  /* background-color: transparent !important; REMOVED transparency */
  background-color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity .4s ease;
}

#kbg-placeholder.is-hidden {
  opacity: 0;
  z-index: -1;
  pointer-events: none;
}


#kbg-placeholder-content {
  width: 100%;
  pointer-events: auto;
}

/* === Toolbar / Filtres === */
#kbg-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 20px 0 12px;
}

#kbg-filters-bar {
  background: #0b1320;
  border: 1px solid var(--kbg-border);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.1);
}

#kbg-filters-bar input,
#kbg-filters-bar select {
  background: #0f172a;
  border: 1px solid var(--kbg-border);
  color: var(--kbg-text);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color .25s, background .25s;
}

#kbg-filters-bar input:focus,
#kbg-filters-bar select:focus {
  border-color: var(--kbg-accent);
  background: #1e293b;
  outline: none;
}

/* === Grille de jeux === */
#kbg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 22px;
  padding: 20px 10px 50px;
  justify-items: center;
  justify-content: center;
  /* Center the grid content horizontally */
  animation: fadeUp .6s ease-in-out;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* --- Cartes de jeux dynamiques (taille réglable dans l’admin) --- */

#kbg-grid .kbg-card {
  width: var(--kbg-card-w);
  height: var(--kbg-card-h);
  background: #020617;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid #1f2937;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, border-color 0.2s;
  position: relative;
}

/* Animation de Click et Hover */
#kbg-grid .kbg-card:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 10px 25px rgba(56, 189, 248, 0.25);
  border-color: var(--kbg-accent);
}

#kbg-grid .kbg-card.is-active {
  transform: scale(0.95);
  border-color: var(--kbg-green);
  box-shadow: 0 0 15px var(--kbg-green);
}

.kbg-card-img-wrap {
  position: relative;
  width: 100%;
  height: 65%;
  overflow: hidden;
}

#kbg-grid .kbg-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

#kbg-grid .kbg-card:hover img {
  transform: scale(1.1);
}

/* Labels de statut (New location) */
.kbg-status-row {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  text-align: center;
  margin: 6px 12px 2px;
  /* Espacement autour */
  padding: 4px;
  border-radius: 5px;
  letter-spacing: 0.5px;
}

.kbg-status-row.dev {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.kbg-status-row.play {
  color: #34d399;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
}


#kbg-grid .kbg-card .title {
  padding: 6px;
  font-size: 16px;
  color: #fff;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  font-weight: 600;
}

#kbg-grid .kbg-card .desc {
  padding: 4px 6px;
  font-size: 13px;
  color: #aaa;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
}

/* === Badges de Compatibilité === */
.kbg-badges {
  padding: 0 6px 6px;
  justify-content: center;
}

.kbg-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 5px;
  border-radius: 4px;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.kbg-badge.online {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border-color: #38bdf8;
}

.kbg-badge.pc {
  background: #334155;
  color: #94a3b8;
  border-color: #475569;
}

.kbg-badge.tablet {
  background: #7c3aed;
  /* Violet */
  border-color: #8b5cf6;
}

.kbg-badge.mobile {
  background: #ea580c;
  /* Orange Mobile */
  border-color: #f97316;
}

/* === Compteur sous la grille === */
#kbg-grid-count {
  text-align: center;
  color: var(--kbg-muted);
  font-size: 13px;
  margin-top: 8px;
}

/* === Leaderboard Sidebar (si existe) === */
#kbg-leaderboard-block {
  margin: 20px 0;
  padding: 12px;
  border: 1px solid var(--kbg-border);
  border-radius: 12px;
  background: #0b1320;
  color: var(--kbg-text);
  box-shadow: inset 0 0 15px rgba(56, 189, 248, 0.15);
}

#kbg-leaderboard-block h3 {
  margin: 0 0 6px 0;
  font-weight: 700;
  color: var(--kbg-accent);
  text-align: center;
}

.kbg-leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--kbg-text);
}

.kbg-leaderboard-table th,
.kbg-leaderboard-table td {
  padding: .6rem;
  border-bottom: 1px solid var(--kbg-border);
  text-align: left;
}

.kbg-leaderboard-table tr:nth-child(even) {
  background: #0f172a;
}

.kbg-leaderboard-table th {
  color: var(--kbg-accent);
}

/* === Responsive === */
@media (max-width:768px) {
  #kbg-container {
    padding: 0 !important;
    /* Zero padding to touch edges */
    border: none;
    border-radius: 0;
    margin: 0 -10px;
    /* Force overflow parent margins if any */
    width: 100vw;
    box-shadow: none;
  }

  #kbg-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    /* Smaller cards */
    gap: 10px;
    padding: 10px 0 40px;
    /* Remove side padding */
    width: 100%;
  }

  /* Make iframe full width */
  #kbg-stage {
    border-radius: 4px;
    border-left: 0;
    border-right: 0;
  }

  .kbg-card img {
    height: 110px;
  }

  .kbg-card .title {
    font-size: 14px;
  }

  .kbg-card .desc {
    display: none;
    /* Hide desc on mobile to save space */
  }

  #kbg-iframe {
    min-height: 700px;
    width: 100vw;
  }

  /* Adjust Topbar padding since container has none */
  #kbg-topbar {
    padding: 10px;
    flex-direction: column;
    gap: 10px;
  }

  #kbg-info {
    margin: 0 10px 10px;
    /* Add some margin back for info bar */
  }
}

@media (max-width:480px) {
  #kbg-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    justify-content: center;
  }

  .kbg-card img {
    height: 120px;
  }

  .kbg-card .desc {
    display: none;
  }

  #kbg-iframe {
    min-height: 600px;
  }

  #kbg-container {
    padding: 10px;
    /* More space for content */
  }
}