:root {
  --primary-color: #4361ee;
  --primary-dark: #3a56d4;
  --background-color: #f9f9f9;
  --card-color: #ffffff;
  --text-color: #333333;
  --border-color: #e0e0e0;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.6;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.panels-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

@media (min-width: 900px) {
  .panels-container {
    flex-direction: row;
  }
  
  .panel-controls {
    flex: 1;
  }
  
  .panel-preview {
    flex: 1;
  }
}

.panel {
  background-color: var(--card-color);
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  padding: 1.5rem;
}

.panel-title {
  margin-top: 0;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--primary-color);
}

.form-group {
  margin-bottom: 1.5rem;
  position: relative;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.counter {
  font-size: 0.8rem;
  color: #666;
  float: right;
}

input, textarea, select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  font-size: 1rem;
  transition: border-color 0.3s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

.primary-btn {
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s;
  display: block;
  width: 100%;
}

.primary-btn:hover {
  background-color: var(--primary-dark);
}

.download-options {
  width: 100%;
  margin-top: 1rem;
}

.download-info {
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: #666;
}

.download-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.download-btn {
  background-color: #28a745;
  color: white;
  border: none;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s;
  flex: 1;
  min-width: 140px;
}

.download-btn:hover {
  background-color: #218838;
}

.download-btn-svg {
  background-color: #17a2b8;
}

.download-btn-svg:hover {
  background-color: #138496;
}

.download-btn-gif {
  background-color: #9c27b0; /* Purple color for GIF button */
}

.download-btn-gif:hover {
  background-color: #7B1FA2; /* Darker purple on hover */
}

.options-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.hidden {
  display: none !important;
  visibility: hidden;
}

.active {
  display: block !important;
  visibility: visible;
}

.qr-preview-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  width: 100%;
}

.qr-preview-container.hidden {
  display: none !important;
  height: 0;
  overflow: hidden;
}

#qrcode {
  width: 300px;
  height: 300px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  padding: 16px;
  background-color: rgba(0, 0, 0, 0.03);
  border-radius: 8px;
  position: relative;
}

/* Checkerboard pattern for transparent backgrounds */
#qrcode.transparent {
  background-image: 
    linear-gradient(45deg, #f0f0f0 25%, transparent 25%), 
    linear-gradient(-45deg, #f0f0f0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f0f0f0 75%),
    linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

#qrcode canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.qr-image {
  width: 2048px;
  height: 2048px;
  transform-origin: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

.preview-data {
  width: 100%;
}

.preview-text {
  margin-top: 1rem;
  padding: 1rem;
  background-color: #f0f0f0;
  border-radius: 5px;
  max-width: 100%;
  overflow-wrap: break-word;
  font-size: 0.9rem;
}

.no-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  height: auto;
  min-height: 200px;
  background-color: transparent;
  border-radius: 8px;
  padding: 2rem 0;
}

.preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  text-align: center;
  max-width: 90%;
}

.preview-placeholder svg {
  margin-bottom: 1rem;
  opacity: 0.7;
}

.preview-placeholder p {
  margin: 0;
  margin-bottom: 0.75rem;
  color: #666;
  font-size: 0.95rem;
  line-height: 1.4;
}

.instruction-list {
  text-align: left;
  margin: 0.5rem 0 1rem;
  padding-left: 1.5rem;
  color: #666;
  font-size: 0.9rem;
  line-height: 1.4;
  width: 100%;
}

.instruction-list li {
  margin-bottom: 0.5rem;
  position: relative;
}

.instruction-list li::marker {
  color: var(--primary-color);
}

.instruction-tip {
  background-color: rgba(67, 97, 238, 0.05);
  border-left: 3px solid var(--primary-color);
  padding: 0.6rem 1rem;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  text-align: left;
  border-radius: 0 4px 4px 0;
  width: 100%;
  box-sizing: border-box;
}

.style-options,
.style-button,
.emoji-picker-container,
.emoji-picker {
  /* Remove these styles */
  display: none !important;
}

.file-input-container {
  position: relative;
  display: inline-block;
  width: 100%;
}

.custom-file-input {
  padding: 8px 16px;
  background-color: #f5f5f5;
  color: #333;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  display: inline-block;
  margin-bottom: 10px;
}

.custom-file-input:hover {
  background-color: #e5e5e5;
}

.file-name-display {
  margin-left: 10px;
  font-size: 0.9em;
  color: #666;
}

/* Hide the actual file input */
.file-input-container input[type="file"] {
  position: absolute;
  left: -9999px;
  opacity: 0;
  width: 1px;
  height: 1px;
}

/* Remove text labels for style buttons */

@media (max-width: 600px) {
  .options-container {
    grid-template-columns: 1fr;
  }
}

.logo-container {
  pointer-events: none;
}

.logo-input-group {
  display: flex;
  gap: 10px;
  align-items: center;
  pointer-events: auto;
}

.clear-btn {
  background-color: #dc3545;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s;
  flex-shrink: 0;
}

.clear-btn:hover {
  background-color: #bd2130;
}

.logo-container input[type="file"] {
  pointer-events: auto;
  max-width: 100%;
  box-sizing: border-box;
  flex-grow: 1;
}

.logo-container label {
  pointer-events: none;
}

.logo-container #logoControls {
  pointer-events: auto;
}

#logoSize {
  width: 85%;
  margin-left: 15px; /* Indentation under the label */
  margin-bottom: 5px; /* Small space below the slider */
  padding: 0;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  outline: none;
}

#logoSize::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary-color);
  cursor: pointer;
}

#logoSize::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary-color);
  cursor: pointer;
  border: none;
}

.logo-size-container {
  margin-top: 20px;  /* Increased spacing between file picker and logo size */
  margin-bottom: 0;  /* Set bottom margin to 0 */
}

.logo-size-container label {
  display: block;
  margin-bottom: 0;  /* Set bottom margin to 0 */
}

#logoSizeValue {
  font-weight: 600;
  color: var(--primary-color);
}

.logo-style-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 15px; /* Add space between slider and checkbox */
}

.logo-style-option input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
}

.logo-style-option label {
  font-size: 0.9rem;
  margin: 0;
  cursor: pointer;
  font-weight: normal;
  pointer-events: auto;
}

.emoji-picker-container {
  display: none;
  margin-top: 8px;
  width: 100%;
  position: absolute;
  z-index: 1000;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.emoji-picker-container.visible {
  display: block;
}

.emoji-picker {
  width: 100% !important;
  --rgb-background: 255, 255, 255;
  --rgb-input: 51, 51, 51;
  --rgb-color: 67, 97, 238;
  --input-border-color: var(--border-color);
  --input-border-radius: 4px;
  --input-font-size: 1rem;
  --input-padding: 8px;
  --outline-color: var(--primary-color);
}

/* Hide the emoji picker's category buttons for a cleaner look */
.emoji-picker::part(category-buttons) {
  display: none;
}

/* Adjust the emoji grid size */
.emoji-picker::part(emoji-grid) {
  max-height: 200px;
}

/* Color picker styles */
.color-inputs-container {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.color-input {
  flex: 1;
  min-width: 200px;
}

.sub-label {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 5px;
}

.color-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-input-row input[type="color"] {
  width: 50px;
  height: 40px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 2px;
}

.color-input-row input[type="text"] {
  flex: 1;
}

.bg-toggle-container {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bg-toggle-container input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
}

.color-input-row.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.color-input-row.disabled input {
  background-color: #f0f0f0;
  cursor: not-allowed;
}

.logo-header {
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  overflow: hidden;
  padding: 0.5rem 0;
}

.header-logo {
  max-width: 100%;
  height: auto;
  max-height: 80px;
  display: block;
  margin: 0 auto;
  transition: all 0.3s ease;
}

/* Responsive breakpoints for the logo */
@media (max-width: 900px) {
  .header-logo {
    max-height: 70px;
  }
}

@media (max-width: 768px) {
  .header-logo {
    max-height: 60px;
  }
}

@media (max-width: 600px) {
  .header-logo {
    max-height: 50px;
    width: auto;
  }
}

@media (max-width: 480px) {
  .header-logo {
    max-height: 40px;
    width: auto;
  }
  
  .logo-header {
    margin-bottom: 1rem;
    padding: 0.25rem 0;
  }
}

@media (max-width: 375px) {
  .header-logo {
    max-height: 35px;
    width: 90%;
    object-fit: contain;
  }
}

@media (max-width: 320px) {
  .header-logo {
    max-height: 30px;
    width: 85%;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0.75rem;
  }
  
  .panel {
    padding: 1.25rem;
  }
}

/* QR logo overlay for animated GIFs */
.qr-logo-overlay {
  position: absolute;
  z-index: 10;
  pointer-events: none; /* Allow clicking through the logo */
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: block;
  max-width: 30%; /* Match the max size allowed in the UI */
  height: auto;
  object-fit: contain;
}

/* QR logo background for animated GIFs */
.qr-logo-background {
  position: absolute;
  z-index: 9;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background-color: white;
  pointer-events: none;
}

/* Batch Processing Styles */
.mode-toggle {
  display: flex;
  margin-bottom: 20px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #ddd;
}

.mode-btn {
  flex: 1;
  padding: 10px 15px;
  background: #f5f5f5;
  border: none;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s ease;
}

.mode-btn.active {
  background: var(--primary-color);
  color: white;
}

.batch-section {
  margin-top: 20px;
  padding: 15px;
  background-color: #f9f9f9;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
}

.batch-instructions,
.serial-instructions {
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e0e0e0;
}

.template-link {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
}

.template-link:hover {
  text-decoration: underline;
}

.progress-bar-container {
  width: 100%;
  height: 20px;
  background-color: #f0f0f0;
  border-radius: 10px;
  margin: 15px 0;
  overflow: hidden;
}

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

#progressStatus {
  text-align: center;
  font-size: 14px;
  color: #555;
  margin-bottom: 15px;
}

.batch-preview {
  margin-top: 25px;
}

.preview-container {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin-top: 10px;
}

.qr-preview-item {
  border: 1px solid #ddd;
  padding: 10px;
  border-radius: 6px;
  background: white;
  width: calc(20% - 15px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.qr-preview-item img,
.qr-preview-item svg {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

.qr-preview-label {
  font-size: 12px;
  text-align: center;
  margin-top: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .qr-preview-item {
    width: calc(33.333% - 15px);
  }
}

@media (max-width: 480px) {
  .qr-preview-item {
    width: calc(50% - 15px);
  }
}

/* Improved switch styling */
.toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: 10px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  margin-left: 8px;
}

.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: 22px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--primary-color);
}

input:focus + .slider {
  box-shadow: 0 0 1px var(--primary-color);
}

input:checked + .slider:before {
  transform: translateX(18px);
}

/* Fix for color-section styles in batch mode */
.batch-section .color-section {
  padding: 15px;
  background: rgba(0,0,0,0.02);
  border-radius: 8px;
  margin-bottom: 15px;
}

.batch-section .color-input-row {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
}

.batch-section .color-input-row:last-child {
  margin-bottom: 0;
}

.batch-section .color-input-row label {
  min-width: 140px;
  margin-bottom: 0;
}

.batch-section .color-text {
  margin-left: 10px;
  width: 100px;
}

/* Batch mode preview panel styles */
.batch-instructions-preview {
  text-align: center;
  padding: 1rem 0;
}

/* Logo controls for batch mode */
#batchLogoControls {
  width: 100%;
  pointer-events: auto; 
}

#batchLogoSize {
  width: 85%;
  margin-left: 15px;
  margin-bottom: 5px;
  padding: 0;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  outline: none;
}

#batchLogoSize::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary-color);
  cursor: pointer;
}

#batchLogoSize::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary-color);
  cursor: pointer;
  border: none;
}

#batchLogoSizeValue {
  font-weight: 600;
  color: var(--primary-color);
}

/* Make sure the batch toggle is always clickable */
.batch-section .toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.batch-section .toggle-wrapper input[type="checkbox"] {
  width: auto;
  cursor: pointer;
  margin-left: 8px;
  height: 16px;
  width: 16px;
}

/* Ensure all controls in batch mode are accessible */
.batch-section input,
.batch-section select,
.batch-section button {
  pointer-events: auto;
}

.serial-section {
  margin-top: 20px;
  padding: 15px;
  background-color: #f9f9f9;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
}

/* Hide Single mode controls when in Serial or Batch mode */
.mode-btn.active ~ .form-group:not(.batch-section):not(.serial-section) {
  display: none;
}

.mode-btn.active ~ .color-inputs-container:not(.batch-section):not(.serial-section) {
  display: none;
}

.mode-btn.active ~ .logo-container:not(.batch-section):not(.serial-section) {
  display: none;
}

/* Show Single mode controls only when Single mode is active */
#singleModeBtn.active ~ .form-group:not(.batch-section):not(.serial-section) {
  display: block;
}

#singleModeBtn.active ~ .color-inputs-container:not(.batch-section):not(.serial-section) {
  display: flex;
}

#singleModeBtn.active ~ .logo-container:not(.batch-section):not(.serial-section) {
  display: block;
}

/* Mode-based display controls */
.single-mode-section,
.batch-mode-section,
.serial-mode-section {
  display: none;
}

.single-mode-section.active,
.batch-mode-section.active,
.serial-mode-section.active {
  display: block;
}

/* Preview panel visibility control */
#singlePreviewPanel,
#batchPreviewPanel,
#serialPreviewPanel {
  display: none;
}

#singlePreviewPanel:not(.hidden),
#batchPreviewPanel:not(.hidden),
#serialPreviewPanel:not(.hidden) {
  display: block;
}

/* Mode-specific controls visibility */
.batch-mode-section .form-group,
.batch-mode-section .color-section,
.batch-mode-section .logo-container,
.serial-mode-section .form-group,
.serial-mode-section .color-section,
.serial-mode-section .logo-container {
  display: block;
}

.batch-mode-section.hidden .form-group,
.batch-mode-section.hidden .color-section,
.batch-mode-section.hidden .logo-container,
.serial-mode-section.hidden .form-group,
.serial-mode-section.hidden .color-section,
.serial-mode-section.hidden .logo-container {
  display: none;
}

/* Ensure visibility classes work properly */
.hidden {
  display: none !important;
  visibility: hidden;
}

.active {
  display: block !important;
  visibility: visible;
}