/* =====================================================
   Magic Tool — Main Stylesheet
   ===================================================== */

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

:root {
  --primary: #6C63FF;
  --primary-dark: #4f46e5;
  --primary-light: #ede9fe;
  --accent: #f59e0b;
  --bg: #f8faff;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07);
  --shadow: 0 4px 16px rgba(108,99,255,.10);
  --shadow-hover: 0 8px 30px rgba(108,99,255,.18);
  --radius: 14px;
  --radius-sm: 8px;
  --transition: 0.22s ease;
  --header-h: 64px;
  --font: 'Inter', system-ui, sans-serif;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { text-decoration: none; color: inherit; }
img { display: block; max-width: 100%; }

/* === Container === */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* =====================================================
   HEADER
   ===================================================== */
.site-header {
  position: relative;
  z-index: 100;
  background: rgba(255,255,255,.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
}

.header-inner {
  display: flex;
  align-items: center;
  height: var(--header-h);
  gap: 12px;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  text-decoration: none;
}

.logo-icon {
  font-size: 1.6rem;
  filter: drop-shadow(0 0 6px rgba(108,99,255,.35));
  animation: sparkle 3s ease-in-out infinite;
}

@keyframes sparkle {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(108,99,255,.35)); }
  50% { filter: drop-shadow(0 0 12px rgba(108,99,255,.7)); }
}

.logo-text {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -.5px;
  color: var(--text);
  line-height: 1;
}

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

/* Desktop Nav */
.nav-desktop {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}

.nav-link {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}

.nav-link:hover {
  background: var(--primary-light);
  color: var(--primary);
}

/* Header Right */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

.search-toggle, .hamburger {
  border: none;
  background: none;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 1rem;
  transition: background var(--transition), color var(--transition);
  line-height: 1;
}

.search-toggle:hover, .hamburger:hover {
  background: var(--primary-light);
  color: var(--primary);
}

/* Hamburger Icon */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  width: 36px;
  height: 36px;
  justify-content: center;
  align-items: center;
  order: 99;
}

.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform var(--transition), opacity var(--transition);
}

.hamburger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Search Bar */
.search-bar-wrap {
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 12px 0;
  display: none;
}

.search-bar-wrap.open { display: block; animation: slideDown .2s ease; }

/* Search toggle button — hidden on mobile/tablet (search always visible there) */
@media (max-width: 900px) {
  .search-toggle { display: none; }
  .search-bar-wrap {
    display: block !important;
    border-top: none;
    padding: 8px 0 10px;
    background: #f8faff;
  }
  .search-bar-wrap .search-input {
    font-size: .9rem;
    padding: 10px 40px 10px 38px;
  }
  .search-bar-wrap .search-results {
    grid-template-columns: 1fr;
  }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  font-size: .9rem;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 12px 44px 12px 40px;
  border: 2px solid var(--border);
  border-radius: 40px;
  font-size: .95rem;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(108,99,255,.12);
}

.search-clear {
  position: absolute;
  right: 14px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  display: none;
  font-size: .85rem;
  padding: 4px;
}

.search-clear.visible { display: block; }

/* Search Results */
.search-results {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  text-decoration: none;
  color: inherit;
}

.search-result-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.search-result-icon { font-size: 1.4rem; flex-shrink: 0; }

.search-result-name {
  font-weight: 600;
  font-size: .9rem;
  color: var(--text);
}

.search-result-desc {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.search-no-result {
  text-align: center;
  color: var(--text-muted);
  padding: 20px 0;
  font-size: .9rem;
  grid-column: 1 / -1;
}

/* Mobile Nav */
.nav-mobile {
  display: none;
  flex-direction: column;
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 8px 0 16px;
}

.nav-mobile.open { display: flex; }

.nav-mobile .nav-link {
  padding: 11px 20px;
  font-size: .95rem;
  border-radius: 0;
  border-left: 3px solid transparent;
}

.nav-mobile .nav-link:hover {
  background: var(--primary-light);
  border-left-color: var(--primary);
}

/* =====================================================
   HERO
   ===================================================== */
.hero {
  background: linear-gradient(135deg, #6C63FF 0%, #4f46e5 60%, #7c3aed 100%);
  padding: 64px 0 0;
  text-align: center;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -60px; left: -60px;
  width: 300px; height: 300px;
  background: rgba(255,255,255,.06);
  border-radius: 50%;
}

.hero::after {
  content: '';
  position: absolute;
  bottom: 30px; right: -80px;
  width: 250px; height: 250px;
  background: rgba(255,255,255,.05);
  border-radius: 50%;
}

.hero-inner { position: relative; z-index: 1; padding-bottom: 48px; }

.hero-title {
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 14px;
}

.gradient-text {
  background: linear-gradient(135deg, #fbbf24, #f59e0b, #fff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  font-size: 1.1rem;
  opacity: .88;
  margin-bottom: 28px;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat strong {
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1;
}

.stat span {
  font-size: .78rem;
  opacity: .8;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.hero-wave { line-height: 0; margin-top: 20px; }
.hero-wave svg { width: 100%; height: 50px; display: block; }

/* =====================================================
   MAIN CONTENT
   ===================================================== */
.main-content {
  flex: 1;
  padding: 40px 0 60px;
}

/* Filter Bar */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 40px;
}

.filter-btn {
  padding: 7px 16px;
  border: 2px solid var(--border);
  border-radius: 40px;
  background: var(--bg-card);
  cursor: pointer;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  font-family: var(--font);
  transition: all var(--transition);
  white-space: nowrap;
}

.filter-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Tool Sections */
.tool-section {
  margin-bottom: 52px;
  transition: opacity var(--transition);
}

.tool-section.hidden { display: none; }

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}

.section-icon { font-size: 1.4rem; }

/* Tool Grid */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

/* Tool Card */
.tool-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  overflow: hidden;
}

.tool-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #7c3aed);
  transform: scaleX(0);
  transition: transform var(--transition);
  transform-origin: left;
}

.tool-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: rgba(108,99,255,.25);
}

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

.tool-icon {
  font-size: 1.8rem;
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  border-radius: 10px;
  line-height: 1;
}

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

.tool-info h3 {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.3;
}

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

.tool-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: linear-gradient(135deg, var(--accent), #f97316);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 40px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* =====================================================
   FOOTER
   ===================================================== */
.site-footer {
  background: #111827;
  color: #9ca3af;
}

.footer-inner {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 40px;
  padding: 48px 20px;
}

.footer-brand .logo { margin-bottom: 12px; }

.footer-brand .logo-text,
.footer-brand .logo-accent { color: #fff; }

.footer-brand .logo-accent { color: var(--primary); }

.footer-brand p {
  font-size: .85rem;
  line-height: 1.7;
  color: #6b7280;
}

.footer-links h4 {
  font-size: .85rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: .07em;
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.footer-links a {
  font-size: .85rem;
  color: #6b7280;
  padding: 4px 0;
  transition: color var(--transition);
}

.footer-links a:hover { color: var(--primary); }

.footer-bottom {
  text-align: center;
  border-top: 1px solid #1f2937;
  padding: 16px 20px;
  font-size: .8rem;
  color: #4b5563;
}

/* =====================================================
   BACK TO TOP
   ===================================================== */
.back-to-top {
  position: fixed;
  bottom: 28px;
  right: 24px;
  z-index: 900;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: .9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(108,99,255,.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition), transform var(--transition);
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}

.back-to-top:hover { transform: translateY(-3px); }

/* =====================================================
   TOOL PAGE (shared layout for all tools)
   ===================================================== */
.tool-page-header {
  background: linear-gradient(135deg, #6C63FF 0%, #4f46e5 100%);
  color: #fff;
  padding: 40px 0 36px;
}

.tool-page-header .breadcrumb {
  font-size: .82rem;
  opacity: .75;
  margin-bottom: 10px;
}

.tool-page-header .breadcrumb a { color: #fff; }
.tool-page-header .breadcrumb a:hover { opacity: .8; }

.tool-page-header h1 {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.tool-page-header p {
  opacity: .85;
  font-size: .95rem;
}

.tool-page-content {
  padding: 40px 0 60px;
}

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

.tool-box h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Input / Textarea shared */
.tool-input,
.tool-textarea,
.tool-select {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .9rem;
  color: var(--text);
  background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.tool-input:focus,
.tool-textarea:focus,
.tool-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108,99,255,.12);
}

.tool-textarea {
  resize: vertical;
  min-height: 140px;
  line-height: 1.6;
  font-size: .88rem;
}

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

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

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(108,99,255,.4);
  transform: translateY(-1px);
}

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

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

.btn-success {
  background: #10b981;
  color: #fff;
}

.btn-success:hover { background: #059669; }

.btn-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

/* Result area */
.result-box {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: .9rem;
  min-height: 48px;
  word-break: break-all;
  line-height: 1.6;
}

.result-box.code {
  font-family: 'Courier New', monospace;
  font-size: .85rem;
  white-space: pre-wrap;
}

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

.stat-pill {
  background: var(--primary-light);
  color: var(--primary);
  padding: 6px 14px;
  border-radius: 40px;
  font-size: .82rem;
  font-weight: 600;
}

/* Copy toast */
.copy-toast {
  position: fixed;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #10b981;
  color: #fff;
  padding: 10px 22px;
  border-radius: 40px;
  font-size: .88rem;
  font-weight: 600;
  z-index: 2000;
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
}

.copy-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 900px) {
  .nav-desktop { display: none; }
  .hamburger { display: flex; margin-left: 4px; }

  .footer-inner {
    grid-template-columns: 1fr 1fr;
  }

  .footer-brand {
    grid-column: 1 / -1;
  }
}

@media (max-width: 600px) {
  :root { --header-h: 56px; }

  .hero { padding: 44px 0 0; }
  .hero-title { font-size: 1.7rem; }
  .hero-sub { font-size: .95rem; }

  .filter-bar { gap: 6px; }
  .filter-btn { font-size: .75rem; padding: 5px 12px; }

  .tool-grid { grid-template-columns: 1fr; gap: 12px; }

  .footer-inner {
    grid-template-columns: 1fr;
    gap: 28px;
    padding: 36px 20px;
  }

  .tool-box { padding: 18px; }
  .btn-group { gap: 8px; }

  .search-results {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 400px) {
  .hero-stats { gap: 20px; }
  .stat strong { font-size: 1.4rem; }
}

/* =====================================================
   ANIMATIONS & UTILITIES
   ===================================================== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.tool-section {
  animation: fadeInUp .35s ease both;
}

.highlight {
  background: rgba(108,99,255,.15);
  border-radius: 3px;
  padding: 0 2px;
  color: var(--primary);
  font-weight: 600;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #c4cdd8; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* Focus outline for accessibility */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Smooth link underline for tool page breadcrumb */
.tool-page-header .breadcrumb span { opacity: .7; margin: 0 6px; }
