/* Quiz Mobile-First CSS */
:root {
  --primary: #3a54a9;
  --primary-dark: #2b3a65;
  --secondary: #ff5722;
  --success: #4caf50;
  --danger: #f44336;
  --warning: #ff9800;
  --info: #2196f3;
  --dark: #1e2236;
  --light: #f8f9fa;
  --gray: #adb5bd;
  --white: #ffffff;
  
  --border-radius: 12px;
  --box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Roboto', sans-serif;
  background: url('../img/uti_back.jpg') no-repeat center center fixed;
  background-size: cover;
  color: var(--light);
  line-height: 1.6;
  overflow-x: hidden;
  position: relative;
}

body::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(30, 34, 54, 0.85);
  z-index: -1;
}

/* Containers */
.app-container {
  width: 100%;
  height: 100vh; /* Altura fixa para evitar rolagem */
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Impede rolagem */
}

.game-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0.5rem;
  transition: var(--transition);
  overflow: hidden; /* Impede rolagem */
  height: 100%; /* Usa todo o espaço disponível */
  position: relative; /* Para posicionamento absoluto de elementos filhos */
}

/* Layout principal com flexbox para garantir compatibilidade com a estrutura HTML */
.main-content {
  display: flex;
  flex-direction: row;
  gap: 0.75rem;
  height: calc(100vh - 140px); /* Altura que ocupa quase toda a tela, deixando espaço para header e tools-bar */
  margin-bottom: 1rem; /* Espaço acima da barra de ferramentas */
}

.stage-info {
  flex: 0.55; /* 55% da largura - aumentado */
  background-color: var(--primary-dark);
  border-radius: var(--border-radius);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  height: 100%; /* Ocupa toda a altura disponível */
  font-size: 0.9rem;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Header */
.header {
  background-color: rgba(30, 34, 54, 0.95);
  background-image: linear-gradient(to right, rgba(30, 34, 54, 0.95), rgba(40, 44, 74, 0.95));
  padding: 0.5rem;
  border-radius: var(--border-radius);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  z-index: 10;
  margin-bottom: 0.75rem;
}

.stats-container {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.25rem;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--white);
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.stat-item i {
  color: var(--secondary);
  font-size: 0.9rem;
}

/* Stage Info - Estilos de background já definidos acima */
.stage-description {
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--white);
  background-color: rgba(0, 0, 0, 0.15);
  padding: 0.5rem;
  border-radius: var(--border-radius);
  border-left: 3px solid var(--secondary);
}

.stage-description p:last-child {
  font-weight: 600;
  color: var(--secondary-light);
  margin-top: 0.5rem;
}

.stage-number {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--white);
  background-color: var(--secondary);
  display: inline-block;
  padding: 0.3rem 0.8rem;
  border-radius: 2rem;
  margin-bottom: 0.5rem;
  align-self: flex-start;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.stage-description {
  font-size: 0.95rem;
  line-height: 1.2;
  font-weight: 300;
}

/* Options Area */
.options-area {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#options-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  background-color: rgba(30, 34, 54, 0.4); /* Mais sutil */
  border-radius: var(--border-radius);
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.08); /* Sombra mais sutil */
  margin-bottom: 0.5rem;
  padding: 0.5rem;
  flex: 1;
  overflow-y: auto;
  /* max-height: calc(100% - 100px); */
}

.option-card {
  background-color: rgba(255, 255, 255, 0.05);
  border: 2px solid transparent;
  border-radius: var(--border-radius);
  padding: 0.75rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 100px;
}

.option-card:hover, .option-card:focus {
  background-color: rgba(255, 255, 255, 0.1);
  transform: translateY(-3px);
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3);
  border-color: var(--secondary-light);
  background-color: rgba(40, 44, 64, 0.95);
}

.option-card.selected {
  border-color: var(--secondary);
  background-color: rgba(58, 84, 169, 0.2);
  box-shadow: 0 0 0 2px var(--secondary), 0 5px 10px rgba(0, 0, 0, 0.3);
  transform: translateY(-3px);
}

.option-card img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.option-card-title {
  font-size: 0.85rem;
  font-weight: 500;
}

/* Sub-options */
.sub-options-container {
  display: none;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: var(--border-radius);
  padding: 0.75rem;
  border-left: 3px solid var(--secondary);
}

.sub-options-container.active {
  display: block;
  animation: fadeIn 0.3s ease-in-out;
}

.sub-option {
  background-color: rgba(30, 34, 54, 0.95);
  border-radius: var(--border-radius);
  padding: 0.9rem 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  margin-bottom: 0.5rem;
}

.sub-option:hover, .sub-option:focus {
  background-color: rgba(255, 255, 255, 0.15);
}

.sub-option.selected {
  background-color: rgba(58, 84, 169, 0.2);
  border-left: 3px solid var(--primary);
}

/* Action Bar - Posicionada ao lado do stage-info, mais sutil */
.action-bar {
  flex: 0.45; /* 45% da largura - reduzido */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background-color: rgba(30, 34, 54, 0.85); /* Mais transparente */
  padding: 0.5rem;
  border-radius: var(--border-radius);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15); /* Sombra mais sutil */
  height: 100%; /* Ocupa toda a altura disponível */
  overflow-y: auto; /* Permite rolagem se necessário */
}

.selected-answers {
  margin-bottom: 0.5rem;
  background-color: rgba(255, 255, 255, 0.05); /* Mais sutil */
  border-radius: var(--border-radius);
  padding: 0.4rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-height: 2.5rem; /* Altura mínima fixa */
  max-height: 10%; /* Reduzido para 10% */
  overflow-y: auto;
  font-size: 0.85rem;
}

.action-buttons {
  width: 100%;
}

.confirm-btn {
  width: 100%;
}

.action-buttons {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.action-label {
  font-size: 0.85rem;
  color: var(--secondary-light);
  font-weight: 500;
}

.confirm-btn {
  background-color: var(--success);
  background-image: linear-gradient(to right, var(--success), #4CAF50);
  color: var(--white);
  border: none;
  border-radius: var(--border-radius);
  padding: 0.5rem 1rem; /* Ainda mais compacto */
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem; /* Reduzido */
  letter-spacing: 0.5px;
  transition: var(--transition);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15); /* Sombra mais sutil */
  text-transform: uppercase;
  margin-top: 0;
  flex: 0 0 auto;
}

.confirm-btn:hover, .confirm-btn:focus {
  background-image: linear-gradient(to right, #4CAF50, var(--success));
  transform: translateY(-2px);
  box-shadow: 0 6px 8px rgba(0, 0, 0, 0.3);
}

.confirm-btn:active {
  transform: translateY(1px);
}

.selected-answers {
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius);
  padding: 0.5rem;
  max-width: 60%;
  overflow-x: auto;
  white-space: nowrap;
  font-size: 0.8rem;
}

.selected-answer-chip {
  display: inline-block;
  background-color: var(--primary);
  color: var(--white);
  padding: 0.25rem 0.5rem;
  border-radius: 20px;
  margin-right: 0.35rem;
  font-size: 0.75rem;
}

/* Tools Bar */
.tools-bar {
  display: flex;
  justify-content: space-around;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 0.5rem 0.5rem;
  background-color: rgba(30, 34, 54, 0.95);
  border-radius: var(--border-radius) var(--border-radius) 0 0;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
  height: 60px; /* Altura fixa para garantir espaço consistente */
}

.tool-button {
  background-color: #5a4ab8;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 12px;
  min-width: 90px;
  max-width: 150px;
  width: auto;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: var(--transition);
  padding: 0.5rem 0.5rem;
  gap: 6px;
  box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: visible;
}

.tool-button:hover, .tool-button:focus {
  background-color: #46379b;
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 5px 8px rgba(0, 0, 0, 0.3);
}

.tool-button:hover::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 70%);
  opacity: 0;
  animation: pulse 1.5s ease-out;
}

@keyframes pulse {
  0% { opacity: 0.7; transform: scale(0.5); }
  100% { opacity: 0; transform: scale(1.5); }
}

@keyframes neon-breathing {
  0% { opacity: 0.4; box-shadow: 0 0 5px rgba(72, 58, 160, 0.4), 0 0 10px rgba(72, 58, 160, 0.2); }
  50% { opacity: 0.8; box-shadow: 0 0 10px rgba(72, 58, 160, 0.7), 0 0 20px rgba(72, 58, 160, 0.5); }
  100% { opacity: 0.4; box-shadow: 0 0 5px rgba(72, 58, 160, 0.4), 0 0 10px rgba(72, 58, 160, 0.2); }
}

.tool-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 12px;
  background-color: rgba(72, 58, 160, 0.15);
  z-index: -1;
  animation: neon-breathing 3s ease-in-out infinite;
}

.tool-button::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: 12px;
  border: 1px solid rgba(72, 58, 160, 0.6);
  z-index: -2;
  filter: blur(1px);
  animation: neon-breathing 3s ease-in-out infinite reverse;
  animation-delay: -1.5s;
}

.tool-button {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  padding: 0.5rem;
  gap: 6px;
}

.tool-button img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex-shrink: 0;
}

.tool-button-title {
  font-size: 0.65rem;
  font-weight: 300;
  color: #ffffff;
  text-align: center;
  line-height: 1.1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  white-space: normal;
  overflow-wrap: break-word;
  word-break: keep-all;
  max-width: 100%;
}

#sound-icon {
  color: #ffffff;
  font-size: 24px;
}

.success-message {
  text-align: center;
  padding: 10px;
  background-color: rgba(72, 58, 160, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  margin: 5px 0;
}

.success-message p {
  margin: 5px 0;
  font-size: 1rem;
  color: #ffffff;
}

.success-message strong {
  color: #ffffff;
  font-weight: 700;
}

/* Estilos específicos para o modal de vitória */
#victory-modal .modal-content {
  border: 3px solid #483AA0;
  box-shadow: 0 0 20px rgba(72, 58, 160, 0.7);
}

#victory-modal .modal-header {
  background-color: rgba(72, 58, 160, 0.2);
}

#victory-modal .modal-header i {
  animation: pulse-award 2s infinite;
}

@keyframes pulse-award {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 450px;
  background-color: var(--dark);
  border-radius: var(--border-radius);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  z-index: 101;
  overflow: hidden;
  display: none;
}

.modal-header {
  padding: 1rem;
  background-color: var(--primary-dark);
  color: var(--white);
  text-align: center;
}

.modal-header h2 {
  font-size: 1.25rem;
  margin: 0;
}

.modal-body {
  padding: 1.5rem;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 1rem;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  background-color: rgba(0, 0, 0, 0.1);
}

.modal-btn {
  padding: 0.6rem 1.2rem;
  border-radius: var(--border-radius);
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.modal-btn-primary {
  background-color: var(--primary);
  color: var(--white);
}

.modal-btn-primary:hover, .modal-btn-primary:focus {
  background-color: var(--primary-dark);
}

.modal-btn-success {
  background-color: var(--success);
  color: var(--white);
}

.modal-btn-success:hover, .modal-btn-success:focus {
  background-color: #3d8b40;
}

.modal-btn-danger {
  background-color: var(--danger);
  color: var(--white);
}

.modal-btn-danger:hover, .modal-btn-danger:focus {
  background-color: #d32f2f;
}

.modal-btn-secondary {
  background-color: #483AA0;
  color: var(--white);
  border: 1px solid white;
  box-shadow: 0 0 10px rgba(72, 58, 160, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.modal-btn-secondary:hover, .modal-btn-secondary:focus {
  background-color: #5B4BC2;
  box-shadow: 0 0 15px rgba(72, 58, 160, 0.9);
}

/* Video Modal */
.video-modal .modal-body {
  padding: 0;
}

.video-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.video-container video {
  width: 100%;
  max-height: 55vh; /* Mantendo o ajuste anterior para vídeos de monitor cardíaco */
  object-fit: contain;
  display: block;
  margin-bottom: 10px; /* Espaço reduzido entre vídeo e botão conforme solicitado */
}

/* Feedback Modals */
.correct-modal .modal-header {
  background-color: var(--success);
}

.incorrect-modal .modal-header {
  background-color: var(--danger);
}

/* Welcome Screen */
.welcome-modal {
  text-align: center;
}

.welcome-modal .modal-body {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: center;
  padding: 0.5rem;
}

.welcome-modal h1 {
  color: var(--white);
  font-size: 1.5rem;
  margin: 0;
  line-height: 1.1;
}

.welcome-modal p {
  color: var(--light);
  opacity: 0.9;
  margin: 0;
  padding: 0;
  line-height: 1.2;
}

.name-input {
  width: 100%;
  padding: 0.5rem;
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--light);
  margin-top: 0.2rem;
  font-size: 1rem;
}

.name-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(58, 84, 169, 0.2);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.fade-in {
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes slideInUp {
  from {
    transform: translate(-50%, 10%);
    opacity: 0;
  }
  to {
    transform: translate(-50%, -50%);
    opacity: 1;
  }
}

.slide-in-up {
  animation: slideInUp 0.1s ease-out;
}

@keyframes slideOutDown {
  0% {
    transform: translate(-50%, -50%);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, 10%);
    opacity: 0;
  }
}

.slide-out-down {
  animation: slideOutDown 0.2s ease-out forwards;
}

/* Estilo para o aviso flutuante de pontuação */
.floating-score {
  position: fixed;
  top: 70px;
  right: 20px;
  font-size: 2.5rem;
  font-weight: bold;
  color: #ff3b30;
  background-color: rgba(0, 0, 0, 0.6);
  padding: 10px 15px;
  border-radius: 10px;
  z-index: 9999;
  opacity: 0;
  transform: translateY(-20px);
  pointer-events: none;
}

/* Estilos para o lightbox */
.lightbox {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  z-index: 10000;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.lightbox.active {
  display: flex;
}

.lightbox-content {
  max-width: 90%;
  max-height: 90vh;
  position: relative;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.lightbox-close {
  position: absolute;
  top: -20px;
  right: -20px;
  width: 40px;
  height: 40px;
  background-color: #ff3b30;
  color: white;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 20px;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

@keyframes floatingScoreAnimation {
  0% {
    opacity: 0;
    transform: translateY(-20px) scale(0.8);
  }
  20% {
    opacity: 1;
    transform: translateY(0) scale(1.2);
  }
  80% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(20px) scale(0.8);
  }
}

.floating-score.show {
  animation: floatingScoreAnimation 1.5s ease-in-out forwards;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.pulse {
  animation: pulse 2s infinite;
}

/* Device Orientation Message */
.orientation-message {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--dark);
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  text-align: center;
  padding: 2rem;
}

.orientation-message img {
  width: 64px;
  height: 64px;
  margin-bottom: 1.5rem;
  animation: rotate 2s infinite ease-in-out;
}

@keyframes rotate {
  0% { transform: rotate(0deg); }
  50% { transform: rotate(90deg); }
  100% { transform: rotate(0deg); }
}

.orientation-message h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.orientation-message p {
  font-size: 1rem;
  max-width: 80%;
  margin: 0 auto;
}

/* Responsive Adjustments */
@media (min-width: 768px) {
  .stage-info {
    max-width: 40%;
  }
  
  .options-area {
    flex: 2;
  }
  
  .options-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
  
  .stat-item {
    font-size: 0.9rem;
  }
  
  .modal {
    max-width: 600px;
  }
  
  .main-content {
    margin-bottom: 1rem; /* Menos espaço necessário em telas maiores */
  }
}

@media (min-width: 1024px) {
  .game-container {
    padding: 1.5rem;
  }
  
  .options-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
  
  .option-card img {
    width: 38px;
    height: 38px;
  }
  
  .option-card-title {
    font-size: 0.5rem;
    font-weight: normal;
  }
  
  .modal {
    max-width: 700px;
  }
}
