/**
 * CodLeads Tools — Custom CSS
 * assets/css/custom.css
 *
 * Supplements TailwindCSS with brand-specific tokens and
 * component styles that Tailwind's CDN doesn't cover natively.
 */

/* ─── CSS Custom Properties ──────────────────────────────────────────────── */
:root {
  --primary:       #1e3a68;
  --primary-light: #2a52a0;
  --accent:        #3b82f6;
  --bg:            #f8fafc;
  --surface:       #ffffff;
  --border:        #e2e8f0;
  --text:          #0f172a;
  --muted:         #64748b;
  --radius:        0.75rem;
  --shadow-sm:     0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md:     0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg:     0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* ─── Base ───────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
}

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

body {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Typography ─────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
}

/* ─── Focus styles (accessibility) ──────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ─── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track  { background: #f1f5f9; }
::-webkit-scrollbar-thumb  { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ─── Ad Slots ───────────────────────────────────────────────────────────── */
.ad-slot {
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ad-slot:empty::after {
  content: '[ Advertisement ]';
  color: #cbd5e1;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ─── Tool Box (shared tool interface container) ─────────────────────────── */
.tool-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

/* ─── Inputs ─────────────────────────────────────────────────────────────── */
.tool-input,
.tool-textarea {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  resize: vertical;
}
.tool-input:focus,
.tool-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.15);
}
.tool-textarea {
  min-height: 140px;
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: 0.875rem;
  line-height: 1.6;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover  { background: var(--primary-light); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-secondary:hover { background: #f8fafc; border-color: #94a3b8; }

.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #f0fdf4;
  color: #059669;
  border: 1px solid #bbf7d0;
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-copy:hover   { background: #dcfce7; }
.btn-copy.copied  { background: #059669; color: #fff; border-color: #059669; }

/* ─── Output area ────────────────────────────────────────────────────────── */
.tool-output {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: 0.875rem;
  line-height: 1.7;
  min-height: 100px;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-x: auto;
}
.tool-output:empty::before {
  content: 'Output will appear here…';
  color: #64748b;
  font-style: italic;
}

/* ─── Character counter ──────────────────────────────────────────────────── */
.char-counter {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: right;
  margin-top: 0.25rem;
}
.char-counter.warn  { color: #f59e0b; }
.char-counter.error { color: #ef4444; font-weight: 600; }

/* ─── Breadcrumb ─────────────────────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  font-size: 0.8125rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { color: #cbd5e1; }
.breadcrumb .current { color: var(--text); font-weight: 500; }

/* ─── Tool hero section ──────────────────────────────────────────────────── */
.tool-hero {
  background: linear-gradient(135deg, var(--primary) 0%, #2a52a0 100%);
  color: #fff;
  padding: 3rem 1.5rem;
  border-radius: 1rem;
  margin-bottom: 2rem;
}
.tool-description {
  font-size: 1.0625rem;
  color: var(--muted);
  margin-top: 0.5rem;
  line-height: 1.7;
}

/* ─── FAQ Accordion ──────────────────────────────────────────────────────── */
.faq details {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  margin-bottom: 0.75rem;
  overflow: hidden;
}
.faq details summary {
  padding: 1rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  transition: background 0.15s;
}
.faq details summary::-webkit-details-marker { display: none; }
.faq details summary::after {
  content: '+';
  font-size: 1.25rem;
  color: var(--primary);
  font-weight: 300;
  transition: transform 0.2s;
}
.faq details[open] summary {
  background: #f8fafc;
}
.faq details[open] summary::after {
  content: '−';
}
.faq details > p,
.faq details > div {
  padding: 0.875rem 1.25rem 1.25rem;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.7;
  border-top: 1px solid var(--border);
}

/* ─── Strength meter ─────────────────────────────────────────────────────── */
.strength-bar {
  height: 6px;
  border-radius: 99px;
  background: #e2e8f0;
  overflow: hidden;
  margin-top: 0.5rem;
}
.strength-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.3s ease, background 0.3s ease;
}
.strength-fill.weak   { background: #ef4444; }
.strength-fill.fair   { background: #f59e0b; }
.strength-fill.good   { background: #3b82f6; }
.strength-fill.strong { background: #10b981; }

/* ─── Tabs ───────────────────────────────────────────────────────────────── */
.tab-list {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.25rem;
}
.tab-btn {
  padding: 0.625rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.tab-btn:hover   { color: var(--primary); }
.tab-btn.active  { color: var(--primary); border-bottom-color: var(--primary); }

/* ─── Stats cards (word counter, etc.) ──────────────────────────────────── */
.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem;
  text-align: center;
}
.stat-card .stat-value {
  font-size: 1.875rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}
.stat-card .stat-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── Color swatch ───────────────────────────────────────────────────────── */
.color-swatch {
  width: 3rem;
  height: 3rem;
  border-radius: 0.5rem;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: transform 0.15s;
}
.color-swatch:hover { transform: scale(1.1); }

/* ─── Range slider ───────────────────────────────────────────────────────── */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: 99px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: background 0.15s;
}
input[type="range"]::-webkit-slider-thumb:hover { background: var(--primary-light); }

/* ─── Density bar ────────────────────────────────────────────────────────── */
.density-bar {
  height: 8px;
  border-radius: 99px;
  background: var(--accent);
  max-width: 100%;
  transition: width 0.3s ease;
}

/* ─── Toast notification ─────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 5rem;
  right: 1.5rem;
  background: #1e293b;
  color: #fff;
  border-radius: 0.625rem;
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  opacity: 0;
  transform: translateY(0.5rem);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ─── Responsive article content ─────────────────────────────────────────── */
.content-article h2 {
  font-size: 1.375rem;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}
.content-article h3 {
  font-size: 1.125rem;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}
.content-article p  { margin-bottom: 1rem; color: #334155; }
.content-article ul,
.content-article ol { margin: 1rem 0 1rem 1.5rem; color: #334155; }
.content-article li { margin-bottom: 0.375rem; }
.content-article a  { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

/* ─── Responsive utilities ───────────────────────────────────────────────── */
@media (max-width: 640px) {
  .tool-hero { padding: 2rem 1rem; }
  .tool-box  { padding: 1rem; }
}

/* ─── Print ──────────────────────────────────────────────────────────────── */
@media print {
  header, footer, .ad-slot, #back-to-top { display: none !important; }
  body { background: #fff; }
}
