/**
 * Accessibility Toolbar Styles
 * Sistema completo di accessibilità WCAG 2.1 AA
 */

/* ========================================
   TOOLBAR BASE
   ======================================== */

.accessibility-toolbar {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 99999;
    transition: transform 0.3s ease;
}

.accessibility-toolbar.collapsed .accessibility-panel {
    transform: translateY(-20px) scale(0.95);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Toggle Button */
.accessibility-toggle {
    position: relative;
    left: 0;
    top: 0;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.accessibility-toggle:hover,
.accessibility-toggle:focus {
    background: linear-gradient(135deg, #1976d2 0%, #0d47a1 100%);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transform: scale(1.1);
}

.accessibility-toggle:focus {
    outline: 3px solid #fff;
    outline-offset: 2px;
}

/* Panel */
.accessibility-panel {
    position: absolute;
    top: 60px;
    right: 0;
    width: 350px;
    max-height: 90vh;
    background: white;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    overflow-y: auto;
    transition: transform 0.3s ease, visibility 0.3s ease;
    visibility: visible;
}

/* Scrollbar styling */
.accessibility-panel::-webkit-scrollbar {
    width: 8px;
}

.accessibility-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.accessibility-panel::-webkit-scrollbar-thumb {
    background: #2196f3;
    border-radius: 4px;
}

.accessibility-panel::-webkit-scrollbar-thumb:hover {
    background: #1976d2;
}

/* ========================================
   HEADER
   ======================================== */

.accessibility-header {
    background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.accessibility-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
}

.accessibility-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.accessibility-close:hover,
.accessibility-close:focus {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.accessibility-close:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* ========================================
   CONTENT
   ======================================== */

.accessibility-content {
    padding: 1rem;
}

.accessibility-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
}

.accessibility-section:last-of-type {
    border-bottom: none;
}

.section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
}

/* ========================================
   BUTTONS
   ======================================== */

/* Font Size Buttons */
.btn-group-custom {
    display: flex;
    gap: 0.5rem;
    justify-content: space-between;
}

.btn-accessibility {
    flex: 1;
    background: #f5f5f5;
    border: 2px solid #e0e0e0;
    padding: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
    min-height: 44px;
    min-width: 44px;
}

.btn-accessibility:hover {
    background: #e3f2fd;
    border-color: #2196f3;
    transform: translateY(-2px);
}

.btn-accessibility:focus {
    outline: 3px solid #2196f3;
    outline-offset: 2px;
}

.btn-accessibility.active {
    background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
    border-color: #1976d2;
    color: white;
    font-weight: 600;
}

/* Feature Buttons */
.controls-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.btn-accessibility-feature {
    background: white;
    border: 2px solid #e0e0e0;
    padding: 1rem 0.5rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    font-size: 0.85rem;
}

.btn-accessibility-feature:hover {
    background: #f5f5f5;
    border-color: #2196f3;
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.2);
}

.btn-accessibility-feature:focus {
    outline: 3px solid #2196f3;
    outline-offset: 2px;
}

.btn-accessibility-feature.active {
    background: linear-gradient(135deg, #4caf50 0%, #388e3c 100%);
    border-color: #388e3c;
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.btn-accessibility-feature i {
    color: #666;
    transition: color 0.2s ease;
}

.btn-accessibility-feature.active i {
    color: white;
}

/* Reset Button */
.btn-reset {
    width: 100%;
    background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
    border: none;
    color: white;
    padding: 0.75rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
    font-size: 1rem;
}

.btn-reset:hover {
    background: linear-gradient(135deg, #f57c00 0%, #e65100 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.3);
}

.btn-reset:focus {
    outline: 3px solid #ff9800;
    outline-offset: 2px;
}

/* ========================================
   INFO
   ======================================== */

.accessibility-info {
    margin-top: 1rem;
    padding: 0.75rem;
    background: #e3f2fd;
    border-radius: 8px;
    text-align: center;
}

/* ========================================
   ACCESSIBILITY FEATURES STYLES
   ======================================== */

/* Font Sizes */
body.font-small {
    font-size: 14px !important;
}

body.font-large {
    font-size: 18px !important;
}

body.font-xlarge {
    font-size: 22px !important;
}

/* High Contrast */
body.high-contrast {
    filter: contrast(200%);
}

body.high-contrast *:not(.accessibility-toolbar *) {
    background-color: black !important;
    color: white !important;
    border-color: white !important;
}

body.high-contrast a:not(.accessibility-toolbar a) {
    color: yellow !important;
}

/* Grayscale */
body.grayscale {
    filter: grayscale(100%);
}

/* Highlight Links */
body.highlight-links a:not(.accessibility-toolbar a) {
    background-color: yellow !important;
    color: black !important;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 600;
}

/* Underline Links */
body.underline-links a:not(.accessibility-toolbar a) {
    text-decoration: underline !important;
    text-decoration-thickness: 2px !important;
    text-underline-offset: 3px !important;
}

/* Dyslexic Font */
body.dyslexic-font {
    font-family: 'OpenDyslexic', 'Comic Sans MS', cursive !important;
}

body.dyslexic-font * {
    font-family: 'OpenDyslexic', 'Comic Sans MS', cursive !important;
}

/* Increased Line Height */
body.increased-line-height {
    line-height: 2 !important;
}

body.increased-line-height * {
    line-height: 2 !important;
}

/* Increased Letter Spacing */
body.increased-letter-spacing {
    letter-spacing: 0.15em !important;
}

body.increased-letter-spacing * {
    letter-spacing: 0.15em !important;
}

/* Reading Guide */
.reading-guide {
    position: fixed;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent 0%, #ff0000 50%, transparent 100%);
    pointer-events: none;
    z-index: 99998;
    display: none;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
}

.reading-guide::before {
    content: '';
    position: absolute;
    left: 0;
    top: -20px;
    width: 100%;
    height: 40px;
    background: rgba(255, 255, 0, 0.2);
    border-top: 1px dashed rgba(255, 0, 0, 0.5);
    border-bottom: 1px dashed rgba(255, 0, 0, 0.5);
}

.reading-guide.active {
    display: block;
}

/* Big Cursor */
body.big-cursor,
body.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 2 L2 28 L12 22 L16 30 L20 28 L16 20 L26 20 Z" fill="black" stroke="white" stroke-width="2"/></svg>') 2 2, auto !important;
}

/* ========================================
   TEXT-TO-SPEECH CONTROLS
   ======================================== */

.tts-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.btn-tts-main,
.btn-tts-secondary {
    width: 100%;
    background: linear-gradient(135deg, #9c27b0 0%, #7b1fa2 100%);
    border: none;
    color: white;
    padding: 0.75rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-tts-main:hover,
.btn-tts-secondary:hover {
    background: linear-gradient(135deg, #7b1fa2 0%, #6a1b9a 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(156, 39, 176, 0.3);
}

.btn-tts-main:focus,
.btn-tts-secondary:focus {
    outline: 3px solid #9c27b0;
    outline-offset: 2px;
}

.btn-tts-secondary {
    background: linear-gradient(135deg, #673ab7 0%, #512da8 100%);
}

.btn-tts-secondary:hover {
    background: linear-gradient(135deg, #512da8 0%, #4527a0 100%);
    box-shadow: 0 4px 12px rgba(103, 58, 183, 0.3);
}

/* TTS Player */
.tts-player {
    background: #f3e5f5;
    border-radius: 10px;
    padding: 1rem;
    margin: 0.75rem 0;
}

.tts-player-header {
    margin-bottom: 0.75rem;
}

.tts-status {
    display: flex;
    align-items: center;
    color: #7b1fa2;
    font-weight: 600;
    font-size: 0.9rem;
}

.tts-player-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.btn-tts-control {
    flex: 1;
    background: white;
    border: 2px solid #9c27b0;
    color: #9c27b0;
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
    min-width: 44px;
    font-size: 1.1rem;
}

.btn-tts-control:hover {
    background: #9c27b0;
    color: white;
    transform: scale(1.05);
}

.btn-tts-control:focus {
    outline: 3px solid #9c27b0;
    outline-offset: 2px;
}

/* Speed Control */
.tts-speed-control {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tts-speed-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #7b1fa2;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tts-speed-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e1bee7;
    outline: none;
    -webkit-appearance: none;
}

.tts-speed-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #9c27b0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tts-speed-slider::-webkit-slider-thumb:hover {
    background: #7b1fa2;
    transform: scale(1.2);
}

.tts-speed-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #9c27b0;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.tts-speed-slider::-moz-range-thumb:hover {
    background: #7b1fa2;
    transform: scale(1.2);
}

.tts-speed-slider:focus {
    outline: none;
}

.tts-speed-slider:focus::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px rgba(156, 39, 176, 0.3);
}

.tts-speed-slider:focus::-moz-range-thumb {
    box-shadow: 0 0 0 3px rgba(156, 39, 176, 0.3);
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .accessibility-panel {
        width: 300px;
    }
    
    .controls-grid {
        grid-template-columns: 1fr;
    }
    
    .btn-group-custom {
        flex-wrap: wrap;
    }
}

@media (max-height: 600px) {
    .accessibility-panel {
        max-height: 80vh;
    }
}

/* ========================================
   PRINT
   ======================================== */

@media print {
    .accessibility-toolbar {
        display: none !important;
    }
    
    .reading-guide {
        display: none !important;
    }
}

/* ========================================
   REDUCED MOTION
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    .accessibility-toolbar,
    .accessibility-panel,
    .accessibility-toggle,
    .btn-accessibility,
    .btn-accessibility-feature,
    .btn-reset {
        transition: none !important;
        animation: none !important;
    }
}

/* ========================================
   HIGH CONTRAST MODE (OS)
   ======================================== */

@media (prefers-contrast: high) {
    .accessibility-panel {
        border: 3px solid currentColor;
    }
    
    .btn-accessibility,
    .btn-accessibility-feature,
    .btn-reset {
        border-width: 3px;
    }
}

