/**
 * Quick Word List Styles
 * Warm, welcoming design matching the home page aesthetic
 */

/* ==========================================================================
   WARM COLOUR PALETTE (matching index.html)
   ========================================================================== */

:root {
  --warm-cream: #faf8f5;
  --warm-cream-dark: #f5f2ed;
  --teal-soft: #0d9488;
  --teal-light: #14b8a6;
  --teal-pale: #ccfbf1;
  --teal-dark: #0f766e;
}

/* ==========================================================================
   BASE LAYOUT
   ========================================================================== */

body {
  background: var(--warm-cream);
}

.generator-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 2rem;
  min-height: calc(100vh - var(--header-height));
  display: flex;
  flex-direction: column;
}

.generator-container main {
  flex: 1;
}

/* ==========================================================================
   MAIN SECTION
   ========================================================================== */

#quick-words-section {
  scroll-margin-top: 2rem;
  max-width: 100%;
  padding: 0;
}

/* ==========================================================================
   SEARCH AREA - Warm, inviting input
   ========================================================================== */

.quick-words-search {
  display: flex;
  gap: 0.75rem;
  align-items: stretch;
  margin-bottom: 1.5rem;
  transition: margin 0.15s ease;
}

/* Compact state when results are showing */
.quick-words-search.has-results {
  margin-bottom: 0.75rem;
}

.quick-words-search.has-results .quick-search-input {
  padding: 0.5rem 0.875rem;
  font-size: 1rem;
}

.quick-words-search.has-results .quick-search-btn {
  padding: 0.5rem 1rem;
  font-size: 1rem;
}

.quick-search-input {
  flex: 1;
  padding: 0.75rem 1rem;
  font-size: 1.125rem;
  font-family: inherit;
  color: var(--color-text-primary);
  background: #fff;
  border: 2px solid var(--warm-cream-dark);
  border-radius: 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, padding 0.15s ease, font-size 0.15s ease;
}

.quick-search-input:focus {
  outline: none;
  border-color: var(--teal-soft);
  box-shadow: 0 0 0 4px var(--teal-pale);
}

.quick-search-input::placeholder {
  color: var(--color-gray-400);
}

.quick-search-btn {
  padding: 0.75rem 1.5rem;
  font-size: 1.125rem;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: var(--teal-soft);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease, padding 0.15s ease, font-size 0.15s ease;
  white-space: nowrap;
}

.quick-search-btn:hover:not(:disabled) {
  background: var(--teal-dark);
}

.quick-search-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.quick-search-btn:focus-visible {
  outline: 3px solid var(--teal-soft);
  outline-offset: 2px;
}

.quick-search-btn:disabled {
  opacity: 0.7;
  cursor: default;
}

/* Button loading spinner */
.quick-search-btn .btn-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: qw-spin 0.7s linear infinite;
}

@keyframes qw-spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   ERROR MESSAGE
   ========================================================================== */

#quick-error {
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  font-size: 1rem;
  color: var(--color-error);
  background: var(--color-error-light);
  border-radius: 12px;
}

/* ==========================================================================
   RESULTS AREA
   ========================================================================== */

#quick-words-results {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--warm-cream-dark);
}

/* ==========================================================================
   SELECTED WORDS CONTAINER (Sticky below header)
   ========================================================================== */

.selected-words-container {
  position: sticky;
  top: 70px; /* Account for header height */
  z-index: 10;
  background: #fff;
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
  border: 2px solid var(--warm-cream-dark);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.selected-placeholder {
  margin: 0;
  font-size: 1rem;
  color: var(--color-text-muted);
  font-style: italic;
}

.selected-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  min-height: 0;
}

.selected-word-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  font-size: 1.0625rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--teal-dark);
  background: var(--teal-pale);
  border: 2px solid var(--teal-soft);
  border-radius: 24px;
  cursor: pointer;
  transition: all 0.12s ease;
  min-height: 48px;
}

.selected-word-chip:hover {
  background: var(--color-error-light);
  border-color: var(--color-error);
  color: var(--color-error);
}

.selected-word-chip:focus-visible {
  outline: 3px solid var(--teal-soft);
  outline-offset: 2px;
}

.selected-word-chip .remove-icon {
  font-size: 1.25rem;
  font-weight: 300;
  line-height: 1;
  opacity: 0.6;
}

.selected-word-chip:hover .remove-icon {
  opacity: 1;
}

/* ==========================================================================
   RELATED WORDS SECTION (appears immediately below selected words)
   ========================================================================== */

.related-words-section {
  background: #f0fdf4; /* Light green to distinguish from selected words */
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
  border: 2px solid #86efac;
}

.related-words-section[hidden] {
  display: none;
}

.related-words-heading {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: #065f46;
}

.related-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  line-height: 1.8;
}

/* Related word chips - styled like main word chips but with green accent */
.related-chips-container .word-chip {
  color: #059669;
}

.related-chips-container .word-chip:hover:not(.selected) {
  color: #047857;
}

.related-chips-container .word-chip::after {
  background: transparent;
}

.related-chips-container .word-chip:hover:not(.selected)::after {
  background: #d1fae5;
}

/* Get more words button */
.btn-get-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  margin-top: 1rem;
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--teal-soft);
  background: #fff;
  border: 2px solid var(--teal-soft);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.12s ease;
  min-height: 48px;
}

.btn-get-more:hover:not(:disabled) {
  background: var(--teal-pale);
}

.btn-get-more:disabled {
  cursor: default;
  opacity: 0.7;
}

.btn-get-more .btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--teal-pale);
  border-top-color: var(--teal-soft);
  border-radius: 50%;
  animation: qw-spin 0.7s linear infinite;
}

/* ==========================================================================
   WORD CHIPS
   ========================================================================== */

.word-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  line-height: 1.8;
}

.word-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0;
  font-size: 1.125rem;
  font-weight: 400;
  font-family: inherit;
  color: var(--teal-soft);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.12s ease;
  position: relative;
}

.word-chip::after {
  content: '';
  position: absolute;
  bottom: 0.25rem;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
  transition: background 0.12s ease;
}

.word-chip:hover:not(.expanded):not(.loading):not(.selected) {
  color: var(--teal-dark);
}

.word-chip:hover:not(.expanded):not(.loading):not(.selected)::after {
  background: var(--teal-pale);
}

.word-chip:focus-visible {
  outline: 2px solid var(--teal-pale);
  outline-offset: 4px;
  border-radius: 2px;
}

/* Expanded state (legacy) */
.word-chip.expanded {
  color: var(--color-success);
  cursor: default;
}

.expanded-check {
  display: inline-flex;
  align-items: center;
  margin-left: 0.25rem;
}

.expanded-check::before {
  content: '\2713';
  font-size: 0.875rem;
  font-weight: 600;
}

/* Selected state */
.word-chip.selected {
  color: var(--color-success);
  background: var(--color-success-light);
  padding: 0.375rem 0.5rem;
  border-radius: 4px;
  cursor: default;
}

.word-chip.selected::after {
  display: none;
}

.selected-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 0.375rem;
  background: var(--color-success);
  border-radius: 50%;
  flex-shrink: 0;
}

.selected-check::before {
  content: '\2713';
  font-size: 0.6875rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

/* Related words divider */
.related-words-divider {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0 1rem;
  color: var(--color-text-muted);
  font-size: 0.875rem;
  font-weight: 500;
}

.related-words-divider::before,
.related-words-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--warm-cream-dark);
}

/* Loading state */
.word-chip.loading {
  color: var(--color-gray-400);
  cursor: wait;
}

.chip-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--color-gray-200);
  border-top-color: var(--teal-soft);
  border-radius: 50%;
  animation: qw-spin 0.6s linear infinite;
  margin-left: 0.375rem;
}

/* ==========================================================================
   HINT TEXT
   ========================================================================== */

#quick-words-hint {
  margin-top: 2rem;
  padding: 0;
  font-size: 1rem;
  color: var(--color-text-muted);
  text-align: center;
}

/* ==========================================================================
   ACTION BUTTONS - Simplified and warm
   ========================================================================== */

.quick-words-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 2px solid var(--warm-cream-dark);
}

.quick-words-actions .btn {
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 52px;
}

.quick-words-actions .btn-primary {
  background: var(--teal-soft);
  color: #fff;
  border: 2px solid var(--teal-soft);
}

.quick-words-actions .btn-primary:hover {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
}

.quick-words-actions .btn-secondary {
  color: var(--teal-soft);
  background: #fff;
  border: 2px solid var(--warm-cream-dark);
}

.quick-words-actions .btn-secondary:hover {
  background: var(--warm-cream);
  border-color: var(--teal-soft);
}

.quick-words-actions .btn-ghost {
  color: var(--color-text-muted);
  background: none;
  border: none;
  padding-left: 1rem;
  padding-right: 1rem;
}

.quick-words-actions .btn-ghost:hover {
  color: var(--color-text-secondary);
  background: var(--warm-cream);
}

/* ==========================================================================
   HIDDEN LOADING DIV (kept for compatibility)
   ========================================================================== */

#quick-loading {
  display: none !important;
}

/* ==========================================================================
   WARNING BANNER
   ========================================================================== */

.warning-banner {
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--color-warning-light);
  border: 2px solid var(--color-warning);
  border-radius: 12px;
  color: var(--color-warning);
  font-weight: 500;
}

.warning-banner[hidden] {
  display: none;
}

/* ==========================================================================
   MOBILE BOTTOM NAV
   ========================================================================== */

.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid var(--warm-cream-dark);
  padding: 0.625rem 0;
  z-index: 100;
}

.mobile-bottom-nav ul {
  display: flex;
  justify-content: space-around;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
}

.mobile-bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 1rem;
  text-decoration: none;
  color: var(--color-text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 10px;
  transition: background 0.15s, color 0.15s;
  min-width: 64px;
}

.mobile-bottom-nav a:hover,
.mobile-bottom-nav a.active {
  background: var(--teal-pale);
  color: var(--teal-soft);
}

.mobile-bottom-nav .nav-icon {
  font-size: 1.375rem;
}

/* ==========================================================================
   ACCESSIBILITY
   ========================================================================== */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   BALANCE INFORMATION (40/40/20 Clinical Balance)
   ========================================================================== */

.balance-info {
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  background: #fff;
  border: 2px solid var(--warm-cream-dark);
  border-radius: 12px;
  font-size: 1rem;
}

.balance-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.balance-label {
  color: var(--color-text-secondary);
  font-weight: 500;
}

.balance-value {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.9375rem;
}

.balance-transactional {
  background: var(--teal-pale);
  color: var(--teal-dark);
}

.balance-conversational {
  background: var(--color-success-light);
  color: #065f46;
}

.balance-repair {
  background: var(--color-warning-light);
  color: #92400e;
}

/* Balance warnings */
.balance-warning {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.balance-warning-warning {
  background: #fef9c3;
  color: #854d0e;
  border: 1px solid #fde047;
}

.balance-warning-critical {
  background: var(--color-error-light);
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.warning-icon {
  flex-shrink: 0;
  font-size: 1rem;
}

.warning-text {
  flex: 1;
}

/* ==========================================================================
   RESPONSIVE - Mobile
   ========================================================================== */

@media (max-width: 640px) {
  .mobile-bottom-nav {
    display: block;
  }

  /* Add padding at bottom of page to account for fixed nav */
  .generator-container {
    padding-bottom: 90px;
  }

  /* Stack search on mobile */
  .quick-words-search {
    flex-direction: column;
    gap: 0.5rem;
  }

  .quick-search-input {
    font-size: 1rem;
    padding: 0.75rem;
  }

  .quick-search-btn {
    width: 100%;
    font-size: 1rem;
    padding: 0.75rem;
  }

  /* Compact mobile state - even denser */
  .quick-words-search.has-results {
    flex-direction: row;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
  }

  .quick-words-search.has-results .quick-search-input {
    padding: 0.5rem 0.75rem;
    font-size: 0.9375rem;
  }

  .quick-words-search.has-results .quick-search-btn {
    width: auto;
    padding: 0.5rem 0.875rem;
    font-size: 0.9375rem;
  }

  /* Word chips */
  .word-chips-container {
    gap: 0.625rem;
  }

  .word-chip {
    font-size: 1rem;
  }

  /* Selected words container */
  .selected-words-container {
    top: 60px;
    padding: 1rem;
    margin-bottom: 1.5rem;
  }

  .selected-word-chip {
    padding: 0.5rem 0.875rem;
    font-size: 1rem;
    min-height: 44px;
  }

  .selected-placeholder {
    font-size: 0.9375rem;
  }

  /* Action buttons - Stack vertically */
  .quick-words-actions {
    flex-direction: column;
    gap: 0.75rem;
  }

  .quick-words-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* Related words section */
  .related-words-section {
    padding: 1rem;
    margin-bottom: 1.5rem;
  }

  .related-words-heading {
    font-size: 0.9375rem;
    margin-bottom: 0.75rem;
  }

  .related-chips-container {
    gap: 0.625rem;
  }

  /* Balance info */
  .balance-summary {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .balance-value {
    margin-left: 0;
  }
}

/* ==========================================================================
   REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .quick-search-btn,
  .word-chip,
  .selected-word-chip,
  .btn-get-more {
    transition: none;
  }
}
