* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: sans-serif;
  line-height: 1.4;
  /* padding: 1rem; */
  display: flex;
  flex-direction: column;
  max-width: 500px;
  width: calc(100vw - 10px);
  margin-left: auto;
  margin-right: auto;
  border-radius: 6px;
  min-width: 1em;
  margin-top: 5px;
  margin-bottom: 5px;
  min-height: 710px;
}

nav {
  margin-bottom: 1rem;
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

a,
button,
select,
input {
  min-height: 2.5rem;
}

button,
select,
input[type="text"],
input[type="number"] {
  font: inherit;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
/* Avatar styles */
.avatar-section {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid #ddd;
  border-radius: 6px;
}

.avatar-section h3 {
  margin: 0 0 1rem 0;
  font-size: 1.1em;
}

.avatar-controls {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.avatar-preview {
  width: 80px;
  height: 80px;
  border: 2px dashed #ccc;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background-color: #f9f9f9;
  flex-shrink: 0;
}

.avatar-preview.has-image {
  border: 2px solid #1d4b8f;
  border-style: solid;
}

.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.avatar-placeholder {
  font-size: 0.8em;
  color: #666;
  text-align: center;
  padding: 0.5rem;
}

.avatar-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.avatar-actions input[type="file"] {
  font-size: 0.9em;
}

.avatar-actions button {
  padding: 0.5rem;
}

/* Avatar in character header */
.character-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.character-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid #1d4b8f;
}

.character-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.character-info h1 {
  margin: 0;
}

.character-info h2 {
  margin: 0.25rem 0 0 0;
}

@media (max-width: 400px) {
  .avatar-controls {
    flex-direction: column;
    align-items: center;
  }
  
  .character-header {
    flex-direction: column;
    text-align: center;
  }
  
  .character-avatar {
    width: 80px;
    height: 80px;
  }
}
}

.list-item {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid #ccc;
  justify-content: space-between;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.4rem 0;
}

/* .tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  min-width: 136px;
  justify-content: center;
} */

.desc {
  min-height: 1.4em;
  margin: 0.25rem 0 1rem;
}

.skill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.4rem;
}

.actions {
  margin: 1rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

label {
  display: block;
  margin: 0.75rem 0 0.25rem;
}

a, button {
  color: #1d4b8f;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  border: #1d4b8f 1px solid;
  border-radius: 0.25rem;
  background: none;
  min-width: 136px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.medium {
  width: calc(50% - 6px);
  border-top: black 1px solid;
  border-left: black 1px solid;
  border-radius: 4px 0 0 0;
  position: relative;
  margin: 3px;
  padding-bottom: 10px;
}

main {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}

h1 {
  margin: 0;
}

#content > section {
  margin: 20px 0;
}

section > div {
  justify-content: center;
}

.skill-row {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.skill-display {
  display: inline-flex;
  gap: 2px;
}

.circle-container {
  position: relative;
  display: inline-block;
  width: 1.2em;
  height: 1.2em;
}

.circle-container span {
  background-color: none;
}

.circle-empty {
  background-color: none;
  position: absolute;
  top: 0;
  left: 0;
  font-size: 1.2em;
  line-height: 1.2;
  z-index: 1;
}

.circle-filled {
  background-color: none;
  position: absolute;
  top: 0;
  left: 0;
  font-size: 0.8em;
  line-height: 1.2;
  z-index: 2;
  pointer-events: none;
}

#dice-section {
  display: flex;
  align-items: center;
  flex-direction: column;
}

#description {
  order: 1;
}

section > h2 {
  /* margin: 10px 0; */
  font-size: 1em;
  position: relative;
  top: -12px;
  background-color: white;
  left: 8px;
  display: inline;
  padding: 0 4px;
}

#error {
  margin: 0;
}

header {
  display: flex;
  /* justify-content: space-between; */
  align-items: center;
}

header h2 {
  margin: 0;
}

.skill-row > span {
  color: #1d4b8f;
  border-radius: 4px;
  height: 38px;
  width: 40px;
  display: flex;
  align-items: center;
}

.skill-display {
  display: inline-flex;
  font-size: 1.4em;
}

.circle {
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  width: 20px;
  height: 20px;
}

.circle svg {
  width: 20px;
  height: 20px;
  display: block;
}

.skill-row {
  margin: 10px;
}

#content > section > div {
  display: flex;
  flex-wrap: wrap;
}

/* Styles pour les boutons de dé */
.dice-btn {
  min-width: 40px !important;
  width: 40px;
  height: 40px;
  padding: 8px !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
}

.dice-btn svg {
  width: 20px;
  height: 20px;
}

/* Styles pour les boutons "x" plus petits */
.tag button:last-child,
.skill-row button:last-child {
  min-width: 40px !important;
  /* width: 24px;
  height: 24px; */
  padding: 0 !important;
  font-size: 14px;
  line-height: 1;
  display: flex !important;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
}

/* Harmonisation des marges pour les tags */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 2px;
}

/* .tag button:first-child {
  border-radius: 0.25rem 0 0 0.25rem;
  border-right: none;
}

.tag button:last-child {
  border-radius: 0 0.25rem 0.25rem 0;
  border-left: none;
} */

/* Styles pour la navigation en bas */
#actions {
  margin-top: 2rem;
  padding: 1rem 0;
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  border-top: 1px solid #ccc;
}

#edit-actions {
  display: flex;
  gap: 0.5rem;
}

/* Amélioration de l'affichage du niveau dans le header */
#level-display {
  font-size: 1.5rem;
  font-weight: bold;
  color: #1d4b8f;
}

#form {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#form > section {
  margin-top: 25px;
}

.add-btn {
  min-width: 40px !important;
}

/* Responsive pour mobile */
@media (max-width: 500px) {
  /* .row {
    gap: 0.25rem;
  } */
  
  .dice-btn {
    min-width: 40px !important;
    /* width: 36px;
    height: 36px; */
  }
  
  .tag button:last-child,
  .skill-row button:last-child {
    min-width: 40px !important;
  }
  
  .medium {
    /* width: 100%; */
    margin: 2px 0;
  }
  
  #form main {
    flex-direction: column;
  }

  #form .medium {
    width: 100%;
  }

  #form .tags {
    flex-direction: column;
    align-items: center;
  }
}

/* Styles pour les domaines */
.skill-container {
  margin-bottom: 15px;
  border-left: 1px solid transparent;
  /* padding-left: 10px; */
}

.skill-container.has-domains {
  border-left-color: black;
}

.domain-section {
  margin-top: 8px;
  margin-left: 20px;
}

.domain-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.domain-row input {
  flex: 1;
  min-width: 150px;
}

.domain-row select {
  flex: 1;
  min-width: 150px;
}

.domains-display {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.5rem;
  margin-left: 20px;
}

.domain-tag {
  /* background-color: #f0f4ff !important; */
  border-color: #1d4b8f !important;
  font-size: 0.9em !important;
  min-width: auto !important;
  padding: 0.2rem 0.4rem !important;
}

.domain-tag button {
  background-color: #f0f4ff !important;
}

.domain-tag:hover {
  background-color: #e0e8ff !important;
}

.character-avatar img {
  width: 50px;
  height: 50px;
  border-radius: 90px;
}

.character-info {
  margin-left: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.avatar-preview img {
  width: 50px;
  height: 50px;
  border-radius: 90px;
}

.avatar-preview {
  display: flex;
  justify-content: center;
}