/* Tool View & Interactive Components */
.tool-view {
  max-width: 900px;
  margin-inline: auto;
}

.tool-header {
  margin-bottom: 2rem;
}

.tool-breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 1rem;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.tool-breadcrumb:hover {
  opacity: 0.8;
}

.tool-header-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.tool-header-desc {
  font-size: 1.05rem;
  color: var(--text-secondary);
}

/* Tool Main Container Card */
.tool-workspace {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-card);
  margin-bottom: 2rem;
}

/* Tool Mode Tabs */
.tool-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.75rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.75rem;
  overflow-x: auto;
}

.tool-tab {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.tool-tab:hover {
  color: var(--text-primary);
  background-color: var(--bg-surface-hover);
}

.tool-tab.active {
  color: var(--color-primary);
  background-color: var(--color-primary-light);
}

/* Form Actions Row */
.tool-actions-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* Results Display Box */
.result-card {
  margin-top: 2rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  animation: fadeIn 0.3s ease;
}

.result-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.result-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.result-main-value {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--color-primary);
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.result-formula {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.95rem;
  padding: 0.6rem 1rem;
  background-color: var(--bg-code);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  margin-block: 0.75rem;
  direction: ltr;
  text-align: left;
}

/* Stats Grid for Age, Date, Counts */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.stat-item {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
}

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

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  font-weight: 500;
}

/* Units Table */
.units-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.units-table th, .units-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  text-align: start;
}

.units-table th {
  background-color: var(--bg-surface-hover);
  color: var(--text-muted);
  font-weight: 600;
}

.units-table tr:hover td {
  background-color: var(--bg-surface-hover);
}

/* Textarea / Code Editor Styles */
.editor-textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  min-height: 220px;
  resize: vertical;
  white-space: pre;
  tab-size: 2;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.quick-actions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

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

@media (max-width: 640px) {
  .tool-workspace {
    padding: 1.25rem;
  }
  .tool-header-title {
    font-size: 1.5rem;
  }
  .result-main-value {
    font-size: 1.75rem;
  }
}
