/* =========================
   Sheet Modal
========================= */

/* Garantir que tudo respeite as bordas */
* {
  box-sizing: border-box;
}

/* Overlay */
.sheet-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;
}

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

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

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

/* Cabeçalho do Modal */
.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid rgba(212, 175, 55, 0.3);
  background: var(--surface, #1a1a2e);
}

.sheet-header h2 {
  color: var(--gold, #d4af37);
  font-family: 'Cinzel', serif;
  font-size: 1.3rem;
  margin: 0;
}

.sheet-close {
  background: none;
  border: none;
  color: var(--text-muted, #b0b0c0);
  font-size: 1.8rem;
  cursor: pointer;
  padding: 0 0.5rem;
  line-height: 1;
  transition: color 0.2s ease;
}

.sheet-close:hover {
  color: var(--gold, #d4af37);
}

/* Conteúdo Scrollável */
.sheet-content {
  padding: 0.8rem;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: calc(90vh - 70px);
  flex: 1;
  color: var(--text, #f0f0f0);
  font-family: 'Crimson Text', serif;
  width: 100%;
}

/* =========================
   HEADER FIXO DA FICHA
========================= */
.sheet-header-fixed {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 16px;
  padding: 0.6rem;
  margin-bottom: 0.5rem;
  border: 1px solid rgba(212, 175, 55, 0.15);
  width: 100%;
}

.sheet-row {
  display: flex;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
  width: 100%;
}

.sheet-row:last-child {
  margin-bottom: 0;
}

/* Campo Nome e Nível */
.sheet-field--name {
  flex: 3;
}

.sheet-field--level {
  flex: 1;
}

.sheet-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gold, #d4af37);
  margin-bottom: 0.2rem;
  font-family: 'Cinzel', serif;
}

.sheet-input {
  width: 100%;
  padding: 0.5rem 0.7rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 10px;
  color: var(--text, #f0f0f0);
  font-family: 'Crimson Text', serif;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

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

.sheet-input::placeholder {
  color: var(--text-muted, #b0b0c0);
  font-style: italic;
}

/* Grid de Atributos */
.attributes-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.3rem;
  width: 100%;
}

.attribute-item {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(212, 175, 55, 0.15);
  border-radius: 8px;
  padding: 0.4rem;
  text-align: center;
}

.attribute-label {
  display: block;
  color: var(--gold, #d4af37);
  font-weight: bold;
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
  font-family: 'Cinzel', serif;
}

.attribute-input {
  width: 100%;
  padding: 0.3rem;
  text-align: center;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 6px;
  color: var(--text, #f0f0f0);
  font-size: 0.95rem;
  font-weight: bold;
}

/* =========================
   Status Vitais
========================= */
.sheet-row--vitals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  width: 100%;
  margin-bottom: 0.8rem;
}

.vitals-group {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  padding: 0.4rem 0.5rem;
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.vitals-label {
  color: var(--gold, #d4af37);
  font-weight: bold;
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  white-space: nowrap;
  flex-shrink: 0;
  width: 2.5rem;
}

.vitals-fields {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex: 1;
  min-width: 0;
  justify-content: flex-end;
}

.vitals-input {
  flex: 1;
  min-width: 0;
  width: 3.2rem;
  padding: 0.3rem 0.2rem;
  text-align: center;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 5px;
  color: var(--text, #f0f0f0);
  font-size: 0.9rem;
}

.vitals-separator {
  color: var(--gold, #d4af37);
  font-weight: bold;
  font-size: 1rem;
  flex-shrink: 0;
  width: 0.8rem;
  padding: 0 0.1rem;
}

/* Notas */
.sheet-field--notas {
  width: 100%;
}

.sheet-textarea--notas {
  min-height: 80px;
  width: 100%;
  resize: vertical;
}

/* =========================
   ABAS
========================= */
.sheet-tabs {
  display: flex;
  gap: 0.4rem;
  position: sticky;
  top: 0;
  background: var(--surface, #1a1a2e);
  padding: 0.2rem 0;
  z-index: 5;
  -webkit-tap-highlight-color: transparent;
}

.sheet-tab {
  flex: 1;
  padding: 0.6rem 0.3rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 20px;
  color: var(--text-muted, #b0b0c0);
  font-weight: bold;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Cinzel', serif;
  white-space: nowrap;
}

.sheet-tab:hover {
  background: rgba(212, 175, 55, 0.1);
  color: var(--gold, #d4af37);
}

.sheet-tab[aria-expanded="true"] {
  background: var(--gold, #d4af37);
  color: #1a1a1a;
  border-color: var(--gold, #d4af37);
}

/* =========================
   PAINÉIS
========================= */
.sheet-panel {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 16px;
  padding: 1rem;
  margin-bottom: 1.2rem;
  border: 1px solid rgba(212, 175, 55, 0.15);
  width: 100%;
}

.sheet-panel[hidden] {
  display: none;
}

.panel-title {
  color: var(--gold, #d4af37);
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  margin: 0 0 0.8rem 0;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid rgba(212, 175, 55, 0.3);
}

.panel-row {
  display: flex;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
  width: 100%;
}

.panel-row:last-child {
  margin-bottom: 0;
}

.sheet-field--half {
  flex: 1;
}

.sheet-field--third {
  flex: 1;
}

.sheet-field--full {
  width: 100%;
}

/* Textareas */
.sheet-textarea {
  width: 100%;
  padding: 0.6rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 10px;
  color: var(--text, #f0f0f0);
  font-family: 'Crimson Text', serif;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 70px;
  transition: all 0.2s ease;
}

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

.sheet-textarea::placeholder {
  color: var(--text-muted, #b0b0c0);
  font-style: italic;
}

/* Campos de XP */
.panel-row--xp {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  padding: 0.6rem;
  display: flex;
  justify-content: space-around;
}

.xp-field {
  text-align: center;
  flex: 1;
}

.xp-label {
  display: block;
  color: var(--gold, #d4af37);
  font-size: 0.75rem;
  font-weight: bold;
  margin-bottom: 0.2rem;
  font-family: 'Cinzel', serif;
}

.xp-input {
  width: 80%;
  padding: 0.3rem;
  text-align: center;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 6px;
  color: var(--text, #f0f0f0);
  font-size: 0.9rem;
}

/* Limites de Peso */
.panel-row--limits {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  padding: 0.6rem;
  display: flex;
  justify-content: space-around;
}

.limit-field {
  text-align: center;
  flex: 1;
  color: var(--gold, #d4af37);
}

.limit-label {
  display: block;
  color: var(--gold, #d4af37);
  font-size: 0.75rem;
  font-weight: bold;
  margin-bottom: 0.2rem;
  font-family: 'Cinzel', serif;
}

.limit-input {
  width: 80%;
  padding: 0.3rem;
  text-align: center;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 6px;
  color: var(--text, #f0f0f0);
  font-size: 0.9rem;
}

/* =========================
   Botões Exportar/Importar
========================= */

.sheet-export-import-section {
  margin: 1rem 0;
}

.sheet-export-import-buttons {
  display: flex;
  gap: 0.8rem;
  margin-bottom: 0.5rem;
}

.sheet-export-button,
.sheet-import-button {
  flex: 1;
  padding: 0.8rem;
  background: var(--surface-light);
  border: 2px solid rgba(212, 175, 55, 0.3);
  border-radius: 30px;
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Cinzel', serif;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  -webkit-tap-highlight-color: transparent;
}

.sheet-export-button:hover,
.sheet-import-button:hover {
  background: rgba(212, 175, 55, 0.1);
  border-color: var(--gold);
  transform: translateY(-2px);
}

.sheet-export-button:active,
.sheet-import-button:active {
  transform: translateY(0);
}

.export-icon,
.import-icon {
  font-size: 1.1rem;
}

.import-feedback {
  margin-top: 0.5rem;
  padding: 0.5rem;
  border-radius: 20px;
  text-align: center;
  font-family: 'Crimson Text', serif;
  font-weight: 600;
  animation: fadeInOut 2s ease forwards;
}

.import-feedback.success {
  background: rgba(46, 125, 50, 0.2);
  border: 1px solid #2e7d32;
  color: #81c784;
}

.import-feedback.error {
  background: rgba(192, 57, 43, 0.2);
  border: 1px solid #c0392b;
  color: #e74c3c;
}

/* Responsivo*/
@media (max-width: 480px) {
  .sheet-export-import-buttons {
    flex-direction: row;
    gap: 0.5rem;
  }
  
  .sheet-export-button,
  .sheet-import-button {
    padding: 0.6rem 0.3rem;
    font-size: 0.8rem;
    gap: 0.3rem;
  }
  
  .export-icon,
  .import-icon {
    font-size: 1rem;
  }
}

@media (max-width: 360px) {
  .sheet-export-button,
  .sheet-import-button {
    padding: 0.5rem 0.2rem;
    font-size: 0.75rem;
  }
  
  .export-icon,
  .import-icon {
    font-size: 0.9rem;
  }
}

/* =========================
   Botão Salvar na Área do Jogador
========================= */

.sheet-save-section {
  margin: 1rem 0;
  position: relative;
}

.sheet-save-button {
  width: 100%;
  padding: 0.9rem;
  background: linear-gradient(135deg, var(--gold) 0%, #b8860b 100%);
  border: none;
  border-radius: 30px;
  color: #1a1a1a;
  font-weight: bold;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Cinzel', serif;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
  -webkit-tap-highlight-color: transparent;
}

.sheet-save-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(212, 175, 55, 0.4);
}

.sheet-save-button:active {
  transform: translateY(0);
}

.save-icon {
  font-size: 1.2rem;
}

.save-feedback {
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: rgba(46, 125, 50, 0.2);
  border: 1px solid #2e7d32;
  border-radius: 20px;
  color: #81c784;
  text-align: center;
  font-family: 'Crimson Text', serif;
  font-weight: 600;
  animation: fadeInOut 2s ease forwards;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translateY(-10px); }
  10% { opacity: 1; transform: translateY(0); }
  90% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-10px); }
}

/* Feedback de erro */
.save-feedback.error {
  background: rgba(192, 57, 43, 0.2);
  border-color: #c0392b;
  color: #e74c3c;
}

/* =========================
   BOTÃO LIMPAR
========================= */
.sheet-clear-button {
  width: 100%;
  padding: 0.7rem;
  background: transparent;
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 20px;
  color: var(--text, #f0f0f0);
  font-weight: bold;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Cinzel', serif;
  margin-top: 0.5rem;
  -webkit-tap-highlight-color: transparent;
}

.sheet-clear-button:hover {
  background: rgba(212, 175, 55, 0.1);
  border-color: var(--gold, #d4af37);
}

.clear-confirmation {
  margin-top: 1rem;
  padding: 0.8rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(212, 175, 55, 0.15);
  border-radius: 12px;
}

.clear-confirmation p {
  color: var(--gold, #d4af37);
  font-family: 'Cinzel', serif;
  text-align: center;
  margin-bottom: 0.8rem;
  font-size: 0.9rem;
}

.clear-actions {
  display: flex;
  gap: 0.6rem;
}

.clear-actions button {
  flex: 1;
  padding: 0.5rem;
  background: transparent;
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 20px;
  color: var(--text, #f0f0f0);
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.85rem;
  -webkit-tap-highlight-color: transparent;
}

.clear-actions button:hover {
  background: rgba(212, 175, 55, 0.1);
}

.clear-actions .danger {
  background: rgba(192, 57, 43, 0.2);
  border-color: #c0392b;
  color: #c0392b;
}

.clear-actions .danger:hover {
  background: rgba(192, 57, 43, 0.3);
}

/* =========================
   SCROLLBAR
========================= */
.sheet-content::-webkit-scrollbar {
  width: 6px;
}

.sheet-content::-webkit-scrollbar-track {
  background: rgba(212, 175, 55, 0.1);
  border-radius: 10px;
}

.sheet-content::-webkit-scrollbar-thumb {
  background: var(--gold, #d4af37);
  border-radius: 10px;
}

/* =========================
   RESPONSIVIDADE
========================= */
@media (max-width: 500px) {
  .sheet-header h2 {
    font-size: 1.1rem;
  }
  
  .attributes-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.2rem;
  }
  
  .sheet-row--vitals {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .sheet-textarea--notas {
    min-height: 70px;
  }
  
  .panel-row {
    flex-direction: column;
    gap: 0.6rem;
  }
  
  .panel-row--xp, .panel-row--limits {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .panel-row--triple {
  flex-direction: row;
  flex-wrap: nowrap;
  }
  
  .panel-row--triple .sheet-field--third {
  min-width: 0;
  }
  
  .clear-actions {
    flex-direction: column;
  }
  
  .sheet-tabs {
    gap: 0.2rem;
  }
  
  .sheet-tab {
    font-size: 0.6rem;
    padding: 0.5rem 0.2rem;
  }

  .vitals-input {
    width: 2.8rem;
    min-width: 2.8rem;
    font-size: 0.85rem;
  }
  
  .vitals-label {
    width: 2.2rem;
    font-size: 0.9rem;
  }
}

@media (max-height: 700px) {
  .sheet-content {
    padding: 1rem;
  }
  
  .sheet-header-fixed {
    padding: 0.6rem;
    margin-bottom: 0.8rem;
  }
  
  .sheet-tabs {
    margin: 1rem 0 0.6rem;
  }
  
  .sheet-textarea {
    min-height: 60px;
  }

  .sheet-textarea--notas {
    min-height: 60px;
  }
  
  .panel-row {
    margin-bottom: 0.6rem;
  }
}