/* Estilos para o Modal de Execução de Treino */

/* Botão compacto - mesmo tamanho do botão Executar das fichas */
.btn-complete-set-compact {
  padding: 0.15rem 0.35rem !important;
  height: 28px !important;
  min-height: 28px !important;
  line-height: 1 !important;
  border-radius: 5px !important;
  font-size: 0.8rem !important;
}

.btn-complete-set-compact i {
  font-size: 0.75rem !important;
}

.exercise-card {
  transition: all 0.3s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  border-radius: 8px !important;
  overflow: hidden;
  background: linear-gradient(to bottom, #ffffff 0%, #fafafa 100%);
  border-left: 4px solid #e5e7eb !important;
}

.exercise-card.border-primary {
  box-shadow: 0 4px 12px rgba(13, 110, 253, 0.2), 0 2px 4px rgba(13, 110, 253, 0.1);
  transform: translateY(-2px);
  border-left: 4px solid #0d6efd !important;
  border-top: 1px solid #0d6efd !important;
  border-right: 1px solid #0d6efd !important;
  border-bottom: 1px solid #0d6efd !important;
  background: linear-gradient(to bottom, #f0f7ff 0%, #e7f1ff 100%);
}

.exercise-card.border-success {
  background: linear-gradient(to bottom, #f0fdf4 0%, #dcfce7 100%);
  box-shadow: 0 3px 8px rgba(25, 135, 84, 0.15);
  border-left: 4px solid #198754 !important;
  border-top: 1px solid #198754 !important;
  border-right: 1px solid #198754 !important;
  border-bottom: 1px solid #198754 !important;
}

.exercise-card.border-light {
  border-left: 4px solid #d1d5db !important;
}

.exercise-card .card-body {
  background: transparent;
}

.rest-timer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.rest-timer .display-4 {
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.rest-timer .progress {
  width: 300px;
  background-color: rgba(255, 255, 255, 0.2);
}

.rest-timer .btn {
  min-width: 60px;
}

/* ===== BOTTOM SHEET COMPONENT ===== */

.bottom-sheet-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bottom-sheet-overlay.show {
  opacity: 1;
  visibility: visible;
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10001;
  max-height: 80vh;
  overflow: hidden;
}

.bottom-sheet.show {
  transform: translateY(0);
}

.bottom-sheet-handle {
  width: 40px;
  height: 4px;
  background: #ddd;
  border-radius: 2px;
  margin: 12px auto 8px;
  cursor: grab;
}

.bottom-sheet-handle:active {
  cursor: grabbing;
}

.bottom-sheet-header {
  padding: 16px 24px 8px;
  border-bottom: 1px solid #eee;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}

.bottom-sheet-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  color: #333;
}

.bottom-sheet-subtitle {
  font-size: 0.9rem;
  color: #666;
  margin: 4px 0 0;
}

.bottom-sheet-content {
  padding: 24px;
  max-height: calc(80vh - 120px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.bottom-sheet-actions {
  padding: 16px 24px 24px;
  display: flex;
  gap: 12px;
  position: sticky;
  bottom: 0;
  background: white;
  border-top: 1px solid #eee;
}

/* Campos de input otimizados para mobile */
.input-group-mobile {
  margin-bottom: 20px;
}

.input-label-mobile {
  display: block;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.input-control-mobile {
  display: flex;
  align-items: center;
  background: #f8f9fa;
  border: 2px solid #e9ecef;
  border-radius: 12px;
  padding: 4px;
  transition: all 0.2s ease;
  position: relative;
}

.input-control-mobile:hover {
  border-color: rgba(13, 110, 253, 0.4);
  background: #fff;
  box-shadow: 0 2px 8px rgba(13, 110, 253, 0.1);
}

.input-control-mobile:focus-within {
  border-color: #0d6efd;
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.1);
  background: #fff;
}

.input-mobile {
  flex: 1;
  border: 2px solid transparent;
  background: rgba(13, 110, 253, 0.05);
  padding: 12px 16px;
  font-size: 1.1rem;
  font-weight: 500;
  text-align: center;
  color: #333;
  outline: none;
  min-width: 0;
  border-radius: 8px;
  cursor: text;
  transition: all 0.2s ease;
  
  /* CRÍTICO: Permitir seleção e edição */
  user-select: text !important;
  -webkit-user-select: text !important;
  -moz-user-select: text !important;
  -ms-user-select: text !important;
  
  /* CRÍTICO: Comportamento touch no mobile */
  -webkit-tap-highlight-color: rgba(13, 110, 253, 0.3);
  touch-action: manipulation;
  pointer-events: auto;
  
  /* CRÍTICO: Garantir que é editável */
  -webkit-appearance: none;
  -moz-appearance: textfield;
  appearance: none;
  
  /* Prevenir zoom no iOS */
  font-size: max(16px, 1.1rem);
}

/* Remover spinner de number input no Chrome/Safari/Edge */
.input-mobile::-webkit-outer-spin-button,
.input-mobile::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.input-mobile:hover {
  background: rgba(13, 110, 253, 0.1);
  border-color: rgba(13, 110, 253, 0.3);
  transform: scale(1.02);
  cursor: pointer;
}

.input-mobile:active {
  transform: scale(0.98);
  background: rgba(13, 110, 253, 0.15);
}

.input-mobile:focus {
  outline: none;
  background: #fff;
  border-color: #0d6efd;
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
  cursor: text;
  transform: scale(1);
  
  /* Garantir que o teclado apareça */
  -webkit-user-select: text !important;
  user-select: text !important;
}

/* Indicador visual de que o campo é editável */
.input-mobile::placeholder {
  color: #6c757d;
  opacity: 0.6;
  font-style: italic;
}

/* Ajustes específicos para mobile */
@media (max-width: 768px) {
  .input-mobile {
    /* Garantir tamanho mínimo para não dar zoom no iOS */
    font-size: 16px !important;
    min-height: 48px;
    
    /* Melhorar touch target */
    padding: 14px 16px;
  }
  
  .input-control-mobile {
    /* Garantir que o container não interfira */
    pointer-events: none;
  }
  
  .input-mobile,
  .btn-stepper {
    /* Apenas os elementos interativos devem receber eventos */
    pointer-events: auto;
  }
}

/* Botões stepper */
.btn-stepper {
  width: 44px;
  height: 44px;
  border: none;
  background: #0d6efd;
  color: white;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: bold;
  touch-action: manipulation;
  transition: all 0.2s;
}

.btn-stepper:hover {
  background: #0b5ed7;
  transform: scale(1.05);
}

.btn-stepper:active {
  transform: scale(0.95);
}

.btn-stepper:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}

/* Botões de ação principais */
.btn-bottom-sheet {
  flex: 1;
  padding: 14px 20px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 1rem;
  border: none;
  transition: all 0.2s;
  touch-action: manipulation;
}

.btn-bottom-sheet-primary {
  background: #0d6efd;
  color: white;
}

.btn-bottom-sheet-primary:hover {
  background: #0b5ed7;
  transform: translateY(-1px);
}

.btn-bottom-sheet-secondary {
  background: #f8f9fa;
  color: #495057;
  border: 2px solid #e9ecef;
}

.btn-bottom-sheet-secondary:hover {
  background: #e9ecef;
}

/* Valores sugeridos */
.suggested-values {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.suggested-value {
  background: #e7f3ff;
  color: #0d6efd;
  border: 1px solid #b8daff;
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.suggested-value:hover {
  background: #0d6efd;
  color: white;
}

/* Preview da série */
.serie-preview {
  background: #f8f9fa;
  border: 2px dashed #dee2e6;
  border-radius: 12px;
  padding: 16px;
  margin: 16px 0;
  text-align: center;
}

.serie-preview-title {
  font-weight: 600;
  color: #495057;
  margin-bottom: 8px;
}

.serie-preview-content {
  font-size: 1.1rem;
  color: #0d6efd;
  font-weight: 600;
}

/* Responsividade */
@media (max-width: 576px) {
  .exercise-card .row.text-center > div {
    font-size: 0.85rem;
  }

  .rest-timer .progress {
    width: 250px;
  }

  .rest-timer .display-4 {
    font-size: 2.5rem;
  }

  .bottom-sheet {
    border-radius: 16px 16px 0 0;
  }

  .bottom-sheet-content {
    padding: 20px;
  }

  .input-mobile {
    font-size: 1.2rem;
  }
}

/* Modal fullscreen em mobile */
@media (max-width: 575.98px) {
  .modal-dialog.modal-fullscreen-sm-down {
    width: 100vw;
    height: 100vh;
    margin: 0;
    max-width: none;
  }

  .modal-dialog.modal-fullscreen-sm-down .modal-content {
    height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .modal-dialog.modal-fullscreen-sm-down .modal-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Animações */
@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

.exercise-card.border-primary .btn-success {
  animation: pulse 2s infinite;
}

.badge {
  font-size: 0.7em;
}

/* === Formulário de Edição de Exercício === */
.edit-exercise-form {
  padding: 0;
}

.exercise-edit-field {
  margin-bottom: 20px;
}

.exercise-edit-field label {
  display: block;
  font-weight: 600;
  color: #495057;
  margin-bottom: 8px;
  font-size: 0.9em;
}

.exercise-edit-field .input-stepper {
  display: flex;
  align-items: center;
  background: #f8f9fa;
  border: 2px solid #e9ecef;
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.exercise-edit-field .input-stepper:focus-within {
  border-color: #007bff;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.exercise-edit-field .input-stepper input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 16px;
  font-size: 1.1em;
  font-weight: 600;
  text-align: center;
  color: #495057;
  min-height: 56px;
}

.exercise-edit-field .input-stepper input:focus {
  outline: none;
}

.exercise-edit-field .btn-stepper,
.exercise-edit-field .stepper-btn {
  background: #007bff;
  border: none;
  color: white;
  width: 44px;
  height: 56px;
  font-size: 1.2em;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.exercise-edit-field .btn-stepper:hover,
.exercise-edit-field .stepper-btn:hover {
  background: #0056b3;
}

.exercise-edit-field .btn-stepper:active,
.exercise-edit-field .stepper-btn:active {
  background: #004494;
  transform: scale(0.95);
}

.exercise-edit-buttons {
  display: flex;
  gap: 12px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid #e9ecef;
}

.exercise-edit-buttons .btn {
  flex: 1;
  padding: 16px;
  font-weight: 600;
  border-radius: 12px;
  font-size: 1.1em;
  border: 2px solid transparent;
  transition: all 0.2s;
  min-height: 56px;
}

.exercise-edit-buttons .btn-secondary {
  background: #f8f9fa;
  color: #495057;
  border-color: #e9ecef;
}

.exercise-edit-buttons .btn-secondary:hover {
  background: #e9ecef;
  color: #495057;
}

.exercise-edit-buttons .btn-primary {
  background: #007bff;
  color: white;
}

.exercise-edit-buttons .btn-primary:hover {
  background: #0056b3;
}

.exercise-edit-buttons .btn:active {
  transform: scale(0.95);
}

/* Responsividade para telas menores */
@media (max-width: 768px) {
  .exercise-edit-field .input-stepper input {
    font-size: 1.2em;
    padding: 18px;
    min-height: 60px;
  }

  .exercise-edit-field .btn-stepper,
  .exercise-edit-field .stepper-btn {
    width: 48px;
    height: 60px;
    font-size: 1.3em;
  }

  .exercise-edit-buttons .btn {
    padding: 18px;
    font-size: 1.2em;
    min-height: 60px;
  }
}
