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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --green-500: #22c55e;
  --red-500: #ef4444;
  --yellow-500: #eab308;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.1), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --transition: 150ms ease;
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Header ===== */
.site-header {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  height: 60px;
  gap: 1rem;
}
.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  text-decoration: none;
}
.logo:hover { text-decoration: none; }
.logo span { color: var(--gray-700); }

.header-search {
  flex: 1;
  max-width: 400px;
  position: relative;
}
.header-search input {
  width: 100%;
  padding: .5rem .75rem .5rem 2.25rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: .875rem;
  outline: none;
  transition: border var(--transition);
}
.header-search input:focus { border-color: var(--primary); }
.header-search svg {
  position: absolute;
  left: .625rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--gray-400);
}
.search-results {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 300px;
  overflow-y: auto;
  z-index: 200;
}
.search-results.active { display: block; }
.search-results a {
  display: block;
  padding: .5rem .75rem;
  color: var(--gray-700);
  font-size: .875rem;
  border-bottom: 1px solid var(--gray-100);
}
.search-results a:hover {
  background: var(--primary-light);
  text-decoration: none;
}

.header-nav {
  display: flex;
  gap: .25rem;
}
.header-nav a {
  padding: .375rem .75rem;
  border-radius: var(--radius);
  font-size: .8125rem;
  color: var(--gray-600);
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}
.header-nav a:hover { background: var(--gray-100); color: var(--gray-900); text-decoration: none; }
.header-nav a.active { background: var(--primary-light); color: var(--primary); }

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: .5rem;
  color: var(--gray-600);
}

/* ===== Ad Slots ===== */
.ad-slot {
  background: var(--gray-100);
  border: 1px dashed var(--gray-300);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  font-size: .75rem;
  overflow: hidden;
}
.ad-top {
  max-width: 728px;
  height: 90px;
  margin: 1rem auto;
}
.ad-sidebar {
  width: 100%;
  height: 250px;
  margin-bottom: 1rem;
}
.ad-bottom {
  max-width: 728px;
  height: 280px;
  margin: 1.5rem auto;
}

/* ===== Main Layout ===== */
.page-wrapper {
  flex: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
  width: 100%;
}
.content-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.5rem;
  align-items: start;
}
.main-content { min-width: 0; }

/* ===== Sidebar ===== */
.sidebar { position: sticky; top: 76px; }
.related-tools {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1rem;
}
.related-tools h3 {
  font-size: .875rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: .75rem;
}
.related-tools a {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem;
  border-radius: 6px;
  color: var(--gray-600);
  font-size: .8125rem;
  transition: background var(--transition);
}
.related-tools a:hover { background: var(--gray-100); text-decoration: none; }
.related-tools a .tool-icon { font-size: 1rem; }

/* ===== Tool Card (Landing Page) ===== */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.tool-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: box-shadow var(--transition), border-color var(--transition);
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.tool-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
  text-decoration: none;
}
.tool-card .card-icon {
  font-size: 1.75rem;
}
.tool-card h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
}
.tool-card p {
  font-size: .8125rem;
  color: var(--gray-500);
  line-height: 1.5;
}

/* ===== Tool Page Components ===== */
.tool-header {
  margin-bottom: 1.5rem;
}
.tool-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: .25rem;
}
.tool-header p {
  color: var(--gray-500);
  font-size: .875rem;
}
.tool-container {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

/* Form Elements */
textarea, input[type="text"], input[type="number"], input[type="url"], select {
  width: 100%;
  padding: .625rem .75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: .875rem;
  font-family: inherit;
  outline: none;
  transition: border var(--transition);
  background: #fff;
}
textarea:focus, input[type="text"]:focus, input[type="number"]:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
textarea {
  resize: vertical;
  min-height: 120px;
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas, monospace;
  font-size: .8125rem;
  line-height: 1.5;
}
label {
  display: block;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: .375rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: .8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  line-height: 1.4;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary {
  background: #fff;
  color: var(--gray-700);
  border-color: var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn-sm { padding: .375rem .625rem; font-size: .75rem; }
.btn-group { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 1rem;
}
.tab-btn {
  padding: .5rem 1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  transition: all var(--transition);
}
.tab-btn:hover { color: var(--gray-700); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Output / Code Block */
.output-area {
  background: var(--gray-800);
  color: #e5e7eb;
  padding: 1rem;
  border-radius: var(--radius);
  font-family: 'SF Mono', 'Fira Code', Menlo, Consolas, monospace;
  font-size: .8125rem;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  position: relative;
  min-height: 60px;
}
.copy-btn {
  position: absolute;
  top: .5rem;
  right: .5rem;
  padding: .25rem .5rem;
  background: var(--gray-700);
  color: var(--gray-300);
  border: none;
  border-radius: 4px;
  font-size: .6875rem;
  cursor: pointer;
}
.copy-btn:hover { background: var(--gray-600); }
.copy-btn.copied { background: var(--green-500); color: #fff; }

/* Status Messages */
.status { padding: .5rem .75rem; border-radius: var(--radius); font-size: .8125rem; margin-top: .5rem; }
.status-success { background: #dcfce7; color: #166534; }
.status-error { background: #fef2f2; color: #991b1b; }
.status-info { background: var(--primary-light); color: var(--primary-dark); }

/* ===== Footer ===== */
.site-footer {
  background: var(--gray-800);
  color: var(--gray-400);
  padding: 2rem 1rem;
  margin-top: auto;
}
.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
}
.footer-col h4 {
  color: var(--gray-200);
  font-size: .875rem;
  font-weight: 600;
  margin-bottom: .75rem;
}
.footer-col a {
  display: block;
  color: var(--gray-400);
  font-size: .8125rem;
  padding: .2rem 0;
}
.footer-col a:hover { color: #fff; text-decoration: none; }
.footer-bottom {
  max-width: 1280px;
  margin: 1.5rem auto 0;
  padding-top: 1rem;
  border-top: 1px solid var(--gray-700);
  font-size: .75rem;
  text-align: center;
}

/* ===== Landing Page ===== */
.hero {
  text-align: center;
  padding: 2.5rem 0 1.5rem;
}
.hero h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--gray-900);
  margin-bottom: .5rem;
}
.hero p {
  font-size: 1.0625rem;
  color: var(--gray-500);
  max-width: 600px;
  margin: 0 auto;
}
.category-label {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-400);
  margin: 1.5rem 0 .75rem;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .content-layout {
    grid-template-columns: 1fr;
  }
  .sidebar { position: static; }
  .ad-sidebar { max-width: 400px; }
}

@media (max-width: 768px) {
  .header-nav { display: none; }
  .mobile-menu-btn { display: block; }
  .header-nav.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    padding: .5rem;
    box-shadow: var(--shadow-md);
  }
  .hero h1 { font-size: 1.5rem; }
  .hero p { font-size: .9375rem; }
  .tools-grid { grid-template-columns: 1fr; }
  .ad-top { max-width: 100%; height: 60px; }
  .ad-bottom { max-width: 100%; }
  .tool-header h1 { font-size: 1.25rem; }
}

@media (max-width: 480px) {
  .header-search { display: none; }
  .tool-container { padding: 1rem; }
}
