/* Disponível e Indisponível (lógica em scripts/features/availability.js). */
body[data-design] .choices.av-workspace {
  --av-height: clamp(400px, calc(100dvh - 150px), 900px);
  display: block;
  width: 100%;
  max-width: none;
  margin: 0;
}

body.training-fullscreen .choices.av-workspace {
  --av-height: calc(100dvh - 24px);
}

body[data-design] .av-page {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  height: var(--av-height);
}

body[data-design] .av-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
}

body.training-fullscreen .av-tools,
body.app-locked .av-tools {
  display: none;
}

body.training-fullscreen .av-page,
body.app-locked .av-page {
  grid-template-rows: minmax(0, 1fr);
}

body[data-design] .av-edit-button {
  min-height: 44px;
  padding: 8px 18px;
  border: 2px solid #1f2937;
  border-radius: 999px;
  background: #fff;
  color: #1f2937;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

body[data-design] .av-edit-button.is-active {
  background: #1f2937;
  color: #fff;
}

body[data-design] .av-hint {
  color: #475569;
  font-weight: 800;
}

/* Os dois quadros lado a lado, ocupando a tela toda. */
body[data-design] .av-boards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(10px, 1.6vw, 20px);
  min-height: 0;
}

body[data-design] .av-board {
  --av-color: #16a34a;
  --av-dark: #15803d;
  --av-light: #dcfce7;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
  min-height: 0;
  padding: clamp(10px, 1.4vw, 18px);
  border: 6px solid var(--av-dark);
  border-radius: 24px;
  background: var(--av-color);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
}

body[data-design] .av-board.is-red {
  --av-color: #dc2626;
  --av-dark: #991b1b;
  --av-light: #fee2e2;
}

body[data-design] .av-board header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

body[data-design] .av-board h3 {
  margin: 0;
  color: #fff;
  font-size: clamp(1.3rem, 2.6vw, 2.2rem);
  font-weight: 900;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
}

body[data-design] .av-badge {
  display: grid;
  width: clamp(44px, 5vw, 64px);
  aspect-ratio: 1;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.2));
}

body[data-design] .av-badge svg {
  width: 100%;
  height: 100%;
}

body[data-design] .av-grid {
  display: grid;
  grid-template-columns: repeat(var(--av-columns, 3), minmax(0, 1fr));
  grid-template-rows: repeat(var(--av-rows, 2), minmax(0, 1fr));
  gap: clamp(8px, 1.2vw, 14px);
  min-height: 0;
}

/* Células. */
body[data-design] .av-cell {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  justify-items: center;
  align-items: center;
  gap: 4px;
  min-width: 0;
  min-height: 0;
  padding: 8px;
  border: 0;
  border-radius: 16px;
  background: #fff;
  color: #1f2937;
  font: inherit;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.25s ease, box-shadow 0.25s ease, filter 0.3s ease, opacity 0.3s ease;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

body[data-design] .av-cell.is-blank {
  background: rgba(255, 255, 255, 0.16);
  box-shadow: none;
  cursor: default;
}

body[data-design] .av-cell.is-empty {
  grid-template-rows: auto auto;
  align-content: center;
  border: 3px dashed rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.18);
  box-shadow: none;
  color: #fff;
}

body[data-design] .av-cell.is-empty b {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
}

body[data-design] .av-cell.is-empty small {
  font-weight: 900;
}

body[data-design] .av-picture {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
}

body[data-design] .av-picture img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

body[data-design] .av-cell strong {
  max-width: 100%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: clamp(0.78rem, 1.3vw, 1.05rem);
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
}

/* Indisponível: cinza e sem toque (no editar continua colorido para arrumar). */
body[data-design] .av-workspace:not(.is-editing) .av-board.is-red .av-cell.is-filled {
  filter: grayscale(1);
  opacity: 0.6;
  cursor: not-allowed;
}

body[data-design] .av-cell.is-blocked {
  animation: av-shake 0.4s ease;
}

body[data-design] .av-timer {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #1f2937;
  color: #fff;
  font-size: clamp(0.75rem, 1.3vw, 0.95rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

body[data-design] .av-edit-mark {
  position: absolute;
  top: 6px;
  left: 8px;
  color: #64748b;
  font-weight: 900;
}

/* Escolhida no verde: cresce e fica em destaque. */
body[data-design] .av-cell.is-chosen {
  z-index: 2;
  transform: scale(1.12);
  box-shadow: 0 0 0 6px #fde047, 0 12px 26px rgba(0, 0, 0, 0.3);
  animation: av-chosen 0.45s ease;
}

/* Acabou de ficar disponível: entra pulando e brilhando. */
body[data-design] .av-cell.is-arriving {
  animation: av-arrive 1.4s ease;
}

@keyframes av-shake {
  0%, 100% { translate: 0 0; }
  25% { translate: -6px 0; }
  50% { translate: 6px 0; }
  75% { translate: -3px 0; }
}

@keyframes av-chosen {
  0% { transform: scale(1); }
  60% { transform: scale(1.18); }
  100% { transform: scale(1.12); }
}

@keyframes av-arrive {
  0% { transform: translateX(60%) scale(0.3) rotate(-12deg); opacity: 0; box-shadow: 0 0 0 0 rgba(253, 224, 71, 0.9); }
  45% { transform: scale(1.18) rotate(4deg); opacity: 1; box-shadow: 0 0 0 14px rgba(253, 224, 71, 0.7); }
  70% { transform: scale(0.96); box-shadow: 0 0 0 6px rgba(253, 224, 71, 0.5); }
  100% { transform: scale(1); box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18); }
}

/* Janela de opções (menu da figura e tempo). */
.av-overlay {
  position: fixed;
  inset: 0;
  z-index: 340;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.45);
}

.av-dialog {
  display: grid;
  gap: 14px;
  width: min(460px, 100%);
  padding: 20px;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
}

.av-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.av-dialog h3 {
  margin: 0;
  color: #1f2937;
  font-size: 1.25rem;
  font-weight: 900;
}

.av-dialog-close {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: #eef2f7;
  font-size: 1.6rem;
  cursor: pointer;
}

.av-dialog-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}

.av-dialog-options button {
  min-height: 48px;
  padding: 8px 12px;
  border: 2px solid #dbe4ee;
  border-radius: 14px;
  background: #fff;
  color: #1f2937;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.av-dialog-options button.is-selected {
  border-color: #18a9ea;
  background: #e8f6fd;
}

.av-dialog-options button.is-danger {
  color: #b91c1c;
}

/* Em pé: um quadro embaixo do outro. */
@media (orientation: portrait) {
  body[data-design]:not(.training-fullscreen) .choices.av-workspace {
    --av-height: clamp(460px, calc(100dvh - 330px), 900px);
  }

  body[data-design] .av-boards {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  body[data-design] .av-cell,
  body[data-design] .av-cell.is-chosen,
  body[data-design] .av-cell.is-arriving,
  body[data-design] .av-cell.is-blocked { animation: none; transition: none; }
}

/* Tela cheia: os botões de sair e travar (canto de cima, à direita) ficam mais transparentes. */
body.training-fullscreen[data-active-module="availability"] .utility-actions {
  border-color: transparent;
  background: rgba(255, 255, 255, 0.35);
  box-shadow: none;
  opacity: 0.45;
  transition: opacity 0.2s ease;
}

body.training-fullscreen[data-active-module="availability"] .utility-actions:active {
  opacity: 0.9;
}
