/**
 * Skin terminal partagé (style mirador / machines).
 * Fond noir–vert, typo mono, kicker // , titres verts.
 * Appliquer la classe .term-skin sur la boîte interne de la modale.
 */

.term-skin {
  color: #d1fae5 !important;
  background: #000 linear-gradient(165deg, #052e16 0%, #000 55%, #001a0f 100%) !important;
  border: 2px solid #22c55e !important;
  box-shadow:
    0 0 24px rgba(34, 197, 94, 0.25),
    0 20px 40px rgba(0, 0, 0, 0.65) !important;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  border-radius: 0.75rem;
}

/* Variante défaite / danger (tons rouges) — même structure que mirador / preview */
.term-skin.term-skin-danger {
  color: #fecaca !important;
  background: #000 linear-gradient(165deg, #450a0a 0%, #000 55%, #1a0505 100%) !important;
  border: 2px solid #ef4444 !important;
  box-shadow:
    0 0 24px rgba(239, 68, 68, 0.28),
    0 20px 40px rgba(0, 0, 0, 0.65) !important;
}

.term-skin.term-skin-danger .term-kicker {
  color: #f87171;
}

.term-skin.term-skin-danger .term-title {
  color: #fca5a5 !important;
}

.term-skin.term-skin-danger .term-subtitle {
  color: #f87171;
}

.term-skin.term-skin-danger .term-close {
  color: #f87171 !important;
  border-color: rgba(239, 68, 68, 0.45);
}

.term-skin.term-skin-danger .term-close:hover {
  color: #fef2f2 !important;
  background: rgba(127, 29, 29, 0.55);
}

.term-skin.term-skin-danger .term-screen,
.term-skin.term-skin-danger .term-panel {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(0, 0, 0, 0.55);
}

.term-skin.term-skin-danger .term-btn-danger,
.term-skin.term-skin-danger .structure-btn-danger {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 0.45rem;
  font-weight: 700;
  font-size: 1rem;
  background: #b91c1c;
  color: #fef2f2;
  border: 1px solid #f87171;
  cursor: pointer;
  transition: background 0.15s;
}

.term-skin.term-skin-danger .term-btn-danger:hover,
.term-skin.term-skin-danger .structure-btn-danger:hover {
  background: #dc2626;
}

.term-skin-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-shrink: 0;
}

.term-skin-header-center {
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.term-kicker {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #4ade80;
  opacity: 0.9;
  line-height: 1.2;
}

.term-title {
  margin: 0.2rem 0 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: #86efac !important;
  line-height: 1.25;
}

.term-subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: #6ee7b7;
  opacity: 0.9;
}

.term-close {
  color: #4ade80 !important;
  background: transparent;
  border: 1px solid rgba(34, 197, 94, 0.35);
  border-radius: 0.35rem;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.term-close:hover {
  color: #f0fdf4 !important;
  background: rgba(22, 101, 52, 0.55);
}

/* Sections / listes */
.term-skin .term-panel,
.term-skin .term-screen {
  border: 1px solid rgba(34, 197, 94, 0.35);
  border-radius: 0.5rem;
  background: rgba(0, 0, 0, 0.55);
}

.term-skin h3,
.term-skin h4 {
  color: #86efac !important;
}

.term-skin .text-green-500 {
  color: #86efac !important;
}

.term-skin .text-gray-400 {
  color: #6ee7b7 !important;
  opacity: 0.85;
}

/* Inputs */
.term-skin input[type="text"],
.term-skin input[type="search"],
.term-skin textarea {
  background: rgba(0, 0, 0, 0.55) !important;
  border: 1px solid rgba(34, 197, 94, 0.35) !important;
  color: #d1fae5 !important;
  border-radius: 0.35rem;
  font-family: inherit;
}

.term-skin input:focus,
.term-skin textarea:focus {
  outline: none;
  border-color: #4ade80 !important;
  box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.35);
}

/* Boutons utilitaires déjà Tailwind — teinte terminal sans casser les IDs */
.term-skin .term-btn,
.term-skin button.bg-gray-700 {
  background: #14532d !important;
  color: #bbf7d0 !important;
  border: 1px solid #22c55e;
}

.term-skin button.bg-gray-700:hover,
.term-skin .term-btn:hover {
  background: #166534 !important;
}

.term-skin button.bg-green-700,
.term-skin button.bg-green-600,
.term-skin button.bg-green-500 {
  background: #15803d !important;
  color: #052e16 !important;
  border: 1px solid #4ade80;
  font-weight: 700;
}

.term-skin button.bg-green-700:hover,
.term-skin button.bg-green-600:hover,
.term-skin button.bg-green-500:hover {
  background: #16a34a !important;
}

/* Tabs magasin */
.term-skin .term-tabs {
  border-bottom: 1px solid rgba(34, 197, 94, 0.45);
}

.term-skin .term-tabs button.border-b-2 {
  color: #6ee7b7;
}

.term-skin .term-tabs button:hover {
  color: #86efac !important;
}

/* Scrollbars discrètes */
.term-skin .overflow-y-auto::-webkit-scrollbar {
  width: 6px;
}
.term-skin .overflow-y-auto::-webkit-scrollbar-thumb {
  background: rgba(34, 197, 94, 0.45);
  border-radius: 3px;
}
.term-skin .overflow-y-auto::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.35);
}

/* Panneaux boot / sélection (pas forcément fullscreen modal) */
.term-skin-panel {
  width: 100%;
  max-width: 32rem;
  padding: 1.1rem 1.15rem 1rem;
}

.term-skin.term-skin-boot {
  max-width: none;
  width: 100%;
  height: 100%;
  border-radius: 0.75rem;
}

#character-selection-screen .term-skin-panel {
  max-width: 36rem;
}

#auth-loading-state.term-skin-panel,
#auth-loading-state .term-skin-inner {
  text-align: center;
}

.term-skin .term-msg-panel {
  border: 1px solid rgba(34, 197, 94, 0.35);
  background: rgba(0, 0, 0, 0.55);
  border-radius: 0.5rem;
}

/* ——— Shell modale plafonnée écran (header/footer fixes, body scroll) ——— */
.term-skin.term-skin-modal-shell {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: 100%;
  max-height: calc(100dvh - 40px);
  min-height: 0;
  overflow: hidden;
}

.term-skin.term-skin-modal-shell > .term-skin-header,
.term-skin.term-skin-modal-shell > .term-skin-footer,
.term-skin.term-skin-modal-shell > .term-screen,
.term-skin.term-skin-modal-shell > .terminal-screen-content {
  flex-shrink: 0;
}

.term-skin.term-skin-modal-shell > .term-skin-footer {
  margin-top: auto;
}

.term-skin.term-skin-modal-shell .term-skin-scroll-body,
.term-skin.term-skin-modal-shell > .structure-rows {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  /* Reveal progressif : ne pas ancrer le scroll sur le contenu qui s'ajoute */
  overflow-anchor: none;
}

/* Preview combat : jamais plus haute que l’écran ; scroll = #combat-preview-log
   (sans !important pour ne pas casser modal-container-hidden / grow) */
#combat-preview-modal > .term-skin.term-skin-modal-shell {
  height: auto;
  max-height: calc(100dvh - 40px);
  margin-top: 0;
  margin-bottom: 0;
}

#combat-preview-modal #combat-preview-log.structure-rows {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-anchor: none;
}

/* Codex liste : shell plafonné, grille scrollable */
#bestiary-modal > .term-skin.term-skin-modal-shell {
  max-height: calc(100dvh - 16px);
  height: calc(100dvh - 16px);
  min-height: 0;
  overflow: hidden;
}

#bestiary-modal #bestiary-grid.term-skin-scroll-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* ——— Rows structurées (mirador / preview combat / bestiaire) ——— */
.term-skin .structure-rows {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overflow-anchor: none;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  font-family: inherit;
}

.term-skin .structure-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid rgba(34, 197, 94, 0.22);
  background: rgba(6, 78, 59, 0.25);
  border-radius: 0.35rem;
  font-size: 0.82rem;
  flex-shrink: 0;
}

/* Titres de catégorie : même cadre que .structure-row (mirador) */
.term-skin .structure-row.structure-section-title {
  margin-top: 0.35rem;
  justify-content: flex-start;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border-color: rgba(34, 197, 94, 0.4);
  background: rgba(6, 78, 59, 0.4);
}

.term-skin .structure-row.structure-section-title:first-child {
  margin-top: 0;
}

.term-skin .structure-row > span:first-child {
  color: #86efac;
  opacity: 0.85;
  flex-shrink: 0;
}

.term-skin .structure-row > span:last-child {
  color: #f0fdf4;
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}

.term-skin .structure-row.structure-row-warn > span:last-child {
  color: #fbbf24;
}

.term-skin .structure-row.structure-row-danger > span:last-child {
  color: #fca5a5;
}

.term-skin .structure-row.structure-row-success > span:last-child {
  color: #86efac;
}

.term-skin .structure-row.structure-row-info > span:last-child {
  color: #fde68a;
}

/* Après les règles label/valeur pour gagner la cascade (1 seul span) */
.term-skin .structure-row.structure-section-title > span:only-child {
  color: #4ade80;
  opacity: 0.95;
  font-weight: 700;
  text-align: left;
}

.term-skin .structure-block {
  padding: 0.5rem 0.6rem;
  border: 1px solid rgba(34, 197, 94, 0.22);
  background: rgba(6, 78, 59, 0.2);
  border-radius: 0.35rem;
  font-size: 0.8rem;
  color: #d1fae5;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  flex-shrink: 0;
}

/* Preview combat : teinte du conteneur d’infos */
#combat-preview-modal #combat-preview-log.structure-rows {
  color: #d1fae5;
  padding: 0.25rem 0 0.5rem;
}
