/* ============================================================
   Business English Communication Templates — Stylesheet
   ============================================================ */

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

/* ---------- Base ---------- */

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: #2c3e50;
  line-height: 1.6;
}

.app-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

/* ---------- Header ---------- */

.app-header {
  text-align: center;
  color: white;
  padding: 2rem 0 1.5rem;
  animation: fadeIn 0.6s ease-out;
}

.back-link {
  display: inline-block;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  padding: 0.4rem 1rem;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  border-radius: 25px;
  transition: background 0.25s, border-color 0.25s;
}

.back-link:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.65);
  color: white;
}

.app-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.5px;
}

.app-subtitle {
  font-size: 1.1rem;
  opacity: 0.9;
  max-width: 700px;
  margin: 0 auto;
  line-height: 1.7;
}

/* ---------- Search ---------- */

.search-container {
  margin: 1.75rem 0 1.25rem;
  animation: slideIn 0.5s ease-out 0.1s both;
}

.search-wrapper {
  position: relative;
  max-width: 650px;
  margin: 0 auto;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
}

.search-input {
  width: 100%;
  padding: 0.9rem 1rem 0.9rem 2.75rem;
  font-size: 1rem;
  font-family: inherit;
  border: 2px solid transparent;
  border-radius: 12px;
  background: white;
  color: #2c3e50;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: border-color 0.25s, box-shadow 0.25s;
  outline: none;
}

.search-input:focus {
  border-color: #667eea;
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3);
}

.search-input::placeholder {
  color: #aaa;
}

.match-counter {
  display: block;
  text-align: center;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 600;
}

/* ---------- Category Navigation ---------- */

.category-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.75rem;
  animation: slideIn 0.5s ease-out 0.15s both;
}

.cat-btn {
  padding: 0.55rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  border-radius: 25px;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  transition: background 0.25s, color 0.25s, border-color 0.25s, transform 0.15s;
  white-space: nowrap;
}

.cat-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.7);
  color: white;
  transform: translateY(-1px);
}

.cat-btn.active {
  background: white;
  color: #667eea;
  border-color: white;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
}

/* ---------- Content Area ---------- */

.content {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

/* ---------- Category Section ---------- */

.category-section {
  grid-column: 1 / -1;
  margin-bottom: 0.5rem;
}

.category-heading {
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid rgba(255, 255, 255, 0.25);
  animation: fadeIn 0.4s ease-out;
}

/* ---------- Template Card ---------- */

.template-card {
  background: white;
  border-radius: 15px;
  padding: 1.75rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  display: flex;
  flex-direction: column;
  animation: fadeInUp 0.45s ease-out both;
}

.template-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.template-card.hidden {
  display: none;
}

.template-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 0.85rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.template-name .icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* ---------- Code Block ---------- */

.template-structure {
  position: relative;
  background: #2c3e50;
  border-radius: 10px;
  padding: 1.1rem 1.1rem 0.9rem;
  margin-bottom: 1rem;
  overflow-x: auto;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.88rem;
  color: #ecf0f1;
  line-height: 1.6;
}

.template-structure .placeholder {
  color: #f9ca24;
  font-weight: 500;
}

/* ---------- Copy Button ---------- */

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  color: white;
  border-color: rgba(255, 255, 255, 0.5);
}

.copy-btn.copied {
  background: #27ae60;
  border-color: #27ae60;
  color: white;
}

/* ---------- Example ---------- */

.template-example {
  background: #f7f9fc;
  border-left: 4px solid #667eea;
  border-radius: 0 10px 10px 0;
  padding: 0.85rem 1rem;
  margin-bottom: 0.85rem;
  font-size: 0.9rem;
  color: #444;
  line-height: 1.6;
  font-style: italic;
}

.template-example strong {
  font-style: normal;
  color: #667eea;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  display: block;
  margin-bottom: 0.3rem;
}

/* ---------- When-to-use ---------- */

.when-to-use {
  font-size: 0.83rem;
  color: #777;
  margin-top: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  padding-top: 0.6rem;
  border-top: 1px solid #eef0f4;
}

.when-to-use .label {
  font-weight: 700;
  color: #555;
  white-space: nowrap;
}

/* ---------- Footer ---------- */

.app-footer {
  text-align: center;
  color: rgba(255, 255, 255, 0.7);
  padding: 2.5rem 0 1rem;
  font-size: 0.85rem;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #2c3e50;
  color: white;
  padding: 0.65rem 1.5rem;
  border-radius: 25px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.25);
  z-index: 1000;
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275),
              opacity 0.3s ease;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ---------- Keyframes ---------- */

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ---------- Responsive: 768px ---------- */

@media (max-width: 768px) {
  .app-container {
    padding: 1.5rem 1rem 2.5rem;
  }

  .app-title {
    font-size: 1.9rem;
  }

  .app-subtitle {
    font-size: 0.95rem;
  }

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

  .cat-btn {
    font-size: 0.8rem;
    padding: 0.45rem 0.8rem;
  }

  .template-card {
    padding: 1.35rem;
  }

  .template-structure {
    font-size: 0.82rem;
  }

  .category-heading {
    font-size: 1.3rem;
  }
}

/* ---------- Responsive: 480px ---------- */

@media (max-width: 480px) {
  .app-container {
    padding: 1rem 0.75rem 2rem;
  }

  .app-title {
    font-size: 1.55rem;
  }

  .app-subtitle {
    font-size: 0.88rem;
  }

  .search-input {
    font-size: 0.9rem;
    padding: 0.75rem 0.85rem 0.75rem 2.5rem;
  }

  .category-nav {
    gap: 0.35rem;
  }

  .cat-btn {
    font-size: 0.75rem;
    padding: 0.4rem 0.7rem;
  }

  .template-card {
    padding: 1.1rem;
    border-radius: 12px;
  }

  .template-structure {
    font-size: 0.78rem;
    padding: 0.85rem;
  }

  .template-name {
    font-size: 1rem;
  }

  .template-example {
    font-size: 0.83rem;
  }

  .category-heading {
    font-size: 1.15rem;
  }

  .copy-btn {
    font-size: 0.7rem;
    padding: 0.3rem 0.55rem;
  }

  .back-link {
    font-size: 0.85rem;
    padding: 0.3rem 0.8rem;
  }
}
