/* ============================================================
   Global Stylesheet — Online Tools Website
   ============================================================ */

/* ----- CSS Variables / Custom Properties ----- */
:root {
  --bg-primary: #ffffff;
  --bg-card: #f8f9fa;
  --bg-card-hover: #e9ecef;
  --text-primary: #1a1a2e;
  --text-secondary: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --cat-text: #2563eb;
  --cat-image: #059669;
  --cat-calc: #ea580c;
  --ad-placeholder: #f1f3f5;
  --border: #dee2e6;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.12);
  --radius: 8px;
  --header-height: 56px;
  --max-width: 1200px;
}

[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --ad-placeholder: #1e293b;
  --border: #334155;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.4);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",
    "Noto Color Emoji";
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background-color 0.25s ease, color 0.25s ease;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  text-decoration: underline;
}

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

ul {
  list-style: none;
}

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

/* ----- Header (sticky top) ----- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  height: var(--header-height);
  transition: background-color 0.25s ease;
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 100%;
}

.header-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.header-logo:hover {
  text-decoration: none;
}

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

.header-search {
  display: flex;
  align-items: center;
  max-width: 360px;
  flex: 1;
  position: relative;
  margin: 0 auto;
}

.header-search input {
  width: 100%;
  padding: 8px 16px 8px 36px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background-color: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.header-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

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

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

.theme-toggle {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background-color: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.theme-toggle:hover {
  background-color: var(--bg-card-hover);
}

/* ----- Breadcrumb ----- */
.breadcrumb {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px 16px 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.breadcrumb a {
  color: var(--text-secondary);
}

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

.breadcrumb .current {
  color: var(--text-primary);
  font-weight: 500;
}

.breadcrumb-sep {
  margin: 0 6px;
  color: var(--text-secondary);
}

/* ----- Ad Slots ----- */
.ad-slot {
  max-width: var(--max-width);
  margin: 16px auto;
  min-height: 90px;
  background-color: var(--ad-placeholder);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.ad-slot-sidebar { min-height: 250px; }

.ad-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: absolute;
  top: 4px;
  right: 8px;
}

/* ----- Hero (homepage) ----- */
.hero {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 48px 16px 32px;
  text-align: center;
}

.hero h1 {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 12px;
}

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

.hero-search {
  max-width: 520px;
  margin: 0 auto;
  position: relative;
}

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

.hero-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

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

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

/* ----- Category Cards ----- */
.cat-grid {
  max-width: var(--max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 0 16px;
}

.cat-card {
  background-color: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--border);
  transition: box-shadow 0.2s ease, transform 0.2s ease, background-color 0.25s ease;
}

.cat-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.cat-card h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.cat-card > p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.cat-card li {
  margin-bottom: 4px;
}

.cat-card li a {
  font-size: 0.875rem;
  color: var(--accent);
}

.cat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.cat-icon.text {
  background-color: var(--cat-text);
}

.cat-icon.image {
  background-color: var(--cat-image);
}

.cat-icon.calc {
  background-color: var(--cat-calc);
}

/* ----- Tool Grid (homepage listing) ----- */
.tool-grid {
  max-width: var(--max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 0 16px;
}

.section-title {
  max-width: var(--max-width);
  margin: 0 auto 16px;
  padding: 0 16px;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.tool-card {
  background-color: var(--bg-card);
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 12px;
  transition: box-shadow 0.2s ease, transform 0.2s ease, background-color 0.25s ease;
  cursor: pointer;
  text-decoration: none;
  color: var(--text-primary);
}

.tool-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
  background-color: var(--bg-card-hover);
  text-decoration: none;
}

.tool-card a {
  color: var(--text-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.tool-card a:hover {
  text-decoration: none;
}

.tool-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 600;
  flex-shrink: 0;
}

.tool-card-icon.text-sub {
  background-color: var(--cat-text);
}

.tool-card-icon.image-sub {
  background-color: var(--cat-image);
}

.tool-card-icon.calc-sub {
  background-color: var(--cat-calc);
}

.tool-card-text {
  flex: 1;
  min-width: 0;
}

.tool-card-text h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-card-text p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ----- Tool Page Layout ----- */
.tool-page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px;
}

.tool-page.with-sidebar {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
}

.tool-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.tool-header p {
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* ----- Tool Workspace ----- */
.tool-workspace {
  background-color: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  transition: background-color 0.25s ease;
}

.tool-input-label,
.tool-output-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 6px;
}

.tool-workspace textarea,
.tool-workspace input[type="text"],
.tool-workspace input[type="number"],
.tool-workspace input[type="url"],
.tool-workspace input[type="email"],
.tool-workspace input[type="search"],
.tool-workspace select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tool-workspace textarea:focus,
.tool-workspace input:focus,
.tool-workspace select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.tool-workspace textarea {
  min-height: 120px;
  resize: vertical;
  font-family: inherit;
}

.tool-workspace textarea::placeholder,
.tool-workspace input::placeholder {
  color: var(--text-secondary);
}

.tool-actions {
  display: flex;
  gap: 8px;
  margin: 12px 0;
  flex-wrap: wrap;
}

/* ----- Buttons ----- */
.btn {
  padding: 8px 18px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

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

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

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

.btn-secondary:hover {
  background-color: var(--bg-card-hover);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ----- Tool Output ----- */
.tool-output {
  min-height: 80px;
  padding: 12px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 8px;
  transition: background-color 0.25s ease;
}

/* ----- SEO Section ----- */
.seo-section {
  max-width: var(--max-width);
  margin: 32px auto;
  padding: 0 16px;
}

.seo-section h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 8px;
}

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

/* ----- Related Tools ----- */
.related-tools {
  max-width: var(--max-width);
  margin: 32px auto;
  padding: 0 16px;
}

.related-tools h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 12px;
}

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

.related-card {
  background-color: var(--bg-card);
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: box-shadow 0.2s ease, background-color 0.25s ease;
  text-decoration: none;
  color: var(--text-primary);
}

.related-card:hover {
  box-shadow: var(--shadow-hover);
  background-color: var(--bg-card-hover);
  text-decoration: none;
}

.related-card h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 2px;
  color: var(--text-primary);
}

.related-card p {
  font-size: 0.75rem;
  color: var(--text-secondary);
}



/* ----- General Page (about / contact / privacy / terms) ----- */
.general-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 32px 16px;
}

.general-page h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.general-page h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 24px 0 8px;
}

.general-page p {
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 12px;
}

.general-page ul {
  list-style: disc;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 12px;
  padding-left: 24px;
}

.general-page ol {
  list-style: decimal;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 12px;
  padding-left: 24px;
}

.general-page li {
  margin-bottom: 4px;
}

/* ----- Footer ----- */
.site-footer {
  background-color: var(--bg-card);
  border-top: 1px solid var(--border);
  margin-top: 48px;
  padding: 40px 16px 24px;
  transition: background-color 0.25s ease;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

.footer-col h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.footer-col ul {
  list-style: none;
}

.footer-col li {
  margin-bottom: 4px;
}

.footer-col a {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
}

.footer-col a:hover {
  color: var(--accent);
}

.footer-bottom {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding-top: 24px;
  margin-top: 24px;
  border-top: 1px solid var(--border);
}

/* ----- Category Page ----- */
.category-page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px;
}

.category-page h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.cat-desc {
  color: var(--text-secondary);
  margin-bottom: 20px;
}

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

/* Tablet / small desktop */
@media (max-width: 1023px) {
  .tool-page.with-sidebar {
    grid-template-columns: 1fr;
  }
}

/* Mobile */
@media (max-width: 767px) {
  .cat-grid,
  .tool-grid,
  .related-grid {
    grid-template-columns: 1fr;
  }

  .footer-inner {
    grid-template-columns: repeat(2, 1fr);
  }

  .hero h1 {
    font-size: 1.6rem;
  }

  .header-search {
    display: block;
    max-width: 100%;
  }
}

/* Small mobile */
@media (max-width: 480px) {
  .footer-inner {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
