/* ============================================================
   DocuForte Accessibility Panel — accessibility.css
   All classes scoped with .acc-* to prevent conflicts
   ============================================================ */


body > *:not(#acc-panel):not(#acc-overlay) { filter: saturate(80%) !important; }

/* ── Trigger Button (navbar icon) ── */
.acc-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  color: inherit;
  font-size: 22px;
  transition: background 0.2s, color 0.2s;
  position: relative;
  z-index: 9990;
  border: 1px solid #e8302c;
}
.acc-trigger:hover {
  background: rgba(0, 0, 0, 0.07);
}
.acc-trigger:focus-visible {
  outline: 2px solid #0d6efd;
  outline-offset: 2px;
}

/* ── Overlay ── */
.acc-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.acc-overlay.acc-open {
  display: block;
}
.acc-overlay.acc-visible {
  opacity: 1;
}

/* ── Panel ── */
.acc-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 360px;
  max-width: 100vw;
  height: 100vh;
  background: #ffffff;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
  z-index: 10001;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}
.acc-panel.acc-open {
  transform: translateX(0);
}

/* ── Panel Header ── */
.acc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid #e8e8e8;
  flex-shrink: 0;
  background: #f8f9fa;
}
.acc-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.acc-header-icon {
  font-size: 22px;
  color: #0d6efd;
}
.acc-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #1a1a2e;
  letter-spacing: 0.01em;
}
.acc-header p {
  margin: 2px 0 0;
  font-size: 11px;
  color: #6c757d;
}
.acc-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  color: #6c757d;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
  padding: 0;
}
.acc-close-btn:hover {
  background: #e9ecef;
  color: #1a1a2e;
}
.acc-close-btn:focus-visible {
  outline: 2px solid #0d6efd;
  outline-offset: 2px;
}

/* ── Panel Body (scrollable) ── */
.acc-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 24px;
  scrollbar-width: thin;
  scrollbar-color: #dee2e6 transparent;
}
.acc-body::-webkit-scrollbar {
  width: 5px;
}
.acc-body::-webkit-scrollbar-thumb {
  background: #dee2e6;
  border-radius: 10px;
}

/* ── Section Labels ── */
.acc-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #6c757d;
  margin: 20px 0 10px 2px;
}
.acc-section-label:first-of-type {
  margin-top: 4px;
}

/* ── Card Grid ── */
.acc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.acc-grid-full {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

/* ── Base Card ── */
.acc-card {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 10px;
  padding: 12px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s;
}
.acc-card:hover {
  border-color: #c8d1d9;
}
.acc-card-title {
  font-size: 11px;
  font-weight: 600;
  color: #495057;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.acc-card-title i {
  font-size: 13px;
  color: #0d6efd;
}

/* ── Counter Controls (font size etc.) ── */
.acc-counter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.acc-counter-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid #dee2e6;
  background: #ffffff;
  color: #1a1a2e;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
  line-height: 1;
}
.acc-counter-btn:hover {
  background: #e9ecef;
  border-color: #adb5bd;
}
.acc-counter-btn:active {
  background: #dee2e6;
}
.acc-counter-val {
  font-size: 12px;
  font-weight: 600;
  color: #1a1a2e;
  min-width: 32px;
  text-align: center;
}

/* ── Toggle Switch ── */
.acc-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.acc-toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.acc-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.acc-toggle-slider {
  position: absolute;
  inset: 0;
  background: #ced4da;
  border-radius: 22px;
  cursor: pointer;
  transition: background 0.25s;
}
.acc-toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  left: 3px;
  top: 3px;
  transition: transform 0.25s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.acc-toggle input:checked + .acc-toggle-slider {
  background: #0d6efd;
}
.acc-toggle input:checked + .acc-toggle-slider::before {
  transform: translateX(18px);
}
.acc-toggle input:focus-visible + .acc-toggle-slider {
  outline: 2px solid #0d6efd;
  outline-offset: 2px;
}

/* ── Slider ── */
.acc-slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.acc-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: #dee2e6;
  border-radius: 4px;
  cursor: pointer;
  outline: none;
  flex: 1;
}
.acc-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #0d6efd;
  cursor: pointer;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.acc-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #0d6efd;
  cursor: pointer;
  border: 2px solid #ffffff;
}
.acc-slider:focus-visible {
  outline: 2px solid #0d6efd;
}
.acc-slider-val {
  font-size: 11px;
  font-weight: 600;
  color: #495057;
  min-width: 26px;
  text-align: right;
}

/* ── TTS Card ── */
.acc-tts-instruction {
  font-size: 11px;
  color: #6c757d;
  line-height: 1.5;
}
.acc-tts-controls {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.acc-tts-btn {
  flex: 1;
  min-width: 60px;
  padding: 6px 8px;
  border-radius: 7px;
  border: 1px solid #dee2e6;
  background: #ffffff;
  font-size: 11px;
  font-weight: 600;
  color: #495057;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background 0.15s, border-color 0.15s;
}
.acc-tts-btn:hover {
  background: #e9ecef;
  border-color: #adb5bd;
}
.acc-tts-btn.acc-active {
  background: #0d6efd;
  color: #ffffff;
  border-color: #0d6efd;
}
.acc-tts-btn i { font-size: 12px; }

/* ── Reset Button ── */
.acc-reset-btn {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1.5px solid #dc3545;
  background: transparent;
  color: #dc3545;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.2s, color 0.2s;
  margin-top: 8px;
}
.acc-reset-btn:hover {
  background: #dc3545;
  color: #ffffff;
}
.acc-reset-btn i { font-size: 14px; }

/* ── Active state for toggle cards ── */
.acc-card.acc-card-active {
  border-color: #0d6efd;
  background: #eef3ff;
}
.acc-card.acc-card-active .acc-card-title {
  color: #0d6efd;
}

/* ── TTS status badge ── */
.acc-tts-status {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 600;
  background: #e9ecef;
  color: #6c757d;
  display: inline-block;
  margin-left: 4px;
}
.acc-tts-status.reading {
  background: #d1e7dd;
  color: #0a5c36;
}

/* ── Responsive ── */
@media (max-width: 400px) {
  .acc-panel {
    width: 100vw;
  }
  .acc-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Dark mode support for panel itself ── */
/* Triggered by body.dark-mode (the panel's own Dark Mode toggle) */
body.dark-mode .acc-panel {
  background: #1e2130;
  box-shadow: -4px 0 24px rgba(0,0,0,0.5);
}
body.dark-mode .acc-header {
  background: #181a28;
  border-bottom-color: #2e3248;
}
body.dark-mode .acc-header h2 { color: #e9ecef; }
body.dark-mode .acc-header p  { color: #8892a0; }
body.dark-mode .acc-close-btn { color: #8892a0; }
body.dark-mode .acc-close-btn:hover { background: #2e3248; color: #e9ecef; }
body.dark-mode .acc-section-label { color: #8892a0; }
body.dark-mode .acc-card { background: #252840; border-color: #2e3248; }
body.dark-mode .acc-card:hover { border-color: #4a5070; }
body.dark-mode .acc-card-title { color: #ced4da; }
body.dark-mode .acc-counter-btn { background: #1e2130; border-color: #3a3f55; color: #e9ecef; }
body.dark-mode .acc-counter-btn:hover { background: #2e3248; }
body.dark-mode .acc-counter-val { color: #e9ecef; }
body.dark-mode .acc-toggle-slider { background: #3a3f55; }
body.dark-mode .acc-slider { background: #3a3f55; }
body.dark-mode .acc-slider-val { color: #ced4da; }
body.dark-mode .acc-tts-instruction { color: #8892a0; }
body.dark-mode .acc-tts-btn { background: #1e2130; border-color: #3a3f55; color: #ced4da; }
body.dark-mode .acc-tts-btn:hover { background: #2e3248; }
body.dark-mode .acc-card.acc-card-active { border-color: #4d7cf6; background: #1a2040; }
body.dark-mode .acc-card.acc-card-active .acc-card-title { color: #6da3ff; }
body.dark-mode .acc-tts-status { background: #2e3248; color: #8892a0; }
body.dark-mode .acc-body { scrollbar-color: #3a3f55 transparent; }
body.dark-mode .acc-body::-webkit-scrollbar-thumb { background: #3a3f55; }
body.dark-mode .acc-reset-btn { border-color: #e05260; color: #e05260; }
body.dark-mode .acc-reset-btn:hover { background: #e05260; color: #ffffff; }

/* ==============================
   APPLIED EFFECTS (on <html>)
   ============================== */

/* Dark Mode */
html.acc-dark-mode {
  filter: invert(1) hue-rotate(180deg);
}
html.acc-dark-mode img,
html.acc-dark-mode video,
html.acc-dark-mode iframe,
html.acc-dark-mode .acc-panel,
html.acc-dark-mode .acc-overlay {
  filter: invert(1) hue-rotate(180deg);
}

/* Invert Colors */
html.acc-invert {
  filter: invert(1);
}
html.acc-invert img,
html.acc-invert video,
html.acc-invert iframe {
  filter: invert(1);
}

/* Dyslexia Font */
html.acc-dyslexia * {
  font-family: 'OpenDyslexic', 'Comic Sans MS', 'Arial', sans-serif !important;
}

/* ADHD Mode */
html.acc-adhd * {
  letter-spacing: 0.06em !important;
  word-spacing: 0.2em !important;
  line-height: 1.9 !important;
}
html.acc-adhd p,
html.acc-adhd li,
html.acc-adhd td {
  max-width: 75ch !important;
}

/* Highlight Links */
html.acc-highlight-links a {
  outline: 2px solid #f90 !important;
  outline-offset: 2px !important;
  background: rgba(255, 153, 0, 0.12) !important;
  border-radius: 2px !important;
}

/* Large Cursor */
html.acc-large-cursor,
html.acc-large-cursor * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cpolygon points='4,4 4,28 10,22 14,34 18,32 14,20 22,20' fill='black' stroke='white' stroke-width='1.5'/%3E%3C/svg%3E") 4 4, auto !important;
}

/* ── Font Size A- / A / A+ buttons ── */
.acc-fs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.acc-fs-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 6px 4px;
  border-radius: 7px;
  border: 1px solid #dee2e6;
  background: #ffffff;
  color: #1a1a2e;
  cursor: pointer;
  font-weight: 700;
  line-height: 1;
  transition: background 0.15s, border-color 0.15s;
}
.acc-fs-btn:hover {
  background: #e9ecef;
  border-color: #adb5bd;
}
.acc-fs-btn:active {
  background: #dee2e6;
}
.acc-fs-btn sup {
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  margin-top: -6px;
}
.acc-fs-a {
  font-weight: 700;
  line-height: 1;
  color: #1a1a2e;
}
.acc-fs-a-sm { font-size: 11px; }
.acc-fs-a-md { font-size: 14px; }
.acc-fs-a-lg { font-size: 18px; }
.acc-fs-btn-reset .acc-fs-a-md {
  color: #495057;
}

body.dark-mode .acc-fs-btn { background: #1e2130; border-color: #3a3f55; color: #e9ecef; }
body.dark-mode .acc-fs-btn:hover { background: #2e3248; }
body.dark-mode .acc-fs-a { color: #e9ecef; }