/* Updated CSS with proper preview styling and responsive design */

/* Custom styles to complement Tailwind CSS */

/* Style for the form field groups */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.field-group label {
  font-weight: 500;
  color: #374151;
}

.field-group input,
.field-group select,
.field-group textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  border: 1px solid #d1d5db;
  border-radius: 0.75rem;
  transition: border-color 0.2s;
}

.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
  outline: none;
  border-color: #d41973;
  box-shadow: 0 0 0 2px rgba(232, 93, 159, 0.2);
}

/* Added tab system styling for Your Details and Customization tabs */
.builder-tabs {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
  margin-bottom: 2rem;
  border-bottom: 2px solid #e5e7eb;
}

.tab-button {
  padding: 1rem 2rem;
  border: none;
  background: none;
  font-weight: 600;
  color: #6b7280;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1rem;
  position: relative;
  bottom: -2px;
}

.tab-button:hover {
  color: #d41973;
  background-color: rgba(232, 93, 159, 0.05);
}

.tab-button.active {
  color: #1f2937;
  border-bottom: 3px solid #d41973;
}

/* Improved tab content animation and min-height */
.tab-content {
  display: none;
  animation: fadeIn 0.3s ease-in;
  min-height: 400px;
}

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

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Styles for the live preview container */
#pdf-viewer {
  padding: 1rem;
}

/* Updated preview container to show at normal size with scrollbar, only scale for download */
.preview-a4 {
  width: 100%;
  max-width: 794px;
  margin: 0 auto;
  background: #ffffff;
  border-radius: 0.5rem;
  position: relative;
  overflow: hidden;
  /* Show at full size with fixed height for scrolling */
  height: 1123px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  /* Removed transform scale - show at 100% normal size */
  transform: scale(1);
  transform-origin: top center;
  margin-bottom: 0;
}

/* Removed #preview-bg-img styles since we're using CSS background-image instead */

/* Adjusted preview content padding to reduce spacing and fit content in A4 */
.preview-content-scroll-area {
  height: 100%;
  /* Allow scrolling to see all content at normal size */
  overflow-y: auto;
  /* Reduced padding from 40px 70px to save space */
  padding: 30px 50px;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
  scroll-behavior: smooth;
}

/* Custom scrollbar */
.preview-content-scroll-area::-webkit-scrollbar {
  width: 8px;
}

.preview-content-scroll-area::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.preview-content-scroll-area::-webkit-scrollbar-thumb {
  background: #b0b0b0;
  border-radius: 10px;
}

.preview-content-scroll-area::-webkit-scrollbar-thumb:hover {
  background: #888;
}

/* Inner preview content styles */
/* Reduced header margins */
.preview-header {
  text-align: center;
  margin-bottom: 1rem;
}

.preview-divider {
  border: none;
  height: 1px;
  background-color: #e0e0e0;
  width: 80px;
  margin: 10px auto;
}

/* Reduced photo size to fit better */
.preview-photo {
  width: 100px;
  height: 120px;
  margin: 0 auto 0.75rem;
  border: 2px solid #c8a45c;
  background: #f0f0f0;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 2rem;
  color: #aaa;
}

.preview-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Reduced name font size */
.preview-name {
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  font-size: 1.4rem;
  color: #333;
  font-weight: 600;
  margin-bottom: 0.5rem;
  text-align: center;
}

/* Reduced gap between sections */
.preview-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

/* Reduced section margins */
.preview-section-block {
  display: flex;
  flex-direction: column;
  align-items: baseline;
  margin-bottom: 0.5rem;
}

/* Reduced section title size and margins */
.preview-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: black;
  text-decoration: underline;
  text-decoration-color: #d41973;
  text-decoration-thickness: 2px;
  padding: 0.2rem 0.6rem;
  margin-bottom: 0.5rem;
  display: inline-block;
  border-radius: 0.25rem;
  text-align: center;
}

/* CORRECTED: Preview field for perfect two-column centering */
/* Reduced field margins and font size */
.preview-field {
  display: flex;
  align-items: baseline;
  width: 450px;
  max-width: 95%;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  line-height: 1.4;
}

/* The Label part (e.g., "Gender:") */
.preview-label {
  font-weight: 600;
  color: #1f2937;
  flex-basis: 180px;
  flex-shrink: 0;
  padding-right: 1.5rem;
}

/* The Value part (e.g., "Male") */
/* Reduced value font size */
.preview-value {
  color: #444;
  word-break: break-word;
  font-size: 0.85rem;
  flex-grow: 1;
  text-align: left;
}
/* Hero section */
.hero-section {
  background: #d41973;
  padding: 4rem 0 3rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero-section::before,
.hero-section::after {
  content: "";
  position: absolute;
  width: 200px;
  height: 200px;
  opacity: 0.3;
}

.hero-section::before {
  top: 20px;
  left: 40px;
  transform: rotate(-15deg);
}

.hero-section::after {
  bottom: 20px;
  right: 40px;
  transform: rotate(15deg);
}

.hero-section .container {
  max-width: 900px;
  position: relative;
  z-index: 1;
  margin: 0 auto;
  padding: 0 1rem;
}

.hero-section h1 {
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: white;
  letter-spacing: -0.02em;
  line-height: 1.1;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.hero-section h1 .highlight {
  color: #ffd700;
  display: block;
}

.hero-section p {
  font-size: clamp(1rem, 2vw, 1.125rem);
  color: white;
  margin-bottom: 2rem;
  line-height: 1.7;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-primary {
  background-color: white;
  color: #d41973;
  font-weight: 600;
  padding: 1rem 2.5rem;
  font-size: 1.125rem;
  border-radius: 9999px;
  text-decoration: none;
  display: inline-block;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border: none;
  cursor: pointer;
}

.btn-primary:hover {
  background-color: #f8f8f8;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.hero-badges {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}

.hero-badge {
  color: white;
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hero-badge::before {
  content: "●";
  color: #ffd700;
  font-size: 0.5rem;
}

/* Template gallery */
.template-gallery {
  margin: 3rem 0;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1.5rem;
}

.template-item {
  position: relative;
  aspect-ratio: 210 / 297;
  border-radius: 0.75rem;
  overflow: hidden;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all 0.3s ease;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.template-item:hover {
  transform: translateY(-6px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
  border-color: #d41973;
}

.template-item.active {
  border-color: #d41973;
  box-shadow: 0 0 0 4px rgba(232, 93, 159, 0.3);
  transform: scale(1.05);
}

.template-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.template-item:hover img {
  transform: scale(1.05);
}

.template-overlay {
  position: absolute;
  inset: 0;
  background: rgba(232, 93, 159, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 1.125rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.template-item:hover .template-overlay {
  opacity: 1;
}

.template-item.active .template-overlay {
  opacity: 1;
  background: rgba(232, 93, 159, 0.95);
}

.template-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  margin-top: 2rem;
}

.btn-outline {
  background-color: transparent;
  color: #d41973;
  border: 2px solid #d41973;
  font-weight: 600;
  padding: 0.75rem 2rem;
  font-size: 1rem;
  border-radius: 9999px;
  text-decoration: none;
  display: inline-block;
  transition: all 0.3s ease;
  cursor: pointer;
}

.btn-outline:hover {
  background-color: #d41973;
  color: white;
  transform: translateY(-2px);
}

/* Section styles */
.section {
  padding: 4rem 0;
}

.section-title {
  text-align: center;
  font-size: 2.5rem;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 1rem;
}

.section-subtitle {
  text-align: center;
  font-size: 1.125rem;
  color: #6b7280;
  margin-bottom: 3rem;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Why Choose Us section */
.why-choose-us {
  padding: 4rem 0;
  background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin-top: 3rem;
}

.feature-card {
  background: white;
  padding: 2rem;
  border-radius: 1rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  border: 1px solid #e5e7eb;
  transition: all 0.3s ease;
  text-align: left;
}

.feature-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
  border-color: #d41973;
}

.feature-icon {
  width: 60px;
  height: 60px;
  background: #f5f1eb;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  margin-bottom: 1.5rem;
  color: #d41973;
}

.feature-card h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 0.5rem;
}

.feature-card p {
  color: #6b7280;
  line-height: 1.7;
  margin: 0;
  font-size: 1rem;
}

/* How It Works section */
.how-it-works {
  padding: 4rem 0;
  background: #f9fafb;
}

.steps-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 3rem;
  margin-top: 3rem;
  position: relative;
}

.step-card {
  text-align: center;
  position: relative;
  z-index: 1;
  background: white;
  padding: 2rem;
  border-radius: 1rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  border: 1px solid #e5e7eb;
}

.step-number {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: #d41973;
  color: white;
  font-size: 2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: -50px auto 1.5rem;
  box-shadow: 0 4px 12px rgba(232, 93, 159, 0.3);
}

.step-icon {
  width: 80px;
  height: 80px;
  background: #f5f1eb;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 1.5rem;
}

.step-card h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 0.5rem;
}

.step-card p {
  color: #6b7280;
  line-height: 1.7;
  margin: 0;
  font-size: 1rem;
}

/* SEO content section */
.seo-content {
  max-width: 900px;
  margin: 0 auto;
  line-height: 1.8;
}

.seo-content h2 {
  margin-top: 3rem;
  margin-bottom: 1.5rem;
  font-size: 2rem;
  font-weight: 700;
  color: #1f2937;
}

.seo-content h3 {
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-size: 1.5rem;
  font-weight: 600;
  color: #d41973;
}

.seo-content ul {
  list-style-type: disc;
  padding-left: 20px;
  margin-left: 2rem;
  margin-bottom: 1.5rem;
}

.seo-content li {
  margin-bottom: 0.5rem;
    line-height: 1.6;
  color: #6b7280;
}

.seo-content p {
  margin-bottom: 1rem;
  color: #4b5563;
}

/* Improved collapsible section transitions */
.collapsible-content {
  transition: max-height 0.4s ease-in-out, opacity 0.3s ease-in-out;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
}

.collapsible-content.open {
  opacity: 1;
}

.collapsible-header .toggle-arrow {
  transition: transform 0.3s ease;
}

.collapsible-header .toggle-arrow.rotate-180 {
  transform: rotate(180deg);
}

/* Responsive adjustments */
@media (max-width: 1200px) {
  .template-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 768px) {

  /* Make builder container stack vertically on mobile */
  .builder-container {
    flex-direction: column !important;
    flex-wrap: wrap !important;
  }

  .builder-form-section,
  .builder-preview-section {
    flex: 1 1 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
  }

  /* Show 2 templates per row on tablets */
  .template-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1rem;
  }

  .features-grid {
    grid-template-columns: 1fr;
  }

  .steps-container {
    grid-template-columns: 1fr;
  }

  .hero-section {
    padding: 3rem 0 2rem;
  }

  .section {
    padding: 3rem 0;
  }

  .preview-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* This centers the sections */
    gap: 1.5rem;
  }

  .preview-section-block:nth-last-child(-n + 2) {
    grid-column: 1;
  }

  .preview-a4 {
    max-width: 100%;
    aspect-ratio: 794 / 1123;
  }

  /* Stack tabs vertically on mobile */
  .builder-tabs {
    flex-direction: column;
    gap: 0;
  }

  .tab-button {
    width: 100%;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
    border-left: 3px solid transparent;
    bottom: 0;
  }

  .tab-button.active {
    border-bottom: 1px solid #e5e7eb;
    border-left: 3px solid #d41973;
  }

  .preview-content-scroll-area {
    padding: 30px 25px;
  }

  .preview-field {
    /* On mobile, we let the field take up more width */
    max-width: 100%;
    width: 300px;

  }
}

@media (max-width: 480px) {

  /* Show 2 templates per row on mobile phones instead of 1 */
  .template-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.75rem;
  }

  /* Further reduce preview padding on small phones */
  .preview-content-scroll-area {
    padding: 25px 20px;
  }

  .preview-name {
    font-size: 1.5rem;
  }

  .preview-section-title {
    font-size: 1rem;
  }

  .preview-field {
    font-size: 0.85rem;
    width: 300px;
  }

  .preview-label,
  .preview-value {
    font-size: 0.85rem;
  }
}