:root {
  --card-background: #fff;
}

.email-container {
  display: grid;
  margin: 2rem auto;
  padding: 1.25rem;
  background: var(--card); 
  border-radius: 1.5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  font-size: 1rem;
  color: var(--text); 
}

.email-container:hover {
  transform: translateY(-1px);
  opacity: 1;
}

.email-container h1 {
  font-size: 2rem;
  font-weight: 800;
  margin: .4rem 0 0.5rem;
  text-align: center;
  color: var(--text);
}

.email-container p {
  font-size: 1rem;
  text-align: center;
  color: var(--soft);
  margin-bottom: 2rem;
}

.email-generator-layout {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Left card */
.form-section {
 border: 1px solid var(--border);
  padding: 2rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  text-align: left;
}

.form-section:hover {
  transform: translateY(-1px);
  opacity: 1;
}

.preview-section {
  border: 1px solid var(--border);
  padding: 2rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  text-align: left;
}

.preview-section:hover {
  transform: translateY(-1px);
  opacity: 1;
}

h3 {
  font-size: 1.2rem;
  margin-top: 0;
  margin-bottom: 1.5rem;
  color: var(--primary);
  text-align: center;
}

.input-group {
  margin-bottom: 1rem;
}

label {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}

input, select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-sizing: border-box;
  transition: border 0.3s;
  background: var(--card-background);
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
}

.social-links-dropdown {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 20px;
}

.social-links-dropdown summary {
  padding: 12px;
  font-weight: 550;
  color: black;
  background: var(--card-background);
  border-radius: 10px;
  cursor: pointer;
  list-style: none;
  position: relative;
}

.social-links-dropdown summary::after {
  content: '▼';
  position: absolute;
  right: 12px;
  transition: transform 0.2s;
}

.social-links-dropdown[open] summary::after {
  transform: rotate(180deg);
}

.dropdown-content {
  padding: 10px 12px 0;
  border-top: 1px solid var(--soft);
  bg: var(--secondary-color);
}

.signature-box {
  border: 1px solid var(--border);
  padding: 20px;
  min-height: 150px;
  border-radius: 8px;
  color: var(--hard);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: #f8f9fa;
  overflow: auto !important;
}

.button-group {
  justify-content: center;
  margin-top: 2rem;
  margin-left: 5rem;
}


/* Accessibility focus highlight */
input:focus, select:focus, button:focus {
  outline: 2px solid var(--ring);
  outline-offset: 0px;
}

.copy-message {
  text-align: center;
  margin-top: 15px;
  color: green;
  font-weight: bold;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.copy-message.show {
  opacity: 1;
}

/* Desktop shifting Fix */
@media (min-width: 768px) {
  .email-generator-layout {
    display: flex;
    align-items: stretch; /* makes both sides equal height */
    height: 100%;
  }

  /* lock both columns equal height */
  .form-section,
  .preview-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: auto;
  }

  /* prevent layout jump when preview grows */
  .email-container {
    display: flex;
    flex-direction: column;
    height: 100%;
  }

  /* limit the preview section to fixed height */
  .preview-section {
    overflow-y: auto;
    max-height: 800px;
  }

  /* lock the entire container height */
  html, body {
    overflow-x: hidden;
  }

  /* optional: smooth height control if content expands */
  .email-generator-layout {
    min-height: 650px;
  }
}

/* ==== Inline Form Validation ==== */
.input-error {
  color: #e63946;
  font-size: 0.85rem;
  margin-top: 4px;
  display: block;
  font-weight: 500;
}

input.invalid {
  border-color: #e63946 !important;
  box-shadow: 0 0 0 2px rgba(230, 57, 70, 0.15);
  background-color: #fff8f8;
}


/* =========================
   MOBILE (≤520px) 
   ========================= */
@media (max-width: 520px) {

  .email-container {
    max-width: none !important; 
    width: 98% !important;
    padding: 1.4rem !important;
    margin: 1rem auto 1rem !important;
    border-radius: 12px !important;
    box-shadow: 0 3px 10px rgba(0,0,0,0.15) !important;
  }

  /* Headings & Text */
  .email-container h1 {
    font-size: 1.55rem !important;
    line-height: 1.3 !important;
    text-align: center !important;
  }

  .email-container h3 {
    font-size: 1rem !important;
    text-align: center !important;
  }

  .email-container p {
    font-size: 0.92rem !important;
    line-height: 1.55 !important;
    text-align: center !important;
    margin-bottom: 1rem !important;
    display: -webkit-box;   /* Truncate the paragraph */
    -webkit-line-clamp: 3; 
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* Form Grid */
  .email-generator-layout {
    gap: 1rem !important;
  }

  .form-section, .preview-section {
    flex: 1;
    width: 100% !important;
    background: var(--muted);
    padding: 1rem;
    border-radius: 12px;
    border: 0rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    overflow: auto;
  }

  /* Inputs & Labels */
  .email-container input {
    padding: 0.75rem 0.85rem !important;
    font-size: 0.96rem !important;
    border-radius: 8px !important;
    min-height: 46px !important;
    appearance: none;
  }

  .email-container label {
    font-size: 0.88rem !important;
    font-weight: 600;
  }

  input:focus, button:focus {
    outline: 2px solid var(--ring);
    outline-offset: 0px;
  }

  .email-generator-layout {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .email-container {
    overflow: hidden;
  }

  .form-section *,
  .preview-section * {
    word-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
  }

  .signature-box {
    overflow: auto;
  }

  .button-group {
    justify-content: center;
    margin-left: 1rem;
  }
}

@media (min-width: 768px) {
  .email-generator-layout {
    flex-direction: row;
    align-items: stretch; 
  }
    .button-group {
    justify-content: center;
    margin-left: 0.8rem;
  }

}