/* ========================================
   RESET Y VARIABLES
   ======================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #7c5aa8;
  --primary-dark: #6a4b90;
  --bg: #faf9fb;
  --card: #ffffff;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --success: #10b981;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
}

/* ========================================
   UPLOAD AREA
   ======================================== */
.upload-area {
  background: var(--card);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  margin: 2rem 0;
  transition: all 0.3s ease;
  cursor: pointer;
}

.upload-area:hover {
  border-color: var(--primary);
  background: #faf5ff;
}

.upload-area.drag-over {
  border-color: var(--primary);
  background: #faf5ff;
  transform: scale(1.02);
}

.upload-icon {
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.upload-area h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.upload-area p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

/* ========================================
   CROP EDITOR
   ======================================== */
.crop-editor {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  margin: 2rem 0;
  box-shadow: var(--shadow-lg);
}

.crop-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.crop-header h3 {
  font-size: 1.1rem;
  color: var(--text);
}

.crop-container {
  margin-bottom: 1.5rem;
  background: #2a2a2a;
  border-radius: 8px;
  padding: 2rem;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 400px;
}

.crop-canvas-wrapper {
  position: relative;
  display: inline-block;
}

#cropCanvas {
  display: block;
  max-width: 100%;
  height: auto;
}

.crop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.crop-rect {
  cursor: move;
  pointer-events: all;
}

.crop-handle {
  cursor: pointer;
  pointer-events: all;
}

.crop-handle:hover {
  r: 10;
}

#handleNW { cursor: nw-resize; }
#handleNE { cursor: ne-resize; }
#handleSW { cursor: sw-resize; }
#handleSE { cursor: se-resize; }

.crop-guides line {
  stroke-dasharray: 5, 5;
}

.crop-info {
  background: #faf5ff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.crop-info p {
  margin: 0.25rem 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.crop-info strong {
  color: var(--primary);
  font-weight: 600;
}

/* ========================================
   BUTTONS
   ======================================== */
.btn-primary,
.btn-secondary,
.btn-download,
.btn-cancel {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-large {
  width: 100%;
  padding: 1rem 1.5rem;
  font-size: 1rem;
}

.btn-secondary {
  background: var(--card);
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-secondary:hover {
  background: #faf5ff;
}

.btn-cancel {
  background: #f3f4f6;
  color: var(--text);
  padding: 0.5rem 1rem;
}

.btn-cancel:hover {
  background: #e5e7eb;
}

.btn-download {
  background: var(--primary);
  color: white;
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
}

.btn-download:hover {
  background: var(--primary-dark);
}

/* ========================================
   IMAGES GRID
   ======================================== */
.images-grid {
  margin: 2rem 0;
}

.grid-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.grid-header h3 {
  font-size: 1.25rem;
  color: var(--text);
}

.images-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

/* ========================================
   IMAGE CARD
   ======================================== */
.image-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.image-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.image-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #f9fafb;
  position: relative;
  overflow: hidden;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-info {
  padding: 1rem;
}

.image-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-stats {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
}

.stat-label {
  color: var(--text-muted);
}

.stat-value {
  color: var(--text);
  font-weight: 500;
}

.stat-savings {
  color: var(--success);
  font-weight: 600;
}

/* ========================================
   BRANDING
   ======================================== */
.branding-badge {
  margin: 3rem 0 2rem;
  text-align: center;
  color: var(--text);
  font-weight: 600;
}

.branding-badge a {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

.branding-badge a:hover {
  text-decoration: underline;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
  .upload-area {
    padding: 2rem 1rem;
  }

  .crop-editor {
    padding: 1rem;
  }

  .crop-container {
    padding: 1rem;
    min-height: 300px;
  }

  .images-list {
    grid-template-columns: 1fr;
  }

  .grid-header {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 640px) {
  .branding-badge {
    margin: 2rem 0 1.5rem;
    font-size: 0.95rem;
  }
}
