:root {
  --primary-color: #5c6bc0;
  --secondary-color: #ff5722;
  --background-color: #333333;
  --panel-background: #444444;
  --text-color: #f5f5f5;
  --border-radius: 12px;
  --box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
  --input-background: #555555;
  --input-border: #666666;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Poppins', sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 30px 20px;
}

h1 {
  text-align: center;
  color: var(--secondary-color);
  margin-bottom: 40px;
  font-size: 2.5rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  letter-spacing: 1px;
}

h2 {
  color: var(--text-color);
  margin-bottom: 25px;
  font-size: 1.8rem;
  position: relative;
  padding-bottom: 10px;
}

h2:after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 60px;
  height: 3px;
  background: var(--secondary-color);
}

.app-container {
  display: flex;
  flex-wrap: wrap;
  gap: 40px;
}

.editor-container, .preview-container {
  flex: 1;
  min-width: 300px;
  background: var(--panel-background);
  padding: 30px;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
}

.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text-color);
}

input, select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  font-family: 'Poppins', sans-serif;
  background-color: var(--input-background);
  color: var(--text-color);
  transition: all 0.3s ease;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(92, 107, 192, 0.3);
}

.code-container {
  display: flex;
  gap: 10px;
}

.code-container input {
  flex: 1;
}

button {
  background-color: var(--secondary-color);
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
  transition: all 0.3s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

button:hover {
  background-color: #e64a19;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

#generateRandomCode {
  white-space: nowrap;
}

#banner-rotator {
  display: flex;
  justify-content: center;
  margin: 0 auto 30px auto;
  max-width: 100%;
  overflow: hidden;
}

#banner-rotator a {
  display: none;
  max-width: 100%;
}

#banner-rotator a img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.letter-spacing-control,
.line-height-control {
  margin-top: 10px;
}

.spacing-slider {
  width: 100%;
  margin-top: 5px;
}

.coupon {
  position: relative;
  border: 3px dashed #ff5722;
  border-radius: 8px;
  padding: 25px;
  max-width: 350px;
  margin: 0 auto;
  text-align: center;
  background-color: white;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  background-clip: padding-box; /* Ensures background doesn't extend beyond border */
}

.background-image-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  overflow: hidden;
}

.background-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.coupon-content {
  position: relative;
  z-index: 1;
}

.coupon-logo {
  margin-bottom: 15px;
  height: 80px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.coupon-logo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.business-name {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.service-promotion {
  font-size: 1.2rem;
  font-weight: 500;
  font-style: italic;
  margin-bottom: 10px;
  color: #555;
}

.offer-text {
  font-size: 2rem;
  font-weight: 800;
  color: var(--secondary-color);
  margin-bottom: 15px;
}

.valid-until, .coupon-code {
  margin-bottom: 10px;
}

.coupon-code {
  font-size: 1.2rem;
  font-weight: 600;
  padding: 5px 15px;
  background-color: #f0f0f0;
  display: inline-block;
  border-radius: 4px;
  letter-spacing: 1px;
}

.coupon-scissors {
  width: 24px;
  height: 24px;
  fill: var(--secondary-color);
  margin-top: 10px;
}

.actions {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 30px;
}

.actions button {
  min-width: 150px;
  font-size: 1.1rem;
}

.coupon-footer {
  margin-top: 15px;
  font-size: 0.8rem;
  border-top: 1px solid #eee;
  padding-top: 5px;
}

.coupon-footer a {
  color: var(--primary-color);
  text-decoration: none;
}

.coupon-footer a:hover {
  text-decoration: underline;
}

/* Template Styles */
.coupon.classic {
  border-color: #ff5722;
}

.coupon.modern {
  border-style: solid;
  border-radius: 15px;
  padding: 30px;
}

.coupon.modern .business-name {
  text-transform: uppercase;
  letter-spacing: 2px;
}

.coupon.elegant {
  border-style: double;
  border-width: 6px;
  border-radius: 0;
}

.coupon.elegant .business-name {
  font-family: 'Times New Roman', serif;
  font-style: italic;
}

.coupon.elegant .offer-text {
  font-family: 'Times New Roman', serif;
}

.coupon.vintage {
  border-style: dotted;
  border-width: 4px;
  font-family: 'Courier New', monospace;
}

.coupon.vintage .business-name {
  font-family: 'Georgia', serif;
  text-transform: uppercase;
  letter-spacing: 3px;
}

.coupon.minimalist {
  border-width: 1px;
  border-radius: 0;
  padding: 30px 20px;
}

.coupon.minimalist .business-name {
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 300;
}

.coupon.festive {
  border-style: dashed;
  border-width: 3px;
  border-radius: 20px;
}

.coupon.festive .offer-text {
  transform: rotate(-5deg);
  display: inline-block;
  margin: 10px 0;
  font-size: 2.2rem;
}

.background-image-controls {
  margin-top: 15px;
}

.opacity-slider {
  width: 100%;
  margin-top: 10px;
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }
  
  .coupon {
    max-width: 100%;
  }
  
  .container {
    padding: 15px 10px;
  }
  
  #banner-rotator {
    margin-bottom: 20px;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 2rem;
  }
  
  h2 {
    font-size: 1.5rem;
  }
  
  .editor-container, .preview-container {
    padding: 20px 15px;
  }
}

@media (min-width: 769px) {
  .preview-container {
    position: sticky;
    top: 20px;
    align-self: flex-start;
    max-height: 90vh;
    overflow-y: auto;
  }
}

@media (max-width: 768px) {
  .preview-container {
    position: sticky;
    top: 70px; /* Space to avoid overlapping with input fields */
    z-index: 10;
    background: var(--panel-background);
    margin-bottom: 30px;
    max-height: 50vh;
    overflow-y: auto;
  }
  
  /* Add padding to editor container to prevent the sticky preview from covering input fields */
  .editor-container {
    padding-bottom: 50px;
  }
  
  /* Add additional margin when focused on input to prevent preview from covering */
  input:focus, select:focus, textarea:focus {
    margin-bottom: 30px;
  }
}