/* =========================================================
   ToolNest — Main Stylesheet
   Mobile-first, White & Blue theme, Dark mode via [data-theme]
   ========================================================= */

/* ---------- Design Tokens ---------- */
:root {
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --blue-100: #dbeafe;
  --blue-50: #eff6ff;

  --bg: #f7f9fc;
  --surface: #ffffff;
  --text: #0f172a;
  --text-muted: #5b6b81;
  --border: #e5e9f0;
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-hover: 0 10px 28px rgba(37, 99, 235, 0.15);
  --radius: 16px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #131c2e;
  --text: #eef2f9;
  --text-muted: #9aa8c0;
  --border: #22304a;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 10px 28px rgba(59, 130, 246, 0.25);
  --blue-50: #16233d;
  --blue-100: #1c2c4a;
}

/* ---------- Reset ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.25s ease, color 0.25s ease;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select { font-family: inherit; }

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Navbar ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  max-width: 1100px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--blue-600);
}

.brand .dot { color: var(--text); }

.nav-links {
  position: fixed;
  top: 0;
  right: -100%;
  height: 100vh;
  width: min(75vw, 300px);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 80px 24px 24px;
  transition: right 0.3s ease;
  box-shadow: -8px 0 24px rgba(0,0,0,0.08);
}

.nav-links.open { right: 0; }

.nav-links a {
  padding: 12px 8px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 500;
}

.nav-links a:hover,
.nav-links a.active {
  background: var(--blue-50);
  color: var(--blue-600);
}

.nav-actions { display: flex; align-items: center; gap: 10px; }

.icon-btn {
  background: var(--blue-50);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: transform 0.2s ease, background 0.2s ease;
}

.icon-btn:hover { transform: translateY(-2px); background: var(--blue-100); }

.hamburger {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  z-index: 101;
}

.hamburger span {
  width: 24px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}
.nav-overlay.open { display: block; }

/* ---------- Hero ---------- */
.hero {
  padding: 56px 0 40px;
  text-align: center;
  background: linear-gradient(180deg, var(--blue-50) 0%, var(--bg) 100%);
}

.hero h1 {
  font-size: clamp(1.8rem, 5vw, 2.75rem);
  font-weight: 800;
  margin-bottom: 12px;
}

.hero h1 span { color: var(--blue-600); }

.hero p {
  color: var(--text-muted);
  max-width: 520px;
  margin: 0 auto 28px;
  font-size: 1rem;
}

/* ---------- Search Bar ---------- */
.search-wrap {
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

.search-wrap input {
  width: 100%;
  padding: 14px 18px 14px 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  box-shadow: var(--shadow);
  outline: none;
}

.search-wrap input:focus { border-color: var(--blue-500); }

.search-wrap .search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

/* ---------- Section Titles ---------- */
.section { padding: 40px 0; }

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 18px;
}

.section-title span { color: var(--blue-600); }

/* ---------- Category Chips ---------- */
.category-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.chip {
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* ---------- Tool Grid & Cards ---------- */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

@media (min-width: 640px) {
  .tool-grid { grid-template-columns: repeat(3, 1fr); gap: 18px; }
}

@media (min-width: 900px) {
  .tool-grid { grid-template-columns: repeat(4, 1fr); }
}

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.tool-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: var(--blue-500);
}

.tool-card .icon {
  font-size: 1.8rem;
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: var(--blue-50);
}

.tool-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.tool-card p {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: none;
}

@media (min-width: 640px) {
  .tool-card p { display: block; }
}

.hidden { display: none !important; }

/* ---------- Footer ---------- */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 32px 0 20px;
  margin-top: 40px;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
  text-align: center;
}

@media (min-width: 640px) {
  .footer-inner { flex-direction: row; justify-content: space-between; text-align: left; }
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer-links a:hover { color: var(--blue-600); }

.footer-note {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 18px;
}

/* ---------- Generic Page Header (About/Contact/Legal/Tool pages) ---------- */
.page-header {
  padding: 36px 0 8px;
}

.page-header h1 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 800;
  margin-bottom: 8px;
}

.page-header p { color: var(--text-muted); }

.breadcrumb {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.breadcrumb a:hover { color: var(--blue-600); }

.content-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.content-block h2 {
  font-size: 1.15rem;
  margin-bottom: 10px;
  color: var(--blue-600);
}

.content-block p, .content-block li {
  color: var(--text-muted);
  margin-bottom: 10px;
}

.content-block ul { padding-left: 20px; }

/* ---------- Forms / Tool UI ---------- */
.tool-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: var(--shadow);
  max-width: 560px;
  margin: 0 auto;
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.field input[type="text"],
.field input[type="number"],
.field input[type="date"],
.field select,
.field textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}

.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--blue-500);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.checkbox-row input { width: 16px; height: 16px; accent-color: var(--blue-600); }

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.btn {
  flex: 1;
  min-width: 120px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--blue-600); color: #fff; }
.btn-primary:hover { background: var(--blue-500); }

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--blue-500); color: var(--blue-600); }

.btn-copy {
  background: var(--blue-50);
  color: var(--blue-600);
  border: 1px solid var(--blue-100);
  padding: 8px 14px;
  font-size: 0.82rem;
}

/* ---------- Result Box ---------- */
.result-box {
  margin-top: 18px;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: var(--blue-50);
  border: 1px solid var(--blue-100);
  display: none;
}

.result-box.show { display: block; }

.result-box .result-main {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--blue-600);
  margin-bottom: 4px;
}

.result-box .result-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.result-line {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}
.result-line:last-child { border-bottom: none; }

/* ---------- Password strength bar ---------- */
.strength-bar {
  height: 6px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
  margin-top: 10px;
}
.strength-fill {
  height: 100%;
  width: 0%;
  border-radius: 4px;
  transition: width 0.25s ease, background 0.25s ease;
}

/* ---------- Counts row (word/char counter) ---------- */
.count-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 16px;
}
@media (min-width: 480px) {
  .count-grid { grid-template-columns: repeat(4, 1fr); }
}
.count-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}
.count-item .num { font-size: 1.3rem; font-weight: 800; color: var(--blue-600); }
.count-item .lbl { font-size: 0.72rem; color: var(--text-muted); }

/* ---------- QR output ---------- */
.qr-output {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}
.qr-output img {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
  padding: 8px;
}

/* ---------- Back to tools link ---------- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--blue-600);
  margin-top: 20px;
  font-weight: 600;
}

/* ---------- Utility ---------- */
.text-center { text-align: center; }
.mt-20 { margin-top: 20px; }
.small-note { font-size: 0.78rem; color: var(--text-muted); margin-top: 8px; }
