/* ========================================
   ToolsIfy - Free Online Tools
   Clean, Professional, AdSense-Optimized
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap');

/* --- CSS Variables --- */
:root {
  --brand: #0A7558;
  --brand-light: #0D9B74;
  --brand-dark: #065C45;
  --brand-bg: #F0FAF6;
  --accent: #E8683A;
  --accent-light: #FFF0EB;
  --text-primary: #1A2332;
  --text-secondary: #4A5568;
  --text-muted: #8896A6;
  --bg-primary: #FFFFFF;
  --bg-secondary: #F7F9FC;
  --bg-card: #FFFFFF;
  --border: #E2E8F0;
  --border-light: #EDF2F7;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --font-heading: 'DM Sans', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --max-width: 1200px;
  --header-height: 70px;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-secondary);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--brand); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--brand-dark); }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

h1 { font-size: 2.2rem; }
h2 { font-size: 1.7rem; }
h3 { font-size: 1.3rem; }
p { margin-bottom: 1rem; color: var(--text-secondary); }

/* --- Container --- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* --- Header / Navigation --- */
.site-header {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--header-height);
  display: flex;
  align-items: center;
}

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

.site-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--text-primary);
}

.site-logo .logo-icon {
  width: 36px;
  height: 36px;
  background: var(--brand);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
}

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

.main-nav { display: flex; align-items: center; gap: 8px; }

.main-nav a {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s;
}

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

.mobile-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--text-primary);
}

.mobile-toggle svg { width: 24px; height: 24px; }

/* --- Hero Section --- */
.hero {
  background: linear-gradient(135deg, var(--brand-bg) 0%, #FFFFFF 100%);
  padding: 60px 0 50px;
  text-align: center;
  border-bottom: 1px solid var(--border-light);
}

.hero h1 {
  font-size: 2.6rem;
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

.hero h1 .accent { color: var(--brand); }

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

.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: var(--radius-lg);
  font-size: 1rem;
  font-family: var(--font-body);
  background: var(--bg-primary);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.hero-search input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(10,117,88,0.1);
}

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

/* --- Tool Categories --- */
.categories-section {
  padding: 50px 0;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.section-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
}

.category-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--brand-bg);
  color: var(--brand);
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 100px;
}

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

.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 24px;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.tool-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--brand);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

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

.tool-card:hover::before { transform: scaleX(1); }

.tool-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.tool-card-icon.img    { background: #DBEAFE; color: #2563EB; }
.tool-card-icon.text   { background: #FEF3C7; color: #D97706; }
.tool-card-icon.web    { background: #D1FAE5; color: #059669; }
.tool-card-icon.calc   { background: #EDE9FE; color: #7C3AED; }
.tool-card-icon.code   { background: #FFE4E6; color: #E11D48; }

.tool-card h3 {
  font-size: 1.05rem;
  font-weight: 600;
}

.tool-card p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
  flex-grow: 1;
}

.tool-card .card-arrow {
  color: var(--brand);
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  opacity: 0;
  transform: translateX(-8px);
  transition: all 0.25s;
}

.tool-card:hover .card-arrow {
  opacity: 1;
  transform: translateX(0);
}

/* --- Tool Page Layout --- */
.tool-page {
  padding: 40px 0 60px;
}

.tool-page-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 40px;
  align-items: start;
}

.tool-main {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 36px;
}

.tool-main h1 {
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.tool-main .tool-tagline {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-light);
}

/* --- Tool UI Components --- */
.tool-workspace { margin-bottom: 24px; }

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s;
  background: var(--bg-secondary);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--brand);
  background: var(--brand-bg);
}

.upload-zone .upload-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  color: var(--text-muted);
}

.upload-zone p {
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.upload-zone .upload-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.tool-input-group {
  margin-bottom: 20px;
}

.tool-input-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.tool-input-group input,
.tool-input-group select,
.tool-input-group textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
  background: var(--bg-primary);
  transition: border-color 0.2s;
  outline: none;
}

.tool-input-group textarea {
  min-height: 140px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.6;
}

.tool-input-group input:focus,
.tool-input-group select:focus,
.tool-input-group textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(10,117,88,0.08);
}

.tool-options {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.tool-option-btn {
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.tool-option-btn:hover { border-color: var(--brand); color: var(--brand); }
.tool-option-btn.active {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: var(--brand);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover { background: var(--brand-dark); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 20px;
}

/* --- Output Area --- */
.tool-output {
  margin-top: 24px;
  padding: 24px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  display: none;
}

.tool-output.visible { display: block; }

.tool-output h3 {
  font-size: 1rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-output pre {
  background: var(--text-primary);
  color: #E2E8F0;
  padding: 18px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
}

.tool-output .output-text {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  padding: 14px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  word-break: break-all;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--brand-bg);
  color: var(--brand);
  border: 1px solid var(--brand);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-body);
}

.copy-btn:hover { background: var(--brand); color: white; }

/* --- Sidebar --- */
.tool-sidebar { display: flex; flex-direction: column; gap: 24px; }

.sidebar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 24px;
}

.sidebar-card h3 {
  font-size: 1rem;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-card ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-card li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: all 0.2s;
}

.sidebar-card li a:hover {
  background: var(--brand-bg);
  color: var(--brand);
}

/* --- Article / SEO Content --- */
.tool-article {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 36px;
  margin-top: 32px;
}

.tool-article h2 {
  font-size: 1.4rem;
  margin-bottom: 16px;
  margin-top: 32px;
}

.tool-article h2:first-child { margin-top: 0; }

.tool-article h3 {
  font-size: 1.1rem;
  margin-bottom: 10px;
  margin-top: 24px;
}

.tool-article p {
  font-size: 0.95rem;
  line-height: 1.8;
  margin-bottom: 14px;
}

.tool-article ul, .tool-article ol {
  margin: 12px 0 18px 24px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.8;
}

.tool-article li { margin-bottom: 6px; }

.faq-section { margin-top: 32px; }

.faq-item {
  border-bottom: 1px solid var(--border-light);
  padding: 16px 0;
}

.faq-item:last-child { border-bottom: none; }

.faq-q {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-a {
  padding-top: 10px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.7;
  display: none;
}

.faq-item.open .faq-a { display: block; }

/* --- Info/Legal Pages --- */
.page-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 50px 0 70px;
}

.page-content h1 {
  font-size: 2rem;
  margin-bottom: 8px;
}

.page-content .page-updated {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-light);
}

.page-content h2 {
  font-size: 1.3rem;
  margin-top: 32px;
  margin-bottom: 12px;
}

.page-content p {
  font-size: 0.95rem;
  line-height: 1.8;
}

.page-content ul {
  margin: 10px 0 18px 24px;
  color: var(--text-secondary);
  line-height: 1.8;
}

.page-content a { text-decoration: underline; }

/* --- Breadcrumbs --- */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

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

/* --- Footer --- */
.site-footer {
  background: var(--text-primary);
  color: #CBD5E1;
  padding: 50px 0 30px;
  margin-top: auto;
}

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

.footer-brand p {
  color: #8896A6;
  font-size: 0.88rem;
  line-height: 1.7;
  margin-top: 12px;
}

.footer-col h4 {
  color: white;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

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

.footer-col a {
  color: #8896A6;
  font-size: 0.88rem;
  transition: color 0.2s;
}

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

.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: #64748B;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  .tool-page-grid {
    grid-template-columns: 1fr;
  }
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .hero h1 { font-size: 1.8rem; }
  .hero { padding: 40px 0 36px; }
  .tools-grid { grid-template-columns: 1fr; }

  .main-nav {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    flex-direction: column;
    padding: 24px;
    border-top: 1px solid var(--border);
    z-index: 999;
  }

  .main-nav.open { display: flex; }
  .mobile-toggle { display: block; }

  .footer-grid { grid-template-columns: 1fr; gap: 28px; }
  .footer-bottom { flex-direction: column; gap: 10px; text-align: center; }
  .tool-main { padding: 24px; }
  .tool-article { padding: 24px; }

  .page-content { padding: 30px 0 50px; }
}

/* --- Utility --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

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

/* --- Ad Placeholder (for AdSense slots) --- */
.ad-slot {
  background: var(--bg-secondary);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Color Picker Specific --- */
.color-display {
  width: 100%;
  height: 120px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.color-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.color-value-item {
  padding: 10px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* --- Password Strength --- */
.strength-bar {
  height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  margin-top: 8px;
  overflow: hidden;
}

.strength-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s, background 0.3s;
}

/* --- Preview Image --- */
.preview-container {
  margin: 16px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: repeating-conic-gradient(#f0f0f0 0% 25%, transparent 0% 50%) 50% / 20px 20px;
}

.preview-container img {
  max-width: 100%;
  max-height: 400px;
  object-fit: contain;
  margin: 0 auto;
}

/* --- Contact Form --- */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; }
}

.form-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--brand);
}

.form-group textarea {
  min-height: 140px;
  resize: vertical;
}

/* --- Animations --- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.tool-card {
  animation: fadeInUp 0.4s ease forwards;
  opacity: 0;
}

.tool-card:nth-child(1) { animation-delay: 0.05s; }
.tool-card:nth-child(2) { animation-delay: 0.1s; }
.tool-card:nth-child(3) { animation-delay: 0.15s; }
.tool-card:nth-child(4) { animation-delay: 0.2s; }
.tool-card:nth-child(5) { animation-delay: 0.25s; }
.tool-card:nth-child(6) { animation-delay: 0.3s; }
.tool-card:nth-child(7) { animation-delay: 0.35s; }
.tool-card:nth-child(8) { animation-delay: 0.4s; }
