/* ============================================================================
   IMAGE STYLER - Premium Production Design CSS
   ============================================================================
   Modern dark theme with gradient accents, responsive layout,
   and professional visual hierarchy without scrollbars.
   ============================================================================
*/

:root {
  /* Premium Color Palette - Modern Dark Theme */
  --bg: #0f1419;
  --surface: #1a1f2e;
  --surface-alt: #252d3d;
  --card: #202938;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-dark: #4f46e5;
  --accent-vibrant: #06b6d4;
  --border: #3d4556;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e0;
  --text-muted: #94a3b8;
  --success: #10b981;
  --error: #ef4444;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.2);
  --shadow-xl: 0 20px 48px rgba(99, 102, 241, 0.15);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', sans-serif;
  margin: 0;
  background: linear-gradient(135deg, var(--bg) 0%, var(--surface) 100%);
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
  display: flex;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: inherit;
  min-width: 0;
  overflow: hidden;
}

/* ============================================================================
   HEADER SECTION
   ============================================================================
*/

.header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 16px;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

h1 {
  margin: 0;
  padding: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--text-primary);
  background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent-vibrant) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-controls {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.mode-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.mode-selector .label-title {
  white-space: nowrap;
}

.header-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ============================================================================
   MAIN CONTENT AREA
   ============================================================================
*/

.main-content {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  width: 100%;
}

/* ============================================================================
   PREVIEW SECTION
   ============================================================================
*/

.preview {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

.preview-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: #000;
  position: relative;
}


#outputCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Ensure canvas fills its container and preserves drawing aspect via JS */
.preview-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: #000;
  position: relative;
}

/* Ensure canvas scales up on large displays while remaining responsive */
.preview {
  min-height: 60vh;
}

/* ============================================================================
   SIDEBAR - SETTINGS AND CONTROLS
   ============================================================================
*/

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
  min-width: 0;
}

/* File Upload Area */

.drop-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px 12px;
  background: var(--card);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.drop-area:hover {
  border-color: var(--accent-vibrant);
  background: var(--surface-alt);
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.2);
}

.drop-area.highlight {
  border-color: var(--accent-vibrant);
  background: rgba(6, 182, 212, 0.1);
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.3);
}

.drop-area p {
  margin: 0;
  color: var(--text-secondary);
  font-weight: 600;
}

#fileElem {
  display: none;
}

.btn-upload {
  display: inline-block;
  padding: 8px 20px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-upload:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.btn-upload:active {
  transform: translateY(0);
}

/* Settings Tabs */

.settings-tabs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

.tab-buttons {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  padding: 10px 12px;
  background: var(--surface-alt);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  background: var(--card);
  color: var(--text-primary);
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.tab-content {
  display: none;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  background: var(--card);
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.tab-content.active {
  display: flex;
}

/* Scrollbar Styling for Tab Content */
.tab-content::-webkit-scrollbar {
  width: 4px;
}

.tab-content::-webkit-scrollbar-track {
  background: transparent;
}

.tab-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.tab-content::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* ============================================================================
   CONTROLS AND FORM ELEMENTS
   ============================================================================
*/

.control-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.label-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0;
}

.range-input {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-alt);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent-vibrant) 100%);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(99, 102, 241, 0.3);
  transition: all 0.2s ease;
}

.range-input::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.range-input::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent-vibrant) 100%);
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 4px rgba(99, 102, 241, 0.3);
  transition: all 0.2s ease;
}

.range-value {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.number-input,
.select-input {
  padding: 8px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  transition: all 0.2s ease;
}

.number-input:hover,
.select-input:hover {
  border-color: var(--accent-vibrant);
}

.number-input:focus,
.select-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.2);
}

/* Paint Mix Checkboxes */

.paint-mix {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.paint-mix label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  transition: color 0.2s ease;
}

.paint-mix label:hover {
  color: var(--accent-vibrant);
}

.paint-mix input[type='checkbox'] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* ASCII Text Area */

.ascii-text {
  padding: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.4;
  resize: none;
  transition: all 0.2s ease;
}

.ascii-text:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.2);
}

.ascii-actions {
  display: flex;
  gap: 6px;
}

.ascii-actions .btn {
  flex: 1;
}

/* ============================================================================
   BUTTONS
   ============================================================================
*/

.btn {
  padding: 12px 18px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: var(--card);
  border-color: var(--accent-vibrant);
  color: var(--accent-vibrant);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: white;
  border-color: var(--accent-dark);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn.primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

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

/* ============================================================================
   FOOTER
   ============================================================================
*/

.notes {
  padding: 8px 12px;
  background: var(--surface-alt);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  margin: 0;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

/* ============================================================================
   ALERTS
   ============================================================================
*/

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  animation: slideIn 0.3s ease;
  border: 1px solid;
}

.alert.error {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}

.alert.success {
  background: rgba(16, 185, 129, 0.1);
  color: #86efac;
  border-color: rgba(16, 185, 129, 0.3);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================
*/

/* Tablet (768px to 1024px) */
@media (max-width: 1024px) {
  .main-content {
    grid-template-columns: 1.5fr 1fr;
  }
}

/* Mobile (max 768px) */
@media (max-width: 768px) {
  .container {
    padding: 6px;
    gap: 6px;
  }

  h1 {
    font-size: 20px;
  }

  .header {
    padding: 10px 12px;
    gap: 10px;
  }

  .header-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .mode-selector {
    width: 100%;
  }

  .mode-selector .select-input {
    width: 100%;
  }

  .header-buttons {
    width: 100%;
    justify-content: space-between;
  }

  .header-buttons .btn {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    padding: 8px 10px;
  }

  .main-content {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }

  .preview {
    max-height: 60vh;
    min-height: 200px;
  }

  .sidebar {
    min-height: 0;
    max-height: 45vh;
  }

  .drop-area {
    padding: 16px 10px;
  }

  .tab-content {
    padding: 10px;
  }

  .label-title {
    font-size: 12px;
  }

  .btn {
    padding: 8px 12px;
    font-size: 12px;
  }

  .ascii-text {
    font-size: 10px;
  }

  .notes {
    padding: 6px 10px;
    font-size: 11px;
  }
}

/* Small Mobile (max 480px) */
@media (max-width: 480px) {
  .container {
    padding: 4px;
    gap: 4px;
  }

  h1 {
    font-size: 18px;
  }

  .header {
    padding: 8px 10px;
    gap: 8px;
  }

  .header-buttons .btn {
    font-size: 11px;
    padding: 6px 8px;
  }

  .preview {
    max-height: 55vh;
    min-height: 160px;
  }

  .sidebar {
    max-height: 50vh;
  }

  .tab-btn {
    padding: 8px 10px;
    font-size: 11px;
  }

  .tab-content {
    padding: 8px;
    gap: 8px;
  }

  .control-block {
    gap: 8px;
  }

  .drop-area {
    padding: 12px 8px;
  }

  .drop-area p {
    font-size: 12px;
  }

  .btn {
    padding: 6px 10px;
    font-size: 11px;
  }

  .btn-upload {
    padding: 6px 16px;
    font-size: 12px;
  }

  .ascii-text {
    font-size: 9px;
  }

  .label-title {
    font-size: 11px;
  }

  .range-input {
    height: 4px;
  }

  .range-input::-webkit-slider-thumb {
    width: 14px;
    height: 14px;
  }

  .range-value {
    font-size: 11px;
  }

  .notes {
    padding: 4px 8px;
    font-size: 10px;
  }
}

/* =====================
   Modal / Dialog Styles
   ===================== */
.modal.hidden {
  display: none;
}
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.45);
  z-index: 1200;
  padding: 20px;
}
.modal-content {
  width: 100%;
  max-width: 520px;
  background: var(--card);
  border-radius: 12px;
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.modal-content h2 {
  margin: 0 0 10px 0;
  font-size: 20px;
}
.modal-label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.modal-label input[type="text"] {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-primary);
  font-size: 15px;
}
.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ASCII preview specific */
.ascii-preview {
  width: 100%;
  height: 360px;
  max-height: 60vh;
  overflow: auto;
  background: #0b0b0b;
  color: #e6e6e6;
  border-radius: 8px;
  padding: 12px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.1;
  white-space: pre;
}
