/* ============================================================
   ToolNest – tools.css
   Styles specific to individual tool pages
   ============================================================ */

/* ────────────────────────────────────────────────────────────
   1. TOOL PAGE LAYOUT
──────────────────────────────────────────────────────────── */
.tool-page {
  padding: var(--sp-3) 0 var(--sp-6);
}

.tool-page__layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-3);
}

.tool-page__layout--with-sidebar {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: var(--sp-4);
  align-items: start;
}

.tool-page__main {
  min-width: 0; /* prevent overflow in grid */
}

.tool-page__sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

@media (max-width: 1023px) {
  .tool-page__layout--with-sidebar {
    grid-template-columns: 1fr;
  }
  .tool-page__sidebar {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

/* ────────────────────────────────────────────────────────────
   2. TOOL HEADER
──────────────────────────────────────────────────────────── */
.tool-header {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: var(--sp-3) 0 var(--sp-2);
}

.tool-header__icon-wrap {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  flex-shrink: 0;
  background: var(--primary-light);
  box-shadow: var(--shadow-md);
}

.tool-header__info {
  flex: 1;
  min-width: 0;
}

.tool-header__category {
  margin-bottom: 6px;
}

.tool-header__title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  margin-bottom: 6px;
  line-height: var(--leading-tight);
}

.tool-header__desc {
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: var(--leading-normal);
  margin-bottom: 10px;
}

.tool-header__stats {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.tool-header__stat {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.tool-header__stat svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

@media (max-width: 639px) {
  .tool-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .tool-header__title {
    font-size: var(--text-xl);
  }
}

/* Category colour theming for tool header icon */
[data-category="text"]     .tool-header__icon-wrap { background: rgba(79,126,247,0.12); color: var(--cat-text); }
[data-category="calc"]     .tool-header__icon-wrap { background: rgba(16,185,129,0.12); color: var(--cat-calc); }
[data-category="convert"]  .tool-header__icon-wrap { background: rgba(245,158,11,0.12); color: var(--cat-convert); }
[data-category="image"]    .tool-header__icon-wrap { background: rgba(236,72,153,0.12); color: var(--cat-image); }
[data-category="security"] .tool-header__icon-wrap { background: rgba(139,92,246,0.12); color: var(--cat-security); }
[data-category="dev"]      .tool-header__icon-wrap { background: rgba(239,68,68,0.12);  color: var(--cat-dev); }
[data-category="writing"]  .tool-header__icon-wrap { background: rgba(6,182,212,0.12);  color: var(--cat-writing); }

/* ────────────────────────────────────────────────────────────
   3. TOOL INTERFACE CONTAINER
──────────────────────────────────────────────────────────── */
.tool-interface {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  margin-bottom: var(--sp-3);
}

.tool-interface__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px var(--sp-3);
  border-bottom: 1px solid var(--border);
  background: var(--bg-input);
}

.tool-interface__title {
  font-size: var(--text-sm);
  font-weight: var(--font-semi);
  color: var(--text-primary);
}

.tool-interface__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-interface__body {
  padding: var(--sp-3);
}

.tool-interface__footer {
  padding: var(--sp-2) var(--sp-3);
  border-top: 1px solid var(--border);
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

/* ────────────────────────────────────────────────────────────
   4. TOOL TEXTAREA & INPUT STYLES
──────────────────────────────────────────────────────────── */
.tool-input {
  width: 100%;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: var(--text-base);
  padding: 14px 16px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition),
              background var(--transition-md);
  resize: vertical;
}

.tool-input::placeholder { color: var(--text-muted); }

.tool-input:focus {
  border-color: var(--primary);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(79,126,247,0.15);
}

.tool-input--code {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.6;
}

.tool-input--lg {
  min-height: 200px;
  font-size: var(--text-base);
}

.tool-input--xl {
  min-height: 320px;
}

.tool-input--fixed {
  resize: none;
}

/* Input row (label + field) */
.tool-field {
  margin-bottom: var(--sp-2);
}

.tool-field__label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  margin-bottom: 6px;
}

.tool-field__hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 4px;
}

/* Input/Output split layout */
.tool-io {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
}

@media (max-width: 767px) {
  .tool-io { grid-template-columns: 1fr; }
}

/* ────────────────────────────────────────────────────────────
   5. OUTPUT BOX
──────────────────────────────────────────────────────────── */
.output-box {
  position: relative;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.output-box__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.output-box__label {
  font-size: var(--text-xs);
  font-weight: var(--font-semi);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.output-box__content {
  padding: 14px 16px;
  min-height: 80px;
  font-size: var(--text-base);
  color: var(--text-primary);
  line-height: var(--leading-loose);
  word-break: break-all;
  white-space: pre-wrap;
}

.output-box__content--code {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.6;
  word-break: break-word;
}

.output-box__content--empty {
  color: var(--text-muted);
  font-style: italic;
}

.output-box__content--scroll {
  max-height: 320px;
  overflow-y: auto;
}

/* Copy button (inline with output header) */
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

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

.copy-btn.is-copied {
  color: var(--success);
  border-color: var(--success);
  background: rgba(16,185,129,0.08);
}

.copy-btn svg {
  width: 13px;
  height: 13px;
}

/* ────────────────────────────────────────────────────────────
   6. TOOL ACTION BAR
──────────────────────────────────────────────────────────── */
.tool-action-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  flex-wrap: wrap;
  padding: var(--sp-2) 0;
}

.tool-action-bar--center {
  justify-content: center;
}

.tool-action-bar--between {
  justify-content: space-between;
}

/* ────────────────────────────────────────────────────────────
   7. TOOL OPTIONS / SETTINGS PANEL
──────────────────────────────────────────────────────────── */
.tool-options {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-2);
}

.tool-options__title {
  font-size: var(--text-sm);
  font-weight: var(--font-semi);
  color: var(--text-primary);
  margin-bottom: var(--sp-1);
}

.tool-options__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--sp-2);
}

/* ────────────────────────────────────────────────────────────
   8. HOW TO USE SECTION
──────────────────────────────────────────────────────────── */
.how-to-use {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.how-to-use__title {
  font-size: var(--text-lg);
  font-weight: var(--font-semi);
  color: var(--text-primary);
  margin-bottom: var(--sp-2);
  display: flex;
  align-items: center;
  gap: 10px;
}

.how-to-use__title svg {
  width: 20px;
  height: 20px;
  color: var(--primary);
}

.how-to-use__steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.how-to-use__step {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.how-to-use__step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.how-to-use__step-content {}

.how-to-use__step-title {
  font-size: var(--text-sm);
  font-weight: var(--font-semi);
  color: var(--text-primary);
  margin-bottom: 3px;
}

.how-to-use__step-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-loose);
}

/* ────────────────────────────────────────────────────────────
   9. FAQ ACCORDION
──────────────────────────────────────────────────────────── */
.faq-section {
  margin-bottom: var(--sp-3);
}

.faq-section__title {
  font-size: var(--text-xl);
  font-weight: var(--font-semi);
  color: var(--text-primary);
  margin-bottom: var(--sp-2);
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--transition);
}

.faq-item.is-open {
  border-color: var(--primary);
}

.faq-item__question {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px var(--sp-3);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  gap: var(--sp-2);
  transition: background var(--transition);
}

.faq-item__question:hover {
  background: var(--bg-input);
}

.faq-item__chevron {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform var(--transition-md);
}

.faq-item.is-open .faq-item__chevron {
  transform: rotate(180deg);
}

.faq-item__answer {
  display: none;
  padding: 0 var(--sp-3) var(--sp-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-loose);
}

.faq-item.is-open .faq-item__answer {
  display: block;
}

/* ────────────────────────────────────────────────────────────
   10. RELATED TOOLS GRID
──────────────────────────────────────────────────────────── */
.related-tools {
  margin-bottom: var(--sp-4);
}

.related-tools__title {
  font-size: var(--text-xl);
  font-weight: var(--font-semi);
  color: var(--text-primary);
  margin-bottom: var(--sp-2);
  display: flex;
  align-items: center;
  gap: 10px;
}

.related-tools__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-2);
}

@media (max-width: 1023px) {
  .related-tools__grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 639px) {
  .related-tools__grid { grid-template-columns: 1fr; }
}

/* Compact tool card for related section */
.related-tool-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: transform var(--transition-md), box-shadow var(--transition-md),
              border-color var(--transition-md);
}

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

.related-tool-card__icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.related-tool-card__name {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.related-tool-card__cat {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

/* ────────────────────────────────────────────────────────────
   11. RELATED BLOG POSTS (2-column)
──────────────────────────────────────────────────────────── */
.tool-blog-posts {
  margin-bottom: var(--sp-4);
}

.tool-blog-posts__title {
  font-size: var(--text-xl);
  font-weight: var(--font-semi);
  color: var(--text-primary);
  margin-bottom: var(--sp-2);
}

.tool-blog-posts__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
}

@media (max-width: 639px) {
  .tool-blog-posts__grid { grid-template-columns: 1fr; }
}

/* ────────────────────────────────────────────────────────────
   12. TOOL PAGE ADSENSE CONTAINERS
──────────────────────────────────────────────────────────── */
.tool-ad--top {
  margin-bottom: var(--sp-3);
}

.tool-ad--mid {
  margin: var(--sp-3) 0;
}

.tool-ad--sidebar {
  width: 100%;
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: var(--text-xs);
}

/* ────────────────────────────────────────────────────────────
   13. SIDEBAR WIDGETS
──────────────────────────────────────────────────────────── */
.sidebar-widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.sidebar-widget__header {
  padding: 14px var(--sp-2);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
  font-weight: var(--font-semi);
  color: var(--text-primary);
  background: var(--bg-input);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-widget__body {
  padding: var(--sp-2);
}

.sidebar-tool-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-tool-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background var(--transition);
}

.sidebar-tool-item:hover {
  background: var(--bg-input);
}

.sidebar-tool-item__icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-tool-item__name {
  font-size: var(--text-sm);
  color: var(--text-primary);
  font-weight: var(--font-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ────────────────────────────────────────────────────────────
   14. TOOL CATEGORY COLOUR THEMING (data-category)
──────────────────────────────────────────────────────────── */
[data-category="text"] .tool-interface__header     { border-top: 3px solid var(--cat-text); }
[data-category="calc"] .tool-interface__header     { border-top: 3px solid var(--cat-calc); }
[data-category="convert"] .tool-interface__header  { border-top: 3px solid var(--cat-convert); }
[data-category="image"] .tool-interface__header    { border-top: 3px solid var(--cat-image); }
[data-category="security"] .tool-interface__header { border-top: 3px solid var(--cat-security); }
[data-category="dev"] .tool-interface__header      { border-top: 3px solid var(--cat-dev); }
[data-category="writing"] .tool-interface__header  { border-top: 3px solid var(--cat-writing); }

/* ────────────────────────────────────────────────────────────
   15. CHARACTER / WORD COUNTER BAR
──────────────────────────────────────────────────────────── */
.counter-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding: 8px 0;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.counter-bar__item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.counter-bar__value {
  font-weight: var(--font-semi);
  color: var(--text-secondary);
}

/* ────────────────────────────────────────────────────────────
   16. PROGRESS BAR (e.g. password strength)
──────────────────────────────────────────────────────────── */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-input);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.4s ease, background 0.4s ease;
}

.progress-bar__fill--weak   { background: var(--error);   width: 25%; }
.progress-bar__fill--fair   { background: var(--warning); width: 50%; }
.progress-bar__fill--good   { background: var(--info);    width: 75%; }
.progress-bar__fill--strong { background: var(--success); width: 100%; }

/* ────────────────────────────────────────────────────────────
   17. RESULT HIGHLIGHT
──────────────────────────────────────────────────────────── */
.result-highlight {
  background: var(--primary-light);
  border: 1px solid rgba(79,126,247,0.3);
  border-radius: var(--radius-md);
  padding: var(--sp-2) var(--sp-3);
  text-align: center;
}

.result-highlight__value {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  color: var(--primary);
  line-height: 1;
  margin-bottom: 4px;
}

.result-highlight__label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
