/**
 * Solver Tools Shared Styles
 * Styles for Wordle Solver, Anagram Solver, Crossword Solver,
 * Word Unscrambler, and Cryptic Crossword Solver
 */

/* ==========================================================================
   Variables
   ========================================================================== */

:root {
  --solver-green: #6aaa64;
  --solver-yellow: #c9b458;
  --solver-gray: #787c7e;
  --solver-green-light: #e8f5e8;
  --solver-yellow-light: #fdf6e3;
  --solver-gray-light: #f0f0f0;
  --solver-primary: #667eea;
  --solver-primary-light: #eef0ff;
  --solver-border: #e2e8f0;
  --solver-card-shadow: 0 2px 10px rgba(0,0,0,0.1);
  --solver-radius: 12px;
}

/* ==========================================================================
   Tool Container
   ========================================================================== */

.solver-page {
  max-width: 860px;
  margin: 0 auto;
  padding: 20px;
}

.solver-page h1 {
  font-size: 2rem;
  text-align: center;
  margin-bottom: 8px;
  color: #333;
}

.solver-page .page-subtitle {
  text-align: center;
  color: #666;
  font-size: 1.05rem;
  margin-bottom: 30px;
}

/* ==========================================================================
   Tool Card (main interactive area)
   ========================================================================== */

.tool-card {
  background: #fff;
  border-radius: var(--solver-radius);
  box-shadow: var(--solver-card-shadow);
  padding: 28px;
  margin-bottom: 28px;
}

.tool-card-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: #333;
}

/* ==========================================================================
   Wordle Solver — Letter Input Grid
   ========================================================================== */

.solver-input-group {
  margin-bottom: 20px;
}

.solver-input-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 10px;
  color: #333;
}

.solver-input-label .label-icon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: inline-block;
  flex-shrink: 0;
}

.label-icon.green { background: var(--solver-green); }
.label-icon.yellow { background: var(--solver-yellow); }
.label-icon.gray { background: var(--solver-gray); }

.solver-input-hint {
  font-size: 0.85rem;
  color: #888;
  font-weight: 400;
  margin-left: 4px;
}

/* Position letter boxes (green) */
.letter-boxes {
  display: flex;
  gap: 8px;
}

.letter-box {
  width: 52px;
  height: 52px;
  border: 2px solid var(--solver-border);
  border-radius: 8px;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  background: #fff;
  transition: border-color 0.2s;
  color: #333;
}

.letter-box:focus {
  border-color: var(--solver-green);
  outline: none;
  box-shadow: 0 0 0 3px var(--solver-green-light);
}

.letter-box.filled {
  border-color: var(--solver-green);
  background: var(--solver-green-light);
}

/* Yellow letters input */
.yellow-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.yellow-letter-input {
  width: 44px;
  height: 44px;
  border: 2px solid var(--solver-border);
  border-radius: 8px;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  color: #333;
}

.yellow-letter-input:focus {
  border-color: var(--solver-yellow);
  outline: none;
  box-shadow: 0 0 0 3px var(--solver-yellow-light);
}

.yellow-letter-input.filled {
  border-color: var(--solver-yellow);
  background: var(--solver-yellow-light);
}

.position-exclude {
  display: flex;
  gap: 4px;
  font-size: 0.8rem;
}

.position-exclude label {
  display: flex;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  color: #666;
}

.position-exclude input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.add-yellow-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border: 1px dashed var(--solver-border);
  border-radius: 8px;
  background: transparent;
  color: #888;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.add-yellow-btn:hover {
  border-color: var(--solver-yellow);
  color: var(--solver-yellow);
  background: var(--solver-yellow-light);
}

/* Gray letters keyboard */
.gray-keyboard {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.gray-key {
  width: 36px;
  height: 36px;
  border: 1px solid var(--solver-border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  user-select: none;
}

.gray-key:hover {
  background: #f0f0f0;
}

.gray-key.excluded {
  background: var(--solver-gray);
  color: #fff;
  border-color: var(--solver-gray);
}

/* ==========================================================================
   Tab Switcher (Cryptic Solver)
   ========================================================================== */

.solver-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 2px solid #eee;
  padding-bottom: 0;
}

.solver-tab {
  padding: 10px 20px;
  border: none;
  background: transparent;
  font-size: 0.95rem;
  font-weight: 500;
  color: #888;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.solver-tab:hover {
  color: #555;
}

.solver-tab.active {
  color: var(--solver-primary);
  border-bottom-color: var(--solver-primary);
  font-weight: 600;
}

.solver-tab-content {
  display: none;
}

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

/* Analysis Results */
.analysis-result {
  background: #f8f9fa;
  border-radius: 10px;
  padding: 20px;
}

.analysis-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #eee;
  font-size: 0.95rem;
  color: #444;
  line-height: 1.5;
}

.analysis-row:last-child {
  border-bottom: none;
}

.analysis-icon {
  flex-shrink: 0;
  font-size: 1.1rem;
}

.confidence-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 8px;
}

.conf-high { background: #d4edda; color: #155724; }
.conf-medium { background: #fff3cd; color: #856404; }
.conf-low { background: #f8d7da; color: #721c24; }

@media (max-width: 600px) {
  .solver-tabs {
    overflow-x: auto;
  }
  .solver-tab {
    padding: 8px 14px;
    font-size: 0.85rem;
    white-space: nowrap;
  }
}

/* ==========================================================================
   Crossword Solver — Pattern Boxes & Length Select
   ========================================================================== */

.length-select {
  padding: 10px 14px;
  font-size: 1rem;
  border: 2px solid var(--solver-border);
  border-radius: 8px;
  background: #fff;
  color: #333;
  cursor: pointer;
  min-width: 160px;
}

.length-select:focus {
  border-color: var(--solver-primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--solver-primary-light);
}

.pattern-boxes-wrap {
  flex-wrap: wrap;
  gap: 6px;
}

.pattern-box {
  width: 46px;
  height: 46px;
  border: 2px solid var(--solver-border);
  border-radius: 6px;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  background: #fff;
  color: #333;
  transition: border-color 0.2s;
}

.pattern-box::placeholder {
  color: #ccc;
  font-weight: 400;
}

.pattern-box:focus {
  border-color: var(--solver-primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--solver-primary-light);
}

.pattern-box.filled {
  border-color: var(--solver-primary);
  background: var(--solver-primary-light);
}

@media (max-width: 480px) {
  .pattern-box {
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
  }
}

/* ==========================================================================
   Anagram / Unscrambler Main Input
   ========================================================================== */

.anagram-main-input {
  width: 100%;
  padding: 14px 18px;
  font-size: 1.3rem;
  font-family: 'Courier New', monospace;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 2px solid var(--solver-border);
  border-radius: 10px;
  background: #fff;
  color: #333;
  transition: border-color 0.2s;
}

.anagram-main-input:focus {
  border-color: var(--solver-primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--solver-primary-light);
}

.anagram-main-input::placeholder {
  text-transform: none;
  font-weight: 400;
  letter-spacing: 0;
  color: #aaa;
  font-size: 1rem;
}

/* Length filter pills */
.length-filter-btn {
  padding: 5px 14px;
  border: 1px solid var(--solver-border);
  border-radius: 20px;
  background: #fff;
  font-size: 0.82rem;
  cursor: pointer;
  color: #666;
  transition: all 0.15s;
  white-space: nowrap;
}

.length-filter-btn.active {
  background: var(--solver-primary);
  color: #fff;
  border-color: var(--solver-primary);
}

.length-filter-btn:hover:not(.active) {
  background: #f0f0f0;
}

/* ==========================================================================
   Filter Row (Unscrambler)
   ========================================================================== */

.filter-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.filter-field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #666;
  margin-bottom: 4px;
}

.filter-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 0.9rem;
  border: 1px solid var(--solver-border);
  border-radius: 6px;
  background: #fff;
  color: #333;
  text-transform: uppercase;
  font-family: 'Courier New', monospace;
}

.filter-input:focus {
  border-color: var(--solver-primary);
  outline: none;
  box-shadow: 0 0 0 2px var(--solver-primary-light);
}

select.filter-input {
  text-transform: none;
  font-family: inherit;
  cursor: pointer;
}

@media (max-width: 600px) {
  .filter-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 380px) {
  .filter-row {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Action Buttons
   ========================================================================== */

.solver-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.solver-btn {
  padding: 12px 28px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.solver-btn-primary {
  background: linear-gradient(135deg, var(--solver-primary) 0%, #764ba2 100%);
  color: #fff;
}

.solver-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(102,126,234,0.4);
}

.solver-btn-secondary {
  background: #f8f9fa;
  color: #666;
  border: 1px solid var(--solver-border);
}

.solver-btn-secondary:hover {
  background: #e9ecef;
}

/* ==========================================================================
   Results Area
   ========================================================================== */

.solver-results {
  margin-top: 24px;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #eee;
}

.results-count {
  font-size: 1rem;
  color: #333;
}

.results-count strong {
  color: var(--solver-primary);
}

.results-sort {
  display: flex;
  gap: 6px;
}

.sort-btn {
  padding: 4px 12px;
  border: 1px solid var(--solver-border);
  border-radius: 20px;
  background: #fff;
  font-size: 0.8rem;
  cursor: pointer;
  color: #666;
  transition: all 0.15s;
}

.sort-btn.active {
  background: var(--solver-primary);
  color: #fff;
  border-color: var(--solver-primary);
}

.results-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.word-pill {
  display: inline-block;
  padding: 6px 14px;
  background: #f8f9fa;
  border: 1px solid var(--solver-border);
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: 'Courier New', monospace;
  letter-spacing: 0.05em;
  color: #333;
  cursor: default;
  transition: all 0.15s;
}

.word-pill:hover {
  background: var(--solver-primary-light);
  border-color: var(--solver-primary);
}

.word-pill .scrabble-score {
  font-size: 0.7rem;
  color: #999;
  margin-left: 4px;
  font-family: 'Inter', sans-serif;
}

.results-empty {
  text-align: center;
  padding: 30px;
  color: #888;
}

.results-empty p {
  margin-bottom: 8px;
}

/* Results grouped by length */
.results-group {
  margin-bottom: 20px;
}

.results-group-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #666;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #eee;
}

/* Show more button */
.show-more-btn {
  display: block;
  width: 100%;
  padding: 10px;
  margin-top: 12px;
  border: 1px dashed var(--solver-border);
  border-radius: 8px;
  background: transparent;
  color: var(--solver-primary);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.show-more-btn:hover {
  background: var(--solver-primary-light);
  border-color: var(--solver-primary);
}

/* ==========================================================================
   CTA Banner
   ========================================================================== */

.solver-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 24px;
  background: linear-gradient(135deg, var(--solver-green-light), #f0fdf4);
  border: 1px solid #c6efce;
  border-radius: var(--solver-radius);
  margin-bottom: 28px;
  text-align: center;
}

.solver-cta a {
  color: var(--solver-green);
  font-weight: 600;
  text-decoration: none;
}

.solver-cta a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Content Sections
   ========================================================================== */

.solver-content {
  background: #fff;
  border-radius: var(--solver-radius);
  box-shadow: var(--solver-card-shadow);
  padding: 28px;
  margin-bottom: 28px;
}

.solver-content h2 {
  font-size: 1.4rem;
  color: #333;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid #f0f0f0;
}

.solver-content h3 {
  font-size: 1.1rem;
  color: #444;
  margin: 20px 0 10px;
}

.solver-content p {
  color: #555;
  margin-bottom: 12px;
  line-height: 1.7;
}

.solver-content ul, .solver-content ol {
  padding-left: 24px;
  margin-bottom: 16px;
}

.solver-content li {
  color: #555;
  margin-bottom: 8px;
  line-height: 1.6;
}

.solver-content a {
  color: var(--solver-primary);
  text-decoration: none;
}

.solver-content a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Data Tables
   ========================================================================== */

.solver-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.9rem;
}

.solver-table th {
  background: #f8f9fa;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: #444;
  border-bottom: 2px solid var(--solver-border);
}

.solver-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f0f0f0;
  color: #555;
}

.solver-table tr:nth-child(even) td {
  background: #fafbfc;
}

.solver-table tr:hover td {
  background: var(--solver-primary-light);
}

/* Top 3 highlight */
.solver-table tr.rank-1 td { background: #fff8e1; }
.solver-table tr.rank-2 td { background: #f5f5f5; }
.solver-table tr.rank-3 td { background: #fbe9e7; }

.solver-table .word-cell {
  font-family: 'Courier New', monospace;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.solver-table .score-cell {
  font-weight: 600;
  color: var(--solver-primary);
}

/* ==========================================================================
   FAQ Section (reuse from daily-answers.css)
   ========================================================================== */

.solver-faq h2 {
  font-size: 1.4rem;
  margin-bottom: 16px;
}

/* ==========================================================================
   Related Games / Internal Links
   ========================================================================== */

.solver-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.solver-link-card {
  display: block;
  padding: 16px;
  background: #f8f9fa;
  border: 1px solid var(--solver-border);
  border-radius: 10px;
  text-decoration: none;
  transition: all 0.2s;
}

.solver-link-card:hover {
  background: var(--solver-primary-light);
  border-color: var(--solver-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.solver-link-card .link-title {
  font-weight: 600;
  color: #333;
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.solver-link-card .link-desc {
  font-size: 0.82rem;
  color: #888;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
  .solver-page {
    padding: 15px;
  }

  .solver-page h1 {
    font-size: 1.5rem;
  }

  .tool-card {
    padding: 20px 16px;
  }

  .letter-boxes {
    justify-content: center;
  }

  .letter-box {
    width: 46px;
    height: 46px;
    font-size: 1.2rem;
  }

  .gray-key {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }

  .solver-actions {
    flex-direction: column;
  }

  .solver-btn {
    width: 100%;
    text-align: center;
  }

  .results-header {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }

  .solver-links {
    grid-template-columns: 1fr;
  }

  .solver-content h2 {
    font-size: 1.2rem;
  }

  .solver-table {
    font-size: 0.82rem;
  }

  .solver-table th, .solver-table td {
    padding: 8px 10px;
  }
}

@media (max-width: 480px) {
  .letter-box {
    width: 42px;
    height: 42px;
    font-size: 1.1rem;
  }

  .yellow-letter-input {
    width: 38px;
    height: 38px;
    font-size: 1rem;
  }

  .gray-key {
    width: 29px;
    height: 29px;
    font-size: 0.75rem;
  }

  .word-pill {
    padding: 5px 10px;
    font-size: 0.82rem;
  }
}
