/* === FUNKCJE DOSTĘPNOŚCI === */

/* Zmienne CSS dla dostępności */
:root {
  --base-font-size: 16px;
  --bg-color: #f5f7fa;
  --content-bg: white;
  --text-color: #333;
  --sidebar-bg: linear-gradient(180deg, #2E7D32 0%, #1B5E20 100%);
  --active-color: #ffeb3b;
  
  /* Zmienne dla wysokiego kontrastu */
  --hc-bg-color: #000000;
  --hc-content-bg: #1a1a1a;
  --hc-text-color: #ffffff;
  --hc-link-color: #ffff00;
  --hc-border-color: #ffffff;
  --hc-button-bg: #333333;
  --hc-button-hover: #555555;
}

/* === PANEL DOSTĘPNOŚCI === */
.accessibility-panel {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1002;
}

.accessibility-btn {
  width: 50px;
  height: 50px;
  border: none;
  border-radius: 50%;
  background: #2E7D32;
  color: white;
  cursor: pointer;
  font-weight: bold;
  font-size: 18px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.accessibility-btn:hover {
  background: #1B5E20;
  transform: scale(1.1);
}

.accessibility-btn:focus {
  outline: 3px solid #ffeb3b;
  outline-offset: 2px;
}

/* === ZWIĘKSZANIE CZCIONKI === */
body.large-font {
  font-size: 1.125rem; /* 18px */
}

body.large-font h1 {
  font-size: 2.25rem; /* 36px zamiast 32px */
}

body.large-font h2 {
  font-size: 1.875rem; /* 30px zamiast 24px */
}

body.large-font h3 {
  font-size: 1.5rem; /* 24px zamiast 20px */
}

body.large-font h4 {
  font-size: 1.25rem; /* 20px zamiast 18px */
}

body.large-font .nav-link {
  font-size: 1.125rem;
}

body.large-font .btn {
  font-size: 1.125rem;
  padding: 0.75rem 1.5rem;
}

body.large-font .card-title {
  font-size: 1.375rem;
}

body.large-font .card-text {
  font-size: 1.125rem;
}

/* === JESZCZE WIĘKSZA CZCIONKA === */
body.larger-font {
  font-size: 1.25rem; /* 20px */
}

body.larger-font h1 {
  font-size: 2.5rem; /* 40px */
}

body.larger-font h2 {
  font-size: 2rem; /* 32px */
}

body.larger-font h3 {
  font-size: 1.75rem; /* 28px */
}

body.larger-font h4 {
  font-size: 1.5rem; /* 24px */
}

body.larger-font .nav-link {
  font-size: 1.25rem;
}

body.larger-font .btn {
  font-size: 1.25rem;
  padding: 1rem 2rem;
}

body.larger-font .card-title {
  font-size: 1.5rem;
}

body.larger-font .card-text {
  font-size: 1.25rem;
}

/* === WYSOKI KONTRAST === */

/* BARDZO AGRESYWNE STYLE DLA BODY - MUSZĄ BYĆ PIERWSZE */
html.high-contrast,
body.high-contrast {
  background-color: var(--hc-bg-color) !important;
  background-image: none !important;
  background: var(--hc-bg-color) !important;
  color: var(--hc-text-color) !important;
}

/* Dodatkowe nadpisanie dla body z różnymi selektorami */
.high-contrast body,
html body.high-contrast,
body.high-contrast[style],
body.high-contrast[class] {
  background-color: var(--hc-bg-color) !important;
  background-image: none !important;
  background: var(--hc-bg-color) !important;
  background-attachment: initial !important;
  background-position: initial !important;
  background-repeat: initial !important;
  background-size: initial !important;
  color: var(--hc-text-color) !important;
}

/* Jeszcze bardziej agresywne selektory dla body */
body.high-contrast,
body[class*="high-contrast"],
.high-contrast,
html.high-contrast body,
html body.high-contrast,
body.high-contrast * {
  background-color: var(--hc-bg-color) !important;
  background-image: none !important;
  background: var(--hc-bg-color) !important;
}

/* Wymuszenie przez CSS Custom Properties */
body.high-contrast {
  background: var(--hc-bg-color) !important;
  background-color: var(--hc-bg-color) !important;
  color: var(--hc-text-color) !important;
  --bg-color: var(--hc-bg-color) !important;
  --body-bg: var(--hc-bg-color) !important;
}

/* Wymuś zmianę tła dla wszystkich elementów */
body.high-contrast *:not(.accessibility-btn) {
  background-color: var(--hc-bg-color) !important;
  color: var(--hc-text-color) !important;
}

/* Główne sekcje strony */
body.high-contrast html,
body.high-contrast body,
body.high-contrast .container,
body.high-contrast .container-fluid,
body.high-contrast .content-wrapper,
body.high-contrast .main-content,
body.high-contrast .card,
body.high-contrast .card-body,
body.high-contrast .row,
body.high-contrast .col,
body.high-contrast section,
body.high-contrast main,
body.high-contrast header,
body.high-contrast .info-box,
body.high-contrast .homeless-info-panel {
  background-color: var(--hc-bg-color) !important;
  background-image: none !important;
  background: var(--hc-bg-color) !important;
  color: var(--hc-text-color) !important;
  border-color: var(--hc-border-color) !important;
}

/* Wszystkie div-y i sekcje */
body.high-contrast div,
body.high-contrast section,
body.high-contrast article,
body.high-contrast aside,
body.high-contrast main,
body.high-contrast header,
body.high-contrast footer {
  background-color: var(--hc-bg-color) !important;
  background-image: none !important;
  background: var(--hc-bg-color) !important;
}

/* Karty i panele informacyjne */
body.high-contrast .card,
body.high-contrast .card-header,
body.high-contrast .card-body,
body.high-contrast .card-footer,
body.high-contrast .info-box,
body.high-contrast .homeless-info-panel,
body.high-contrast .panel,
body.high-contrast .box,
body.high-contrast .widget,
body.high-contrast .alert,
body.high-contrast .well {
  background-color: var(--hc-content-bg) !important;
  background-image: none !important;
  background: var(--hc-content-bg) !important;
  color: var(--hc-text-color) !important;
  border: 1px solid var(--hc-border-color) !important;
}

body.high-contrast .navbar,
body.high-contrast .sidebar,
body.high-contrast .footer {
  background: var(--hc-content-bg) !important;
  background-color: var(--hc-content-bg) !important;
  background-image: none !important;
  border-color: var(--hc-border-color) !important;
}

body.high-contrast a,
body.high-contrast .nav-link {
  color: var(--hc-link-color) !important;
  text-decoration: underline;
}

body.high-contrast a:hover,
body.high-contrast .nav-link:hover {
  color: #ffffff !important;
  background-color: var(--hc-button-hover) !important;
}

body.high-contrast .btn {
  background-color: var(--hc-button-bg) !important;
  color: var(--hc-text-color) !important;
  border: 2px solid var(--hc-border-color) !important;
}

body.high-contrast .btn:hover {
  background-color: var(--hc-button-hover) !important;
  color: var(--hc-text-color) !important;
}

body.high-contrast .btn-primary {
  background-color: #444444 !important;
  border-color: var(--hc-border-color) !important;
}

body.high-contrast .btn-primary:hover {
  background-color: #666666 !important;
}

body.high-contrast .form-control,
body.high-contrast .form-select,
body.high-contrast input,
body.high-contrast textarea,
body.high-contrast select {
  background-color: var(--hc-content-bg) !important;
  color: var(--hc-text-color) !important;
  border: 2px solid var(--hc-border-color) !important;
}

body.high-contrast .form-control:focus,
body.high-contrast .form-select:focus,
body.high-contrast input:focus,
body.high-contrast textarea:focus,
body.high-contrast select:focus {
  border-color: var(--hc-link-color) !important;
  box-shadow: 0 0 0 0.2rem rgba(255, 255, 0, 0.5) !important;
}

body.high-contrast .table {
  color: var(--hc-text-color) !important;
  border-color: var(--hc-border-color) !important;
}

body.high-contrast .table th,
body.high-contrast .table td {
  border-color: var(--hc-border-color) !important;
}

body.high-contrast .table-striped tbody tr:nth-of-type(odd) {
  background-color: rgba(255, 255, 255, 0.1) !important;
}

body.high-contrast .table-hover tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.2) !important;
}

/* Panel dostępności w trybie wysokiego kontrastu */
body.high-contrast .accessibility-btn {
  background: var(--hc-button-bg) !important;
  color: var(--hc-text-color) !important;
  border: 2px solid var(--hc-border-color) !important;
}

body.high-contrast .accessibility-btn:hover {
  background: var(--hc-button-hover) !important;
  transform: scale(1.1);
}

/* Uniwersalne nadpisanie dla wszystkich możliwych tła */
body.high-contrast [class*="bg-"],
body.high-contrast [style*="background"],
body.high-contrast [style*="background-color"],
body.high-contrast [style*="background-image"] {
  background-color: var(--hc-bg-color) !important;
  background-image: none !important;
  background: var(--hc-bg-color) !important;
}

/* Specjalne traktowanie dla elementów z własnym tłem */
body.high-contrast .has-background,
body.high-contrast .bg-light,
body.high-contrast .bg-dark,
body.high-contrast .bg-primary,
body.high-contrast .bg-secondary,
body.high-contrast .bg-success,
body.high-contrast .bg-info,
body.high-contrast .bg-warning,
body.high-contrast .bg-danger,
body.high-contrast .bg-white,
body.high-contrast .bg-gray,
body.high-contrast .bg-grey {
  background-color: var(--hc-bg-color) !important;
  background-image: none !important;
  background: var(--hc-bg-color) !important;
  color: var(--hc-text-color) !important;
}

/* === DODATKOWE STYLE DLA POPRAWY DOSTĘPNOŚCI === */

/* Lepsze focus states */
*:focus {
  outline: 3px solid #ffeb3b;
  outline-offset: 2px;
}

body.high-contrast *:focus {
  outline-color: var(--hc-link-color) !important;
}

/* Zwiększone kontrasty dla linków */
a {
  text-decoration: underline;
}

/* Lepsze wsparcie dla screen readerów */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Animacje respektujące preferencje użytkownika */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .accessibility-btn {
    transition: none !important;
  }
  
  .accessibility-btn:hover {
    transform: none !important;
  }
}

/* Responsywność panelu dostępności */
@media (max-width: 768px) {
  .accessibility-panel {
    right: 10px;
    bottom: 10px;
  }
  
  .accessibility-btn {
    width: 45px;
    height: 45px;
    font-size: 16px;
  }
}

/* Tryb druku - ukryj panel dostępności */
@media print {
  .accessibility-panel {
    display: none !important;
  }
}