/* Teamz Lab Tools — Utility Tools CSS
   Extends tools.css for text tools, dev tools, image tools.
   Uses design system tokens from branding/css/tokens.css */

/* ===== Textarea ===== */
.tool-textarea {
  width: 100%;
  min-height: 200px;
  padding: 1rem;
  font-size: var(--text-lg);
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  resize: vertical;
  line-height: 1.5;
  transition: border-color 0.2s, background 0.3s, color 0.3s;
  box-sizing: border-box;
}

.tool-textarea:focus {
  border-color: var(--heading);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}

.tool-textarea--mono {
  font-family: var(--font-code);
  font-size: var(--text-md);
  background: var(--code-bg);
  color: var(--code-text);
  tab-size: 2;
  white-space: pre;
  overflow-x: auto;
}

/* ===== Output ===== */
.tool-output {
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  margin-top: 1rem;
  overflow: visible;
  transition: background 0.3s, border-color 0.3s;
}

.tool-output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  background: none;
  margin-bottom: 0.75rem;
}

.tool-output-title {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--heading);
}

.tool-output--code {
  margin: 0;
  padding: 1rem;
  font-family: var(--font-code);
  font-size: var(--text-md);
  color: var(--code-text);
  background: var(--code-bg);
  overflow-x: auto;
  white-space: pre;
  line-height: 1.5;
  max-height: none;
  overflow-y: visible;
  border-radius: 8px;
}

.tool-output--code code {
  font-family: inherit;
  background: none;
  padding: 0;
}

.tool-output--text {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  font-size: var(--text-lg);
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: none;
  overflow-y: visible;
}

.tool-output--preview {
  padding: 0.75rem;
  font-family: var(--font);
  font-size: var(--text-lg);
  color: var(--text);
  line-height: var(--lh);
  max-height: none;
  overflow-y: visible;
}

.tool-output--preview .tool-result-card {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  box-shadow: none;
}

.tool-output--preview h1,
.tool-output--preview h2,
.tool-output--preview h3 {
  color: var(--heading);
  margin: 1rem 0 0.5rem;
}

.tool-output--preview code {
  font-family: var(--font-code);
  background: var(--code-bg);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: var(--text-md);
}

.tool-output--preview pre {
  background: var(--code-bg);
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
}

.tool-output--preview blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  color: var(--text-muted);
  margin: 1rem 0;
}

/* ===== Diff View ===== */
.tool-diff-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.tool-output--diff {
  padding: 0;
  font-family: var(--font-code);
  font-size: var(--text-md);
  max-height: 500px;
  overflow-y: auto;
}

.diff-line {
  padding: 2px 1rem;
  white-space: pre;
  min-height: 1.4em;
}

.diff-added {
  background: var(--success-bg-subtle, rgba(76, 175, 80, 0.1));
  color: var(--success);
}

.diff-removed {
  background: var(--danger-bg-subtle, rgba(244, 67, 54, 0.1));
  color: var(--danger);
}

.diff-unchanged {
  color: var(--text-muted);
}

/* ===== Stats Bar ===== */
.tool-stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0.75rem 0;
  margin-top: 0.5rem;
}

.tool-stat-item {
  font-size: var(--text-sm);
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 0.3rem 0.8rem;
  white-space: nowrap;
}

.tool-stat-item strong {
  color: var(--heading);
  font-weight: 600;
}

/* ===== File Dropzone ===== */
.tool-dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  padding: 2rem;
  transition: border-color 0.2s, background 0.2s;
}

.tool-dropzone:hover,
.tool-dropzone:focus-visible {
  border-color: var(--heading);
  background: rgba(255, 255, 255, 0.03);
}

.tool-dropzone--active {
  border-color: var(--heading);
  background: rgba(255, 255, 255, 0.06);
}

.tool-dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
}

.tool-dropzone-content svg {
  stroke: var(--heading);
  opacity: 0.5;
}

.tool-dropzone-content p {
  font-size: var(--text-lg);
  margin: 0;
}

.tool-dropzone-content strong {
  color: var(--heading);
}

.tool-dropzone-hint {
  font-size: var(--text-sm);
  opacity: 0.6;
}

/* ===== File Preview ===== */
.tool-file-preview {
  text-align: center;
  padding: 1rem 0;
}

.tool-file-preview img {
  border: 1px solid var(--border);
}

.tool-file-info {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* ===== Download Zone ===== */
.tool-download-zone {
  display: flex;
  justify-content: center;
  text-align: center;
  padding: 1.5rem;
}

/* ===== Utility Inputs Layout ===== */
.utility-inputs {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ===== Responsive ===== */
@media (max-width: 700px) {
  .tool-textarea {
    min-height: 150px;
    font-size: var(--text-md);
  }

  .tool-diff-container {
    grid-template-columns: 1fr;
  }

  .tool-dropzone {
    min-height: 150px;
    padding: 1.5rem;
  }

  .tool-stats-bar {
    gap: 0.5rem;
  }

  .tool-output--code,
  .tool-output--text {
    font-size: var(--text-sm);
    max-height: 350px;
  }

  .tool-textarea {
    font-size: 16px; /* prevents iOS zoom */
  }

  .tool-textarea--mono {
    font-size: 13px;
    tab-size: 2;
  }

  .tool-output-header {
    padding: 0.5rem 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .tool-dropzone-content p {
    font-size: var(--text-md);
  }

  .tool-dropzone-content svg {
    width: 36px;
    height: 36px;
  }

  .tool-file-preview img {
    max-height: 200px;
  }

  .tool-stat-item {
    font-size: var(--text-xs);
    padding: 0.2rem 0.6rem;
  }

  .tool-download-zone {
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  .tool-textarea {
    min-height: 120px;
  }

  .tool-dropzone {
    min-height: 120px;
    padding: 1rem;
  }

  .tool-output--code,
  .tool-output--text {
    max-height: 280px;
    padding: 0.75rem;
  }
}

/* ===== Print ===== */
@media print {
  .tool-dropzone,
  .tool-download-zone,
  .tool-output-header button {
    display: none !important;
  }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  .tool-dropzone {
    transition: none;
  }
}
