/* ================================================================= */
/* ============ VSWM – VISUOSPATIAL WORKING MEMORY – CSS =========== */
/* ================================================================= */

:root {
  --max-w: 1280px;
  --ar-w: 4;
  --ar-h: 3;

  /* Paleta */
  --wall:       #f2ede6;
  --floor:      #c8c4bc;
  --drawer-bg:  rgb(200, 210, 225);
  --drawer-border: rgba(255,255,255,0.95);
  --drawer-shine: rgba(255,255,255,0.55);
  --handle:     #c8a96e;
  --tray-bg:    #adb1b5;
  --tray-border:#8e9298;
  --tray-slot:  rgba(255,255,255,0.12);
  --teal:       #2a7a7b;
  --teal-light: #3a9a9b;
  --text:       #334155;
  --ok:         #2a9d8f;
  --radius:     20px;
  --shadow-lg:  0 20px 50px rgba(17,24,39,.18);
  --shadow-md:  0 10px 24px rgba(17,24,39,.12);
  --shadow-sm:  0 4px 12px rgba(17,24,39,.10);
}

/* ── Geral ──────────────────────────────────────────────────────── */
html, body {
  height: 100%; margin: 0;
  background: #e4dfd8;
  color: var(--text);
  font-family: system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}

/* ── Cena principal ─────────────────────────────────────────────── */
#scene {
  width: min(95vw, var(--max-w));
  aspect-ratio: var(--ar-w) / var(--ar-h);
  position: relative; border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-lg);
}

/* Parede + piso — split em 72% (parede cima, piso baixo) */
#scene::before {
  content: "";
  position: absolute; inset: 0;
  background:
    linear-gradient(to bottom, var(--wall) 0 72%, var(--floor) 72% 100%);
}

/* ── HUD / Título ───────────────────────────────────────────────── */
.hud {
  position: absolute; left: 0; right: 0; top: 0; z-index: 4;
  padding: 10px 16px; text-align: center;
  font-weight: 800; font-size: clamp(14px, 1.8vw, 22px);
  color: #4a5568;
  text-shadow: 0 1px 0 rgba(255,255,255,.8);
  letter-spacing: .04em;
}

/* ── Armário 4×4 ────────────────────────────────────────────────── */
#cabinet {
  position: absolute; z-index: 2;
  /* Maximizado — ocupa quase toda a cena */
  left: 3%; top: 5%; right: 3%; bottom: 22%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 6px;
}

/* ── Gaveta individual ──────────────────────────────────────────── */
.door {
  position: relative;
  border-radius: 12px;
  background: linear-gradient(160deg,
    rgb(230,235,243) 0%,
    rgb(185,198,215) 55%,
    rgb(155,170,195) 100%);
  border: 2.5px solid var(--drawer-border);
  box-shadow:
    inset 0 2px 6px rgba(255,255,255,0.6),
    inset 0 -2px 6px rgba(0,0,0,0.08),
    var(--shadow-sm);
  transform-style: preserve-3d;
  transition: transform .8s cubic-bezier(.2,.8,.2,1), box-shadow .8s ease;
  overflow: visible;
}

/* Reflexo / brilho diagonal na gaveta */
.door::before {
  content: "";
  position: absolute;
  top: 6%; left: 4%;
  width: 28%; height: 55%;
  background: linear-gradient(135deg,
    rgba(255,255,255,0.7) 0%,
    rgba(255,255,255,0.0) 100%);
  border-radius: 6px;
  transform: rotate(-12deg);
  pointer-events: none; z-index: 1;
}

/* Painel (frente da gaveta que abre) */
.door .panel {
  position: absolute; inset: 0;
  border-radius: 10px;
  background: linear-gradient(160deg,
    rgb(220,228,240) 0%,
    rgb(170,185,208) 100%);
  transform-origin: left center;
  backface-visibility: hidden;
  will-change: transform;
  transition: transform 1s ease-in-out;
  z-index: 2;
}

/* Puxador (handle) */
.door::after {
  content: "";
  position: absolute;
  right: 7px; top: 50%;
  width: 8px; height: 22px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #e8d0a0, var(--handle));
  box-shadow: 0 2px 4px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.5);
  z-index: 3;
}

/* O ID da célula (data-matrix-id) existe apenas como atributo interno
   para rastreamento de métricas — não é exibido ao usuário */

/* ── Animações de abertura/fechamento ───────────────────────────── */
.door.is-opening .panel {
  animation: panelOpen 0.8s cubic-bezier(.2,.8,.2,1) forwards;
}
.door.is-open .panel {
  transform: rotateY(-110deg);
}
.door.is-closing .panel {
  animation: panelClose 0.6s cubic-bezier(.2,.8,.2,1) forwards;
}

@keyframes panelOpen {
  0%   { transform: rotateY(0deg); }
  50%  { transform: rotateY(-55deg); }
  100% { transform: rotateY(-110deg); }
}
@keyframes panelClose {
  0%   { transform: rotateY(-110deg); }
  50%  { transform: rotateY(-55deg); }
  100% { transform: rotateY(0deg); }
}

/* ── Imagem revelada dentro da gaveta ──────────────────────────── */
.reveal-img {
  position: absolute; inset: 6%; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  background: white;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
}
.reveal-img img {
  width: 100%; height: 100%;
  object-fit: contain;
  border-radius: 4px;
  mix-blend-mode: normal;
}

/* Imagem colocada (after drag) – oculta quando porta fechada */
.placed-img {
  position: absolute !important;
  top: 50% !important; left: 50% !important;
  transform: translate(-50%,-50%) !important;
  width: 88% !important; height: 88% !important;
  display: flex !important;
  align-items: center !important; justify-content: center !important;
  pointer-events: none !important;
  z-index: 1 !important;
  visibility: hidden !important;
  opacity: 0 !important;
  transition: none !important;
  animation: none !important;
  background: white !important;
  border-radius: 8px !important;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.06) !important;
  padding: 6% !important;
  box-sizing: border-box !important;
}
.door.is-open .placed-img,
.door.is-opening .placed-img,
.door.is-closing .placed-img {
  visibility: visible !important;
  opacity: 1 !important;
}
.placed-img img {
  display: block !important;
  width: 100% !important; height: 100% !important;
  object-fit: contain !important;
  transform: none !important; opacity: 1 !important;
  visibility: visible !important;
  animation: none !important; transition: none !important;
  mix-blend-mode: normal;
}

/* ── Área inferior de itens (sem prateleira visual) ─────────────── */
#bottom-shelf {
  position: absolute; z-index: 5;
  left: 2%; right: 2%;
  top: 79%; bottom: 0%;
}

.shelf-tray {
  width: 100%; height: 100%;
  background: transparent;
  border: none;
  box-shadow: none;
  position: relative;
  overflow: visible;
}

.shelf-tray::before { content: none; }
.shelf-tray::after  { content: none; }

.shelf-layer {
  position: absolute;
  inset: 0;
  overflow: visible;
}

/* ── Itens da prateleira ────────────────────────────────────────── */
.shelf-item {
  position: absolute;
  width: 110px; height: 110px;
  transform: translate(-50%, -50%);
  background: white !important;
  border: none !important;
  border-radius: 10px !important;
  box-shadow: 0 4px 14px rgba(0,0,0,.18) !important;
  padding: 7px !important;
  box-sizing: border-box !important;
  display: flex; align-items: center; justify-content: center;
  cursor: grab; user-select: none; z-index: 6;
  opacity: 1; scale: 1;
  transition: transform .15s ease, box-shadow .15s ease;
}
.shelf-item:hover {
  transform: translate(-50%, -50%) scale(1.08);
  box-shadow: 0 8px 22px rgba(0,0,0,.26) !important;
}
.shelf-item:active { cursor: grabbing; z-index: 1000; }
.shelf-item::before, .shelf-item::after { content: none !important; }
.shelf-item img { width: 100%; height: 100%; object-fit: contain; mix-blend-mode: normal; display: block; }
.shelf-item.is-out { opacity: 0; scale: 1; transition: none; pointer-events: none; }

/* Elemento voador (drag clone) */
.fly {
  position: fixed; z-index: 9999;
  width: 174px; height: 174px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border-radius: 12px;
  box-shadow: 0 14px 36px rgba(0,0,0,.28);
  transform: translate(-50%,-50%) scale(1);
  transition: transform .48s cubic-bezier(.18,.89,.32,1.28), opacity .48s ease;
  pointer-events: none;
}
.fly img { max-width: 100%; max-height: 100%; object-fit: contain; mix-blend-mode: multiply; }

/* ── Grid de drop targets ───────────────────────────────────────── */
#target-grid { position: absolute; inset: 0; pointer-events: none; z-index: 3; }

.cell {
  position: absolute;
  border-radius: 10px;
  pointer-events: auto;
  transition: background .15s ease;
}
.cell:hover {
  background: rgba(42,122,123,.12);
}
.cell.flash::after {
  content: ""; position: absolute; inset: -4px; border-radius: 14px;
  box-shadow: 0 0 0 5px rgba(42,154,143,.65);
  animation: flash .7s ease-out forwards;
}
@keyframes flash { from { opacity: 1 } to { opacity: 0 } }

/* ── Botão iniciar ──────────────────────────────────────────────── */
.actions {
  position: absolute; left: 0; right: 0; bottom: 0.8%; z-index: 8;
  display: flex; justify-content: center;
}
.btn-start {
  border: 0;
  background: var(--teal);
  color: #fff;
  padding: 9px 30px;
  font-weight: 800; font-size: clamp(12px, 1.3vw, 16px);
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(42,122,123,.35);
  cursor: pointer;
  letter-spacing: .05em;
  transition: background .2s, transform .2s;
}
.btn-start:hover { background: var(--teal-light); transform: translateY(-2px); }

/* Estrela decorativa */
.deco-star {
  position: absolute; bottom: 1%; right: 1.5%;
  width: clamp(16px, 2vw, 28px);
  height: clamp(16px, 2vw, 28px);
  color: rgba(255,255,255,0.9);
  filter: drop-shadow(0 0 10px rgba(255,255,255,.45));
  z-index: 2; pointer-events: none;
}
.deco-star svg {
  width: 100%;
  height: 100%;
  display: block;
  fill: currentColor;
}


/* Ícones minimalistas */
.ui-icon, .btn-icon, .section-icon, .input-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
  flex: 0 0 auto;
}
.ui-icon svg, .btn-icon svg, .section-icon svg, .input-icon svg {
  width: 1em;
  height: 1em;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.modal-title, .section-title, .button-label {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
}
.search-field {
  position: relative;
}
.search-field .input-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
  font-size: 1rem;
  pointer-events: none;
}
.search-field .search-input {
  padding-left: 48px;
}
.btn-new-examinando, .btn-select-examinando, .btn-submit, .btn-cancel, .btn-report-final {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
}
.btn-new-examinando .btn-icon, .btn-select-examinando .btn-icon, .btn-submit .btn-icon, .btn-cancel .btn-icon, .btn-report-final .btn-icon {
  font-size: 1rem;
}
.selection-card h2, .registration-card h2, .report-header h2, .report-col h3 {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
}
.empty-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  width: 100%;
}
.empty-state .ui-icon {
  color: #94a3b8;
}

/* ── MODAIS ─────────────────────────────────────────────────────── */

/* Seleção de examinando */
.examinando-selection-modal {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  z-index: 3000;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.4s ease; padding: 20px;
}
.selection-card {
  background: white; border-radius: 24px; padding: 40px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,.5);
  max-width: 700px; width: 100%; max-height: 80vh;
  display: flex; flex-direction: column;
}
.selection-card h2 { margin: 0 0 24px; color: #1e293b; font-size: 2rem; text-align: center; }
.search-container { margin-bottom: 20px; }
.search-input {
  width: 100%; padding: 14px 20px;
  border: 2px solid #e2e8f0; border-radius: 12px;
  font-size: 1rem; transition: all .2s; box-sizing: border-box;
}
.search-input:focus { outline: none; border-color: #667eea; box-shadow: 0 0 0 3px rgba(102,126,234,.1); }
.examinandos-list { overflow-y: auto; max-height: 400px; margin-bottom: 20px; padding-right: 10px; }
.examinando-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px; background: #f8fafc; border-radius: 12px; margin-bottom: 12px;
  transition: all .2s;
}
.examinando-item:hover { background: #f1f5f9; transform: translateX(5px); }
.examinando-info { display: flex; flex-direction: column; gap: 4px; }
.examinando-info strong { color: #1e293b; font-size: 1.1rem; }
.examinando-info span { color: #64748b; font-size: .9rem; }
.btn-select-examinando {
  padding: 10px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white; border: none; border-radius: 8px;
  font-weight: 600; cursor: pointer; transition: all .2s;
}
.btn-select-examinando:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(102,126,234,.3); }
.selection-footer { border-top: 2px solid #e2e8f0; padding-top: 20px; }
.btn-new-examinando {
  width: 100%; padding: 14px;
  background: linear-gradient(135deg, #2a9d8f 0%, #38ef7d 100%);
  color: white; border: none; border-radius: 12px;
  font-size: 1.1rem; font-weight: 700; cursor: pointer; transition: all .2s;
}
.btn-new-examinando:hover { transform: translateY(-2px); box-shadow: 0 10px 25px rgba(42,157,143,.3); }

/* Modal de cadastro */
.registration-modal {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  z-index: 3000; display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.4s ease;
}
.registration-card {
  background: white; border-radius: 24px; padding: 40px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,.5);
  max-width: 500px; width: 90%;
}
.registration-card h2 { margin: 0 0 24px; color: #1e293b; font-size: 2rem; text-align: center; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; color: #475569; font-weight: 600; font-size: .95rem; }
.form-group input, .form-group select {
  width: 100%; padding: 12px 16px;
  border: 2px solid #e2e8f0; border-radius: 12px;
  font-size: 1rem; transition: all .2s; box-sizing: border-box;
}
.form-group input:focus, .form-group select:focus {
  outline: none; border-color: #667eea; box-shadow: 0 0 0 3px rgba(102,126,234,.1);
}
.form-buttons { display: flex; gap: 12px; margin-top: 24px; }
.btn-cancel {
  flex: 1; padding: 14px; background: #e2e8f0; color: #475569;
  border: none; border-radius: 12px; font-size: 1.1rem; font-weight: 700;
  cursor: pointer; transition: all .2s;
}
.btn-cancel:hover { background: #cbd5e1; }
.btn-submit {
  flex: 2; padding: 14px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white; border: none; border-radius: 12px;
  font-size: 1.1rem; font-weight: 700; cursor: pointer;
  transition: transform .2s, box-shadow .2s;
}
.btn-submit:hover { transform: translateY(-2px); box-shadow: 0 10px 25px rgba(102,126,234,.3); }

/* Modais coloridos de instrução */
.colored-modal {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  z-index: 2500;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.4s ease;
}
.colored-modal-content { max-width: 700px; padding: 60px 40px; text-align: center; color: white; }
.colored-modal-content h1 {
  font-size: clamp(2rem, 5vw, 3.5rem); font-weight: 900;
  margin: 0 0 20px;
  text-shadow: 0 4px 15px rgba(0,0,0,.3); line-height: 1.2;
}
.colored-modal-content p {
  font-size: clamp(1.2rem, 3vw, 1.8rem); font-weight: 500;
  margin: 0; text-shadow: 0 2px 10px rgba(0,0,0,.2); line-height: 1.5;
}
.colored-modal.purple  { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.colored-modal.green   { background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%); }
.colored-modal.orange  { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
.colored-modal.blue    { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }
.colored-modal.teal    { background: linear-gradient(135deg, #2a7a7b 0%, #38ef7d 100%); }

/* Modal de fim de teste */
.end-modal {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
  z-index: 2500;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  animation: fadeIn 0.4s ease;
}
.end-modal h1 {
  font-size: clamp(3rem, 6vw, 5rem); font-weight: 900;
  color: white; margin: 0 0 40px;
  text-shadow: 0 4px 20px rgba(0,0,0,.3);
}
.end-modal .btn-report-final {
  padding: 20px 50px; background: white; color: #11998e;
  border: none; border-radius: 50px;
  font-size: 1.5rem; font-weight: 800; cursor: pointer;
  box-shadow: 0 15px 35px rgba(0,0,0,.2);
  transition: transform .3s, box-shadow .3s;
}
.end-modal .btn-report-final:hover { transform: translateY(-5px) scale(1.05); box-shadow: 0 20px 45px rgba(0,0,0,.3); }

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── Utilidades ─────────────────────────────────────────────────── */
.is-hidden { display: none !important; }
