/**
 * BWAT Accessibility Toolbar
 * User-controlled accessibility features
 * Version: 1.1.0
 */

/* ============================================
   TOOLBAR BUTTON (Fixed to side of screen)
   ============================================ */
.bwat-toolbar-toggle {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: #0056b3;
    color: #ffffff;
    border: none;
    border-radius: 8px 0 0 8px;
    padding: 15px 10px;
    cursor: pointer;
    z-index: 99998;
    font-size: 18px;
    box-shadow: -2px 2px 8px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-weight: bold;
}

.bwat-toolbar-toggle:hover,
.bwat-toolbar-toggle:focus {
    background: #003d82;
    padding-right: 15px;
    outline: 3px solid #0056b3;
}

.bwat-toolbar-toggle[aria-expanded="true"] {
    background: #003d82;
}

/* ============================================
   TOOLBAR PANEL
   ============================================ */
.bwat-toolbar-panel {
    position: fixed;
    right: -350px;
    top: 0;
    width: 350px;
    height: 100vh;
    background: #ffffff;
    box-shadow: -3px 0 15px rgba(0,0,0,0.2);
    z-index: 99999;
    overflow-y: auto;
    transition: right 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.bwat-toolbar-panel.open {
    right: 0;
}

/* ============================================
   TOOLBAR HEADER
   ============================================ */
.bwat-toolbar-header {
    background: #0056b3;
    color: #ffffff;
    padding: 20px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.bwat-toolbar-title {
    margin: 0 0 5px 0;
    font-size: 20px;
    font-weight: bold;
}

.bwat-toolbar-subtitle {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
}

.bwat-toolbar-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: 2px solid #ffffff;
    color: #ffffff;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    transition: all 0.2s;
}

.bwat-toolbar-close:hover,
.bwat-toolbar-close:focus {
    background: #ffffff;
    color: #0056b3;
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* ============================================
   TOOLBAR CONTENT
   ============================================ */
.bwat-toolbar-content {
    padding: 20px;
}

.bwat-toolbar-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.bwat-toolbar-section:last-child {
    border-bottom: none;
}

.bwat-toolbar-section-title {
    font-size: 16px;
    font-weight: bold;
    margin: 0 0 15px 0;
    color: #333333;
}

/* ============================================
   TOOLBAR CONTROLS
   ============================================ */
.bwat-control {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.bwat-control-label {
    font-size: 14px;
    color: #333333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bwat-control-icon {
    font-size: 18px;
}

/* Toggle Switch */
.bwat-toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.bwat-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.bwat-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cccccc;
    transition: 0.3s;
    border-radius: 26px;
}

.bwat-toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.bwat-toggle input:checked + .bwat-toggle-slider {
    background-color: #0056b3;
}

.bwat-toggle input:focus + .bwat-toggle-slider {
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.3);
}

.bwat-toggle input:checked + .bwat-toggle-slider:before {
    transform: translateX(24px);
}

/* Button Group */
.bwat-button-group {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.bwat-btn {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #0056b3;
    background: #ffffff;
    color: #0056b3;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    text-align: center;
}

.bwat-btn:hover,
.bwat-btn:focus {
    background: #0056b3;
    color: #ffffff;
    outline: 2px solid #0056b3;
    outline-offset: 2px;
}

.bwat-btn.active {
    background: #0056b3;
    color: #ffffff;
}

/* Slider Control */
.bwat-slider-control {
    width: 100%;
}

.bwat-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e0e0e0;
    outline: none;
    margin-top: 8px;
}

.bwat-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #0056b3;
    cursor: pointer;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.bwat-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #0056b3;
    cursor: pointer;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.bwat-slider:focus {
    outline: 2px solid #0056b3;
    outline-offset: 2px;
}

.bwat-slider-value {
    display: inline-block;
    margin-left: 10px;
    font-weight: bold;
    color: #0056b3;
}

/* Reset Button */
.bwat-reset {
    width: 100%;
    padding: 12px;
    background: #d32f2f;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.2s;
}

.bwat-reset:hover,
.bwat-reset:focus {
    background: #b71c1c;
    outline: 3px solid #d32f2f;
    outline-offset: 2px;
}

/* ============================================
   ACCESSIBILITY MODES (Applied to body)
   ============================================ */

/* High Contrast Mode */
body.bwat-high-contrast {
    filter: contrast(1.5);
}

body.bwat-high-contrast-strong {
    background: #000000 !important;
    color: #ffffff !important;
}

body.bwat-high-contrast-strong * {
    background-color: #000000 !important;
    color: #ffffff !important;
    border-color: #ffffff !important;
}

body.bwat-high-contrast-strong a {
    color: #ffff00 !important;
    text-decoration: underline !important;
}

body.bwat-high-contrast-strong img,
body.bwat-high-contrast-strong iframe,
body.bwat-high-contrast-strong video {
    filter: brightness(0.8) contrast(1.2);
}

/* Inverted Colors */
body.bwat-invert {
    filter: invert(1) hue-rotate(180deg);
}

body.bwat-invert img,
body.bwat-invert video,
body.bwat-invert iframe {
    filter: invert(1) hue-rotate(180deg);
}

/* Grayscale */
body.bwat-grayscale {
    filter: grayscale(1);
}

/* Link Highlighting */
body.bwat-highlight-links a {
    background-color: #ffff00 !important;
    color: #000000 !important;
    padding: 2px 4px !important;
    border-radius: 2px !important;
    text-decoration: underline !important;
}

/* Readable Font */
body.bwat-readable-font,
body.bwat-readable-font * {
    font-family: Arial, Helvetica, sans-serif !important;
}

/* Text Spacing */
body.bwat-text-spacing * {
    line-height: 1.8 !important;
    letter-spacing: 0.12em !important;
    word-spacing: 0.16em !important;
}

body.bwat-text-spacing p {
    margin-bottom: 2em !important;
}

/* Hide Images */
body.bwat-hide-images img:not(.bwat-toolbar-icon) {
    opacity: 0.1;
}

/* Cursor Size */
body.bwat-big-cursor,
body.bwat-big-cursor * {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewport="0 0 48 48"><circle cx="24" cy="24" r="20" fill="black"/><circle cx="24" cy="24" r="18" fill="white"/><circle cx="24" cy="24" r="10" fill="black"/></svg>') 24 24, auto !important;
}

/* Text Size */
body.bwat-text-size-120 {
    font-size: 120% !important;
}

body.bwat-text-size-150 {
    font-size: 150% !important;
}

body.bwat-text-size-200 {
    font-size: 200% !important;
}

/* Line Height */
body.bwat-line-height-150 * {
    line-height: 1.5 !important;
}

body.bwat-line-height-175 * {
    line-height: 1.75 !important;
}

body.bwat-line-height-200 * {
    line-height: 2.0 !important;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .bwat-toolbar-panel {
        width: 100%;
        right: -100%;
    }
    
    .bwat-toolbar-toggle {
        top: auto;
        bottom: 20px;
        right: 20px;
        transform: none;
        border-radius: 50%;
        width: 60px;
        height: 60px;
        writing-mode: horizontal-tb;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ============================================
   PRINT - Hide toolbar when printing
   ============================================ */
@media print {
    .bwat-toolbar-toggle,
    .bwat-toolbar-panel {
        display: none !important;
    }
}
