/* =====================================================
   ToolPulse — Global Design System
   Clean, Professional, AdSense-Optimized
   ===================================================== */

/* ----- Google Fonts loaded via HTML ----- */

/* ----- CSS Custom Properties ----- */
:root {
  --bg-body: #f5f7fa;
  --bg-white: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f0f4ff;
  --bg-tool: #f8fafc;
  --bg-header: #ffffff;
  --bg-footer: #1e293b;

  --border: #e2e8f0;
  --border-hover: #cbd5e1;
  --border-accent: #6366f1;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-white: #f8fafc;
  --text-link: #4f46e5;

  --accent: #4f46e5;
  --accent-light: #6366f1;
  --accent-bg: #eef2ff;
  --accent-hover: #4338ca;

  --green: #10b981;
  --green-bg: #ecfdf5;
  --blue: #3b82f6;
  --blue-bg: #eff6ff;
  --orange: #f59e0b;
  --orange-bg: #fffbeb;
  --red: #ef4444;
  --red-bg: #fef2f2;
  --purple: #8b5cf6;
  --purple-bg: #f5f3ff;
  --pink: #ec4899;
  --pink-bg: #fdf2f8;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 999px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;

  --transition: 0.2s ease;
  --max-width: 1200px;
}

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

html { font-size: 16px; scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }

body {
  font-family: var(--font);
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--text-link); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; height: auto; }

/* ----- Header ----- */
.site-header {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
}

.logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.logo-text {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
}

.logo-text span {
  color: var(--accent);
}

.nav-links {
  display: flex;
  gap: 4px;
  list-style: none;
}

.nav-links a {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.nav-links a:hover, .nav-links a.active {
  background: var(--accent-bg);
  color: var(--accent);
}

/* Mobile menu */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-primary);
  padding: 4px;
}

/* ----- Main Content ----- */
.main-content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 24px 60px;
}

/* ----- Ad Slots ----- */
.ad-slot {
  background: var(--bg-tool);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  margin: 24px 0;
  min-height: 90px;
  text-align: center;
}

.ad-slot.banner { min-height: 90px; }
.ad-slot.rectangle { min-height: 250px; max-width: 336px; margin-left: auto; margin-right: auto; }

/* ----- Hero Section (Homepage) ----- */
.hero {
  text-align: center;
  padding: 48px 0 40px;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 12px;
  line-height: 1.2;
}

.hero h1 em {
  font-style: normal;
  background: linear-gradient(135deg, var(--accent), #06b6d4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

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

.search-input {
  width: 100%;
  padding: 14px 20px 14px 48px;
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  font-family: var(--font);
  font-size: 1rem;
  background: var(--bg-white);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-bg);
}

.search-input::placeholder { color: var(--text-muted); }

.search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.1rem;
  pointer-events: none;
}

/* ----- Category Section ----- */
.categories {
  margin-top: 48px;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.category-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.category-icon.text { background: var(--blue-bg); }
.category-icon.dev { background: var(--purple-bg); }
.category-icon.calc { background: var(--green-bg); }
.category-icon.prod { background: var(--orange-bg); }
.category-icon.image { background: var(--pink-bg); }
.category-icon.convert { background: var(--red-bg); }

.category-header h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
}

/* ----- Tool Cards Grid ----- */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 40px;
}

.tool-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-primary);
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.tool-card:hover {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  color: var(--text-primary);
}

.tool-card .tool-emoji {
  font-size: 1.6rem;
  flex-shrink: 0;
}

.tool-card .tool-info h3 {
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.tool-card .tool-info p {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* ----- Tool Page Layout ----- */
.tool-page-header {
  margin-bottom: 24px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--border); }

.tool-page-header h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.tool-page-header .tool-desc {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 700px;
}

/* Tool Area */
.tool-area {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

/* Tool inputs */
.tool-textarea {
  width: 100%;
  min-height: 180px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.6;
  background: var(--bg-tool);
  color: var(--text-primary);
  resize: vertical;
  outline: none;
  transition: border-color var(--transition);
}

.tool-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.tool-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 0.95rem;
  background: var(--bg-tool);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition);
}

.tool-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

/* Stats row */
.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-tool);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
}

.stat-item .stat-label { color: var(--text-muted); }
.stat-item .stat-value { font-weight: 700; color: var(--accent); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--bg-tool);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

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

/* Result area */
.result-area {
  margin-top: 20px;
  padding: 20px;
  background: var(--bg-tool);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 100px;
  max-height: 400px;
  overflow-y: auto;
}

/* ----- Content Section (SEO text) ----- */
.content-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.content-section h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.content-section p {
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.8;
}

.content-section ul, .content-section ol {
  color: var(--text-secondary);
  padding-left: 24px;
  margin-bottom: 12px;
}

.content-section li {
  margin-bottom: 6px;
  line-height: 1.7;
}

/* FAQ Accordion */
.faq-list {
  margin-top: 16px;
}

.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  overflow: hidden;
}

.faq-question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 16px 20px;
  background: var(--bg-tool);
  border: none;
  font-family: var(--font);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition);
}

.faq-question:hover { background: var(--accent-bg); }

.faq-question::after {
  content: '+';
  font-size: 1.2rem;
  color: var(--text-muted);
  transition: transform var(--transition);
}

.faq-item.open .faq-question::after {
  content: '−';
}

.faq-answer {
  padding: 0 20px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
}

.faq-item.open .faq-answer {
  padding: 16px 20px;
  max-height: 500px;
}

.faq-answer p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.7;
}

/* Related Tools */
.related-tools {
  margin-top: 16px;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

/* ----- Footer ----- */
.site-footer {
  background: var(--bg-footer);
  color: var(--text-white);
  padding: 40px 24px 24px;
  margin-top: 60px;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 32px;
}

.footer-brand .logo-text {
  color: var(--text-white);
  font-size: 1.3rem;
  margin-bottom: 8px;
}

.footer-brand p {
  color: #94a3b8;
  font-size: 0.85rem;
  line-height: 1.6;
}

.footer-col h4 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #94a3b8;
  margin-bottom: 12px;
}

.footer-col a {
  display: block;
  color: #cbd5e1;
  font-size: 0.88rem;
  padding: 4px 0;
  transition: color var(--transition);
}

.footer-col a:hover { color: white; }

.footer-bottom {
  border-top: 1px solid #334155;
  padding-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: #64748b;
}

.footer-bottom a {
  color: #64748b;
  margin-left: 16px;
}

.footer-bottom a:hover { color: #94a3b8; }

/* ----- Responsive ----- */

/* Global overflow prevention */
html, body { overflow-x: hidden; }
.main-content { overflow-x: hidden; }
.tool-area { overflow-x: hidden; }

/* Tables — horizontal scroll on mobile */
table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Pre/code blocks — scroll instead of overflow */
pre, code { word-wrap: break-word; overflow-wrap: break-word; }
pre { overflow-x: auto; max-width: 100%; }

/* Inputs and selects constrained */
select, input[type="text"], input[type="number"], input[type="email"], input[type="url"], textarea {
  max-width: 100%; box-sizing: border-box;
}

@media (max-width: 768px) {
  .header-inner { height: 56px; }
  .nav-links { display: none; }
  .menu-toggle { display: block; }

  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    padding: 8px;
    box-shadow: var(--shadow-lg);
  }

  .hero h1 { font-size: 1.8rem; }
  .hero p { font-size: 0.95rem; }
  .tools-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 24px; }
  .footer-bottom { flex-direction: column; gap: 8px; text-align: center; }

  .tool-area { padding: 16px; }
  .content-section { padding: 20px; }
  .tool-page-header h1 { font-size: 1.5rem; }

  /* Options rows — stack vertically */
  .options-row, .batch-row { flex-direction: column; align-items: stretch; }
  .options-row > div { width: 100%; }

  /* Quality/compression buttons — 2-col grid */
  .quality-opt { flex-direction: column; }
  .quality-opt .q-btn { min-width: unset; }

  /* Page grids — 2 columns max */
  .page-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

  /* Button rows — wrap */
  .btn-row { justify-content: center; }

  /* Result grid (compress PDF) */
  .result-grid { grid-template-columns: 1fr; text-align: center; }
  .arrow { transform: rotate(90deg); }

  /* Stats — wrap better */
  .stats { gap: 8px; }
  .stat { min-width: 70px; padding: 8px 10px; }
  .stat .val { font-size: 1rem; }

  /* Related tools grid */
  .related-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

@media (max-width: 480px) {
  .main-content { padding: 16px 12px 40px; }
  .tools-grid { gap: 10px; }
  .tool-card { padding: 14px 16px; }
  .footer-grid { grid-template-columns: 1fr; }
  .stats-row { gap: 8px; }
  .stat-item { padding: 6px 12px; font-size: 0.8rem; }
  .tool-area { padding: 12px; }
  .tool-page-header h1 { font-size: 1.3rem; }
  .breadcrumb { font-size: 0.75rem; flex-wrap: wrap; }
  .btn { padding: 8px 16px; font-size: 0.85rem; }

  /* Page cards (PDF tools) */
  .page-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .page-card .card-footer { flex-direction: column; gap: 4px; }
}

/* ----- Utility Classes ----- */
.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;
}

.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
