/* ==========================================================================
   PDF Monster - Crop Tool Styles
   Visuelles Schneidewerkzeug
   ========================================================================== */

/* Crop Workspace Layout */
.crop-workspace {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.crop-layout {
  display: grid !important;
  grid-template-columns: 1fr 340px !important;
  gap: 32px;
  gap: var(--space-6, 32px);
  margin-top: 32px;
  margin-top: var(--space-6, 32px);
  align-items: start;
}

.crop-sidebar {
  display: block !important;
  background: var(--bg-secondary, #1a1a2e);
  border-radius: 16px;
  border-radius: var(--radius-xl, 16px);
  padding: 24px;
  padding: var(--space-5, 24px);
}

@media (max-width: 1024px) {
  .crop-layout {
    grid-template-columns: 1fr !important;
  }
  .crop-sidebar {
    display: none !important;
  }
}

/* Crop Main Area */
.crop-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Page Navigation */
.crop-page-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
}

.crop-page-info {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  min-width: 120px;
  text-align: center;
}

/* Canvas Container */
.crop-canvas-container {
  position: relative;
  background: var(--bg-tertiary);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
  min-height: 500px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: auto;
}

.crop-canvas-wrapper {
  position: relative;
  display: inline-block;
  box-shadow: var(--shadow-lg);
  background: white;
}

.crop-preview-image {
  display: block;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* Crop Overlay */
.crop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.crop-overlay-top,
.crop-overlay-right,
.crop-overlay-bottom,
.crop-overlay-left {
  position: absolute;
  background: rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  cursor: crosshair;
}

.crop-overlay-top {
  top: 0;
  left: 0;
}

.crop-overlay-bottom {
  left: 0;
}

.crop-overlay-left {
  left: 0;
}

.crop-overlay-right {}

/* Crop Selection Box */
.crop-selection {
  position: absolute;
  border: 2px dashed var(--color-primary);
  background: transparent;
  cursor: move;
  pointer-events: auto;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}

.crop-selection::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border: 1px solid rgba(255, 255, 255, 0.5);
}

/* Grid lines inside selection */
.crop-selection::after {
  content: '';
  position: absolute;
  top: 33.33%;
  left: 0;
  right: 0;
  height: 33.33%;
  border-top: 1px dashed rgba(255, 255, 255, 0.3);
  border-bottom: 1px dashed rgba(255, 255, 255, 0.3);
  pointer-events: none;
}

/* Resize Handles */
.crop-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--color-primary);
  border: 2px solid white;
  border-radius: 2px;
  pointer-events: auto;
  z-index: 10;
}

.crop-handle-nw { top: -6px; left: -6px; cursor: nw-resize; }
.crop-handle-n { top: -6px; left: 50%; margin-left: -6px; cursor: n-resize; }
.crop-handle-ne { top: -6px; right: -6px; cursor: ne-resize; }
.crop-handle-e { top: 50%; right: -6px; margin-top: -6px; cursor: e-resize; }
.crop-handle-se { bottom: -6px; right: -6px; cursor: se-resize; }
.crop-handle-s { bottom: -6px; left: 50%; margin-left: -6px; cursor: s-resize; }
.crop-handle-sw { bottom: -6px; left: -6px; cursor: sw-resize; }
.crop-handle-w { top: 50%; left: -6px; margin-top: -6px; cursor: w-resize; }

.crop-handle:hover {
  background: var(--color-primary-hover);
  transform: scale(1.2);
}

/* Size Display */
.crop-size-display {
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-primary);
  color: white;
  padding: 4px 10px;
  border-radius: var(--radius-md);
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
}

/* Zoom Controls */
.crop-zoom-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
}

.crop-zoom-level {
  min-width: 50px;
  text-align: center;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

/* Quick Actions */
.crop-quick-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: center;
  flex-wrap: wrap;
}

/* Crop Sidebar */
.crop-sidebar {
  position: sticky;
  top: 100px;
}

/* Crop Info Grid */
.crop-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.crop-info-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.crop-info-item label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-tertiary);
  min-width: 40px;
}

.crop-info-item .form-input {
  width: 70px;
  text-align: right;
}

/* Option List */
.option-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.option-radio-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s;
}

.option-radio-item:hover {
  background: var(--bg-tertiary);
}

.option-radio-item input[type="radio"] {
  display: none;
}

.option-radio-mark {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-color);
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
  transition: border-color 0.15s;
}

.option-radio-item input:checked + .option-radio-mark {
  border-color: var(--color-primary);
}

.option-radio-mark::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  background: var(--color-primary);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.15s;
}

.option-radio-item input:checked + .option-radio-mark::after {
  transform: translate(-50%, -50%) scale(1);
}

.option-radio-label {
  font-size: var(--fs-sm);
  color: var(--text-primary);
}

/* Custom Pages Input */
.custom-pages-input {
  margin-top: var(--space-3);
  padding-left: calc(18px + var(--space-3));
}

.input-hint {
  display: block;
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

/* Page Thumbnails */
.crop-page-thumbs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
  max-height: 300px;
  overflow-y: auto;
  padding: var(--space-2);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
}

.crop-thumb {
  position: relative;
  aspect-ratio: 0.707;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.15s;
}

.crop-thumb:hover {
  transform: scale(1.05);
}

.crop-thumb.active {
  border-color: var(--color-primary);
}

.crop-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.crop-thumb-num {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 3px;
}

.crop-thumb-more {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--space-2);
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
}

/* Responsive */
@media (max-width: 768px) {
  .crop-canvas-container {
    min-height: 400px;
    padding: var(--space-2);
  }

  .crop-quick-actions {
    flex-direction: column;
  }

  .crop-quick-actions .btn {
    width: 100%;
  }

  .crop-handle {
    width: 16px;
    height: 16px;
  }

  .crop-handle-nw { top: -8px; left: -8px; }
  .crop-handle-n { top: -8px; margin-left: -8px; }
  .crop-handle-ne { top: -8px; right: -8px; }
  .crop-handle-e { right: -8px; margin-top: -8px; }
  .crop-handle-se { bottom: -8px; right: -8px; }
  .crop-handle-s { bottom: -8px; margin-left: -8px; }
  .crop-handle-sw { bottom: -8px; left: -8px; }
  .crop-handle-w { left: -8px; margin-top: -8px; }
}
