/* =========================
   Spells Modal - Refatorado
   Filtros e metas sempre em linha
========================= */

/* Overlay */
.spells-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 2000;
}

.spells-overlay.active { display: block; }

/* Modal principal */
.spells-modal {
  display: none;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 95%; max-width: 600px;
  height: 80vh;
  background: var(--surface);
  border: 2px solid var(--gold);
  border-radius: 24px;
  z-index: 2001;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  overflow: hidden;
}

.spells-modal.active { display: flex; }

/* Cabeçalho fixo */
.spells-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 1.5rem 0.75rem;
  border-bottom: 1px solid rgba(212,175,55,0.3);
  background: var(--surface);
  flex-shrink: 0;
}

.spells-header h2 {
  color: var(--gold);
  font-family: 'Cinzel', serif;
  font-size: 1.5rem;
  margin: 0;
}

.spells-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 2rem;
  cursor: pointer;
  padding: 0 0.5rem;
  line-height: 1;
  transition: color 0.2s;
}

.spells-close:hover { color: var(--gold); }

/* Toolbar fixa */
.spells-toolbar {
  padding: 1rem 1.5rem 0.5rem;
  background: var(--surface);
  border-bottom: 1px solid rgba(212,175,55,0.2);
  flex-shrink: 0;
}

#spells-search {
  width: 100%;
  padding: 0.8rem 1rem;
  font-size: 1rem;
  font-family: 'Crimson Text', serif;
  background: var(--surface-light);
  border: 1px solid rgba(212,175,55,0.3);
  border-radius: 12px;
  color: var(--text);
  margin-bottom: 0.8rem;
  transition: all 0.2s;
}

#spells-search:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(212,175,55,0.2);
}

#spells-search::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

/* 🔹 FILTROS - SEMPRE EM LINHA */
.spells-filters {
  display: flex;
  flex-direction: row; /* Força linha */
  gap: 0.5rem;
  padding: 0.25rem 0;
  width: 100%;
}

.filter-group {
  position: relative;
  flex: 1; /* Divide espaço igualmente */
  min-width: 0; /* Permite compressão se necessário */
}

.filter-toggle {
  width: 100%;
  padding: 0.5rem;
  background: transparent;
  border: 1px solid rgba(212,175,55,0.3);
  border-radius: 8px;
  color: var(--text);
  font-family: 'Crimson Text', serif;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-toggle:hover {
  border-color: var(--gold);
  background: rgba(212,175,55,0.1);
}

.filter-options {
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 0.5rem;
  margin-top: 0.25rem;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.filter-options label {
  display: block;
  padding: 0.5rem;
  color: var(--text);
  font-family: 'Crimson Text', serif;
  font-size: 0.95rem;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s;
  white-space: nowrap;
}

.filter-options label:hover {
  background: rgba(212,175,55,0.1);
}

.filter-options input[type="checkbox"] {
  margin-right: 0.5rem;
  accent-color: var(--gold);
}

/* Área de conteúdo rolável */
.spells-content {
  padding: 1rem 1.5rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* Lista de magias */
.spells-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.8rem;
}

@media (min-width: 600px) {
  .spells-list { grid-template-columns: repeat(2, 1fr); }
}

/* Item de magia */
.spell-item {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(212,175,55,0.15);
  border-radius: 12px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.spell-item:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(212,175,55,0.2);
}

.spell-item:active { transform: translateY(0); }

.spell-name {
  font-weight: bold;
  font-size: 1.1rem;
  color: var(--gold);
  margin-bottom: 0.5rem;
  font-family: 'Cinzel', serif;
}

/* 🔹 METADADOS - SEMPRE EM LINHA */
.spell-meta {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-family: 'Crimson Text', serif;
  display: flex;
  flex-direction: row; /* Força linha */
  gap: 0.5rem;
  flex-wrap: wrap; /* Quebra se não couber, mas tenta manter em linha */
  align-items: center;
}

.spell-meta span {
  background: rgba(212,175,55,0.1);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border: 1px solid rgba(212,175,55,0.2);
  display: inline-block;
  white-space: nowrap; /* Evita quebra dentro do span */
}

/* Estados especiais */
.spell-item.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  padding: 2rem;
  cursor: default;
}

.spell-item.empty-state:hover {
  transform: none;
  border-color: rgba(212,175,55,0.15);
}

.spell-brief {
  margin: 0;
  font-size: 0.9em;
  color: white;
  line-height: 1.4;
  font-weight: normal;
  font-size: 0.3 rem;
  font-family: 'Crimson Text', serif;
  /* Limita o texto a 3 linhas com ellipsis */
  display: -webkit-box;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spells-loading {
  text-align: center;
  color: var(--gold);
  padding: 2rem;
  grid-column: 1 / -1;
}

.spells-loading::after {
  content: "...";
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0%, 20% { content: "."; }
  40% { content: ".."; }
  60%, 100% { content: "..."; }
}

/* Scroll customizado */
.spells-content::-webkit-scrollbar { width: 8px; }
.spells-content::-webkit-scrollbar-track {
  background: rgba(212,175,55,0.1);
  border-radius: 10px;
}
.spells-content::-webkit-scrollbar-thumb {
  background: var(--gold);
  border-radius: 10px;
}

/* =========================
   Spell Detail Modal
========================= */

.spell-detail-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 2100; /* Acima do modal de magias */
}

.spell-detail-overlay.active { display: block; }

.spell-detail-modal {
  display: none;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  background: var(--surface);
  border: 2px solid var(--gold);
  border-radius: 24px;
  z-index: 2101;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  overflow: hidden;
}

.spell-detail-modal.active { display: flex; }

.spell-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 1.5rem 0.75rem;
  border-bottom: 1px solid rgba(212,175,55,0.3);
  background: var(--surface);
  flex-shrink: 0;
}

.spell-detail-header h2 {
  color: var(--gold);
  font-family: 'Cinzel', serif;
  font-size: 1.3rem;
  margin: 0;
  padding-right: 1rem;
}

.spell-detail-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 2rem;
  cursor: pointer;
  padding: 0 0.5rem;
  line-height: 1;
  transition: color 0.2s;
}

.spell-detail-close:hover { color: var(--gold); }

.spell-detail-content {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.spell-detail-section {
  display: flex;
  margin-bottom: 1rem;
  padding: 0.5rem;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
}

.spell-detail-label {
  flex: 0 0 80px;
  color: var(--gold);
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  font-weight: 600;
}

.spell-detail-value {
  flex: 1;
  color: var(--text);
  font-family: 'Crimson Text', serif;
  font-size: 1rem;
}

.spell-detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
  padding: 0.5rem 0;
  border-top: 1px solid rgba(212,175,55,0.2);
  border-bottom: 1px solid rgba(212,175,55,0.2);
}

.spell-detail-tag {
  background: rgba(212,175,55,0.1);
  border: 1px solid rgba(212,175,55,0.3);
  border-radius: 16px;
  padding: 0.3rem 0.8rem;
  color: var(--text-muted);
  font-family: 'Crimson Text', serif;
  font-size: 0.85rem;
  text-transform: capitalize;
}

.spell-detail-tag.combat {
  background: rgba(192,57,43,0.1);
  border-color: #c0392b;
  color: #c0392b;
}

.spell-detail-description {
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(0,0,0,0.2);
  border-radius: 12px;
  border-left: 3px solid var(--gold);
}

.spell-detail-description p {
  color: var(--text);
  font-family: 'Crimson Text', serif;
  font-size: 1rem;
  line-height: 1.6;
  margin: 0;
}

/* Responsivo - apenas ajustes finos */
@media (max-width: 480px) {
  .spells-header h2 { font-size: 1.2rem; }
  
  /* 🔹 Garante que filtros continuem em linha mesmo em telas pequenas */
  .spells-filters {
    gap: 0.3rem;
  }
  
  .filter-toggle {
    font-size: 0.85rem;
    padding: 0.4rem;
  }
  
  .filter-options label {
    font-size: 0.85rem;
    padding: 0.4rem;
  }
  
  /* 🔹 Ajuste fino para metadados */
  .spell-meta {
    gap: 0.3rem;
  }
  
  .spell-meta span {
    font-size: 0.85rem;
    padding: 0.15rem 0.4rem;
  }
}

/* Ajuste para telas muito estreitas */
@media (max-width: 360px) {
  .filter-toggle {
    font-size: 0.8rem;
    padding: 0.3rem;
  }
  
  .spell-meta span {
    font-size: 0.8rem;
  }
}

@media (max-height: 600px) {
  .spells-modal { height: 90vh; }
  .spells-header { padding: 1rem 1.5rem 0.5rem; }
  .spells-toolbar { padding: 0.5rem 1.5rem; }
  .spells-content { padding: 0.5rem 1.5rem; }
  .spell-item { padding: 0.6rem; }
  .spell-name { font-size: 1rem; }
}