/* ============================================
   HASH GENERATOR — css/tools/hash-generator.css
   All selectors namespaced .hg-*
   ============================================ */

/* ── Tool wrapper ────────────────────────────────────────────────────────── */
.hg-tool {
  max-width: 900px;
  margin: 0 auto;
}

/* ── Mode tabs ───────────────────────────────────────────────────────────── */
.hg-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.25rem;
}

.hg-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius) var(--radius) 0 0;
  transition: var(--transition);
  min-height: 44px;
}

.hg-tab:hover {
  color: var(--primary);
  background: rgba(var(--primary-rgb), 0.05);
}

.hg-tab-active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: rgba(var(--primary-rgb), 0.06);
}

/* ── Panes ───────────────────────────────────────────────────────────────── */
.hg-pane {
  margin-bottom: 1rem;
}

/* ── Textarea ────────────────────────────────────────────────────────────── */
.hg-textarea {
  width: 100%;
  min-height: 140px;
  padding: 0.875rem 1rem;
  font-family: 'SF Mono', 'Cascadia Code', 'Roboto Mono', Menlo, Consolas, monospace;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  resize: vertical;
  transition: var(--transition);
  box-sizing: border-box;
}

.hg-textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.hg-textarea::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.hg-text-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
}

.hg-char-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Drop zone ───────────────────────────────────────────────────────────── */
.hg-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 3rem 2rem;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  position: relative;
}

.hg-dropzone:hover,
.hg-dropzone:focus-visible,
.hg-dropzone-active {
  border-color: var(--primary);
  background: rgba(var(--primary-rgb), 0.04);
}

.hg-dropzone:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.hg-dropzone-icon {
  color: var(--text-muted);
  transition: color 0.2s;
}

.hg-dropzone:hover .hg-dropzone-icon,
.hg-dropzone-active .hg-dropzone-icon {
  color: var(--primary);
}

.hg-dropzone-title {
  font-size: 1rem;
  color: var(--text);
  margin: 0;
}

.hg-dropzone-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}

.hg-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ── File info ───────────────────────────────────────────────────────────── */
.hg-file-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
}

.hg-file-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1;
  color: var(--text-muted);
}

.hg-file-details {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.hg-file-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hg-file-size {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.hg-file-clear-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.hg-file-clear-btn:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.06);
}

/* ── Progress bar ────────────────────────────────────────────────────────── */
.hg-progress {
  margin-bottom: 0.75rem;
}

.hg-progress-track {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.35rem;
}

.hg-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.hg-progress-bar-empty {
  width: 0;
}

.hg-progress-text {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── HMAC row ────────────────────────────────────────────────────────────── */
.hg-hmac-row {
  margin-bottom: 0.75rem;
}

.hg-hmac-label {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  user-select: none;
  min-height: 44px;
}

.hg-hmac-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.hg-hmac-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
}

.hg-hmac-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.hg-hmac-key-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.hg-hmac-key-input {
  font-family: 'SF Mono', monospace;
  letter-spacing: 0.02em;
}

.hg-hmac-key-hint {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── Status message ──────────────────────────────────────────────────────── */
.hg-status {
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.hg-status-error {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--danger);
}

.hg-status-success {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--success);
}

/* ── Results panel ───────────────────────────────────────────────────────── */
.hg-results {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 1rem;
}

.hg-results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.hg-fmt-group {
  display: inline-flex;
  gap: 0.25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.15rem;
}

.hg-fmt-btn {
  padding: 0.3rem 0.75rem;
  font-size: 0.78rem;
  font-family: 'SF Mono', monospace;
  font-weight: 600;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  min-height: 30px;
}

.hg-fmt-active {
  background: var(--primary);
  color: var(--on-primary);
}

.hg-results-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* ── Results table ───────────────────────────────────────────────────────── */
.hg-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.hg-table {
  width: 100%;
  border-collapse: collapse;
}

.hg-thead th {
  padding: 0.5rem 0.875rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.hg-row {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.hg-row:last-child {
  border-bottom: none;
}

.hg-row:hover {
  background: rgba(var(--primary-rgb), 0.03);
}

.hg-cell-rating,
.hg-cell-algo,
.hg-cell-hash,
.hg-cell-copy {
  padding: 0.75rem 0.875rem;
  vertical-align: middle;
}

.hg-cell-rating {
  white-space: nowrap;
  width: 130px;
}

.hg-cell-algo {
  white-space: nowrap;
  width: 110px;
}

.hg-cell-hash {
  width: 100%;
}

.hg-cell-copy {
  width: 44px;
}

/* Security dot */
.hg-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: middle;
  flex-shrink: 0;
}

.hg-dot-broken      { background: var(--danger); }
.hg-dot-deprecated  { background: var(--warning); }
.hg-dot-recommended { background: var(--success); }
.hg-dot-strong      { background: var(--success); }
.hg-dot-strongest   { background: var(--primary); }
.hg-dot-hmac        { background: var(--primary); }

/* Rating label */
.hg-rating-label {
  font-size: 0.75rem;
  font-weight: 700;
  vertical-align: middle;
}

.hg-rating-broken      { color: var(--danger); }
.hg-rating-deprecated  { color: var(--warning); }
.hg-rating-recommended { color: var(--success); }
.hg-rating-strong      { color: var(--success); }
.hg-rating-strongest   { color: var(--primary); }
.hg-rating-hmac        { color: var(--primary); }

/* Algorithm name */
.hg-algo-name {
  font-family: 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  background: transparent;
}

/* Hash value */
.hg-hash-value {
  display: block;
  font-family: 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;
  font-size: 0.8rem;
  color: var(--text);
  word-break: break-all;
  overflow-wrap: anywhere;
  line-height: 1.5;
  user-select: all;
}

/* Copy button */
.hg-copy-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.hg-copy-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: rgba(var(--primary-rgb), 0.06);
}

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

/* HMAC separator */
.hg-separator td {
  padding: 0.3rem 0.875rem;
  background: var(--bg);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.hg-separator span {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ── Mobile (≤ 640px) ────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .hg-tabs { gap: 0; }

  .hg-tab { padding: 0.5rem 0.8rem; font-size: 0.85rem; }

  .hg-textarea { min-height: 110px; font-size: 0.9rem; }

  .hg-dropzone { padding: 2rem 1rem; }

  .hg-results-toolbar { flex-direction: column; align-items: stretch; gap: 0.5rem; }

  .hg-results-actions { justify-content: flex-end; }

  .hg-cell-rating { width: auto; }

  .hg-cell-algo { display: none; }

  .hg-hash-value { font-size: 0.72rem; }

  .hg-thead th:nth-child(2) { display: none; }

  .hg-rating-label { font-size: 0.68rem; }
}
