:root {
  --primary: #4F46E5;
  --bg-color: #f3f4f6;
  --panel-bg: #ffffff;
  --border-color: #e5e7eb;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: #1f2937;
  box-sizing: border-box;
}

*, *:before, *:after {
  box-sizing: inherit;
}

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}

.left-panel {
  width: 350px;
  min-width: 350px;
  background: var(--panel-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.upload-division {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.images-division {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.right-panel {
  flex: 1 1 0%;
  display: flex;
  flex-direction: column;
  background: var(--bg-color);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.sheet-division {
  flex: 1 1 0%;
  padding: 20px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.sheet-container {
  flex: 1 1 0%; /* Changed from flex: 1 */
  background: white;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  position: relative;
  min-width: 0;
  min-height: 0;
  /* Visual checkerboard for transparency */
  background-image: linear-gradient(45deg, #ccc 25%, transparent 25%), 
    linear-gradient(-45deg, #ccc 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #ccc 75%), 
    linear-gradient(-45deg, transparent 75%, #ccc 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.sheet-content {
  /* This will grow vertically based on required height */
  width: 100%;
  min-height: 100%;
  position: relative;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background-color: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-primary:hover {
  background-color: #4338ca;
}

h3 {
  margin-top: 0;
  font-size: 0.9rem;
  text-transform: uppercase;
  color: #6b7280;
  letter-spacing: 0.05em;
}

.empty-state {
  text-align: center;
  color: #999;
  font-style: italic;
  padding: 20px;
}

.image-item {
  display: flex;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  font-size: 0.85rem;
}

.image-thumb-container {
  width: 50px;
  height: 50px;
  min-width: 50px;
  position: relative;
  background: #f0f0f0;
  border-radius: 4px;
  overflow: hidden;
  margin-right: 12px;
  border: 1px solid var(--border-color);
}

.image-thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.progress-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: rgba(0,0,0,0.1);
}

.progress-bar {
  height: 100%;
  background: #10b981; /* Green */
  transition: width 0.2s ease;
}

.image-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.image-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.image-meta {
  display: flex;
  gap: 8px;
  color: #666;
  font-size: 0.75rem;
}

.dpi-badge {
  background: #e5e7eb;
  padding: 1px 4px;
  border-radius: 4px;
  font-weight: 600;
}

.dpi-badge.dpi-warning {
  background: #fee2e2;
  color: #dc2626; /* Red for <300 DPI */
}

.image-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}

.repeat-control {
  display: flex;
  align-items: center;
  gap: 4px;
}

.repeat-control input {
  width: 40px;
  padding: 2px 4px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  text-align: center;
}

.actions {
  display: flex;
  gap: 4px;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #6b7280;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: #f3f4f6;
  color: #374151;
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.sheet-stats {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  background: #e0e7ff;
  padding: 4px 8px;
  border-radius: 4px;
}

.packed-item {
  position: absolute;
  /* background: rgba(59, 130, 246, 0.1); */
}

.packed-bounds {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 1px dashed rgba(59, 130, 246, 0.4);
  pointer-events: none;
}

.icon-btn.remove-btn:hover {
  background: #fee2e2;
  color: #dc2626;
}

/* Enhanced Upload Modal */
.upload-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(4px);
}

.upload-modal {
  background: white;
  width: 600px;
  max-width: 90vw;
  max-height: 80vh;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  position: relative;
}

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

.upload-modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #9ca3af;
  line-height: 1;
}

.close-btn:hover {
  color: #111827;
}

.upload-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.upload-modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: center;
  background: #f9fafb;
}

.upload-row {
  display: flex;
  align-items: center;
  gap: 15px;
  background: #f9fafb;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  transition: all 0.3s ease;
}

.upload-row.success {
  border-color: #10b981;
}

.upload-row.error {
  border-color: #ef4444;
}

.upload-row-thumb {
  width: 60px;
  height: 60px;
  border-radius: 4px;
  overflow: hidden;
  background: #eee;
  border: 1px solid #ddd;
}

.upload-row-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.upload-row-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.upload-status {
  font-size: 0.8rem;
  font-weight: 600;
  color: #4b5563;
}

.upload-row.success .upload-status {
  color: #059669;
}

.upload-row.error .upload-status {
  color: #dc2626;
}

.upload-progress-container {
  width: 100%;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s ease;
}

.upload-row.success .upload-progress-fill {
  background: #10b981;
}

.upload-row.error .upload-progress-fill {
  background: #ef4444;
}

.gear-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #9ca3af;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  margin-top: auto;
  align-self: center;
}

.gear-btn:hover {
  background: #f3f4f6;
  color: #4b5563;
  transform: rotate(30deg);
}

.btn-secondary:hover {
  background: #e5e7eb !important;
}
