/* === INHERIT CMS DESIGN SYSTEM === */
:root {
  --primary: #1ba4c8;
  --primary-dark: #1892B2;
  --secondary: #1892B2;
  --light-bg: #F8FCFF;
  --border: #e1e5f1;
  --text: #333;
  --text-light: #666;
  --danger: #ff6b6b;
  --success: #06d6a0;
  --warning: #ffd166;
  --radius-sm: 4px;
}

button.primary { text-transform: none; }
.flex { flex: 1; }

input[type=text], textarea, select {
    margin-bottom: 0px;
}

.btn-inverse:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    background-color: rgba(27, 164, 200, 0.2) !important;
    color: var(--primary) !important;
}

/* Main Container */
.container-custom {
  max-width: 1200px;
  margin: 0 auto;
  background-color: white;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow-x: hidden;
}

.container-custom p {
  text-align: center;
  line-height: 1;
}
.container-custom select {
  margin-bottom: 0;
}
.container-custom h3,
.container-custom h3 a {
  font-size: 18px !important;
  padding: 0;
}

/* Content Wrapper */
.content-wrapper-custom {
  display: flex;
  gap: 0;
  width: 100%;
  overflow-x: hidden;
}

/* Left Panel */
.left-panel-custom {
  flex: 0 0 385px;
  padding: 15px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: fit-content;
  align-items: stretch;
  width: 385px;
  box-sizing: border-box;
}

/* Right Panel */
.right-panel-custom {
  flex: 1;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: fit-content;
  box-sizing: border-box;
}

/* Section styling */
.section-custom {
    background: var(--light-bg);
    border-radius: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    position: relative;
}

/* Typography */
h1 {
  font-size: 18px !important;
  font-weight: 600;
  color: var(--secondary);
  margin: 0 0 12px 0;
  padding: 0;
}

/* Form Controls */
.form-group-custom {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.form-group-custom label {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

input[type="range"] {
  width: 100%;
  height: 5px;
  -webkit-appearance: none;
  background: #e0e0e0;
  border-radius: 2.5px;
  outline: none;
  margin: 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Switch toggle styling */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

.switch input:checked + .slider {
  background-color: var(--primary);
}

.switch input:checked + .slider:before {
  transform: translateX(18px);
}

/* Switch label styling */
.switch-label {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
}

/* Grid control group */
.grid-control-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

/* Enhanced color input styling */
.color-input-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.grid-color-hex {
  width: 80px;
  padding: 8px 10px !important;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: var(--text);
  background: white;
  height: 36px;
  box-sizing: border-box;
  margin: 0;
}

.grid-color-hex:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(27, 164, 200, 0.2);
}

.color-display {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.2s;
  flex-shrink: 0;
  background-color: #ffffff;
  box-sizing: border-box;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}

.color-display:hover {
  transform: scale(1.05);
  border-color: var(--primary);
}

/* Grid control row */
.grid-control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 5px;
  margin-bottom: 10px;
  width: 100%;
}

/* Color control group */
.color-control-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: flex-end;
}

.color-label {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
}

/* Grid warning icon */
.grid-warning-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  cursor: help;
  position: relative;
  flex-shrink: 0;
  z-index: 100;
}

.grid-warning-icon svg {
  display: block;
  color: #7c8995;
}

/* Custom tooltip styling */
.custom-tooltip {
  position: fixed;
  display: none;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  max-width: 250px;
  width: max-content;
  z-index: 99999;
  pointer-events: none;
  line-height: 1.4;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.15);
  word-wrap: break-word;
  white-space: normal;
}

.custom-tooltip::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid rgba(0, 0, 0, 0.9);
}

/* Buttons */
.btn-primary,
.btn-secondary {
  padding: 10px 15px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  box-sizing: border-box;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
}

.btn-secondary {
  background: var(--light-bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #e9ecef;
}

.btn-secondary.active {
  background-color: #4a6fa5 !important;
  color: white !important;
}

/* Upload Area */
.upload-area-custom {
    border: 2px dashed var(--primary);
    border-radius: 8px;
    padding: 5px 10px;
    text-align: center;
    background-color: rgba(75, 108, 183, 0.03);
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 0px;
    min-height: 140px; /* Fixed minimum height */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
.upload-area-custom:hover {
    background-color: rgba(75, 108, 183, 0.08);
    border-color: var(--primary-dark);
}
.upload-area-custom i {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 2px;
}
.upload-area-custom h3 {
    font-size: 1rem;
    margin-bottom: 6px;
    color: var(--secondary);
}
.upload-area-custom p {
    color: var(--text-light);
    font-size: 0.85rem;
    margin-bottom: 10px;
    text-align: center;
}

#upload {
  display: none;
}

.upload-hint {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 8px;
  text-align: center;
}

/* Collapsible Headers - CSS ARROWS */
.collapsible-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  cursor: pointer;
  font-weight: 600;
  color: var(--secondary);
  font-size: 1rem;
  border-bottom: 1px solid var(--border);
  margin-top: 10px;
}

.collapsible-header:first-child {
  margin-top: 0;
}

.collapsible-header::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--text-light);
  transition: transform 0.2s ease;
}

.collapsible-header.active::after {
  transform: rotate(180deg);
}

/* Sliders Container */
.sliders-container {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}

.sliders-container.expanded {
  max-height: 500px;
  margin-bottom: 10px;
}

/* Palettes Container */
.palettes-container {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}

.palettes-container.expanded {
  max-height: 800px;
  margin-bottom: 10px;
}

/* Category Accordion - CSS ARROWS */
.category-header {
  padding: 6px 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.category-header:first-child {
  margin-top: 0;
}

.category-header::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid var(--text-light);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  margin-left: 8px;
  margin-right: 2px;
  transition: transform 0.2s ease;
}

.category-header.open::after {
  transform: rotate(90deg);
}

.category-palettes {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  margin-top: 6px;
}

.category-palettes.visible {
  max-height: 240px;
}

/* Palette Scroll */
.palette-scroll {
  height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}

.palette-scroll::-webkit-scrollbar {
  width: 6px;
}

.palette-scroll::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.palette-scroll::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.palette-scroll::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Palette Cards */
.palette-group {
  padding: 0px 5px 5px 5px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.2s;
  border: 1px solid transparent;
}

.palette-group:first-child {
  margin-top: 0;
}

.palette-group:hover {
  background: var(--light-bg);
}

.palette-group.active {
  background: rgba(27, 164, 200, 0.08);
  border-color: var(--primary);
}

.palette-name {
  font-size: 12px;
  margin-bottom: 4px;
  font-weight: 600;
  text-transform: capitalize;
  color: var(--text);
}

.palette-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
}

.palette-swatch {
  width: 16px;
  height: 16px;
}

/* Palette toggle row */
.palette-toggle-row {
  display: flex;
  align-items: center;
  padding: 8px 0;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

/* Grid controls */
.grid-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Action Buttons */
.action-buttons-custom {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: nowrap;
  align-items: flex-start;
}

.action-buttons-custom button {
  white-space: nowrap;
  flex: 1;
}

/* Preview Area */
.preview-area-custom {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 500px;
  background: linear-gradient(45deg, #f5f5f5 25%, transparent 25%), 
              linear-gradient(-45deg, #f5f5f5 25%, transparent 25%), 
              linear-gradient(45deg, transparent 75%, #f5f5f5 75%), 
              linear-gradient(-45deg, transparent 75%, #f5f5f5 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--border);
  flex: 1;
}

/* Preview Placeholder Styles */
.preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  color: #aaa;
  text-align: center;
  z-index: 10;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(2px);
}

.preview-placeholder.hidden {
  display: none;
}

.preview-placeholder i {
  font-size: 64px;
  color: #ddd;
}

.preview-placeholder p {
  font-size: 18px;
  color: #999;
  margin: 0;
  font-weight: 500;
}

/* Canvas */
#canvas {
  max-width: 95%;
  max-height: 95%;
  width: auto;
  height: auto;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  border: 1px solid #e0e0e0;
  background: white;
}

#canvas.grid-enabled {
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Dimensions Overlay */
.dimensions-overlay {
  position: absolute;
  top: 15px;
  left: 15px;
  background: rgba(0, 0, 0, 0.75);
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-family: 'Courier New', monospace;
  font-weight: 500;
  z-index: 10;
  pointer-events: none;
  backdrop-filter: blur(2px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.dimensions-overlay::before {
  content: "DIM: ";
  margin-right: 4px;
  font-weight: bold;
}

/* Grid Message Styling */
.grid-message {
  position: absolute;
  top: 50px;
  left: 15px;
  background: rgba(255, 107, 107, 0.9); /* Red color for warning */
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-family: 'Courier New', monospace;
  font-weight: 500;
  z-index: 10;
  pointer-events: none;
  backdrop-filter: blur(2px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  display: none;
}

.grid-message::before {
  content: "NOTE: ";
  margin-right: 4px;
  font-weight: bold;
}

/* Responsive: Stack on small screens */
@media (max-width: 900px) {
  .content-wrapper-custom {
    flex-direction: column;
    min-width: auto;
    width: 100%;
  }

  .left-panel-custom {
    flex: 0 0 auto;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 15px;
    box-sizing: border-box;
  }

  .right-panel-custom {
    width: 100%;
    padding: 15px;
    box-sizing: border-box;
  }

  .preview-area-custom {
    min-height: 300px;
    align-items: center;
  }
  
  .form-group-custom,
  .section-custom,
  .upload-area-custom,
  .grid-controls,
  .action-buttons-custom {
    width: 100%;
    max-width: 100%;
  }
  
  #canvas {
    max-width: 90%;
    max-height: 90%;
  }
  
  .grid-control-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  
  .grid-control-group,
  .color-control-group {
    width: 100%;
    justify-content: space-between;
  }
  
  .grid-message {
    top: 45px;
    font-size: 12px;
    padding: 5px 10px;
  }
  
  .dimensions-overlay {
    top: 12px;
    font-size: 12px;
    padding: 5px 10px;
  }
  
  .preview-placeholder i {
    font-size: 48px;
  }
  
  .preview-placeholder p {
    font-size: 16px;
  }
}

/* Small mobile devices */
@media (max-width: 480px) {
  .container-custom {
    border-radius: 0;
    box-shadow: none;
    margin: 0;
  }
  
  .content-wrapper-custom {
    gap: 0;
  }
  
  .left-panel-custom,
  .right-panel-custom {
    padding: 12px;
  }

  .grid-controls {
    flex-direction: column;
    gap: 10px;
  }

  .grid-control-row {
    flex-direction: column;
    gap: 10px;
  }

  .action-buttons-custom {
    flex-direction: column;
    gap: 10px;
  }

  .upload-area-custom {
    min-height: 120px;
    padding: 12px 8px;
  }

  .preview-area-custom {
    min-height: 250px;
  }
  
  .preview-placeholder i {
    font-size: 40px;
  }
  
  .preview-placeholder p {
    font-size: 14px;
  }
  
  .btn-primary,
  .btn-secondary {
    width: 100%;
    padding: 12px 15px;
  }
  
  .dimensions-overlay,
  .grid-message {
    top: 10px;
    left: 10px;
    font-size: 11px;
    padding: 5px 8px;
  }
  
  .grid-message {
    top: 45px;
  }
  
  .grid-control-row {
    flex-wrap: wrap;
  }
  
  .grid-color-hex {
    width: 100%;
    margin-top: 0;
  }
  
  .switch {
    align-self: flex-start;
  }
  
  .color-control-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }
}

/* Extra small devices */
@media (max-width: 320px) {
  .left-panel-custom,
  .right-panel-custom {
    padding: 10px 8px;
  }
  
  .upload-area-custom {
    min-height: 110px;
    padding: 10px 6px;
  }
  
  .preview-area-custom {
    min-height: 200px;
  }
  
  .preview-placeholder i {
    font-size: 36px;
  }
  
  .preview-placeholder p {
    font-size: 13px;
  }
  
  .btn-primary,
  .btn-secondary {
    padding: 10px 12px;
    font-size: 12px;
  }
  
  .dimensions-overlay,
  .grid-message {
    font-size: 10px;
    padding: 4px 6px;
  }
  
  .grid-message {
    top: 40px;
  }
}