/* ==========================================================================
   TOOLS PAGE STYLES - SpeedMath
   Reuses: .container, .page-header, .page-title, .page-subtitle, .btn,
           .btn-primary, .section-title, .text-accent, .faq-* (from main.css)
           CSS variables from variables.css
   ========================================================================== */

/* ==========================================================================
   1. TOOLS HUB
   ========================================================================== */

.tools-hub-section {
  padding: var(--space-6) 0 var(--space-16);
}

/* Filter Tabs */
.tools-filter-tabs-outer {
  overflow-x: auto;
  scrollbar-width: none;
  margin-bottom: var(--space-5);
  padding-bottom: 2px;
  text-align: center;
}
.tools-filter-tabs-outer::-webkit-scrollbar { display: none; }

.tools-filter-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
}

.tools-filter-tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  background: var(--admin-hover-bg);
  color: var(--text-soft);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  font-family: var(--font-main);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}
.tools-filter-tab .lucide { width: 16px; height: 16px; }
.tools-filter-tab:hover { border-color: rgba(59, 130, 249, 0.5); color: var(--accent-primary); background: var(--admin-active-bg);}
.tools-filter-tab.active {
  background: var(--accent-gradient);
  border: none;
  color: #fff;
  font-weight: var(--fw-semibold);
}

/* Tools Grid — flat list layout */
.tools-hub-grid-flat {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}

.tool-hub-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-4) var(--space-5);
  text-decoration: none;
  color: inherit;
  transition: transform var(--transition-base), border-color var(--transition-base), box-shadow var(--transition-base);
}
.tool-hub-card:hover {
  border-color: var(--accent-primary);
  transform: translateX(3px);
  box-shadow: var(--shadow-md);
}

.tool-hub-card-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex: 1;
  min-width: 0;
}

.tool-hub-card-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.tool-hub-card-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.tool-hub-card-icon .lucide { width: 22px; height: 22px; }
.tool-hub-card-icon.icon-blue   { background: var(--gradient-blue); }
.tool-hub-card-icon.icon-green  { background: var(--gradient-green); }
.tool-hub-card-icon.icon-orange { background: var(--gradient-orange); }
.tool-hub-card-icon.icon-purple { background: var(--gradient-purple); }
.tool-hub-card-icon.icon-yellow { background: var(--gradient-yellow); }

.tool-hub-card-category {
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-primary);
}

.tool-hub-card-name {
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  color: var(--text-main);
  line-height: var(--lh-tight);
}

.tool-hub-card-desc {
  font-size: var(--fs-base);
  color: var(--text-soft);
  line-height: var(--lh-normal);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.tool-hub-card-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--accent-gradient);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: #fff;
  white-space: nowrap;
  flex-shrink: 0;
}
.tool-hub-card-cta .lucide { width: 16px; height: 16px; }

/* Empty State */
.tools-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-12);
  color: var(--text-muted);
}
.tools-empty .lucide { width: 40px; height: 40px; }
.tools-empty p { font-size: var(--fs-base); }

/* Guest CTA */
.tools-guest-cta {
  margin-bottom: var(--space-10);
}
.tools-guest-cta-inner {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  background: var(--bg-cta);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  flex-wrap: wrap;
}
.tools-guest-cta-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--btn-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}
.tools-guest-cta-icon .lucide { width: 28px; height: 28px; }
.tools-guest-cta-text { flex: 1; min-width: 200px; }
.tools-guest-cta-text h2 {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  color: #fff;
  margin-bottom: var(--space-2);
}
.tools-guest-cta-text p {
  font-size: var(--fs-base);
  color: rgba(255,255,255,0.7);
  line-height: var(--lh-normal);
}
.tools-guest-cta-actions {
  display: flex;
  gap: var(--space-3);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.tools-guest-cta-actions .btn-outline {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}
.tools-guest-cta-actions .btn-outline:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* ==========================================================================
   2. TOOL PAGE LAYOUT
   ========================================================================== */

.tool-main-content {
  padding-top: var(--space-8);
  padding-bottom: var(--space-16);
  max-width: 800px;
}

.tool-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  color: var(--text-soft);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}
.tool-breadcrumb a {
  color: var(--text-soft);
  text-decoration: none;
}
.tool-breadcrumb a:hover { color: var(--accent-primary); }
.tool-breadcrumb-sep { color: var(--text-muted); font-size: var(--fs-xs); }

/* ==========================================================================
   3. CALCULATOR WIDGET
   ========================================================================== */

.calc-widget {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-2xl);
  overflow: hidden;
  margin-bottom: var(--space-8);
  box-shadow: var(--shadow-sm);
}

.calc-widget-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-section-soft);
}
.calc-widget-header .lucide { width: 20px; height: 20px; color: var(--accent-primary); flex-shrink: 0; }
.calc-widget-title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
}

/* Mode Tabs */
.calc-tabs {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
  scrollbar-width: none;
}
.calc-tabs::-webkit-scrollbar { display: none; }

.calc-tab {
  padding: 6px var(--space-4);
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border-subtle);
  background: transparent;
  color: var(--text-soft);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
  font-family: var(--font-main);
}
.calc-tab:hover { border-color: var(--accent-primary); color: var(--accent-primary); }
.calc-tab.active {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
  font-weight: var(--fw-semibold);
}

/* Body */
.calc-body { padding: var(--space-6); }

.calc-panel { display: none; }
.calc-panel.active { display: block; }

/* Input Fields */
.calc-fields { display: grid; gap: var(--space-4); margin-bottom: var(--space-5); }
.calc-fields-2col { grid-template-columns: 1fr 1fr; }
.calc-fields-3col { grid-template-columns: 1fr 1fr 1fr; }

.calc-field { display: flex; flex-direction: column; gap: var(--space-2); }
.calc-field label {
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  color: var(--text-main);
}
.calc-field input,
.calc-field select,
.calc-field textarea {
  padding: 10px var(--space-4);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-section);
  color: var(--text-main);
  font-size: var(--fs-md);
  font-family: var(--font-main);
  transition: border-color var(--transition-fast);
  width: 100%;
}
.calc-field input:focus,
.calc-field select:focus,
.calc-field textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(0, 126, 255, 0.08);
}
.calc-field textarea { resize: vertical; min-height: 80px; }
.calc-field-hint {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: -4px;
}

/* Action Row */
.calc-action-row {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.calc-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 10px var(--space-6);
  background: var(--btn-gradient);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  font-family: var(--font-main);
  cursor: pointer;
  transition: opacity var(--transition-fast);
}
.calc-btn-primary:hover { opacity: 0.88; }
.calc-btn-primary .lucide { width: 16px; height: 16px; }

.calc-btn-reset {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 10px var(--space-5);
  background: transparent;
  color: var(--text-soft);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  font-family: var(--font-main);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.calc-btn-reset:hover { border-color: var(--text-soft); color: var(--text-main); }
.calc-btn-reset .lucide { width: 14px; height: 14px; }

/* Result Box */
.calc-result {
  display: none;
  background: var(--color-success-bg);
  border: 1.5px solid var(--color-success);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  animation: calcResultIn 0.25s ease;
}
.calc-result.visible { display: block; }

@keyframes calcResultIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.calc-result-main {
  font-size: var(--fs-4xl);
  font-weight: var(--fw-extrabold);
  color: var(--color-success-text);
  line-height: 1.1;
  margin-bottom: 4px;
}
.calc-result-label {
  font-size: var(--fs-base);
  color: var(--text-soft);
  margin-bottom: var(--space-4);
}

.calc-breakdown {
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--space-4);
  display: grid;
  gap: var(--space-2);
}
.calc-breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--fs-base);
  padding: 4px 0;
}
.calc-breakdown-label { color: var(--text-soft); }
.calc-breakdown-value { font-weight: var(--fw-semibold); color: var(--text-main); }
.calc-breakdown-value.positive { color: var(--color-success-text); }
.calc-breakdown-value.negative { color: var(--color-error-text); }

/* Error Box */
.calc-error {
  display: none;
  background: var(--color-error-bg);
  border: 1.5px solid var(--color-error);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  color: var(--color-error-text);
  font-size: var(--fs-base);
  margin-top: var(--space-3);
}
.calc-error.visible { display: block; }

/* ==========================================================================
   4. FORMULA BOX
   ========================================================================== */

.tool-formula-box {
  background: var(--bg-section-soft);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-5) var(--space-6);
  margin-bottom: var(--space-8);
}
.tool-formula-box h3 {
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.tool-formula-box h3 .lucide { width: 18px; height: 18px; color: var(--accent-primary); }

.formula-grid { display: grid; gap: var(--space-3); }
.formula-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
}
.formula-label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.formula-expr {
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  font-family: 'Courier New', Courier, monospace;
  color: var(--text-main);
  overflow-x: auto;
  white-space: nowrap;
}

/* ==========================================================================
   5. HOW TO USE
   ========================================================================== */

.tool-how-section { margin-bottom: var(--space-8); }
.tool-how-section h2 { margin-bottom: var(--space-5); }

.tool-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
}
.tool-step {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  text-align: center;
}
.tool-step-num {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--btn-gradient);
  color: #fff;
  font-weight: var(--fw-bold);
  font-size: var(--fs-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-3);
}
.tool-step-title {
  font-size: var(--fs-base);
  font-weight: var(--fw-bold);
  margin-bottom: var(--space-2);
}
.tool-step-desc {
  font-size: var(--fs-sm);
  color: var(--text-soft);
  line-height: var(--lh-normal);
}

/* ==========================================================================
   6. RELATED TOOLS
   ========================================================================== */

.tool-related-section { margin-bottom: var(--space-12); }
.tool-related-section h2 {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  margin-bottom: var(--space-4);
}

.tool-related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-3);
}
.tool-related-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text-main);
  transition: all var(--transition-fast);
}
.tool-related-card:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  transform: translateX(2px);
}
.tool-related-card-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}
.tool-related-card-icon .lucide { width: 16px; height: 16px; }
.tool-related-card-icon.icon-blue   { background: var(--gradient-blue); }
.tool-related-card-icon.icon-green  { background: var(--gradient-green); }
.tool-related-card-icon.icon-orange { background: var(--gradient-orange); }
.tool-related-card-icon.icon-purple { background: var(--gradient-purple); }
.tool-related-card-icon.icon-yellow { background: var(--gradient-yellow); }

.tool-related-card-name {
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
}

/* FAQ spacing on tool pages */
.tool-faq-section { margin-bottom: var(--space-10); }
.tool-faq-section h2 { margin-bottom: var(--space-5); }

/* ==========================================================================
   7. RESPONSIVE
   ========================================================================== */

/* 3-col → 2-col on medium screens */
@media (max-width: 900px) {
  .calc-fields-3col { grid-template-columns: 1fr 1fr; }
  .tool-steps { grid-template-columns: 1fr 1fr; }
}

/* 3-col → 2-col on medium screens */
@media (max-width: 900px) {
  .calc-fields-3col { grid-template-columns: 1fr 1fr; }
  .tool-steps { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .calc-fields-2col,
  .calc-fields-3col { grid-template-columns: 1fr; }
  .tool-steps { grid-template-columns: 1fr; }
  .calc-result-main { font-size: var(--fs-3xl); }
  .calc-body { padding: var(--space-4); }
  .calc-widget-header { padding: var(--space-3) var(--space-4); }
  .calc-tabs { padding: var(--space-3) var(--space-4); }
  .tool-formula-box { padding: var(--space-4); }
  .tool-main-content { padding-top: var(--space-6); }
  .tool-hub-card-desc { display: none; }
  .tools-guest-cta-inner { padding: var(--space-5); gap: var(--space-4); }
}

@media (max-width: 640px) {
  .tool-related-grid { grid-template-columns: 1fr; }
  .tool-hub-card { padding: var(--space-3) var(--space-4); }
  .tool-hub-card-icon { width: 40px; height: 40px; }
  .tool-hub-card-icon .lucide { width: 18px; height: 18px; }
}

@media (max-width: 480px) {
  .calc-action-row { flex-direction: column; }
  .calc-btn-primary,
  .calc-btn-reset { justify-content: center; }
  .calc-result-main { font-size: var(--fs-2xl); }
  .tool-related-grid { grid-template-columns: 1fr 1fr; }
  .tools-guest-cta-actions { width: 100%; }
  .tools-guest-cta-actions .btn { flex: 1; text-align: center; justify-content: center; }
}
