/* ================= FONT PREVIEW STYLES ================= */
select#fontFamily {
  font-size: 14px;
  height: 40px;
}

select#fontFamily option {
  font-size: 16px;
  padding: 10px 5px;
  height: 35px;
}

/* Font family specific previews */
select#fontFamily option[value*="Great Vibes"] {
  font-family: 'Great Vibes', cursive;
  font-size: 18px;
}

select#fontFamily option[value*="Sacramento"] {
  font-family: 'Sacramento', cursive;
  font-size: 16px;
}

select#fontFamily option[value*="Dancing Script"] {
  font-family: 'Dancing Script', cursive;
  font-size: 16px;
}

select#fontFamily option[value*="Pacifico"] {
  font-family: 'Pacifico', cursive;
  font-size: 15px;
}

select#fontFamily option[value*="Allura"] {
  font-family: 'Allura', cursive;
  font-size: 18px;
}

select#fontFamily option[value*="Parisienne"] {
  font-family: 'Parisienne', cursive;
  font-size: 16px;
}

select#fontFamily option[value*="Tangerine"] {
  font-family: 'Tangerine', cursive;
  font-size: 18px;
}

select#fontFamily option[value*="Alex Brush"] {
  font-family: 'Alex Brush', cursive;
  font-size: 18px;
}

select#fontFamily option[value*="Mr De Haviland"] {
  font-family: 'Mr De Haviland', cursive;
  font-size: 16px;
}

select#fontFamily option[value*="Mrs Saint Delafield"] {
  font-family: 'Mrs Saint Delafield', cursive;
  font-size: 16px;
}

select#fontFamily option[value*="Clicker Script"] {
  font-family: 'Clicker Script', cursive;
  font-size: 16px;
}

select#fontFamily option[value*="Berkshire Swash"] {
  font-family: 'Berkshire Swash', cursive;
  font-size: 15px;
}

select#fontFamily option[value*="Kaushan Script"] {
  font-family: 'Kaushan Script', cursive;
  font-size: 15px;
}

select#fontFamily option[value*="Marck Script"] {
  font-family: 'Marck Script', cursive;
  font-size: 15px;
}

select#fontFamily option[value*="Niconne"] {
  font-family: 'Niconne', cursive;
  font-size: 16px;
}

select#fontFamily option[value*="Qwigley"] {
  font-family: 'Qwigley', cursive;
  font-size: 18px;
}

select#fontFamily option[value*="Style Script"] {
  font-family: 'Style Script', cursive;
  font-size: 16px;
}

select#fontFamily option[value*="WindSong"] {
  font-family: 'WindSong', cursive;
  font-size: 16px;
}

/* ================= FOOTER ================= */
.main-footer {
  background: #1f2937;
  color: white;
  padding: 40px 0;
  margin-top: 50px;
  border-radius: 10px;
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 30px;
}

.footer-section h3 {
  color: #3b82f6;
  margin-bottom: 15px;
}

.footer-links {
  list-style: none;
  padding: 0;
}

.footer-links li {
  margin-bottom: 8px;
}

.footer-links a {
  color: #d1d5db;
  text-decoration: none;
  transition: color 0.3s;
}

.footer-links a:hover {
  color: #3b82f6;
}

.footer-bottom {
  text-align: center;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid #374151;
  color: #9ca3af;
}

/* ================= NAVIGATION ================= */
.main-nav {
  background: linear-gradient(135deg, #6a11cb, #2575fc);
  padding: 15px 0;
  border-radius: 10px;
  margin-bottom: 20px;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

.nav-links {
  display: flex;
  justify-content: center;
  gap: 30px;
  flex-wrap: wrap;
}

.nav-links a {
  color: white;
  text-decoration: none;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 6px;
  transition: background 0.3s;
}

.nav-links a:hover {
  background: rgba(255, 255, 255, 0.2);
}

.nav-links a.active {
  background: rgba(255, 255, 255, 0.3);
}

/* Small screen adjustments for navigation */
@media(max-width:899px) {
  .nav-links {
    gap: 15px;
  }

  .nav-links a {
    padding: 6px 12px;
    font-size: 0.9rem;
  }
}

/* ================= GLOBAL ================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f5f6fb;
  color: #222;
}

.container {
  max-width: 1200px;
  margin: 20px auto;
  padding: 16px;
}

header {
  text-align: center;
  padding: 22px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6a11cb, #2575fc);
  color: #fff;
  margin-bottom: 18px;
}

header h1 {
  margin: 0;
  font-size: 1.9rem;
}

.app-description {
  margin-top: 8px;
  opacity: 0.95;
}

.app-container {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

@media(min-width:900px) {
  .app-container {
    flex-direction: row;
  }

  .controls {
    flex: 1;
  }

  .preview {
    flex: 1;
  }
}

.section {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 6px 18px rgba(12, 20, 40, 0.06);
  display: flex;
  flex-direction: column;
}

.section-title {
  font-size: 1.25rem;
  color: #1e73e8;
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid #f1f4fb;
}

/* ================= CATEGORY GALLERY ================= */
.category-gallery {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 6px;
}

.category-item {
  background: linear-gradient(135deg, #6f7efc 0%, #7952c5 100%);
  color: #fff;
  padding: 14px 10px;
  border-radius: 10px;
  text-align: center;
  font-weight: 700;
  cursor: pointer;
  transition: transform .14s ease, box-shadow .14s ease;
  user-select: none;
}

.category-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(13, 24, 60, 0.12);
}

.category-item.selected {
  outline: 3px solid #2b8bff;
  transform: scale(1.03);
}

/* ================= BACKGROUND GALLERY ================= */
.background-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 6px;
}

.background-item {
  position: relative;
  width: calc(33.333% - 8px);
  /* 3 columns minus gap adjustment */
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background: #e9ecf4;
  transition: box-shadow .14s ease, transform .14s ease, border-color .14s;
  display: block;
}

/* Aspect ratio hack using pseudo-element - most robust for Grid */
.background-item::before {
  content: "";
  display: block;
  padding-top: 100%;
  /* Forces 1:1 aspect ratio */
}

.background-item img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.background-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 10px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.0), rgba(0, 0, 0, 0.65));
  color: #fff;
  font-size: 0.85rem;
  text-align: center;
}

.background-item.selected {
  box-shadow: 0 0 0 3px rgba(37, 117, 252, 0.25);
  transform: translateY(-3px);
  border: 2px solid #2575fc;
}

/* ================= QUOTES LIST ================= */
.quotes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 6px;
  border-radius: 8px;
  border: 1px solid #eef2fb;
  padding: 8px;
}

.quote-item {
  padding: 10px;
  border-radius: 6px;
  cursor: pointer;
}

.quote-item:hover {
  background: #fbfdff;
}

.quote-item.selected {
  background: #e8f2ff;
  border-left: 4px solid #2b8bff;
}

.quote-text {
  font-style: italic;
  color: #111;
  margin-bottom: 6px;
}

.quote-author {
  text-align: right;
  font-size: 0.9rem;
  color: #4b5563;
}

/* ================= PREVIEW ================= */
.preview-container {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  border-radius: 10px;
  overflow: auto;
  box-shadow: 0 10px 30px rgba(12, 20, 40, 0.08);
  background: #222;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 80vh;
}

#quoteCanvas {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  background: #000;
}

/* ================= SOCIAL SHARE BUTTONS ================= */
.social-share {
  border-top: 1px solid #eef2fb;
  padding-top: 16px;
  margin-top: 16px;
}

.social-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-social {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.8rem;
  min-width: 100px;
  transition: all 0.2s ease;
}

.btn-social:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-whatsapp {
  background: #25D366;
  color: white;
}

.btn-facebook {
  background: #1877F2;
  color: white;
}

.btn-twitter {
  background: #1DA1F2;
  color: white;
}

.btn-linkedin {
  background: #0077B5;
  color: white;
}

.btn-pinterest {
  background: #BD081C;
  color: white;
}

.btn-share {
  background: #8B5CF6;
  color: white;
}

.btn-whatsapp:hover {
  background: #128C7E;
}

.btn-facebook:hover {
  background: #1666D6;
}

.btn-twitter:hover {
  background: #1A8CD8;
}

.btn-linkedin:hover {
  background: #006097;
}

.btn-pinterest:hover {
  background: #9C0716;
}

.btn-share:hover {
  background: #7C3AED;
}

/* ================= SMALL SCREEN ADJUSTMENTS ================= */
@media(max-width:899px) {
  .category-gallery {
    grid-template-columns: repeat(2, 1fr);
  }

  .background-gallery {
    /* Flexbox override for mobile is automatic via width but we can reset if needed */
    max-height: 400px;
  }

  .background-item {
    width: calc(50% - 6px);
  }

  .section {
    padding: 12px;
  }

  .social-buttons {
    gap: 6px;
  }

  .btn-social {
    min-width: 85px;
    padding: 6px 10px;
    font-size: 0.75rem;
  }

  .preview-container {
    max-height: 60vh;
  }

  #quoteCanvas {
    max-height: 50vh;
  }
}

/* ================= CUSTOM SCROLLBARS ================= */
.category-gallery::-webkit-scrollbar,
.background-gallery::-webkit-scrollbar,
.quotes-list::-webkit-scrollbar {
  width: 8px;
}

.category-gallery::-webkit-scrollbar-thumb,
.background-gallery::-webkit-scrollbar-thumb,
.quotes-list::-webkit-scrollbar-thumb {
  background: #cfd8e8;
  border-radius: 8px;
}

/* ================= MISC ================= */
.placeholder-text {
  text-align: center;
  color: #6b7280;
  padding: 14px;
}

.action-buttons {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  padding: 10px 16px;
  border-radius: 8px;
  border: 0;
  cursor: pointer;
  font-weight: 700;
}

.btn-primary {
  background: #2575fc;
  color: #fff;
}

.btn-success {
  background: #16a34a;
  color: #fff;
}

.customization-options {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.option-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
}

.option-group select,
.option-group input[type="color"],
.option-group input[type="range"] {
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #dbe4fb;
}

.loading {
  text-align: center;
  color: #6b7280;
  padding: 20px;
}

.share-instructions {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  padding: 12px;
  margin-top: 10px;
  font-size: 0.85rem;
  color: #0369a1;
}

/* ================= SEARCH STYLES ================= */
.search-container {
  position: relative;
  margin-bottom: 15px;
}

.search-input {
  width: 100%;
  padding: 10px 40px 10px 12px;
  border: 1px solid #dbe4fb;
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  transition: all 0.3s ease;
}

.search-input:focus {
  outline: none;
  border-color: #2575fc;
  box-shadow: 0 0 0 3px rgba(37, 117, 252, 0.1);
}

.search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #6b7280;
}

.search-results-info {
  margin-top: 8px;
  font-size: 0.85rem;
  color: #6b7280;
  text-align: center;
}

.category-item.hidden {
  display: none;
}

.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 20px;
  color: #6b7280;
  font-style: italic;
}