/* ===== Reset & Variables ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --kf-dark: #0d0a1a;
  --kf-purple: #6c4fb8;
  --kf-purple-light: #9b7fdb;
  --kf-purple-subtle: #f4f0ff;
  --kf-green: #28b905;
  --kf-text: #2d3047;
  --kf-text-muted: #6b7084;
  --kf-bg: #f8f9fc;
  --kf-white: #ffffff;
  --kf-border: #e2e4ec;
  --kf-card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
  --kf-card-shadow-hover: 0 4px 12px rgba(0,0,0,0.08), 0 8px 24px rgba(0,0,0,0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
  --sidebar-width: 260px;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--kf-text);
  background: var(--kf-bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--kf-purple); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--kf-purple-light); }

/* ===== Header ===== */
.site-header {
  background: linear-gradient(135deg, var(--kf-dark) 0%, #1a1040 40%, var(--kf-purple) 100%);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  position: sticky;
  top: 0;
  z-index: 200;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.75rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-logo img { display: block; }

.header-nav {
  display: flex;
  gap: 0.25rem;
}

.nav-link {
  padding: 0.5rem 1rem;
  color: rgba(255,255,255,0.7);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,0.1); }
.nav-link.active { color: #fff; background: rgba(255,255,255,0.15); }

/* ===== Page Layout ===== */
.page-layout {
  display: flex;
  min-height: calc(100vh - 60px);
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--kf-white);
  border-right: 1px solid var(--kf-border);
  padding: 1.5rem 0;
  position: sticky;
  top: 53px;
  height: calc(100vh - 53px);
  overflow-y: auto;
}

.sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--kf-purple);
  color: white;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(108,79,184,0.4);
  align-items: center;
  justify-content: center;
}

.sidebar-heading {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--kf-text-muted);
  padding: 0 1.5rem;
  margin-bottom: 0.75rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.5rem;
  font-size: 0.9rem;
  color: var(--kf-text);
  transition: all var(--transition);
}
.sidebar-link:hover {
  background: var(--kf-purple-subtle);
  color: var(--kf-purple);
}
.sidebar-link.active {
  background: var(--kf-purple-subtle);
  color: var(--kf-purple);
  font-weight: 600;
  border-right: 3px solid var(--kf-purple);
}

.sidebar-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--kf-text-muted);
  background: var(--kf-bg);
  padding: 0.1rem 0.5rem;
  border-radius: 10px;
}

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 2rem 3rem;
  max-width: 1100px;
}

/* ===== Catalog Index / Welcome ===== */
.catalog-hero {
  margin-bottom: 2.5rem;
}

.catalog-hero h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--kf-text);
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.catalog-hero p {
  color: var(--kf-text-muted);
  font-size: 1.05rem;
  max-width: 700px;
}

/* ===== Search ===== */
.catalog-search {
  position: relative;
  margin-bottom: 2rem;
}

.catalog-search svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--kf-text-muted);
}

.catalog-search input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.8rem;
  border: 1px solid var(--kf-border);
  border-radius: var(--radius);
  background: var(--kf-white);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--kf-text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.catalog-search input:focus {
  border-color: var(--kf-purple);
  box-shadow: 0 0 0 3px rgba(108,79,184,0.1);
}
.catalog-search input::placeholder { color: var(--kf-text-muted); }

/* ===== Category Page ===== */
.category-header {
  margin-bottom: 2rem;
}

.category-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--kf-text);
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.category-count {
  font-size: 0.9rem;
  color: var(--kf-text-muted);
}

/* ===== Integration Cards ===== */
.integration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.integration-card {
  background: var(--kf-white);
  border: 1px solid var(--kf-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  text-decoration: none;
  color: inherit;
}
.integration-card:hover {
  box-shadow: var(--kf-card-shadow-hover);
  transform: translateY(-2px);
  border-color: var(--kf-purple-light);
  color: inherit;
}

.integration-card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--kf-text);
  margin-bottom: 0.5rem;
}
.integration-card:hover h3 { color: var(--kf-purple); }

.integration-card p {
  font-size: 0.875rem;
  color: var(--kf-text-muted);
  line-height: 1.55;
  flex-grow: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.integration-card .card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--kf-border);
}

.type-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.2rem 0.6rem;
  border-radius: 10px;
  background: var(--kf-purple-subtle);
  color: var(--kf-purple);
}

.github-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--kf-text-muted);
  transition: color var(--transition);
}
.github-link:hover { color: var(--kf-text); }
.github-link svg { width: 16px; height: 16px; }

/* ===== Integration Detail ===== */
.integration-detail {
  max-width: 800px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--kf-text-muted);
  margin-bottom: 1.5rem;
  transition: color var(--transition), gap var(--transition);
}
.back-link:hover { color: var(--kf-purple); gap: 0.5rem; }

.integration-header {
  margin-bottom: 1.5rem;
}

.integration-header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--kf-text);
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.integration-description {
  font-size: 1.05rem;
  color: var(--kf-text-muted);
  line-height: 1.7;
  margin-bottom: 1.5rem;
}

.btn-github {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: #fff;
  background: var(--kf-text);
  border-radius: var(--radius-sm);
  transition: background var(--transition), transform var(--transition);
}
.btn-github:hover {
  background: #000;
  color: #fff;
  transform: translateY(-1px);
}

.notice {
  padding: 1rem 1.25rem;
  background: #fef3cd;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  color: #92400e;
  font-size: 0.925rem;
}
.notice a { color: #92400e; font-weight: 600; text-decoration: underline; }

.integration-body {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--kf-border);
}

/* ===== Content pages (category listings) ===== */
.main-content h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--kf-text);
  letter-spacing: -0.02em;
  margin-bottom: 1.5rem;
}

.main-content h3 {
  margin-top: 0;
  margin-bottom: 0;
}

.main-content h3 a {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--kf-purple);
}
.main-content h3 a:hover { color: var(--kf-purple-light); }

/* ===== Footer ===== */
.site-footer {
  padding: 1.5rem 2rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--kf-text-muted);
  border-top: 1px solid var(--kf-border);
}
.site-footer a { color: var(--kf-purple); font-weight: 500; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -280px;
    top: 53px;
    height: calc(100vh - 53px);
    width: 280px;
    z-index: 250;
    box-shadow: 4px 0 24px rgba(0,0,0,0.1);
    transition: left var(--transition);
  }
  .sidebar.open { left: 0; }

  .sidebar-toggle { display: flex; }

  .main-content { padding: 1.5rem 1.25rem; }

  .header-inner { padding: 0.75rem 1rem; }
  .header-logo img { width: 140px; }

  .integration-grid { grid-template-columns: 1fr; }

  .integration-header h1 { font-size: 1.5rem; }
}

@media (max-width: 480px) {
  .header-nav { display: none; }
}
