/* ===================================================
   TextKit – tool.css
   Tool page styles: panels, textareas, buttons, stats
   =================================================== */

/* ---------- Page Hero ---------- */
.tool-hero {
  padding-block: var(--sp-xl) var(--sp-lg);
}

.tool-hero h1 {
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: var(--sp-sm);
}

.tool-hero .lead {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  max-width: 600px;
}

/* ---------- Mode Tabs ---------- */
.mode-tabs {
  display: flex;
  gap: var(--sp-xs);
  background: var(--color-surface-2);
  padding: var(--sp-xs);
  border-radius: var(--radius-md);
  width: fit-content;
  margin-bottom: var(--sp-lg);
}

.mode-tab {
  padding: var(--sp-sm) var(--sp-md);
  border-radius: calc(var(--radius-md) - 3px);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  transition: all var(--transition);
  background: transparent;
}

.mode-tab:hover { color: var(--color-text); }

.mode-tab.active {
  background: var(--color-surface);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

/* ---------- Tool Editor ---------- */
.tool-editor {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--sp-md);
  align-items: start;
  margin-bottom: var(--sp-xl);
}

.editor-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.editor-panel:focus-within {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(99,102,241,.12), var(--shadow-sm);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-sm) var(--sp-md);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-2);
  min-height: 44px;
}

.panel-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}

.panel-actions {
  display: flex;
  gap: var(--sp-xs);
  align-items: center;
}

.panel-textarea {
  width: 100%;
  min-height: 240px;
  padding: var(--sp-md);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.7;
  color: var(--color-text);
  background: var(--color-surface);
  border: none;
  outline: none;
  resize: vertical;
}

.panel-textarea::placeholder { color: var(--color-text-faint); }

.panel-textarea[readonly] {
  background: var(--color-surface-2);
  cursor: default;
  user-select: text;
}

/* ---------- Arrow Divider ---------- */
.editor-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 60px;
  flex-shrink: 0;
  color: var(--color-text-faint);
}

.editor-arrow svg {
  width: 22px;
  height: 22px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-xs);
  padding: var(--sp-sm) var(--sp-md);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--transition);
  line-height: 1;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:hover { background: var(--color-primary-hover); }

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}
.btn-ghost:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
  border-color: var(--color-text-muted);
}

.btn-icon {
  padding: var(--sp-sm);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  transition: all var(--transition);
  border: 1px solid transparent;
}
.btn-icon:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn-icon svg { width: 16px; height: 16px; }

.btn-copy.copied {
  color: var(--color-success);
  border-color: var(--color-success);
}

/* ---------- Swap Button ---------- */
.btn-swap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-xs);
  padding: var(--sp-sm) var(--sp-md);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  font-size: var(--text-sm);
  font-weight: 500;
  margin-bottom: var(--sp-lg);
  transition: all var(--transition);
}
.btn-swap:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn-swap svg { width: 16px; height: 16px; }

/* ---------- Stats Bar ---------- */
.stats-bar {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-md) var(--sp-lg);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-lg);
  margin-bottom: var(--sp-xl);
  box-shadow: var(--shadow-sm);
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--color-primary);
  line-height: 1;
}

.stat-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ---------- Count Table (char-count) ---------- */
.count-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.count-table th,
.count-table td {
  padding: var(--sp-sm) var(--sp-md);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.count-table th {
  background: var(--color-surface-2);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}

.count-table td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--color-primary);
}

.count-table tr:last-child td { border-bottom: none; }

/* ---------- Info / Article ---------- */
.tool-article {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-xl);
  margin-bottom: var(--sp-xl);
  box-shadow: var(--shadow-sm);
}

.tool-article h2 {
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: var(--sp-md);
  padding-bottom: var(--sp-sm);
  border-bottom: 1px solid var(--color-border);
}

.tool-article h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-top: var(--sp-lg);
  margin-bottom: var(--sp-sm);
}

.tool-article p {
  color: var(--color-text-muted);
  margin-bottom: var(--sp-md);
}

.tool-article p:last-child { margin-bottom: 0; }

.tool-article code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--color-primary);
}

/* ---------- Related Tools ---------- */
.related-tools {
  margin-bottom: var(--sp-xl);
}

.related-tools h2 {
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: var(--sp-md);
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--sp-md);
}

.related-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--sp-md);
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.related-card:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.related-card .tool-icon {
  font-size: 1.4em;
  flex-shrink: 0;
}

/* ---------- AdSense Placeholder ---------- */
.adsense-placeholder {
  background: var(--color-surface-2);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--sp-xl);
  text-align: center;
  color: var(--color-text-faint);
  font-size: var(--text-xs);
  margin-bottom: var(--sp-xl);
  min-height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-xs);
}

/* ---------- Tool Cards (index) ---------- */
.tools-section {
  padding-block: var(--sp-xl);
}

.tools-section h2 {
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: var(--sp-lg);
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-lg);
}

.tool-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-lg);
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.tool-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--color-primary);
  opacity: 0;
  transition: opacity var(--transition);
}

.tool-card:hover {
  border-color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}

.tool-card:hover::before { opacity: 1; }

.tool-card-icon {
  font-size: 2rem;
  line-height: 1;
}

.tool-card-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
}

.tool-card-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.5;
}

.tool-card-tag {
  display: inline-block;
  font-size: var(--text-xs);
  padding: 2px var(--sp-sm);
  border-radius: 99px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
  margin-top: auto;
  width: fit-content;
}

/* ---------- Hero (index) ---------- */
.index-hero {
  padding-block: var(--sp-2xl) var(--sp-xl);
  text-align: center;
}

.index-hero h1 {
  font-size: clamp(var(--text-3xl), 5vw, var(--text-4xl));
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: var(--sp-md);
}

.index-hero .lead {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  max-width: 540px;
  margin-inline: auto;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-xs);
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: var(--sp-xs) var(--sp-sm);
  border-radius: 99px;
  margin-bottom: var(--sp-md);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---------- Error page ---------- */
.error-page {
  text-align: center;
  padding-block: var(--sp-2xl);
}

.error-page .error-code {
  font-size: 7rem;
  font-weight: 800;
  color: var(--color-primary);
  line-height: 1;
  margin-bottom: var(--sp-md);
}

.error-page h1 {
  font-size: var(--text-2xl);
  margin-bottom: var(--sp-sm);
}

.error-page p {
  color: var(--color-text-muted);
  margin-bottom: var(--sp-xl);
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .tool-editor {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .editor-arrow {
    padding-top: 0;
    transform: rotate(90deg);
    justify-content: center;
  }

  .tool-hero h1 { font-size: var(--text-2xl); }

  .stats-bar { gap: var(--sp-md); }

  .stat-value { font-size: var(--text-xl); }
}

@media (max-width: 480px) {
  .mode-tabs { flex-wrap: wrap; }
  .tools-grid { grid-template-columns: 1fr; }
  .related-grid { grid-template-columns: 1fr 1fr; }
}
