/* ========================================
   FIX DLA STICKY HEADER + WALIDACJA FORMULARZA
   ======================================== */

/* Dodaj padding przy auto-scroll (anchor links, walidacja) */
html {
  scroll-padding-top: 100px; /* 80px header + 20px buffer */
}

/* Wszystkie pola formularza - offset przy walidacji */
.form-input,
.form-textarea,
.form-select {
  scroll-margin-top: 100px;
}

/* ========================================
   STRONA /GENERUJ - KAFELKI + FORMULARZ
   ======================================== */

/* ========================================
   KAFELKI WYBORU TYPU ARTYKUŁU
   ======================================== */

.article-tiles {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.article-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 2rem 1.5rem;
  background: var(--bg);
  border: 2px solid var(--brand-blue);
  border-radius: 12px;
  text-decoration: none;
  transition: all 0.3s ease;
  cursor: pointer;
  text-align: left;
}

.article-tile:hover {
  background: rgba(111, 183, 255, 0.05);
  box-shadow: 0 8px 16px rgba(111, 183, 255, 0.2);
  transform: translateY(-2px);
}

/* Ikona - zmniejszona i wyrównana do lewej */
.article-tile-icon {
  font-size: 2rem;
  margin-bottom: 1rem;
  line-height: 1;
  text-align: left;
}

/* Tytuł + zakres słów */
.article-tile-header {
  margin-bottom: 0.75rem;
}

.article-tile-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--brand-blue);
  margin: 0 0 0.25rem 0;
}

.article-tile-range {
  font-size: 1.05rem;
  color: var(--muted);
  margin: 0;
}

/* Koszt - zwiększona czcionka */
.article-tile-cost {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gold);
  margin: 0 0 1rem 0;
}

/* Cel - zwiększona czcionka */
.article-tile-goal {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.75rem 0;
}

/* Opis - zwiększona czcionka */
.article-tile-description {
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--muted);
  margin: 0 0 1.5rem 0;
  flex-grow: 1;
}

/* Przycisk - zwiększona czcionka */
.article-tile-button {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background: var(--brand-blue);
  color: var(--bg);
  border-radius: 8px;
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
  transition: all 0.3s ease;
  border: 0;
  cursor: pointer;
  width: 100%;
}

.article-tile-button:hover {
  background: var(--gold);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(244, 180, 0, 0.3);
}

/* ========================================
   KAFELEK WYBRANY (selected)
   ======================================== */

.article-tile.selected {
  border-color: var(--gold);
  background: rgba(244, 180, 0, 0.05);
  box-shadow: 0 0 0 3px rgba(244, 180, 0, 0.2);
}

.article-tile.selected .article-tile-title {
  color: var(--gold);
}

.article-tile.selected .article-tile-button {
  background: var(--gold);
  color: var(--bg);
}

/* ========================================
   KAFELEK NIEAKTYWNY (brak tokenów)
   ======================================== */

.article-tile.inactive {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.article-tile.inactive:hover {
  transform: none;
  box-shadow: none;
  background: var(--bg);
}

/* Overlay "Potrzebujesz X tokenów" */
.article-tile-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(11, 30, 63, 0.85);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  pointer-events: auto;
  cursor: default;
}

.article-tile-overlay-text {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1rem;
}

.article-tile-overlay-link {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background: var(--gold);
  color: var(--bg);
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.3s ease;
}

.article-tile-overlay-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(244, 180, 0, 0.4);
  text-decoration: none;
}

/* ========================================
   RESPONSIVE - DESKTOP (≥1024px)
   ======================================== */

@media (min-width: 1024px) {
  .article-tiles {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
  }
  
  .article-tile {
    padding: 2rem 1.5rem;
  }
  
  .article-tile-icon {
    font-size: 2.2rem;
  }
  
  .article-tile-title {
    font-size: 1.6rem;
  }
  
  .article-tile-range {
    font-size: 1.05rem;
  }
  
  .article-tile-cost {
    font-size: 1.25rem;
  }
  
  .article-tile-goal {
    font-size: 1.15rem;
  }
  
  .article-tile-description {
    font-size: 1.05rem;
  }
}

/* ========================================
   RESPONSIVE - LARGE DESKTOP (≥1280px)
   ======================================== */

@media (min-width: 1280px) {
  .article-tiles {
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
  }
  
  .article-tile {
    padding: 2.5rem 2rem;
  }
  
  .article-tile-icon {
    font-size: 2.2rem;
  }
  
  .article-tile-title {
    font-size: 1.7rem;
  }
  
  .article-tile-range {
    font-size: 1.1rem;
  }
  
  .article-tile-cost {
    font-size: 1.3rem;
  }
  
  .article-tile-goal {
    font-size: 1.2rem;
  }
  
  .article-tile-description {
    font-size: 1.1rem;
  }
}

/* Zapobieganie podkreśleniu linków */
.article-tile,
.article-tile *,
.article-tile:hover,
.article-tile:hover * {
  text-decoration: none !important;
}

/* ========================================
   FORMULARZ GENEROWANIA ARTYKUŁU
   ======================================== */

/* Formularz ukryty domyślnie - pojawia się po wyborze kafelka */
.article-form {
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  margin-top: 3rem;
}
.article-form.visible {
  display: block;
  opacity: 1;
}

/* Kontener formularza (nagłówek + pola razem) */
.form-wrapper {
  background: var(--input-bg);
  border: 2px solid var(--brand-blue);
  border-radius: 12px;
  padding: 2rem 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

/* Nagłówek formularza */
.form-header-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0 0 0.5rem 0;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--brand-blue);
  text-align: center;
}

.form-header-subtitle {
  margin: 0 0 1rem 0;
  font-size: 1.05rem;
  color: var(--muted);
  text-align: center;
}

.form-header-change {
  margin: 0 0 1.5rem 0;
  text-align: center;
}

.form-header-change a {
  color: var(--gold);
  text-decoration: none;
  font-size: 1.1rem;
  font-weight: 600;
}

.form-header-change a:hover {
  text-decoration: underline;
}

/* Separator (HR) */
.form-separator {
  border: none;
  height: 2px;
  background-color: var(--brand-blue);
  margin: 0 0 2rem 0;
  max-width: 1200px;
}


/* Grupa pól */
.form-field {
  margin-bottom: 0.7rem;
}

.form-field:last-of-type {
  margin-bottom: 1.5rem;
}

/* Label z tooltipem */
.form-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text);
}

/* Tooltip icon - BEZ kółka, bez hover */
.tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--brand-blue);
  padding: 0.25rem;
  min-width: 24px;
  min-height: 24px;
  position: relative;
  user-select: none;
}

.tooltip-icon:hover {
  color: var(--gold);
  transform: scale(1.15);
}

/* Tooltip - dymek (ukryty domyślnie) */
.tooltip-content {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--brand-blue);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.4;
  white-space: normal;
  min-width: 200px;
  max-width: 300px;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.tooltip-content::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--input-bg);
}

/* Tooltip aktywny (pokazany) */
.tooltip-icon.active .tooltip-content {
  display: block;
}

/* Mobile - większa ikona i area klikalny */
@media (max-width: 1023px) {
  .tooltip-icon {
    font-size: 1.3rem;
    padding: 0.5rem;
    min-width: 36px;
    min-height: 36px;
  }
}

/* Input text - TAKIE SAMO TŁO JAK TEXTAREA */
.form-input {
  width: 100%;
  padding: 0.9rem 1rem;
  background: var(--bg) !important;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  color: var(--text);
  font-size: 1.05rem;
  transition: border-color 0.2s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--brand-blue);
}

/* RESET AUTOFILL - wymuszenie prawidłowego tła (nadpisuje main.css) */
#article-form .form-input:-webkit-autofill,
#article-form .form-input:-webkit-autofill:hover,
#article-form .form-input:-webkit-autofill:focus,
#article-form .form-input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text) !important;
  -webkit-box-shadow: 0 0 0 1000px var(--bg) inset !important;
  box-shadow: 0 0 0 1000px var(--bg) inset !important;
  transition: background-color 5000s ease-in-out 0s !important;
  background-color: var(--bg) !important;
}

/* Textarea - TAKIE SAMO TŁO JAK INPUT */
.form-textarea {
  width: 100%;
  padding: 0.9rem 1rem;
  background: var(--bg);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  color: var(--text);
  font-size: 1.05rem;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
  transition: border-color 0.2s ease;
}

.form-textarea:focus {
  outline: none;
  border-color: var(--brand-blue);
}

/* Select dropdown - więcej paddingu z prawej dla strzałki */
.form-select {
  width: 100%;
  padding: 0.9rem 2.5rem 0.9rem 1rem;
  background: var(--bg);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  color: var(--text);
  font-size: 1.05rem;
  cursor: pointer;
  transition: border-color 0.2s ease;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23b9c3d9' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 12px 8px;
}

.form-select:focus {
  outline: none;
  border-color: var(--brand-blue);
}

.form-select option {
  background: var(--bg);
  color: var(--text);
  font-weight: 700;
}

.form-select option:disabled {
  color: var(--muted);
  font-weight: 400;
}

/* Licznik znaków */
.char-counter {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  text-align: right;
  color: var(--muted);
}

.char-counter.warning {
  color: var(--gold);
}

.char-counter.danger {
  color: #ff6b6b;
}

/* Podpowiedź pod polem */
.field-hint {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.5;
}

/* Przycisk submit */
.form-submit {
  width: 100%;
  padding: 1.1rem 1.5rem;
  background: var(--gold);
  color: var(--bg);
  border: 0;
  border-radius: 8px;
  font-size: 1.15rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.form-submit:hover {
  opacity: 0.92;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(244, 180, 0, 0.4);
}

.form-submit:active {
  transform: translateY(0);
}

/* ========================================
   RESPONSIVE - FORMULARZ
   ======================================== */

/* Mobile (<1024px) - domyślne */
@media (max-width: 1023px) {
  .form-header-title {
    font-size: 1.5rem;
  }
  
  .form-wrapper {
    padding: 1.5rem 1rem;
  }
}

/* Desktop (≥1024px) */
@media (min-width: 1024px) {
  .form-wrapper {
    padding: 2.5rem 2rem;
  }
}

/* Large Desktop (≥1280px) */
@media (min-width: 1280px) {
  .form-wrapper {
    padding: 3rem 2.5rem;
  }
  
  .form-header-title {
    font-size: 2rem;
  }
}
/* Pole warunkowe (ukryte domyślnie) */
.form-field-conditional {
  display: none;
}

.form-field-conditional.visible {
  display: block;
}

/* ========================================
   WALIDACJA INLINE (JavaScript)
   ======================================== */

.error-message {
  color: #ff6b6b;
  font-size: 0.95rem;
  display: block;
  margin-top: 0.3rem;
  text-align: left;
  line-height: 1.4;
  font-weight: 500;
}

/* Pole z błędem - czerwona ramka */
.form-input:invalid,
.form-textarea:invalid,
.form-select:invalid {
  /* Nie używamy :invalid, bo to konfliktuje z HTML5 validation */
  /* Zamiast tego JS ustawia borderColor inline */
}