/* DOT-O-MATIC 3000 - Fresh Start */

:root {
  --bg-dark: #2E2E2E;
  --bg-darker: #1F1F1F;
  --fg-light: #CCCCCC;
  --accent-teal: #008080;
  --accent-teal-hover: #009999;
  --border-teal: #008080;
  --input-bg: #1F1F1F;
  --preview-bg: #008080;
  --panel-width: 280px;
  --preview-size: 600px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background: var(--bg-dark);
  color: var(--fg-light);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  font-size: 14px;
  overflow-x: hidden;
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.top {
  background: var(--bg-dark);
  padding: 20px;
  text-align: center;
  border-bottom: 1px solid var(--border-teal);
}

.logo {
  max-width: 800px;
  height: auto;
  display: block;
  margin: 0 auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.subtitle {
  margin-top: 8px;
  color: var(--fg-light);
  font-size: 12px;
  opacity: 0.8;
}

/* ==========================================================================
   MAIN LAYOUT
   ========================================================================== */
.shell {
  display: grid;
  grid-template-columns: var(--panel-width) 1fr;
  gap: 0;
  height: calc(100vh - 120px);
  max-width: 100%;
  overflow: hidden;
}

/* ==========================================================================
   LEFT PANEL
   ========================================================================== */
.panel {
  background: var(--bg-dark);
  border-right: 2px solid var(--border-teal);
  padding: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: var(--panel-width);
}

.panel::-webkit-scrollbar {
  width: 8px;
}

.panel::-webkit-scrollbar-track {
  background: var(--bg-darker);
}

.panel::-webkit-scrollbar-thumb {
  background: var(--accent-teal);
  border-radius: 4px;
}

.panel::-webkit-scrollbar-thumb:hover {
  background: var(--accent-teal-hover);
}

/* Section Blocks */
.block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-label {
  color: var(--fg-light);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

/* Control Rows */
.row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
  min-height: 24px;
}

.row label {
  color: var(--fg-light);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  justify-self: start;
}

.ctrl {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Image Loading Section */
.image-load-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.image-load-section .btn {
  width: 100%;
}

.image-info-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.image-info-line {
  color: var(--fg-light);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.thumb-container {
  margin-top: 8px;
  position: relative;
}

.thumb {
  max-width: 140px;
  max-height: 100px;
  border: 1px solid var(--border-teal);
  margin-top: 8px;
  display: none;
}

.thumb[src]:not([src=""]):not([src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=="]) {
  display: block;
}

.thumb-placeholder {
  width: 140px;
  height: 100px;
  background: var(--input-bg);
  border: 1px solid var(--border-teal);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-light);
  font-size: 9px;
  text-align: center;
  margin-top: 8px;
  opacity: 0.5;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.thumb[src]:not([src=""]):not([src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=="]) ~ .thumb-placeholder {
  display: none;
}

/* ==========================================================================
   INPUT STYLES
   ========================================================================== */
input[type="text"],
input[type="number"],
select {
  background: var(--input-bg);
  color: var(--fg-light);
  border: 1px solid var(--border-teal);
  padding: 4px 6px;
  font-size: 11px;
  font-family: inherit;
  width: 110px;
  min-width: 110px;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  outline: 2px solid var(--accent-teal);
  outline-offset: -2px;
}

/* Number Input Groups */
.number-input-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.number-input-arrow {
  background: var(--input-bg);
  border: 1px solid var(--border-teal);
  color: var(--fg-light);
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 10px;
  padding: 0;
  transition: background 0.2s;
  line-height: 1;
}

.number-input-arrow:hover {
  background: var(--accent-teal);
  color: var(--bg-dark);
}

.number-input-group input[type="number"] {
  width: 70px;
  min-width: 70px;
  text-align: center;
}

.number-input-group .unit-suffix {
  color: var(--fg-light);
  font-size: 11px;
  margin-left: 4px;
  white-space: nowrap;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Select Dropdown */
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%23008080' d='M5 8L1 4h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  padding-right: 24px;
}

/* Range Slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 120px;
  height: 4px;
  background: var(--input-bg);
  border: 1px solid var(--border-teal);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: var(--accent-teal);
  border: 1px solid var(--bg-dark);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: var(--accent-teal);
  border: 1px solid var(--bg-dark);
  cursor: pointer;
  border-radius: 0;
}

input[type="range"]::-moz-range-track {
  background: var(--input-bg);
  height: 4px;
  border: 1px solid var(--border-teal);
}

/* Checkboxes */
input[type="checkbox"] {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-teal);
  background: var(--input-bg);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}

input[type="checkbox"]:checked {
  background: var(--accent-teal);
  border-color: var(--accent-teal);
}

input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--bg-dark);
  font-size: 10px;
  font-weight: bold;
}

/* Color Inputs */
input[type="color"] {
  width: 60px;
  height: 28px;
  border: 1px solid var(--border-teal);
  background: var(--input-bg);
  cursor: pointer;
  padding: 2px;
}

input[type="file"] {
  display: none;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
  background: var(--accent-teal);
  color: var(--bg-dark);
  border: 1px solid var(--accent-teal);
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
}

.btn:hover:not(:disabled) {
  background: var(--accent-teal-hover);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent-teal);
}

/* ==========================================================================
   RIGHT PANEL
   ========================================================================== */
.stage {
  background: var(--bg-dark);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  overflow-x: hidden;
}

.stage::-webkit-scrollbar {
  width: 8px;
}

.stage::-webkit-scrollbar-track {
  background: var(--bg-darker);
}

.stage::-webkit-scrollbar-thumb {
  background: var(--accent-teal);
  border-radius: 4px;
}

.stage::-webkit-scrollbar-thumb:hover {
  background: var(--accent-teal-hover);
}

/* Action Buttons */
.stage-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  max-width: var(--preview-size);
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

.stage-actions .btn {
  flex: 1;
  min-width: 140px;
  padding: 8px 16px;
}

/* Preview Area */
.canvasStage {
  background: var(--preview-bg);
  border: 2px solid var(--border-teal);
  min-height: var(--preview-size);
  width: var(--preview-size);
  aspect-ratio: 1;
  max-width: 100%;
  margin: 0 auto 20px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.canvasStage::after {
  content: '24"';
  position: absolute;
  right: -45px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--fg-light);
  font-size: 11px;
  white-space: nowrap;
}

.canvasStage::before {
  content: '24"';
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--fg-light);
  font-size: 11px;
  white-space: nowrap;
}

.canvasStage canvas {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Global Settings */
.global-settings {
  max-width: var(--preview-size);
  margin: 16px auto 0;
  width: 100%;
}

.global-settings .section-label {
  margin-bottom: 10px;
}

/* Status */
.status {
  color: var(--fg-light);
  font-size: 10px;
  opacity: 0.8;
  margin-top: auto;
  padding-top: 12px;
}

.meta {
  color: var(--fg-light);
  font-size: 10px;
  opacity: 0.7;
  margin-top: 4px;
}

.auto-update-row {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(128, 128, 128, 0.3);
}

/* Overlay */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
}

.overlay[hidden] {
  display: none;
}

.overlay .box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(128, 128, 128, 0.3);
  border-top-color: var(--accent-teal);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.badge {
  background: var(--bg-dark);
  color: var(--fg-light);
  border: 1px solid var(--border-teal);
  padding: 8px 16px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Button in ctrl */
.row .ctrl .btn {
  width: auto;
  min-width: 100px;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 1024px) {
  .shell {
    grid-template-columns: 1fr;
    height: auto;
  }
  
  .panel {
    border-right: none;
    border-bottom: 1px solid var(--border-teal);
    max-height: 50vh;
  }
  
  .canvasStage {
    min-height: 400px;
    width: 100%;
  }
  
  .canvasStage::after,
  .canvasStage::before {
    display: none;
  }
}

@media (max-width: 768px) {
  :root {
    --panel-width: 100%;
    --preview-size: 100%;
  }
  
  .panel {
    padding: 12px;
  }
  
  .stage {
    padding: 12px;
  }
  
  .stage-actions {
    flex-direction: column;
  }
  
  .stage-actions .btn {
    width: 100%;
  }
  
  .row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .row label {
    margin-bottom: 4px;
  }
  
  input[type="text"],
  input[type="number"],
  select,
  input[type="range"] {
    width: 100%;
  }
}
