/* ============================================================
   TOOLBOX — components.css
   Reusable UI components: cards, buttons, inputs, badges, tabs
   Requires: main.css (CSS variables)
   ============================================================ */

/* --- 1. CARD ------------------------------------------------- */
.card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 1.5rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-dim), 0 4px 16px rgba(0,0,0,0.4);
}
.card-sm { padding: 1rem; }
.card-lg { padding: 2rem; }

/* --- 2. BUTTONS ---------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius-btn);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  background: none;
  color: var(--text);
}
.btn:hover { text-decoration: none; }
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary — solid accent */
.btn-primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 600;
}
.btn-primary:hover { opacity: 0.88; }

/* Ghost — outline accent */
.btn-ghost {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}
.btn-ghost:hover {
  background: var(--accent-dim);
}

/* Danger */
.btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover { background: rgba(255, 68, 68, 0.22); }

/* Surface — subtle dark button */
.btn-surface {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.btn-surface:hover { border-color: var(--border-hover); background: #222; }

/* Size variants */
.btn-sm { padding: 0.375rem 0.875rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.75rem 1.75rem; font-size: 1rem; }

/* Full width */
.btn-block { width: 100%; }

/* --- 3. INPUTS ----------------------------------------------- */
.input {
  display: block;
  width: 100%;
  padding: 0.5rem 0.875rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  line-height: 1.5;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
}
.input::placeholder { color: var(--text-muted); }
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Mono variant (for number/code inputs) */
.input-mono {
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

/* Large search-style input */
.input-search {
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  border-radius: 999px;
  background: var(--surface-2);
}

/* Textarea */
textarea.input {
  resize: vertical;
  min-height: 6rem;
}

/* Label */
.label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* Field group (label + input) */
.field {
  margin-bottom: 1rem;
}

/* Select */
select.input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.875rem center;
  padding-right: 2.25rem;
}

/* --- 4. BADGES ----------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2em 0.65em;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-family: var(--font-mono);
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-math     { background: rgba(99, 179, 237, 0.12); color: #63b3ed; border-color: rgba(99, 179, 237, 0.25); }
.badge-finance  { background: rgba(104, 211, 145, 0.12); color: #68d391; border-color: rgba(104, 211, 145, 0.25); }
.badge-cs       { background: rgba(183, 148, 246, 0.12); color: #b794f6; border-color: rgba(183, 148, 246, 0.25); }
.badge-cyber    { background: rgba(0, 255, 136, 0.10); color: #00ff88; border-color: rgba(0, 255, 136, 0.2); }
.badge-science  { background: rgba(252, 211, 77, 0.10); color: #f6c90e; border-color: rgba(252, 211, 77, 0.2); }
.badge-utility  { background: rgba(246, 135, 96, 0.10); color: #f68760; border-color: rgba(246, 135, 96, 0.2); }

/* --- 5. TABS ------------------------------------------------- */
.tab-group {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}
.tab-group::-webkit-scrollbar { height: 0; }

.tab {
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
  margin-bottom: -1px;
  font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* --- 6. TOOL HEADER ------------------------------------------ */
.tool-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: var(--header-height);
  padding: 0 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
  font-family: var(--font-mono);
  transition: color 0.15s ease;
  justify-self: start;
}
.back-link:hover {
  color: var(--accent);
  text-decoration: none;
}

.tool-title {
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--accent);
  text-align: center;
  justify-self: center;
}

/* --- 7. TOOL MAIN AREA --------------------------------------- */
.tool-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.tool-main-wide {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* --- 8. SECTION TITLE (homepage) ----------------------------- */
.section-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  padding-left: 0.875rem;
  border-left: 3px solid var(--accent);
  margin-bottom: 1.25rem;
}
.section-title .section-icon {
  font-size: 1.1rem;
}
.section-title .section-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: auto;
}

/* --- 9. TOOL CARD (homepage grid) ---------------------------- */
.tool-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  text-decoration: none;
  transition: border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  cursor: pointer;
}
.tool-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  text-decoration: none;
}
.card-name {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}
.card-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
}

/* --- 10. OUTPUT / RESULT BOXES ------------------------------- */
.result-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  padding: 0.875rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--accent);
  word-break: break-all;
  min-height: 2.75rem;
}

.result-box.error {
  color: var(--danger);
  border-color: var(--danger);
}

/* --- 11. RESPONSIVE ------------------------------------------ */
@media (max-width: 640px) {
  .tool-header {
    padding: 0 1rem;
  }
  .tool-main,
  .tool-main-wide {
    padding: 1.25rem 1rem;
  }
  .tab { padding: 0.5rem 0.875rem; font-size: 0.8125rem; }
}
