/* ============================================================
   RESULTS.CSS: MODAL DE RESULTADOS, CONTROLES DE LIMPIEZA Y EXPORTACIÓN
   SaaS Dark Design System (Zinc / Slate)
   ============================================================ */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(9, 9, 11, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  width: 100%;
  max-width: 1100px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface);
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.015em;
  margin: 0;
}

.modal-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 3px;
  margin-bottom: 0;
}

.modal-close-btn {
  background: transparent;
  border: 1px solid transparent;
  color: #a1a1aa;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  transform: scale(1.02);
}

.modal-close-btn:active {
  transform: scale(0.96);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}

/* ============================================================
   CUADRÍCULA DE RESULTADOS SIMÉTRICA (3 COLUMNAS)
   ============================================================ */
.results-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

@media (max-width: 960px) {
  .results-grid {
    grid-template-columns: 1fr;
  }
}

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  height: 100%;
  box-sizing: border-box;
  transition: border-color var(--transition-fast);
}

.result-card:hover {
  border-color: var(--border-color-hover);
}

.result-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.card-tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 9999px;
  line-height: 1.2;
}

.tag-firma {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.tag-nombre {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.tag-cedula {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.card-dimensions {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 2px 7px;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
}

/* Previsualización en Cuadrícula Ajedrez Suave */
.result-preview-box {
  width: 100%;
  height: 140px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.checkerboard-bg {
  width: 100%;
  height: 100%;
  background-color: #1f1f23;
  background-image: 
    linear-gradient(45deg, #27272a 25%, transparent 25%), 
    linear-gradient(-45deg, #27272a 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #27272a 75%), 
    linear-gradient(-45deg, transparent 75%, #27272a 75%);
  background-size: 10px 10px;
  background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  box-sizing: border-box;
}

.result-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.result-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
}

.control-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.checkbox-row {
  flex-direction: row;
  align-items: center;
}

.checkbox-row label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-main);
  cursor: pointer;
  font-size: 0.74rem;
  user-select: none;
}

/* Pie de tarjeta con 3 botones simétricos alineados */
.result-card-footer {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.result-card-footer .btn {
  height: 30px;
  padding: 0 6px;
  font-size: 0.76rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
  width: 100%;
}

.result-card-footer .btn svg {
  flex-shrink: 0;
}

/* Botón Editar Recorte Profesional */
.btn-edit-crop {
  background: var(--bg-overlay);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-main);
  font-weight: 500;
  border-radius: 6px;
  transition: all var(--transition-fast);
}

.btn-edit-crop:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

/* Caja de Siguiente Paso */
.next-step-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.next-step-icon {
  font-size: 1.4rem;
  color: var(--primary);
  flex-shrink: 0;
}

.next-step-content h4 {
  font-size: 0.84rem;
  font-weight: 600;
  color: #ffffff;
  margin: 0 0 2px 0;
}

.next-step-content p {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin: 0;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg-surface);
}

/* Escenario y controles del Editor de Recorte */
.crop-editor-stage {
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.6);
  border-radius: 6px;
  background: #18181b;
}

.crop-editor-canvas-container {
  background: #ffffff;
  margin: auto;
  flex-shrink: 0;
  transition: transform 0.1s ease-out;
}
