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

:root {
  --blue: #2563eb;
  --blue-light: #dbeafe;
  --blue-dark: #1d4ed8;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --yellow: #d97706;
  --yellow-bg: #fef3c7;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --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;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);
  --radius: 10px;
  --radius-sm: 6px;
  --header-h: 64px;
  --sidebar-w: 240px;
  --transition: .2s ease;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

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

/* ========== HEADER ========== */
.header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

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

.header-left { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none; border: none; cursor: pointer; padding: 4px;
}
.menu-toggle span { display: block; width: 20px; height: 2px; background: var(--gray-700); border-radius: 1px; transition: var(--transition); }

.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--gray-900); font-weight: 700; font-size: 1.15rem; }
.logo:hover { text-decoration: none; }
.logo-icon { font-size: 1.5rem; }

.header-center { flex: 1; max-width: 520px; }

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

.search-icon {
  position: absolute; left: 12px;
  width: 18px; height: 18px;
  color: var(--gray-400);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 9px 36px 9px 40px;
  border: 1.5px solid var(--gray-200);
  border-radius: 999px;
  font-size: .9rem;
  background: var(--gray-50);
  outline: none;
  transition: var(--transition);
  font-family: inherit;
}
.search-input:focus { border-color: var(--blue); background: #fff; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.search-input::placeholder { color: var(--gray-400); }

.search-clear {
  position: absolute; right: 8px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: none; border: none;
  font-size: 1.1rem;
  color: var(--gray-400);
  cursor: pointer;
  display: none;
  align-items: center; justify-content: center;
}
.search-clear.visible { display: flex; }
.search-clear:hover { color: var(--gray-600); }

.header-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.sort-select {
  padding: 8px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: .85rem;
  background: #fff;
  cursor: pointer;
  outline: none;
  font-family: inherit;
  color: var(--gray-700);
}
.sort-select:focus { border-color: var(--blue); }

.lang-toggle {
  padding: 7px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  color: var(--gray-700);
  transition: var(--transition);
  font-family: inherit;
}
.lang-toggle:hover { border-color: var(--blue); color: var(--blue); }

/* ========== LAYOUT ========== */
.layout {
  display: flex;
  margin-top: var(--header-h);
  min-height: calc(100vh - var(--header-h));
}

/* ========== SIDEBAR ========== */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  border-right: 1px solid var(--gray-200);
  background: #fff;
  padding: 24px 16px;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
}

.sidebar-section { margin-bottom: 28px; }
.sidebar-title {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-400);
  margin-bottom: 10px;
  padding: 0 12px;
}

.category-list, .pricing-list { list-style: none; }

.category-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: .9rem;
  color: var(--gray-600);
}
.category-item:hover { background: var(--gray-100); color: var(--gray-900); }
.category-item.active { background: var(--blue-light); color: var(--blue); font-weight: 600; }

.category-item .cat-emoji { font-size: 1.1rem; }
.category-item .cat-name { flex: 1; }
.category-item .count {
  font-size: .75rem;
  background: var(--gray-100);
  padding: 1px 7px;
  border-radius: 999px;
  color: var(--gray-500);
  font-weight: 500;
}
.category-item.active .count { background: rgba(37,99,235,.15); color: var(--blue); }

.pricing-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: .9rem;
  color: var(--gray-600);
}
.pricing-item:hover { background: var(--gray-100); }
.pricing-item.active { background: var(--gray-100); color: var(--gray-900); font-weight: 600; }

.pricing-badge {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.pricing-badge.free { background: var(--green); }
.pricing-badge.freemium { background: var(--yellow); }
.pricing-badge.paid { background: var(--red); }

.pricing-item .count {
  margin-left: auto;
  font-size: .75rem;
  background: var(--gray-100);
  padding: 1px 7px;
  border-radius: 999px;
  color: var(--gray-500);
}

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 89;
}

/* ========== MAIN ========== */
.main {
  flex: 1;
  padding: 20px 24px 40px;
  min-width: 0;
}

/* Category pills */
.category-pills-wrapper {
  margin-bottom: 16px;
  overflow: hidden;
}

.category-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}
.category-pills::-webkit-scrollbar { display: none; }

.category-pill {
  flex-shrink: 0;
  padding: 6px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--gray-200);
  background: #fff;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 500;
  color: var(--gray-600);
  transition: var(--transition);
  white-space: nowrap;
  font-family: inherit;
}
.category-pill:hover { border-color: var(--blue); color: var(--blue); }
.category-pill.active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* Results info */
.results-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.results-count { font-size: .85rem; color: var(--gray-500); }

/* ========== TOOL CARDS ========== */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.tool-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  display: flex;
  flex-direction: column;
}
.tool-card:hover {
  border-color: var(--blue);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.tool-card-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }

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

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

.tool-name {
  font-size: .95rem;
  font-weight: 600;
  color: var(--gray-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-desc {
  font-size: .82rem;
  color: var(--gray-500);
  margin-top: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.tool-tags {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.tool-tag {
  font-size: .72rem;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 500;
}
.tool-tag.category { background: var(--blue-light); color: var(--blue); }
.tool-tag.pricing-free { background: var(--green-bg); color: var(--green); }
.tool-tag.pricing-freemium { background: var(--yellow-bg); color: var(--yellow); }
.tool-tag.pricing-paid { background: var(--red-bg); color: var(--red); }

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
}
.empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state h3 { font-size: 1.1rem; color: var(--gray-600); margin-bottom: 4px; }
.empty-state p { font-size: .9rem; }

/* ========== MODAL ========== */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: #fff;
  border-radius: 14px;
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,.25);
  animation: modalIn .25s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-close {
  position: absolute; top: 16px; right: 16px;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--gray-100);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-600);
  transition: var(--transition);
  z-index: 1;
}
.modal-close:hover { background: var(--gray-200); }

.modal-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 28px 28px 0;
}

.modal-icon {
  width: 56px; height: 56px;
  border-radius: var(--radius);
  background: var(--gray-100);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  flex-shrink: 0;
}

.modal-title-area { flex: 1; }
.modal-title { font-size: 1.25rem; font-weight: 700; color: var(--gray-900); }
.modal-tags { display: flex; gap: 8px; margin-top: 6px; }
.modal-category {
  font-size: .78rem; padding: 2px 10px; border-radius: 999px;
  background: var(--blue-light); color: var(--blue); font-weight: 500;
}
.modal-pricing {
  font-size: .78rem; padding: 2px 10px; border-radius: 999px; font-weight: 500;
}
.modal-pricing.free { background: var(--green-bg); color: var(--green); }
.modal-pricing.freemium { background: var(--yellow-bg); color: var(--yellow); }
.modal-pricing.paid { background: var(--red-bg); color: var(--red); }

.modal-body { padding: 20px 28px; }
.modal-description { font-size: .92rem; color: var(--gray-600); line-height: 1.7; }

.modal-features { margin-top: 20px; }
.modal-features h4 { font-size: .9rem; font-weight: 600; color: var(--gray-800); margin-bottom: 8px; }
.modal-features ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.modal-features li {
  font-size: .85rem; color: var(--gray-600);
  padding-left: 20px; position: relative;
}
.modal-features li::before {
  content: '✓';
  position: absolute; left: 0;
  color: var(--green); font-weight: 700;
}

.modal-footer { padding: 0 28px 24px; }
.modal-visit-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 24px;
  background: var(--blue);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: .9rem;
  transition: var(--transition);
}
.modal-visit-btn:hover { background: var(--blue-dark); text-decoration: none; }

/* ========== FOOTER ========== */
.footer {
  border-top: 1px solid var(--gray-200);
  background: #fff;
  padding: 20px;
}
.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .82rem;
  color: var(--gray-500);
}
.footer-link { color: var(--gray-500); }
.footer-link:hover { color: var(--blue); }

/* ========== ANIMATIONS ========== */
.tool-card { animation: fadeInUp .35s ease both; }
.tool-card:nth-child(1) { animation-delay: 0s; }
.tool-card:nth-child(2) { animation-delay: .03s; }
.tool-card:nth-child(3) { animation-delay: .06s; }
.tool-card:nth-child(4) { animation-delay: .09s; }
.tool-card:nth-child(5) { animation-delay: .12s; }
.tool-card:nth-child(6) { animation-delay: .15s; }
.tool-card:nth-child(7) { animation-delay: .18s; }
.tool-card:nth-child(8) { animation-delay: .21s; }
.tool-card:nth-child(9) { animation-delay: .24s; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1100px) {
  .tools-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .menu-toggle { display: flex; }

  .sidebar {
    position: fixed;
    left: -100%;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    z-index: 90;
    transition: left .3s ease;
    box-shadow: none;
  }
  .sidebar.open {
    left: 0;
    box-shadow: var(--shadow-lg);
  }
  .sidebar-overlay.open { display: block; }

  .header-center { order: 3; max-width: none; }

  .header-inner { flex-wrap: wrap; gap: 8px; }
  .header-right { margin-left: auto; }

  .search-input { font-size: .85rem; }

  .tools-grid { grid-template-columns: 1fr; gap: 12px; }
  .main { padding: 16px 14px 30px; }

  .sort-select { font-size: .8rem; padding: 6px 8px; }
  .lang-toggle { padding: 6px 10px; font-size: .8rem; }

  .modal { border-radius: 12px; }
  .modal-header { padding: 20px 20px 0; }
  .modal-body { padding: 16px 20px; }
  .modal-footer { padding: 0 20px 20px; }
}

@media (max-width: 480px) {
  .header-inner { padding: 0 12px; }
  .logo-text { display: none; }
  .tools-grid { grid-template-columns: 1fr; }
}

/* ========== TOOL DETAIL PAGE ========== */
.tool-detail {
  max-width: 720px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}
.tool-detail-back {
  margin-bottom: 1rem;
}
.tool-detail-back a {
  color: var(--blue);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}
.tool-detail-back a:hover {
  text-decoration: underline;
}
.tool-detail-card {
  background: var(--gray-50);
  border-radius: 16px;
  padding: 2rem;
  border: 1px solid var(--gray-200);
}
.tool-detail-header {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
.tool-detail-icon {
  font-size: 3rem;
  line-height: 1;
}
.tool-detail-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 0.5rem;
}
.tool-detail-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.modal-category {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--blue-light);
  color: var(--blue);
}
.modal-pricing {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
}
.tool-detail-desc {
  color: var(--gray-600);
  font-size: 1.05rem;
  line-height: 1.7;
  margin-bottom: 1.5rem;
}
.tool-detail-features {
  margin-bottom: 2rem;
}
.tool-detail-features h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--gray-800);
}
.tool-detail-features ul {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.5rem;
}
.tool-detail-features li {
  padding: 0.5rem 0.75rem;
  background: white;
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}
.tool-detail-features li::before {
  content: "✓ ";
  color: var(--green);
  font-weight: 700;
}
.modal-visit-btn {
  display: inline-block;
  padding: 0.75rem 2rem;
  background: var(--blue);
  color: white;
  text-decoration: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 1rem;
  transition: background 0.2s;
}
.modal-visit-btn:hover {
  background: var(--blue-dark);
}

@media (max-width: 640px) {
  .tool-detail { padding: 0 1rem; margin: 1rem auto; }
  .tool-detail-card { padding: 1.25rem; }
  .tool-detail-header h1 { font-size: 1.3rem; }
  .tool-detail-features ul { grid-template-columns: 1fr; }
}
