/* BarrierFree Plugin Styles */
:root {
  --bf-primary-blue: #2196f3;
  --bf-primary-green: #4caf50;
  --bf-primary-red: #f44336;
  --bf-primary-purple: #9c27b0;
  --bf-primary-orange: #ff9800;
  --bf-primary-teal: #009688;
  --bf-primary-dark: #424242;
  --bf-white: #ffffff;
  --bf-black: #000000;
  --bf-gray: #757575;
  --bf-light-gray: #f5f5f5;
}

/* Toolbar Container - NEUE POSITIONIERUNGSSTRATEGIE */
.barrierfree-toolbar {
  position: fixed;
  top: 20%;
  z-index: 999999;
  background: var(--bf-white);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  padding: 0;
  min-width: 60px;
  max-width: 320px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.barrierfree-toolbar.position-left {
  left: 20px;
  margin-top: -30px; /* Hälfte der Button-Höhe */
}

.barrierfree-toolbar.position-right {
  right: 20px;
  margin-top: -30px; /* Hälfte der Button-Höhe */
}

.barrierfree-toolbar.position-bottom-left {
  bottom: 20px;
  left: 20px;
  top: auto;
  margin-top: 0;
}

.barrierfree-toolbar.position-bottom-right {
  bottom: 20px;
  right: 20px;
  top: auto;
  margin-top: 0;
}

/* Expanded state - zusätzlicher Margin */
.barrierfree-toolbar.expanded.position-left,
.barrierfree-toolbar.expanded.position-right {
  margin-top: -150px; /* Ungefähr Hälfte der Panel-Höhe */
}

/* Collapsed state - only show floating button */
.barrierfree-toolbar.collapsed {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bf-primary-blue) 0%, #1976d2 100%);
  border: 3px solid var(--bf-white);
  box-shadow: 0 4px 20px rgba(33, 150, 243, 0.3), 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Expanded state */
.barrierfree-toolbar.expanded {
  width: 280px;
  min-height: 320px;
  padding: 16px;
  border-radius: 16px;
  background: var(--bf-white);
}

/* Floating Button */
.barrierfree-floating-btn {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: transparent;
  color: var(--bf-white);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  z-index: 999999;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.barrierfree-floating-btn span {
  pointer-events: none;
  user-select: none;
  display: block;
  line-height: 1;
  transform: scale(1);
  transition: transform 0.2s ease;
}

.barrierfree-floating-btn:hover {
  transform: scale(1.05);
}

.barrierfree-floating-btn:hover span {
  transform: scale(1.1);
}

.barrierfree-floating-btn:active {
  transform: scale(0.95);
}

.barrierfree-floating-btn:focus {
  outline: none;
  box-shadow: 0 0 0 4px rgba(33, 150, 243, 0.3);
}

/* Hide floating button when expanded */
.barrierfree-toolbar.expanded .barrierfree-floating-btn {
  display: none;
}

/* Show floating button when collapsed */
.barrierfree-toolbar.collapsed .barrierfree-floating-btn {
  display: flex;
}

/* Color Schemes for Toolbar */
.barrierfree-toolbar.scheme-blue {
  border-left: 4px solid var(--bf-primary-blue);
}
.barrierfree-toolbar.scheme-green {
  border-left: 4px solid var(--bf-primary-green);
}
.barrierfree-toolbar.scheme-red {
  border-left: 4px solid var(--bf-primary-red);
}
.barrierfree-toolbar.scheme-purple {
  border-left: 4px solid var(--bf-primary-purple);
}
.barrierfree-toolbar.scheme-orange {
  border-left: 4px solid var(--bf-primary-orange);
}
.barrierfree-toolbar.scheme-teal {
  border-left: 4px solid var(--bf-primary-teal);
}
.barrierfree-toolbar.scheme-dark {
  border-left: 4px solid var(--bf-primary-dark);
}

/* Toolbar Header - only visible when expanded */
.barrierfree-header {
  display: none;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid #f0f0f0;
}

.barrierfree-toolbar.expanded .barrierfree-header {
  display: flex;
}

.barrierfree-logo {
  font-weight: 700;
  color: var(--bf-primary-blue);
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.barrierfree-close-btn {
  background: #f5f5f5;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.2s ease;
  color: var(--bf-gray);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.barrierfree-close-btn:hover {
  background-color: #e0e0e0;
  color: var(--bf-black);
}

/* Controls Container - only visible when expanded */
.barrierfree-controls {
  display: none;
  grid-template-columns: 1fr;
  gap: 15px;
  max-height: 65vh;
  overflow-y: auto;
  padding-right: 8px;
}

.barrierfree-toolbar.expanded .barrierfree-controls {
  display: grid;
}

/* Custom Scrollbar */
.barrierfree-controls::-webkit-scrollbar {
  width: 6px;
}

.barrierfree-controls::-webkit-scrollbar-track {
  background: #f5f5f5;
  border-radius: 3px;
}

.barrierfree-controls::-webkit-scrollbar-thumb {
  background: #d0d0d0;
  border-radius: 3px;
}

.barrierfree-controls::-webkit-scrollbar-thumb:hover {
  background: var(--bf-primary-blue);
}

/* Pulse animation for floating button */
@keyframes pulse {
  0% {
    box-shadow: 0 4px 20px rgba(33, 150, 243, 0.3), 0 2px 8px rgba(0, 0, 0, 0.15), 0 0 0 0 rgba(33, 150, 243, 0.7);
  }
  70% {
    box-shadow: 0 4px 20px rgba(33, 150, 243, 0.3), 0 2px 8px rgba(0, 0, 0, 0.15), 0 0 0 15px rgba(33, 150, 243, 0);
  }
  100% {
    box-shadow: 0 4px 20px rgba(33, 150, 243, 0.3), 0 2px 8px rgba(0, 0, 0, 0.15), 0 0 0 0 rgba(33, 150, 243, 0);
  }
}

.barrierfree-floating-btn.pulse {
  animation: pulse 2s infinite;
}

/* Tooltip for floating button */
.barrierfree-tooltip {
  position: absolute;
  background: rgba(0, 0, 0, 0.9);
  color: var(--bf-white);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 1000000;
  pointer-events: none;
  backdrop-filter: blur(4px);
}

.barrierfree-toolbar.position-left .barrierfree-tooltip,
.barrierfree-toolbar.position-bottom-left .barrierfree-tooltip {
  left: 75px;
  top: 50%;
  margin-top: -12px; /* Hälfte der Tooltip-Höhe */
}

.barrierfree-toolbar.position-right .barrierfree-tooltip,
.barrierfree-toolbar.position-bottom-right .barrierfree-tooltip {
  right: 75px;
  top: 50%;
  margin-top: -12px; /* Hälfte der Tooltip-Höhe */
}

/* Arrow for tooltip */
.barrierfree-tooltip::before {
  content: "";
  position: absolute;
  top: 50%;
  width: 0;
  height: 0;
  border: 6px solid transparent;
  transform: translateY(-50%);
}

.barrierfree-toolbar.position-left .barrierfree-tooltip::before,
.barrierfree-toolbar.position-bottom-left .barrierfree-tooltip::before {
  left: -12px;
  border-right-color: rgba(0, 0, 0, 0.9);
}

.barrierfree-toolbar.position-right .barrierfree-tooltip::before,
.barrierfree-toolbar.position-bottom-right .barrierfree-tooltip::before {
  right: -12px;
  border-left-color: rgba(0, 0, 0, 0.9);
}

/* Controls Container */
.bf-control-group {
  padding: 12px;
  margin-bottom: 8px;
  background: #fafafa;
  border-radius: 12px;
  border: 1px solid #f0f0f0;
  transition: all 0.2s ease;
}

.bf-control-group:hover {
  background: #f5f5f5;
  border-color: #e0e0e0;
}

.bf-control-group:last-child {
  margin-bottom: 0;
}

.bf-control-group h4 {
  margin: 0 0 8px 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--bf-gray);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Buttons */
.bf-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  background: var(--bf-white);
  color: var(--bf-black);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  margin-bottom: 8px;
}

.bf-btn:hover {
  background-color: #f8f9fa;
  border-color: var(--bf-primary-blue);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.bf-btn.active {
  background-color: var(--bf-primary-blue);
  color: var(--bf-white);
  border-color: var(--bf-primary-blue);
  box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.bf-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.3);
}

/* Compact Icon Buttons */
.bf-btn-icon {
  width: 52px;
  height: 44px;
  padding: 8px;
  justify-content: center;
  font-size: 16px;
  margin-bottom: 6px;
  margin-right: 6px;
}

.bf-btn-icon:last-child {
  margin-right: 0;
}

/* Icon Grid Layout */
.bf-icon-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Spacing Controls */
.bf-spacing-controls {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.bf-spacing-controls .bf-btn-icon {
  flex: 1;
  font-size: 11px;
  font-weight: bold;
  margin-right: 0;
  width: auto;
}

/* Sliders */
.bf-slider-container {
  margin-bottom: 8px;
}

.bf-slider-label {
  margin-bottom: 6px;
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--bf-gray);
}

.bf-slider {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: #e0e0e0;
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.bf-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bf-primary-blue);
  cursor: pointer;
  border: 3px solid var(--bf-white);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
}

.bf-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.bf-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bf-primary-blue);
  cursor: pointer;
  border: 3px solid var(--bf-white);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Speech Controls */
.bf-speech-controls {
  display: flex;
  gap: 6px;
}

.bf-speech-controls .bf-speech-btn {
  flex: 1;
  padding: 8px 4px;
  font-size: 16px;
  justify-content: center;
  margin-bottom: 6px;
  width: auto;
}

.bf-speech-btn {
  flex: 1;
  padding: 10px 8px;
  font-size: 11px;
  font-weight: 600;
}

/* Reading Highlight */
.bf-reading-highlight {
  background-color: #ffeb3b !important;
  color: #000 !important;
  padding: 2px 4px !important;
  border-radius: 4px !important;
  transition: all 0.3s ease !important;
  box-shadow: 0 0 0 2px rgba(255, 235, 59, 0.5) !important;
}

/* Accessibility Features - VOLLSTÄNDIG NEUE FILTER-STRATEGIE */

/* Toolbar IMMER ausschließen - höchste Priorität */
.barrierfree-toolbar,
.barrierfree-toolbar *,
.barrierfree-toolbar::before,
.barrierfree-toolbar::after,
.barrierfree-tooltip {
  filter: none !important;
  -webkit-filter: none !important;
}

/* Graustufen - nur auf HTML-Element, nicht auf body */
html.bf-grayscale {
  filter: grayscale(100%) !important;
  -webkit-filter: grayscale(100%) !important;
}

/* Toolbar bei Graustufen komplett ausschließen */
html.bf-grayscale .barrierfree-toolbar,
html.bf-grayscale .barrierfree-toolbar *,
html.bf-grayscale .barrierfree-toolbar::before,
html.bf-grayscale .barrierfree-toolbar::after,
html.bf-grayscale .barrierfree-tooltip {
  filter: none !important;
  -webkit-filter: none !important;
}

/* Farben umkehren - nur auf HTML-Element */
html.bf-invert-colors {
  filter: invert(1) hue-rotate(180deg) !important;
  -webkit-filter: invert(1) hue-rotate(180deg) !important;
}

/* Toolbar bei Farben umkehren komplett ausschließen */
html.bf-invert-colors .barrierfree-toolbar,
html.bf-invert-colors .barrierfree-toolbar *,
html.bf-invert-colors .barrierfree-toolbar::before,
html.bf-invert-colors .barrierfree-toolbar::after,
html.bf-invert-colors .barrierfree-tooltip {
  filter: none !important;
  -webkit-filter: none !important;
}

/* Kombinierte Filter */
html.bf-grayscale.bf-invert-colors {
  filter: grayscale(100%) invert(1) hue-rotate(180deg) !important;
  -webkit-filter: grayscale(100%) invert(1) hue-rotate(180deg) !important;
}

/* Toolbar bei kombinierten Filtern ausschließen */
html.bf-grayscale.bf-invert-colors .barrierfree-toolbar,
html.bf-grayscale.bf-invert-colors .barrierfree-toolbar *,
html.bf-grayscale.bf-invert-colors .barrierfree-toolbar::before,
html.bf-grayscale.bf-invert-colors .barrierfree-toolbar::after,
html.bf-grayscale.bf-invert-colors .barrierfree-tooltip {
  filter: none !important;
  -webkit-filter: none !important;
}

body.bf-highlight-links a {
  background-color: #ffeb3b !important;
  color: #000 !important;
  padding: 2px 4px !important;
  border-radius: 4px !important;
  box-shadow: 0 0 0 2px rgba(255, 235, 59, 0.5) !important;
}

body.bf-underline-links a {
  text-decoration: underline !important;
  text-decoration-thickness: 2px !important;
  text-underline-offset: 2px !important;
}

body.bf-big-cursor,
body.bf-big-cursor * {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><path d="M2 2l8 20 4-8 8-4z" fill="black"/><path d="M2 2l8 20 4-8 8-4z" fill="white" stroke="black" stroke-width="1"/></svg>')
    2 2, auto !important;
}

/* Font Size Classes */
.bf-font-70 {
  font-size: 70% !important;
}
.bf-font-80 {
  font-size: 80% !important;
}
.bf-font-90 {
  font-size: 90% !important;
}
.bf-font-100 {
  font-size: 100% !important;
}
.bf-font-110 {
  font-size: 110% !important;
}
.bf-font-120 {
  font-size: 120% !important;
}
.bf-font-130 {
  font-size: 130% !important;
}
.bf-font-140 {
  font-size: 140% !important;
}
.bf-font-150 {
  font-size: 150% !important;
}
.bf-font-160 {
  font-size: 160% !important;
}
.bf-font-170 {
  font-size: 170% !important;
}
.bf-font-180 {
  font-size: 180% !important;
}
.bf-font-190 {
  font-size: 190% !important;
}
.bf-font-200 {
  font-size: 200% !important;
}

/* Letter Spacing Classes */
.bf-spacing-normal {
  letter-spacing: normal !important;
}
.bf-spacing-wide {
  letter-spacing: 0.1em !important;
}
.bf-spacing-wider {
  letter-spacing: 0.2em !important;
}
.bf-spacing-widest {
  letter-spacing: 0.3em !important;
}

/* Reading Ruler - Fixed */
.bf-reading-ruler {
  position: fixed;
  left: 0;
  right: 0;
  height: 3px; /* Adjusted height for single line */
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 0, 0, 0.3) 20%,
    rgba(255, 0, 0, 0.8) 50%,
    rgba(255, 0, 0, 0.3) 80%,
    transparent 100%
  );
  z-index: 999998;
  pointer-events: none;
  transition: top 0.1s ease;
  display: none !important;
  box-shadow: 0 0 5px rgba(255, 0, 0, 0.5); /* Softer shadow */
  border-radius: 2px;
  opacity: 0;
  visibility: hidden;
}

body.bf-reading-ruler-active .bf-reading-ruler {
  display: block !important;
  opacity: 1;
  visibility: visible;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .barrierfree-toolbar.expanded {
    position: fixed;
    bottom: 20px;
    top: auto;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: calc(100% - 40px);
    max-width: 350px;
  }

  .barrierfree-toolbar.collapsed {
    width: 56px;
    height: 56px;
    transform: none;
    /* Reset horizontal positioning from the general rule */
    left: auto;
    right: auto;
    top: auto;
    bottom: 20px;
  }

  /* Position the collapsed button based on user settings */
  .barrierfree-toolbar.collapsed.position-left,
  .barrierfree-toolbar.collapsed.position-bottom-left {
    left: 20px;
  }

  .barrierfree-toolbar.collapsed.position-right,
  .barrierfree-toolbar.collapsed.position-bottom-right {
    right: 20px;
  }

  .bf-speech-controls {
    flex-wrap: wrap;
  }

  .bf-speech-btn {
    min-width: 60px;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .barrierfree-toolbar {
    border: 3px solid var(--bf-black);
  }

  .bf-btn {
    border-width: 3px;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .barrierfree-toolbar,
  .bf-btn,
  .bf-reading-highlight,
  .barrierfree-floating-btn {
    transition: none !important;
    animation: none !important;
  }
}

/* Focus Indicators */
.barrierfree-toolbar *:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.3);
}

/* Screen Reader Only */
.bf-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;
}

/* Footer Link Styling */
.bf-footer {
  border-top: 2px solid #f0f0f0 !important;
  border-bottom: none !important;
  padding-top: 16px !important;
  margin-top: 16px !important;
  margin-bottom: 0 !important;
  padding-bottom: 0 !important;
  background: transparent !important;
}

.bf-footer-link {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  color: var(--bf-gray);
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.2s ease;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  justify-content: center;
  border: 2px solid transparent;
}

.bf-footer-link:hover {
  background: linear-gradient(135deg, var(--bf-primary-blue) 0%, #1976d2 100%);
  color: var(--bf-white);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.bf-footer-link:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.3);
}

/* Button Size Classes */
.barrierfree-floating-btn.size-small {
  font-size: 22px;
}

.barrierfree-toolbar.collapsed.size-small {
  width: 56px;
  height: 56px;
}

.barrierfree-floating-btn.size-medium {
  font-size: 28px;
}

.barrierfree-toolbar.collapsed.size-medium {
  width: 64px;
  height: 64px;
}

.barrierfree-floating-btn.size-large {
  font-size: 32px;
}

.barrierfree-toolbar.collapsed.size-large {
  width: 72px;
  height: 72px;
}

/* Button Color Classes */
.barrierfree-toolbar.collapsed.color-blue {
  background: linear-gradient(135deg, var(--bf-primary-blue) 0%, #1976d2 100%);
}

.barrierfree-toolbar.collapsed.color-green {
  background: linear-gradient(135deg, var(--bf-primary-green) 0%, #388e3c 100%);
}

.barrierfree-toolbar.collapsed.color-red {
  background: linear-gradient(135deg, var(--bf-primary-red) 0%, #d32f2f 100%);
}

.barrierfree-toolbar.collapsed.color-purple {
  background: linear-gradient(135deg, var(--bf-primary-purple) 0%, #7b1fa2 100%);
}

.barrierfree-toolbar.collapsed.color-orange {
  background: linear-gradient(135deg, var(--bf-primary-orange) 0%, #f57c00 100%);
}

.barrierfree-toolbar.collapsed.color-teal {
  background: linear-gradient(135deg, var(--bf-primary-teal) 0%, #00796b 100%);
}

.barrierfree-toolbar.collapsed.color-dark {
  background: linear-gradient(135deg, var(--bf-primary-dark) 0%, #212121 100%);
}

/* Accessibility SVG Icon Styling */
.barrierfree-floating-btn svg,
.barrierfree-logo svg {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  fill: currentColor;
}

.barrierfree-floating-btn:hover svg {
  transform: scale(1.1);
}

.barrierfree-floating-btn:active svg {
  transform: scale(0.95);
}

/* Ensure SVG scales properly in different button sizes */
.barrierfree-toolbar.collapsed.size-small svg {
  width: 20px;
  height: 20px;
}

.barrierfree-toolbar.collapsed.size-medium svg {
  width: 24px;
  height: 24px;
}

.barrierfree-toolbar.collapsed.size-large svg {
  width: 28px;
  height: 28px;
}

/* Logo SVG styling */
.barrierfree-logo svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
