/* ============================================
   Clearme.in — Tool Page Styles
   ============================================ */

/* Tool Container Layout */
.tool-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

.tool-main { min-width: 0; }

.tool-sidebar {
  display: none;
}

@media (min-width: 1024px) {
  .tool-container {
    grid-template-columns: 1fr 300px;
    padding: 0 2rem 3rem;
  }
  .tool-sidebar { display: block; }
}

/* ============================================
   Tool Form
   ============================================ */

.tool-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group:last-of-type { margin-bottom: 1.5rem; }

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.375rem;
}

.form-group .label-hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.form-input,
.form-select {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.1);
}

.form-input::placeholder { color: var(--text-light); }

/* Range slider */
.form-range {
  width: 100%;
  margin-top: 0.5rem;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
}

.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.form-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Inline fields */
.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .form-group { flex: 1; }

/* Radio/toggle group */
.toggle-group {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.toggle-group label {
  flex: 1;
  text-align: center;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border-right: 1px solid var(--border);
  transition: all 0.2s;
  margin: 0;
}

.toggle-group label:last-child { border-right: none; }
.toggle-group input { display: none; }
.toggle-group input:checked + label,
.toggle-group label.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Calculate button */
.btn-calculate {
  width: 100%;
  padding: 0.875rem;
  font-size: 1rem;
  font-weight: 700;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
}

.btn-calculate:hover { background: var(--primary-dark); }

/* ============================================
   Tool Result
   ============================================ */

.tool-result {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-top: 1.25rem;
}

.result-highlight {
  text-align: center;
  padding: 1rem 0;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.result-highlight .result-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.result-highlight .result-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.result-item {
  text-align: center;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: var(--radius);
}

.result-item .result-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.result-item .result-value {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
}

@media (min-width: 640px) {
  .result-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Copy button */
.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-copy:hover { border-color: var(--primary); color: var(--primary); }
.btn-copy.copied { border-color: var(--success); color: var(--success); }
.btn-copy svg { width: 14px; height: 14px; }

/* ============================================
   Charts
   ============================================ */

.tool-chart-section {
  margin-top: 1.25rem;
}

.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.chart-container h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.chart-wrap {
  position: relative;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
}

.chart-wrap canvas {
  width: 100% !important;
  height: auto !important;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
  font-size: 0.8125rem;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.chart-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* ============================================
   Result Table
   ============================================ */

.tool-table-section {
  margin-top: 1.25rem;
}

.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-container h3 {
  font-size: 1rem;
  font-weight: 600;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.table-scroll {
  overflow-x: auto;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.result-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  background: var(--bg);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.result-table td {
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.result-table tbody tr:hover { background: var(--border-light); }

.result-table .text-right { text-align: right; }

.table-expandable { cursor: pointer; }
.table-expandable:hover { background: var(--primary-bg); }
.table-child { display: none; background: var(--bg); }
.table-child.open { display: table-row; }
.table-child td { font-size: 0.75rem; color: var(--text-muted); padding-left: 2rem; }

/* ============================================
   Explanation & Example
   ============================================ */

.tool-content-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-top: 1.25rem;
}

.tool-content-section h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.tool-content-section h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.tool-content-section p {
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 0.75rem;
}

.tool-content-section ul,
.tool-content-section ol {
  margin: 0.5rem 0 0.75rem 1.25rem;
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.tool-content-section code {
  background: var(--bg);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-size: 0.875rem;
}

.formula-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 0.75rem 0;
  font-family: 'Courier New', monospace;
  font-size: 0.9375rem;
  text-align: center;
  color: var(--text);
}

/* ============================================
   Related Tools
   ============================================ */

.related-tools {
  margin-top: 1.25rem;
}

.related-tools h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.related-tools-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .related-tools-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 768px) {
  .related-tools-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ============================================
   Tool FAQ (on tool pages)
   ============================================ */

.tool-faq {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-top: 1.25rem;
}

.tool-faq h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

/* ============================================
   Ad Slots
   ============================================ */

.ad-slot {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  color: var(--text-light);
  font-size: 0.75rem;
  margin-top: 1.25rem;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-sidebar {
  position: sticky;
  top: calc(var(--header-height) + 1rem);
}

/* ============================================
   Homepage Tool Embed
   ============================================ */

.hero-tool {
  max-width: 720px;
  margin: 0 auto;
}

.hero-tool .tool-form {
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-bg);
}

.hero-tool .tool-result {
  box-shadow: var(--shadow-md);
}

/* ============================================
   Text Tool Styles
   ============================================ */

.text-input-area,
.text-output-area {
  width: 100%;
  min-height: 160px;
  padding: 0.875rem 1rem;
  font-size: 0.9375rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  font-family: inherit;
  line-height: 1.6;
}

.text-input-area:focus,
.text-output-area:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.1);
}

.text-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.75rem;
}

.text-stat {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.text-stat strong {
  color: var(--text);
  font-weight: 700;
}

/* ============================================
   Sticky Result (Mobile)
   ============================================ */

@media (max-width: 639px) {
  .result-sticky {
    position: sticky;
    bottom: 0;
    z-index: 50;
    margin: 0 -1rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
  }
}
