/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, 
    "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: #e0e6ed;
  min-height: 100vh;
  line-height: 1.6;
}

/* Container and layout */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
  min-height: 100vh;
}

@media (min-width: 768px) {
  .container {
    padding: 2rem;
  }
}

/* Header */
header {
  text-align: center;
  margin-bottom: 2rem;
  padding: 2rem;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

h1 {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  font-weight: 700;
  margin-bottom: 0.5rem;
}

h1 > span { 
  background: linear-gradient(45deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: #b8c5d1;
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  opacity: 0.8;
}

/* Main content */
main {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Controls section */
.controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  padding: 2rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

@media (min-width: 768px) {
  .controls {
    grid-template-columns: repeat(2, 1fr);
  }
}


.scale-controls {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .scale-controls {
    grid-column: span 2;
  }
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.control-group > input[type="file"],
.control-group > select { 
  color: rgb(175, 175, 175);
}

.take-all { 
  grid-column: 1 / -1;
  align-items: center;
}

label {
  font-weight: 600;
  color: #b8c5d1;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Form inputs */
input[type="file"],
select {
  padding: 0.875rem;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: #e0e6ed;
  font-size: 0.875rem;
  transition: all 0.3s ease;
  width: 100%;
}

input[type="file"]:hover,
select:hover {
  border-color: #667eea;
  background: rgba(255, 255, 255, 0.08);
}

input[type="file"]:focus,
select:focus {
  outline: none;
  border-color: #667eea;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* Number input with buttons */
.number-input-wrapper {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow: hidden;
  transition: all 0.3s ease;
  padding: 1px;
}

.number-input-wrapper:hover {
  border-color: #667eea;
  background: rgba(255, 255, 255, 0.08);
}

.number-input-wrapper:focus-within {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.number-input-wrapper input[type="number"] {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.875rem;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  appearance: textfield;
  color: rgb(175, 175, 175);
  margin: 2px;
}

.number-input-wrapper input[type="number"]:focus {
  outline: none;
  box-shadow: none;
}

.number-input-wrapper button {
  min-width: 0px;
  width: auto;
  height: 2.5rem;
  border: none;
  background: rgba(102, 126, 234, 0.2);
  color: #667eea;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  margin-inline: 4px;
}

.number-input-wrapper button:hover {
  background: rgba(102, 126, 234, 0.4);
  color: white;
}

.number-input-wrapper button:active {
  transform: scale(0.95);
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 30px;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: 0.3s;
  border-radius: 30px;
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 2px;
  bottom: 2px;
  background-color: #b8c5d1;
  transition: 0.3s;
  border-radius: 50%;
}

.slider:hover { 
  border-color: #667eea;
}

input:checked + .slider:hover  {
  border-color: #d8a4ff;
}

input:checked + .slider {
  background: linear-gradient(45deg, #667eea 0%, #764ba2 100%);
  border-color: #667eea;
}

input:checked + .slider:before {
  transform: translateX(calc(150% - 3.5px));
  background-color: white;
}

/* Action buttons */
.action-buttons {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
}

button {
  padding: 0.875rem 1.5rem;
  background: linear-gradient(45deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
  min-width: 150px;
}

button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

button:disabled {
  background: rgba(255, 255, 255, 0.1);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  opacity: 0.6;
}

/* Canvas section */
.canvas-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 1024px) {
  .canvas-container {
    grid-template-columns: repeat(2, 1fr);
  }
}

.canvas-wrapper {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 15px;
  padding: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.3s ease;
}

.canvas-wrapper:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
}

.canvas-wrapper h3 {
  margin-bottom: 1rem;
  color: #b8c5d1;
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.canvas-scroll {
  max-height: 500px;
  overflow: auto;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  justify-content: center;
}

canvas {
  display: block;
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

/* Info section */
.info {
  padding: 1.5rem;
  background: rgba(102, 126, 234, 0.1);
  border-radius: 15px;
  border-left: 8px solid #667eea;
  font-size: 0.875rem;
  color: #b8c5d1;
  line-height: 1.6;
}

.info strong {
  color: #e0e6ed;
}

.info:empty {
  display: none;
}

/* File input styling */
input[type="file"]::file-selector-button {
  background: linear-gradient(45deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  margin-right: 0.75rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.3s ease;
}

input[type="file"]::file-selector-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

/* Select dropdown styling */
select, select:hover, select:focus {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'><path fill='%23b8c5d1' d='M2 0L0 2h4zm0 5L0 3h4z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1rem;
  padding-right: 3rem;
  border: 2px solid rgba(255, 255, 255, 0.1);
}

select:hover,
select:focus {
  border-color: #667eea;
  background-color: #333333;
  box-shadow: 0 0 0 3px rgba(0, 122, 204, 0.1);
}

select option {
  background-color: #2a2a2a;
  color: #ffffff;
  padding: 10px;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: rgba(102, 126, 234, 0.5);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(102, 126, 234, 0.7);
}

/* Loading state */
.loading {
  background: black;
  opacity: 0.6;
  pointer-events: none;
}

.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2rem;
  height: 2rem;
  border: 2px solid rgba(102, 126, 234, 0.3);
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Responsive utilities */
@media (max-width: 768px) {
  .action-buttons {
    flex-direction: column;
    align-items: stretch;
  }
  
  button {
    min-width: auto;
  }
}