/* base.css — Solo estructura y layout. Sin colores, fuentes ni decoración visual. */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
}

body {
  min-height: 100vh;
  line-height: 1.4;
}

.sheet-wrapper {
  position: relative;
  max-width: 1400px;
  margin: 0 auto;
  padding: 2.5rem 2rem 2rem;
}

.frame-ornament {
  position: absolute;
  z-index: 10;
  line-height: 1;
  pointer-events: none;
}

.frame-ornament--tl { top: 0.25rem; left: 0.25rem; }
.frame-ornament--tm { top: 0.25rem; left: 50%; transform: translateX(-50%); }
.frame-ornament--tr { top: 0.25rem; right: 0.25rem; }
.frame-ornament--ml { top: 50%; left: 0.25rem; transform: translateY(-50%); }
.frame-ornament--mr { top: 50%; right: 0.25rem; transform: translateY(-50%); }
.frame-ornament--bl { bottom: 0.25rem; left: 0.25rem; }
.frame-ornament--bm { bottom: 0.25rem; left: 50%; transform: translateX(-50%); }
.frame-ornament--br { bottom: 0.25rem; right: 0.25rem; }

/* Toolbar */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.sheet-title {
  flex-shrink: 0;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.load-group {
  display: flex;
  gap: 0.25rem;
}

.theme-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.btn {
  cursor: pointer;
  border: none;
  padding: 0.4rem 0.75rem;
  white-space: nowrap;
}

.btn-file {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.btn-small {
  padding: 0.25rem 0.5rem;
  margin-top: 0.5rem;
}

.load-select {
  min-width: 160px;
  padding: 0.35rem;
}

.print-only {
  display: none;
}

/* Grid: columna izquierda (retrato + stats) | columna derecha (contenido) */

.character-sheet {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(0, 3fr);
  gap: 1.25rem;
  align-items: start;
  width: 100%;
}

.portrait-column {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: sticky;
  top: 1rem;
}

.content-column {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  align-items: start;
}

/* Tarjetas */

.card {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  padding: 1.75rem 1rem 1.25rem;
  margin-top: 0.625rem;
}

.card-label {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  z-index: 2;
  max-width: 92%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Retrato */

.card-portrait {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 1.25rem;
}

.portrait-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.portrait-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.portrait-placeholder {
  font-size: 4rem;
  line-height: 1;
}

.portrait-upload {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: 0.35rem;
  cursor: pointer;
}

.portrait-nameplate {
  width: 100%;
  text-align: center;
  margin-top: 0.75rem;
}

.portrait-name {
  width: 100%;
  text-align: center;
}

/* Cabecera */

.header-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.header-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.header-field label {
  font-size: 0.75em;
  text-transform: uppercase;
}

/* PV */

.hp-row {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  margin: 1rem 0;
  flex-wrap: wrap;
}

.hp-heart {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 90px;
}

.hp-heart-display {
  position: relative;
  width: 4.5rem;
  height: 3.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hp-heart-icon {
  font-size: 3rem;
  line-height: 1;
  pointer-events: none;
  user-select: none;
}

.hp-value {
  position: absolute;
  top: 46%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2.75rem;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  text-align: center;
  z-index: 1;
  -moz-appearance: textfield;
  appearance: textfield;
}

.hp-value::-webkit-outer-spin-button,
.hp-value::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.hp-label {
  margin-top: 0.35rem;
  font-size: 0.85em;
  text-transform: uppercase;
}

.secondary-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  padding-top: 0.75rem;
  margin-top: 0.5rem;
}

.secondary-stat {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.secondary-stat--readonly {
  opacity: 0.95;
}

.computed-value {
  min-width: 2rem;
  text-align: center;
  font-weight: bold;
}

.death-saves {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.death-saves-title {
  font-size: 0.85em;
  text-transform: uppercase;
  text-align: center;
}

.death-save-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-size: 0.85em;
}

.death-save-dots {
  display: flex;
  gap: 0.35rem;
}

.death-save-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  border: 2px solid currentColor;
  background: transparent;
}

.death-save-dot.active {
  background: currentColor;
}

.inspiration-check {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.65rem;
  font-size: 0.9em;
  cursor: pointer;
}

.stat-save-item {
  font-weight: 600;
  border-bottom: 1px dashed rgba(0, 0, 0, 0.15);
  margin-bottom: 0.15rem;
  padding-bottom: 0.2rem !important;
}

.passive-stat--field {
  flex-wrap: wrap;
}

.passive-stat--field .inline-input {
  flex: 1;
  min-width: 120px;
}

/* Estadísticas (columna izquierda, 2×3) */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.625rem;
  margin-top: 0.25rem;
}

.stat-block {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 0.35rem 0.35rem;
  justify-content: flex-start;
  gap: 0.15rem;
}

.stat-skills-list {
  list-style: none;
  margin: 0;
  padding: 0.15rem 0.25rem 0.35rem;
}

.stat-block .skill-item {
  padding: 0.12rem 0;
  gap: 0.35rem;
  font-size: 0.82em;
}

.stat-block .competence-dot {
  width: 11px;
  height: 11px;
}

.stat-block .competence-mod {
  min-width: 2rem;
  font-size: 0.95em;
}

.stat-block .skill-name {
  flex: 1;
  min-width: 0;
  line-height: 1.2;
}

.stat-block .skill-name-select,
.stat-block .skill-custom-input {
  flex: 1;
  min-width: 0;
  font-size: 0.9em;
}

.stat-block .btn-remove {
  font-size: 0.85em;
  padding: 0 0.2rem;
}

.card-stats #btn-add-skill {
  display: block;
  margin: 0.75rem auto 0;
}

.stat-card-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.stat-card-name {
  font-size: 0.65em;
  text-align: center;
  text-transform: uppercase;
}

.stat-card-value {
  width: 100%;
  text-align: center;
  font-size: 1.5rem;
}

.stat-card-modifier {
  padding: 0.15rem 0.5rem;
  text-align: center;
  min-width: 2.25rem;
}

/* Competencias y habilidades */

.competence-list,
.skill-list {
  list-style: none;
  margin-top: 0.25rem;
}

.competence-item,
.skill-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0;
}

.competence-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  cursor: pointer;
}

.competence-name {
  flex: 1;
  min-width: 0;
}

.competence-mod {
  min-width: 2.5rem;
  text-align: right;
  flex-shrink: 0;
}

.header-field--narrow {
  max-width: 5rem;
}

.header-custom {
  margin-top: 0.25rem;
}

.header-field .inline-select {
  width: 100%;
}

.skill-name-select {
  flex: 1;
  min-width: 0;
}

.skill-custom-input {
  flex: 1;
  min-width: 0;
}

.inline-select {
  width: 100%;
  padding: 0.15rem 0.25rem;
  border: none;
  background: transparent;
  cursor: pointer;
}

.inline-select:focus {
  outline: none;
}


.card-competences .competence-list {
  max-height: 220px;
  overflow-y: auto;
}

/* Pasivos */

.passive-row {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  margin-top: 0.25rem;
}

.passive-stat {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
}

.passive-value {
  margin-left: auto;
  min-width: 2rem;
  text-align: right;
}

/* Tablas dinámicas */

.dynamic-table-header {
  display: grid;
  gap: 0.5rem;
  padding: 0.35rem 0;
  font-size: 0.85em;
}

.weapons-header {
  grid-template-columns: 70px 1fr 100px 1fr 32px;
}

.dynamic-table-body {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.weapon-row {
  display: grid;
  grid-template-columns: 70px 1fr 100px 1fr 32px;
  gap: 0.5rem;
  align-items: center;
}

.weapon-row select,
.weapon-row input {
  width: 100%;
  min-width: 0;
}

.col-actions {
  text-align: center;
}

.btn-remove {
  cursor: pointer;
  border: none;
  width: 28px;
  height: 28px;
  padding: 0;
  line-height: 1;
}

/* Listas dinámicas */

.dynamic-list {
  list-style: none;
  margin-top: 0.5rem;
}

.dynamic-list-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0;
}

.dynamic-list-item input {
  flex: 1;
  min-width: 0;
}

/* Espacios de hechizo */

.spell-slots-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.spell-level-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.spell-level-label {
  font-size: 0.85em;
}

.spell-slot-count {
  width: 2.5rem;
  text-align: center;
}

.spell-slot-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: center;
  max-width: 120px;
}

.spell-slot-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* Inventario */

.currency-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
}

.currency-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.currency-input {
  width: 3.5rem;
  text-align: center;
}

/* Notas */

.inline-textarea {
  width: 100%;
  min-height: 100px;
  resize: vertical;
  margin-top: 0.5rem;
}

/* Inputs inline */

.inline-input {
  border: none;
  background: transparent;
  width: 100%;
  padding: 0.15rem 0.25rem;
}

.inline-input:focus {
  outline: none;
}

/* Secciones de ancho completo dentro del grid de contenido */

.card-hp,
.card-passive,
.card-weapons,
.card-equipment,
.card-traits,
.card-spell-slots,
.card-inventory,
.card-notes,
.card-languages {
  grid-column: 1 / -1;
}

.card-passive {
  grid-column: span 1;
}

.card-hp {
  grid-column: span 1;
}

/* Responsive */

@media (max-width: 900px) {
  .character-sheet {
    grid-template-columns: 1fr;
  }

  .portrait-column {
    position: static;
    display: grid;
    grid-template-columns: minmax(160px, 220px) 1fr;
    gap: 1rem;
    align-items: start;
  }

  .card-portrait {
    grid-column: 1;
  }

  .card-stats {
    grid-column: 2;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .sheet-wrapper {
    padding: 1rem;
  }

  .portrait-column {
    grid-template-columns: 1fr;
  }

  .card-stats {
    grid-column: 1;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .card-hp,
  .card-passive,
  .card-weapons,
  .card-equipment,
  .card-traits,
  .card-spell-slots,
  .card-inventory,
  .card-notes,
  .card-languages {
    grid-column: 1;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .weapons-header,
  .weapon-row {
    grid-template-columns: 1fr;
  }

  .weapons-header span:not(:first-child) {
    display: none;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .load-group {
    flex-direction: column;
  }
}
