/* ========================================
   ACCESSIBILITY WIDGET - MODERN DESIGN
   ======================================== */

:root {
  --acc-primary: #064fd3;
  --acc-primary-dark: #053ba0;
  --acc-success: #10b981;
  --acc-warning: #f59e0b;
  --acc-danger: #ef4444;
  --acc-bg: #ffffff;
  --acc-text: #1f2937;
  --acc-text-light: #6b7280;
  --acc-border: #e5e7eb;
  --acc-shadow: rgba(0, 0, 0, 0.1);
  --acc-shadow-lg: rgba(0, 0, 0, 0.15);
}

/* Screen Reader Only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ========================================
   WIDGET CONTAINER
   ======================================== */
.accessibility-widget {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ========================================
   TRIGGER BUTTON
   ======================================== */
.accessibility-trigger {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--acc-primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px var(--acc-shadow-lg);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.accessibility-trigger::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.accessibility-trigger:hover::before {
  width: 100px;
  height: 100px;
}

.accessibility-trigger:hover {
  background: var(--acc-primary-dark);
  transform: scale(1.05);
  box-shadow: 0 6px 20px var(--acc-shadow-lg);
}

.accessibility-trigger:focus {
  outline: 3px solid var(--acc-primary);
  outline-offset: 3px;
}

.accessibility-trigger svg {
  position: relative;
  z-index: 1;
  width: 38px;
  height: 38px;
}

/* ========================================
   ACCESSIBILITY PANEL
   ======================================== */
.accessibility-panel {
  position: absolute;
  bottom: 65px;
  left: 0;
  width: 380px;
  max-height: 600px;
  background: var(--acc-bg);
  border-radius: 16px;
  box-shadow: 0 10px 40px var(--acc-shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.accessibility-panel.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* ========================================
   PANEL HEADER
   ======================================== */
.accessibility-header {
  background: linear-gradient(135deg, var(--acc-primary) 0%, var(--acc-primary-dark) 100%);
  color: white;
  padding: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.accessibility-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  color: white;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

.close-btn:focus {
  outline: 2px solid white;
  outline-offset: 2px;
}

/* ========================================
   PANEL CONTENT
   ======================================== */
.accessibility-content {
  padding: 20px;
  max-height: 480px;
  overflow-y: auto;
}

.accessibility-content::-webkit-scrollbar {
  width: 8px;
}

.accessibility-content::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

.accessibility-content::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.accessibility-content::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ========================================
   RESET BUTTON
   ======================================== */
.reset-all-btn {
  width: 100%;
  padding: 12px 16px;
  background: #f1f5f9;
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  color: var(--acc-text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
  transition: all 0.2s;
}

.reset-all-btn:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
  transform: translateY(-2px);
}

.reset-all-btn:focus {
  outline: 2px solid var(--acc-primary);
  outline-offset: 2px;
}

.reset-all-btn svg {
  width: 16px;
  height: 16px;
}

/* ========================================
   ACCESSIBILITY PROFILES
   ======================================== */
.accessibility-profiles {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.acc-profile {
  background: white;
  border: 2px solid var(--acc-border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.acc-profile::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--acc-primary);
  transform: scaleY(0);
  transition: transform 0.3s;
}

.acc-profile:hover {
  border-color: var(--acc-primary);
  box-shadow: 0 4px 12px rgba(6, 79, 211, 0.1);
  transform: translateX(4px);
}

.acc-profile:hover::before {
  transform: scaleY(1);
}

.acc-profile:focus {
  outline: 2px solid var(--acc-primary);
  outline-offset: 2px;
}

.acc-profile.active {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border-color: var(--acc-primary);
  box-shadow: 0 4px 12px rgba(6, 79, 211, 0.15);
}

.acc-profile.active::before {
  transform: scaleY(1);
}

/* Profile Icon */
.profile-icon {
  width: 44px;
  height: 44px;
  min-width: 44px;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--acc-primary);
  transition: all 0.3s;
}

.acc-profile.active .profile-icon {
  background: linear-gradient(135deg, var(--acc-primary) 0%, var(--acc-primary-dark) 100%);
  color: white;
  transform: scale(1.1);
}

.profile-icon svg {
  width: 20px;
  height: 20px;
}

/* Profile Content */
.profile-content {
  flex: 1;
}

.profile-content h3 {
  margin: 0 0 4px 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--acc-text);
}

.profile-content p {
  margin: 0;
  font-size: 13px;
  color: var(--acc-text-light);
  line-height: 1.4;
}

/* Profile Toggle */
.profile-toggle {
  width: 44px;
  height: 24px;
  background: #e5e7eb;
  border-radius: 12px;
  position: relative;
  transition: all 0.3s;
}

.acc-profile.active .profile-toggle {
  background: var(--acc-primary);
}

.toggle-switch {
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.acc-profile.active .toggle-switch {
  left: 22px;
}

/* ========================================
   ACCESSIBILITY MODES
   ======================================== */

/* 1. Dyslexia Mode */
body.dyslexia-mode * {
  font-family: 'OpenDyslexic', 'Comic Sans MS', cursive !important;
}

/* 2. Epilepsy Safe Mode */
body.epilepsy-mode {
  animation: none !important;
}

body.epilepsy-mode *,
body.epilepsy-mode *::before,
body.epilepsy-mode *::after {
  animation: none !important;
  transition: none !important;
  filter: saturate(0.5) brightness(0.9) !important;
}

/* Exclude widget from epilepsy mode effects */
body.epilepsy-mode .accessibility-widget,
body.epilepsy-mode .accessibility-widget * {
  filter: none !important;
}

/* 3. Visual Impairment Mode */
body.visual-impairment-mode {
  font-size: 125% !important;
}

body.visual-impairment-mode * {
  line-height: 1.8 !important;
  letter-spacing: 0.08em !important;
  font-weight: 500 !important;
}

body.visual-impairment-mode .accessibility-widget,
body.visual-impairment-mode .accessibility-widget * {
  font-size: 14px !important;
  line-height: 1.5 !important;
  letter-spacing: normal !important;
}

/* 4. Cognitive Disability Mode */
body.cognitive-mode {
  background: #fdf6e3 !important;
}

body.cognitive-mode p,
body.cognitive-mode h1,
body.cognitive-mode h2,
body.cognitive-mode h3,
body.cognitive-mode h4,
body.cognitive-mode h5,
body.cognitive-mode h6 {
  background: rgba(255, 255, 200, 0.3) !important;
  padding: 8px !important;
  border-radius: 4px !important;
  line-height: 1.8 !important;
}

body.cognitive-mode img,
body.cognitive-mode video {
  opacity: 0.7 !important;
  filter: grayscale(0.3) !important;
}

body.cognitive-mode *,
body.cognitive-mode *::before,
body.cognitive-mode *::after {
  animation: none !important;
  transition: none !important;
}

/* Exclude widget */
body.cognitive-mode .accessibility-widget,
body.cognitive-mode .accessibility-widget * {
  background: white !important;
  opacity: 1 !important;
  filter: none !important;
}

/* 5. ADHD Mode */
body.adhd-mode {
  position: relative;
}

body.adhd-mode *,
body.adhd-mode *::before,
body.adhd-mode *::after {
  animation: none !important;
  transition: none !important;
}

/* ADHD Reading Guide */
.adhd-reading-guide {
  position: fixed;
  left: 0;
  right: 0;
  height: 150px;
  pointer-events: none;
  z-index: 99998;
  transition: top 0.1s ease-out;
}

.adhd-reading-guide::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: transparent;
  border-top: 3px solid var(--acc-primary);
  border-bottom: 3px solid var(--acc-primary);
  box-shadow: 
    0 -9999px 0 9999px rgba(0, 0, 0, 0.7),
    0 9999px 0 9999px rgba(0, 0, 0, 0.7);
}

/* 6. Blindness Mode (High Contrast) */
body.blindness-mode {
  background: #000 !important;
  color: #fff !important;
}

body.blindness-mode *:not(.accessibility-widget):not(.accessibility-widget *) {
  background-color: #000 !important;
  color: #fff !important;
  border-color: #fff !important;
}

body.blindness-mode a:not(.accessibility-widget *) {
  color: #ffff00 !important;
  text-decoration: underline !important;
  font-weight: bold !important;
}

body.blindness-mode *:focus:not(.accessibility-widget *) {
  outline: 4px solid #ffff00 !important;
  outline-offset: 4px !important;
  background-color: #222 !important;
}

body.blindness-mode img:not(.accessibility-widget *) {
  border: 3px solid #fff !important;
  filter: contrast(1.5) brightness(1.2) !important;
}

/* Keep widget visible in blindness mode */
body.blindness-mode .accessibility-trigger {
  background: #ffff00 !important;
  color: #000 !important;
  border: 3px solid #000 !important;
  box-shadow: 0 0 20px rgba(255, 255, 0, 0.8) !important;
}

body.blindness-mode .accessibility-panel {
  background: #1a1a1a !important;
  border: 3px solid #ffff00 !important;
  box-shadow: 0 0 30px rgba(255, 255, 0, 0.5) !important;
}

body.blindness-mode .accessibility-header {
  background: #ffff00 !important;
  color: #000 !important;
}

body.blindness-mode .accessibility-header h2 {
  color: #000 !important;
}

body.blindness-mode .close-btn {
  background: rgba(0, 0, 0, 0.3) !important;
  color: #000 !important;
}

body.blindness-mode .accessibility-content {
  background: #1a1a1a !important;
}

body.blindness-mode .reset-all-btn {
  background: #2a2a2a !important;
  border-color: #666 !important;
  color: #fff !important;
}

body.blindness-mode .acc-profile {
  background: #2a2a2a !important;
  border-color: #666 !important;
}

body.blindness-mode .acc-profile:hover {
  border-color: #ffff00 !important;
}

body.blindness-mode .acc-profile.active {
  background: #333 !important;
  border-color: #ffff00 !important;
}

body.blindness-mode .profile-icon {
  background: #444 !important;
  color: #fff !important;
}

body.blindness-mode .acc-profile.active .profile-icon {
  background: #ffff00 !important;
  color: #000 !important;
}

body.blindness-mode .profile-content h3 {
  color: #fff !important;
}

body.blindness-mode .profile-content p {
  color: #ccc !important;
}

body.blindness-mode .profile-toggle {
  background: #444 !important;
}

body.blindness-mode .acc-profile.active .profile-toggle {
  background: #ffff00 !important;
}

body.blindness-mode .toggle-switch {
  background: #666 !important;
}

body.blindness-mode .acc-profile.active .toggle-switch {
  background: #000 !important;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media (max-width: 768px) {
  .accessibility-widget {
    bottom: 80px;
    left: 15px;
  }

  .accessibility-trigger {
    width: 56px;
    height: 56px;
  }

  .accessibility-trigger svg {
    width: 24px;
    height: 24px;
  }

  .accessibility-panel {
    width: calc(100vw - 30px);
    max-width: 360px;
    bottom: 70px;
  }
}

@media (max-width: 480px) {
  .accessibility-panel {
    width: calc(100vw - 20px);
    left: -5px;
  }

  .accessibility-content {
    max-height: 400px;
  }

  .acc-profile {
    padding: 12px;
  }

  .profile-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
  }

  .profile-content h3 {
    font-size: 14px;
  }

  .profile-content p {
    font-size: 12px;
  }
}
