/* ==========================================================================
   1. ZMIENNE SYSTEMOWE & PALETA BARW (LitRush Modern Editorial)
   ========================================================================== */
:root {
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-primary-light: #e0e7ff;
  
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-header-bg: rgba(255, 255, 255, 0.92);
  
  --color-text-main: #0f172a;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  
  --font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --max-width: 1100px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   2. RESET & STYLE BAZOWE
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 85px;
}

body {
  font-family: var(--font-family);
  background-color: var(--color-bg);
  color: var(--color-text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   3. IKONY SVG (Mask-Image)
   ========================================================================== */
.icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  background-color: currentColor;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  vertical-align: -0.125em;
  flex-shrink: 0;
}

.icon-search      { -webkit-mask-image: url('/img/icons/search.svg'); mask-image: url('/img/icons/search.svg'); }
.icon-close       { -webkit-mask-image: url('/img/icons/times.svg'); mask-image: url('/img/icons/times.svg'); }
.icon-arrow-up    { -webkit-mask-image: url('/img/icons/arrow-up.svg'); mask-image: url('/img/icons/arrow-up.svg'); }
.icon-arrow-right { -webkit-mask-image: url('/img/icons/arrow-right.svg'); mask-image: url('/img/icons/arrow-right.svg'); }
.icon-file-lines  { -webkit-mask-image: url('/img/icons/file-lines.svg'); mask-image: url('/img/icons/file-lines.svg'); }
.icon-list-check  { -webkit-mask-image: url('/img/icons/list-check.svg'); mask-image: url('/img/icons/list-check.svg'); }
.icon-envelope    { -webkit-mask-image: url('/img/icons/envelope.svg'); mask-image: url('/img/icons/envelope.svg'); }
.icon-check       { -webkit-mask-image: url('/img/icons/circle-check.svg'); mask-image: url('/img/icons/circle-check.svg'); }


/* ==========================================================================
   4. HEADER & NAWIGACJA
   ========================================================================== */
.header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--color-header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  transition: all var(--transition);
}

.header-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
}

/* Logo po lewej stronie - nigdy się nie kurczy */
.logo-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--color-text-main);
  transition: opacity var(--transition);
  flex-shrink: 0;
  margin-right: auto;
}

.logo-link:hover {
  opacity: 0.85;
}

.logo-img {
  height: 34px;
  width: auto;
  display: block;
}

.logo-text {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.5px;
  color: var(--color-text-main);
  white-space: nowrap;
}

/* Nawigacja na PC */
.desktop-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-item {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  transition: all var(--transition);
  white-space: nowrap;
}

.nav-item:hover {
  color: var(--color-primary);
  background-color: var(--color-primary-light);
}

/* Prawa sekcja (wyszukiwarka + hamburger) */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* ==========================================================================
   5. WYSZUKIWARKA (Styl bazowy)
   ========================================================================== */
.search-form {
  position: relative;
  display: flex;
  align-items: center;
  background: #f1f5f9;
  border: 1px solid var(--color-border);
  border-radius: 24px;
  padding: 4px 14px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.search-icon-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 4px 2px;
  flex-shrink: 0;
}

.search-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--color-text-main);
  font-size: 14px;
  font-family: inherit;
  width: 200px;
  padding: 6px 10px;
  transition: width var(--transition);
}

.search-input::placeholder {
  color: #94a3b8;
}

.search-close-btn {
  display: none;
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
  transition: color var(--transition);
}

.search-close-btn:hover {
  color: var(--color-text-main);
}

/* Rozszerzanie na PC (tylko powyżej 900px!) */
@media (min-width: 901px) {
  .search-form:focus-within {
    border-color: var(--color-primary);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
  }

  .search-form:focus-within .search-input {
    width: 250px;
  }
}

/* ==========================================================================
   6. HAMBURGER MENU
   ========================================================================== */
.hamburger-btn {
  display: none;
  position: relative;
  width: 38px;
  height: 38px;
  padding: 0;
  background: #f1f5f9;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  cursor: pointer;
  outline: none;
  transition: all var(--transition);
}

.hamburger-btn:hover {
  background: #e2e8f0;
}

.hamburger-bar {
  position: absolute;
  left: 9px;
  width: 20px;
  height: 2px;
  background-color: var(--color-text-main);
  border-radius: 2px;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), 
              opacity 0.2s ease, 
              top 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.hamburger-bar:nth-child(1) { top: 12px; }
.hamburger-bar:nth-child(2) { top: 18px; }
.hamburger-bar:nth-child(3) { top: 24px; }

.hamburger-btn.is-active .hamburger-bar:nth-child(1) {
  top: 18px;
  transform: rotate(45deg);
}

.hamburger-btn.is-active .hamburger-bar:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.hamburger-btn.is-active .hamburger-bar:nth-child(3) {
  top: 18px;
  transform: rotate(-45deg);
}

/* Rozwijana lista mobilna */
.mobile-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.35s ease, opacity 0.25s ease;
}

.mobile-menu.is-open {
  max-height: 350px;
  opacity: 1;
}

.mobile-menu-links {
  padding: 15px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mobile-nav-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  color: var(--color-text-main);
  text-decoration: none;
  font-weight: 600;
  font-size: 16px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--color-border);
  transition: all var(--transition);
}

.mobile-nav-item:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-color: #c7d2fe;
}

/* ==========================================================================
   7. KONTENER GŁÓWNY (MAIN LAYOUT)
   ========================================================================== */
.main-layout {
  flex: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 40px auto;
  padding: 0 20px;
}

.page-container {
  width: 100%;
}

/* ==========================================================================
   8. STOPKA (Dwupoziomowa)
   ========================================================================== */
.footer {
  margin-top: auto;
  background: #0f172a;
  color: #94a3b8;
  padding: 30px 20px 10px;
  border-top: 1px solid #1e293b;
  text-align: center;
}

.footer-container {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.footer-main-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  flex-wrap: wrap;
}

.footer-nav-link {
  color: #e2e8f0;
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  transition: color var(--transition);
}

.footer-nav-link:hover {
  color: #818cf8;
}

.footer-divider {
  width: 100%;
  max-width: 600px;
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin: 5px 0;
}

.footer-legal-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-legal-nav a {
  color: #94a3b8;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: color var(--transition);
}

.footer-legal-nav a:hover {
  color: #ffffff;
}

.footer-dot {
  color: #475569;
  font-size: 11px;
}

.footer-copyright {
  font-size: 13px;
  color: #64748b;
  margin-top: -5px;
}

/* ==========================================================================
   9. SCROLL TO TOP BUTTON
   ========================================================================== */
.scroll-top-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 44px;
  height: 44px;
  background: var(--color-primary);
  color: #ffffff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transform: translateY(15px);
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.scroll-top-btn:hover {
  background: var(--color-primary-hover);
  transform: translateY(-2px);
}

.scroll-top-btn.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* ==========================================================================
   10. MEDIA QUERIES (Tablety i Mobile <= 900px)
   ========================================================================== */
@media (max-width: 900px) {
  .desktop-nav {
    display: none;
  }

  .hamburger-btn {
    display: block;
  }

  .mobile-menu {
    display: block;
  }

  /* Wyszukiwarka w trybie zwiniętym */
  .search-form {
    width: 38px;
    height: 38px;
    padding: 0;
    justify-content: center;
    border-radius: 10px;
    cursor: pointer;
    overflow: hidden; /* Blokuje wyciekanie elementów */
  }

  .search-icon-btn {
    width: 38px;
    height: 38px;
    padding: 0;
  }

  .search-input {
    display: none; /* Ukryte całkowicie w trybie ikony */
    width: 0;
    padding: 0;
    opacity: 0;
    pointer-events: none;
  }

  /* STAN ROZWINIĘTY: zgrabna szerokość, nie przykrywa logo! */
  .header.search-expanded .search-form {
    width: clamp(180px, 46vw, 260px);
    height: 38px;
    padding: 0 10px;
    border-radius: 12px;
    background: #ffffff;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
    cursor: default;
    overflow: visible;
  }

  .header.search-expanded .search-icon-btn {
    width: auto;
    height: auto;
    margin-right: 4px;
  }

  .header.search-expanded .search-input {
    display: block;
    flex: 1;
    min-width: 0;
    width: 100%;
    opacity: 1;
    pointer-events: auto;
    padding: 4px 6px;
    font-size: 14px;
  }

  .header.search-expanded .search-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Hamburger natychmiast znika, robiąc miejsce dla rozszerzonej lupki */
  .header.search-expanded .hamburger-btn {
    display: none !important;
  }

  .footer-main-nav {
    gap: 18px;
  }
}

@media (max-width: 600px) {
  .header-container {
    padding: 10px 15px;
  }

  .logo-img {
    height: 30px;
  }

  .logo-text {
    font-size: 18px;
  }

  .header.search-expanded .search-form {
    width: clamp(160px, 50vw, 210px);
  }

  .footer-main-nav {
    flex-direction: column;
    gap: 12px;
  }

  .footer-legal-nav {
    flex-direction: column;
    gap: 8px;
  }

  .footer-dot {
    display: none;
  }

  .scroll-top-btn {
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
  }
}

/* ==========================================================================
   WSPÓLNY MODUŁ: PODPOWIEDZI WYSZUKIWARKI W HEADERZE (LIVE SUGGESTIONS)
   ========================================================================== */
.search-form {
  position: relative; /* Wymagane do pozycjonowania rozwijanej listy */
}

.search-autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 320px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
  padding: 8px 0;
  display: none;
  flex-direction: column;
  z-index: 1100;
  overflow: hidden;
}

.search-autocomplete-dropdown.is-visible {
  display: flex;
}

.search-suggestion-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  text-decoration: none;
  color: var(--color-text-main);
  font-size: 14px;
  transition: background-color var(--transition);
}

.search-suggestion-item:hover,
.search-suggestion-item:focus {
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  outline: none;
}

.search-suggestion-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.search-suggestion-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-suggestion-type {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.search-suggestion-arrow {
  font-size: 12px;
  color: var(--color-text-muted);
}

.search-suggestion-all {
  border-top: 1px solid var(--color-border);
  margin-top: 4px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary);
  text-align: center;
  text-decoration: none;
  display: block;
}

.search-suggestion-all:hover {
  background: #f1f5f9;
}

@media (max-width: 900px) {
  .search-autocomplete-dropdown {
    width: 280px;
    right: 0;
    left: auto;
  }
}

@media (max-width: 600px) {
  .search-autocomplete-dropdown {
    position: fixed;
    top: 60px;
    left: 15px;
    right: 15px;
    width: auto;
  }
}

