/**
 * WCAG 2.2 Accessibility Toolbar - Compact Professional Styles
 * @version 1.1.0
 */

/* ============================================================================
   CSS VARIABLES
   ============================================================================ */
:root {
    --wcag-toolbar-bg: #ffffff;
    --wcag-toolbar-border: #e0e0e0;
    --wcag-toolbar-shadow: 0 2px 8px rgba(0,0,0,0.08);
    --wcag-btn-bg: #f5f5f5;
    --wcag-btn-color: #333;
    --wcag-btn-hover-bg: #e8e8e8;
    --wcag-btn-active-bg: #2563eb;
    --wcag-btn-active-color: #fff;
    --wcag-focus-color: #2563eb;
    --wcag-panel-bg: #fff;
    --wcag-panel-overlay: rgba(0,0,0,0.4);
    --wcag-toggle-bg: #d1d5db;
    --wcag-toggle-active: #2563eb;
}

/* ============================================================================
   SCREEN READER ONLY
   ============================================================================ */
.wcag-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0,0,0,0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ============================================================================
   TOOLBAR - COMPACT HORIZONTAL LAYOUT
   ============================================================================ */
.wcag-toolbar {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 6px !important;
    background: var(--wcag-toolbar-bg);
    border: 1px solid var(--wcag-toolbar-border);
    border-radius: 8px;
    padding: 6px 10px !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 13px;
    box-shadow: var(--wcag-toolbar-shadow);
    box-sizing: border-box;
    width: auto !important;
    max-width: 100%;
}

.wcag-toolbar *,
.wcag-toolbar *::before,
.wcag-toolbar *::after {
    box-sizing: border-box;
}

.wcag-toolbar-inner {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 4px !important;
    flex-wrap: nowrap !important;
}

/* ============================================================================
   TOOLBAR POSITIONS
   ============================================================================ */
.wcag-toolbar-fixed-top {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999999;
}

.wcag-toolbar-fixed-bottom {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999999;
}

.wcag-toolbar-sticky-top {
    position: sticky;
    top: 10px;
    z-index: 999999;
}

/* ============================================================================
   TOOL CONTAINERS
   ============================================================================ */
.wcag-tool {
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    flex-shrink: 0;
}

.wcag-tool-label {
    font-size: 11px;
    font-weight: 500;
    color: #666;
    white-space: nowrap;
    display: none; /* Hide by default for compact view */
}

/* Hide labels class */
.wcag-hide-labels .wcag-btn-label,
.wcag-hide-labels .wcag-tool-label {
    display: none !important;
}

/* ============================================================================
   BUTTONS - COMPACT STYLE
   ============================================================================ */
.wcag-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    min-height: 32px !important;
    min-width: 32px !important;
    padding: 4px 8px !important;
    background: var(--wcag-btn-bg) !important;
    color: var(--wcag-btn-color) !important;
    border: 1px solid transparent !important;
    border-radius: 6px !important;
    font-family: inherit !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    line-height: 1 !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}

.wcag-btn:hover {
    background: var(--wcag-btn-hover-bg) !important;
}

.wcag-btn:focus {
    outline: 2px solid var(--wcag-focus-color) !important;
    outline-offset: 1px !important;
}

.wcag-btn:focus:not(:focus-visible) {
    outline: none !important;
}

.wcag-btn[aria-pressed="true"],
.wcag-btn.active {
    background: var(--wcag-btn-active-bg) !important;
    color: var(--wcag-btn-active-color) !important;
}

/* Button labels - hide for compact */
.wcag-btn-label {
    display: none;
}

/* Show labels when space allows */
@media (min-width: 600px) {
    .wcag-toolbar:not(.wcag-hide-labels) .wcag-btn-label {
        display: inline;
    }
}

/* ============================================================================
   BUTTON GROUP - FONT SIZE
   ============================================================================ */
.wcag-btn-group {
    display: inline-flex !important;
    border-radius: 6px !important;
    overflow: hidden !important;
    border: 1px solid var(--wcag-toolbar-border) !important;
}

.wcag-btn-group .wcag-btn {
    border-radius: 0 !important;
    border: none !important;
    min-width: 28px !important;
    padding: 4px 6px !important;
    margin: 0 !important;
}

.wcag-btn-group .wcag-btn:not(:last-child) {
    border-right: 1px solid var(--wcag-toolbar-border) !important;
}

.wcag-btn-group .wcag-btn:first-child {
    border-radius: 5px 0 0 5px !important;
}

.wcag-btn-group .wcag-btn:last-child {
    border-radius: 0 5px 5px 0 !important;
}

/* ============================================================================
   ICONS
   ============================================================================ */
.wcag-icon {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 16px !important;
    height: 16px !important;
    flex-shrink: 0 !important;
}

.wcag-icon svg {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
}

/* Dark mode icon toggle */
.wcag-btn[aria-pressed="true"] .wcag-icon-moon,
.wcag-btn.active .wcag-icon-moon {
    display: none !important;
}

.wcag-icon-sun {
    display: none !important;
}

.wcag-btn[aria-pressed="true"] .wcag-icon-sun,
.wcag-btn.active .wcag-icon-sun {
    display: inline-flex !important;
}

/* ============================================================================
   DIVIDER
   ============================================================================ */
.wcag-divider {
    width: 1px;
    height: 20px;
    background: var(--wcag-toolbar-border);
    margin: 0 2px;
}

/* ============================================================================
   FLOATING BUTTON
   ============================================================================ */
.wcag-floating-trigger {
    position: fixed;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--wcag-btn-active-bg);
    color: #fff;
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 999999;
}

.wcag-floating-trigger:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.wcag-floating-trigger:focus {
    outline: 3px solid var(--wcag-focus-color);
    outline-offset: 2px;
}

.wcag-floating-trigger .wcag-icon {
    width: 24px !important;
    height: 24px !important;
}

.wcag-floating-trigger.position-top-left { top: 15px; left: 15px; }
.wcag-floating-trigger.position-top-right { top: 15px; right: 15px; }
.wcag-floating-trigger.position-bottom-left { bottom: 15px; left: 15px; }
.wcag-floating-trigger.position-bottom-right { bottom: 15px; right: 15px; }

/* ============================================================================
   PANEL
   ============================================================================ */
.wcag-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999999;
}

.wcag-panel[hidden] {
    display: none !important;
}

.wcag-panel-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--wcag-panel-overlay);
}

.wcag-panel-content {
    position: relative;
    width: 420px;
    max-width: 95vw;
    max-height: 85vh;
    background: var(--wcag-panel-bg);
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.wcag-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e5e5;
}

.wcag-panel-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #111;
}

.wcag-panel-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #666;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.wcag-panel-close:hover {
    background: #f0f0f0;
    color: #111;
}

.wcag-panel-close:focus {
    outline: 2px solid var(--wcag-focus-color);
    outline-offset: 1px;
}

.wcag-panel-close svg {
    width: 20px;
    height: 20px;
}

.wcag-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.wcag-panel-section {
    margin-bottom: 20px;
}

.wcag-panel-section:last-child {
    margin-bottom: 0;
}

.wcag-panel-section h3 {
    margin: 0 0 12px 0;
    font-size: 11px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wcag-panel-footer {
    padding: 12px 20px;
    border-top: 1px solid #e5e5e5;
    text-align: center;
}

/* ============================================================================
   PANEL OPTIONS
   ============================================================================ */
.wcag-option {
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.wcag-option:last-child {
    border-bottom: none;
}

/* ============================================================================
   TOGGLE SWITCH
   ============================================================================ */
.wcag-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.wcag-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.wcag-switch-slider {
    position: relative;
    width: 40px;
    height: 22px;
    background: var(--wcag-toggle-bg);
    border-radius: 11px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.wcag-switch-slider::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.wcag-switch input:checked + .wcag-switch-slider {
    background: var(--wcag-toggle-active);
}

.wcag-switch input:checked + .wcag-switch-slider::before {
    transform: translateX(18px);
}

.wcag-switch input:focus + .wcag-switch-slider {
    outline: 2px solid var(--wcag-focus-color);
    outline-offset: 2px;
}

.wcag-switch-label {
    font-size: 13px;
    font-weight: 500;
    color: #333;
}

/* ============================================================================
   RANGE SLIDER
   ============================================================================ */
.wcag-range-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #333;
}

.wcag-option input[type="range"] {
    width: 100%;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
}

.wcag-option input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--wcag-btn-active-bg);
    border-radius: 50%;
    cursor: pointer;
}

.wcag-option input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--wcag-btn-active-bg);
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.wcag-option input[type="range"]:focus {
    outline: 2px solid var(--wcag-focus-color);
    outline-offset: 2px;
}

.wcag-range-value {
    display: inline-block;
    margin-top: 6px;
    padding: 2px 6px;
    background: #f5f5f5;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    color: #666;
}

/* ============================================================================
   COLOR PROFILES
   ============================================================================ */
.wcag-color-profiles {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.wcag-color-profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    background: #f8f8f8;
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    font-size: 10px;
    font-weight: 500;
    color: #666;
}

.wcag-color-profile:hover {
    background: #f0f0f0;
}

.wcag-color-profile:focus {
    outline: 2px solid var(--wcag-focus-color);
    outline-offset: 1px;
}

.wcag-color-profile[aria-pressed="true"] {
    border-color: var(--wcag-btn-active-bg);
    background: #fff;
}

.wcag-profile-preview {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e63946 25%, #2a9d8f 25%, #2a9d8f 50%, #e9c46a 50%, #e9c46a 75%, #264653 75%);
}

.wcag-color-profile[data-profile="protanopia"] .wcag-profile-preview { filter: url(#wcag-protanopia-filter); }
.wcag-color-profile[data-profile="deuteranopia"] .wcag-profile-preview { filter: url(#wcag-deuteranopia-filter); }
.wcag-color-profile[data-profile="tritanopia"] .wcag-profile-preview { filter: url(#wcag-tritanopia-filter); }

/* ============================================================================
   READING GUIDE
   ============================================================================ */
.wcag-reading-guide {
    position: fixed;
    left: 0;
    right: 0;
    height: 40px;
    background: rgba(255, 255, 0, 0.15);
    pointer-events: none;
    z-index: 999998;
    transition: top 0.05s ease-out;
}

/* ============================================================================
   ACCESSIBILITY FEATURE CLASSES
   ============================================================================ */
.wcag-dark-mode {
    filter: invert(1) hue-rotate(180deg);
}

.wcag-dark-mode img,
.wcag-dark-mode video,
.wcag-dark-mode picture,
.wcag-dark-mode canvas,
.wcag-dark-mode svg:not(.wcag-icon svg):not(#wcag-svg-filters) {
    filter: invert(1) hue-rotate(180deg);
}

.wcag-high-contrast {
    filter: contrast(1.5);
}

.wcag-invert-colors {
    filter: invert(1);
}

.wcag-invert-colors img,
.wcag-invert-colors video {
    filter: invert(1);
}

.wcag-grayscale {
    filter: grayscale(100%);
}

.wcag-font-scaled {
    font-size: calc(1rem * var(--wcag-font-scale, 1));
}

.wcag-highlight-links a {
    background-color: #ffff00 !important;
    color: #000 !important;
    text-decoration: underline !important;
    padding: 1px 3px;
}

.wcag-big-cursor,
.wcag-big-cursor * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cpath fill='%23000' stroke='%23fff' stroke-width='2' d='M8 8l28 12-12 4-4 12z'/%3E%3C/svg%3E") 8 8, auto !important;
}

.wcag-dyslexia-font,
.wcag-dyslexia-font * {
    font-family: OpenDyslexic, Comic Sans MS, Arial, sans-serif !important;
}

.wcag-custom-line-height,
.wcag-custom-line-height * {
    line-height: var(--wcag-line-height, 1.5) !important;
}

.wcag-custom-letter-spacing,
.wcag-custom-letter-spacing * {
    letter-spacing: var(--wcag-letter-spacing, 0) !important;
}

.wcag-custom-word-spacing,
.wcag-custom-word-spacing * {
    word-spacing: var(--wcag-word-spacing, 0) !important;
}

.wcag-enhanced-focus *:focus {
    outline: 3px solid var(--wcag-focus-color) !important;
    outline-offset: 2px !important;
}

.wcag-hide-images img,
.wcag-hide-images picture,
.wcag-hide-images svg:not(.wcag-icon svg):not(#wcag-svg-filters),
.wcag-hide-images video {
    opacity: 0.1 !important;
}

.wcag-stop-animations *,
.wcag-stop-animations *::before,
.wcag-stop-animations *::after {
    animation: none !important;
    transition: none !important;
}

.wcag-protanopia { filter: url(#wcag-protanopia-filter); }
.wcag-deuteranopia { filter: url(#wcag-deuteranopia-filter); }
.wcag-tritanopia { filter: url(#wcag-tritanopia-filter); }

/* ============================================================================
   SLIDE PANELS
   ============================================================================ */
.wcag-panel-slide-left .wcag-panel-content {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    max-width: 320px;
    border-radius: 0 12px 12px 0;
}

.wcag-panel-slide-right .wcag-panel-content {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    max-width: 320px;
    border-radius: 12px 0 0 12px;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */
@media (max-width: 480px) {
    .wcag-toolbar {
        padding: 4px 6px !important;
        gap: 4px !important;
    }
    
    .wcag-toolbar-inner {
        gap: 2px !important;
    }
    
    .wcag-btn {
        min-height: 28px !important;
        min-width: 28px !important;
        padding: 3px 5px !important;
    }
    
    .wcag-icon {
        width: 14px !important;
        height: 14px !important;
    }
    
    .wcag-panel-content {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    
    .wcag-color-profiles {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================================================
   PRINT
   ============================================================================ */
@media print {
    .wcag-toolbar,
    .wcag-panel,
    .wcag-floating-trigger,
    .wcag-reading-guide {
        display: none !important;
    }
}

/* ============================================================================
   REDUCED MOTION
   ============================================================================ */
@media (prefers-reduced-motion: reduce) {
    .wcag-toolbar *,
    .wcag-panel * {
        transition: none !important;
    }
}

/* ============================================================================
   ELEMENTOR EDITOR OVERRIDES
   ============================================================================ */
.elementor-editor-active .wcag-toolbar {
    position: relative !important;
    display: inline-flex !important;
    transform: none !important;
    top: auto !important;
    left: auto !important;
    bottom: auto !important;
    right: auto !important;
}

.elementor-editor-active .wcag-toolbar-inner {
    display: inline-flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
}

.elementor-editor-active .wcag-panel {
    display: none !important;
}

.elementor-editor-active .wcag-floating-trigger {
    position: relative !important;
}
