/* Krauss Accessibility Frontend Styles */

/* Accessibility Widget Container */
#krauss-accessibility-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Widget Positioning */
.krauss-widget-bottom-right { bottom: 20px; right: 20px; }
.krauss-widget-bottom-left { bottom: 20px; left: 20px; }
.krauss-widget-top-right { top: 20px; right: 20px; }
.krauss-widget-top-left { top: 20px; left: 20px; }

/* Toggle Button */
#krauss-accessibility-toggle {
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 50px;
    padding: 12px 20px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

/* Size variations */
.krauss-widget-small #krauss-accessibility-toggle {
    padding: 8px 16px;
    font-size: 12px;
}

.krauss-widget-small #krauss-accessibility-toggle .accessibility-icon svg {
    width: 16px;
    height: 16px;
}

.krauss-widget-medium #krauss-accessibility-toggle {
    padding: 12px 20px;
    font-size: 14px;
}

.krauss-widget-medium #krauss-accessibility-toggle .accessibility-icon svg {
    width: 20px;
    height: 20px;
}

.krauss-widget-large #krauss-accessibility-toggle {
    padding: 16px 24px;
    font-size: 16px;
}

.krauss-widget-large #krauss-accessibility-toggle .accessibility-icon svg {
    width: 24px;
    height: 24px;
}

/* Text-only button */
#krauss-accessibility-toggle .widget-text-only {
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Hide widget text on small button with icon */
.krauss-widget-small #krauss-accessibility-toggle:not(:has(.widget-text-only)) .widget-text {
    display: none;
}

#krauss-accessibility-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(33, 150, 243, 0.4);
}

#krauss-accessibility-toggle:focus {
    outline: 3px solid #FFC107;
    outline-offset: 2px;
}

.accessibility-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.accessibility-icon svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Accessibility Panel */
.accessibility-panel {
    position: absolute;
    width: 350px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border: 1px solid #e0e0e0;
    overflow: hidden;
    z-index: 1000000;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

/* Panel positioning based on widget location */
.krauss-widget-bottom-right .accessibility-panel {
    bottom: 70px;
    right: 0;
}

.krauss-widget-bottom-left .accessibility-panel {
    bottom: 70px;
    left: 0;
}

.krauss-widget-top-right .accessibility-panel {
    top: 70px;
    right: 0;
}

.krauss-widget-top-left .accessibility-panel {
    top: 70px;
    left: 0;
}

/* Panel Header */
.panel-header {
    background: #ff9f19;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

#krauss-panel-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

#krauss-panel-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

#krauss-panel-close:focus {
    outline: 2px solid #FFC107;
    outline-offset: -2px;
}

/* Panel Content */
.panel-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.panel-content::-webkit-scrollbar {
    width: 8px;
}

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

.panel-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.panel-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Settings Groups - New Grid Layout */
.settings-group {
    margin-bottom: 25px;
}

.settings-group h4 {
    margin: 0 0 15px 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

/* Setting Buttons */
.setting-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 15px 10px;
    background: white;
    border: 2px solid #ff9f19;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 80px;
    position: relative;
    text-decoration: none;
    color: #333;
}

.setting-button:hover {
    background: #fff5e6;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 159, 25, 0.2);
}

.setting-button:focus {
    outline: 3px solid #ff9f19;
    outline-offset: 2px;
}

.setting-button.active {
    background: #ff9f19;
    color: white;
}

.setting-button.active svg {
    fill: white;
    stroke: white;
}

.setting-button svg {
    width: 24px;
    height: 24px;
    fill: #ff9f19;
    stroke: #ff9f19;
    transition: all 0.2s;
}

.setting-button span {
    font-size: 12px;
    text-align: center;
    line-height: 1.2;
    font-weight: 500;
}

/* Text alignment dropdown */
.dropdown-button {
    position: relative;
    overflow: visible;
    cursor: pointer;
}

.dropdown-button:hover {
    background: #fff5e6;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 159, 25, 0.2);
}

.text-alignment-select {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 5px;
    background: white;
    border: 2px solid #ff9f19;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 10;
    padding: 4px;
    cursor: pointer;
}

/* Panel Actions */
.panel-actions {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.statement-link {
    color: #ff9f19;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: color 0.2s;
    text-align: center;
    padding: 8px;
    border: 1px solid #ff9f19;
    border-radius: 6px;
    display: block;
}

.statement-link:hover {
    background: #ff9f19;
    color: white;
}

.reset-btn {
    background: #f44336;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
    width: 100%;
}

.reset-btn:hover {
    background: #d32f2f;
}

/* Panel Footer */
.panel-footer {
    background: #f5f5f5;
    padding: 12px 20px;
    text-align: center;
    border-top: 1px solid #eee;
    margin-top: auto;
}

.panel-footer p {
    margin: 0;
    font-size: 12px;
    color: #666;
}

.panel-footer strong {
    color: #ff9f19;
}

/* Accessibility Feature Styles */
body.krauss-larger-text {
    font-size: 120% !important;
}

body.krauss-larger-text * {
    font-size: inherit !important;
}

body.krauss-line-height {
    line-height: 1.8 !important;
}

body.krauss-line-height * {
    line-height: inherit !important;
}

body.krauss-text-left * {
    text-align: left !important;
}

body.krauss-text-center * {
    text-align: center !important;
}

body.krauss-text-justify * {
    text-align: justify !important;
}

body.krauss-readable-font {
    font-family: 'Comic Sans MS', 'Arial', sans-serif !important;
}

body.krauss-readable-font * {
    font-family: inherit !important;
}

body.krauss-hide-images img {
    display: none !important;
}

body.krauss-stop-animations * {
    animation: none !important;
    transition: none !important;
}

body.krauss-highlight-links a {
    background: yellow !important;
    color: black !important;
    text-decoration: underline !important;
    padding: 2px 4px !important;
    border-radius: 3px !important;
}

body.krauss-outline-focus h1,
body.krauss-outline-focus h2,
body.krauss-outline-focus h3,
body.krauss-outline-focus h4,
body.krauss-outline-focus h5,
body.krauss-outline-focus h6 {
    outline: 2px solid #2196F3 !important;
    outline-offset: 2px !important;
    padding: 5px !important;
}

body.krauss-grayscale {
    filter: grayscale(100%) !important;
}

body.krauss-high-contrast {
    filter: contrast(200%) !important;
}

body.krauss-high-contrast * {
    background: white !important;
    color: black !important;
}

/* Special Features */
#krauss-reading-mask {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9998;
    pointer-events: none;
}

#krauss-sitemap,
#krauss-language-selector {
    position: fixed;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    z-index: 999998;
    border: 1px solid #ddd;
}

#krauss-sitemap {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 400px;
    max-height: 500px;
    overflow-y: auto;
}

#krauss-language-selector {
    top: 100px;
    right: 20px;
}

.language-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 15px 0;
}

.language-option {
    padding: 10px 15px;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.language-option:hover {
    background: #f5f5f5;
    border-color: #ff9f19;
}

.close-sitemap,
.close-language {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

/* Screen Reader Only */
.krauss-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Screen Reader Skip Links */
.krauss-skip-links {
    position: absolute;
    top: -40px;
    left: 0;
    width: 100%;
    background: #ff9f19;
    z-index: 100000;
    text-align: center;
    padding: 10px 0;
    transition: top 0.3s;
}

.krauss-skip-links:focus-within {
    top: 0;
}

.krauss-skip-links .skip-link {
    color: white;
    padding: 8px 16px;
    display: inline-block;
    text-decoration: none;
    font-weight: 500;
    margin: 0 5px;
    border-radius: 4px;
    background: rgba(0,0,0,0.1);
}

.krauss-skip-links .skip-link:hover,
.krauss-skip-links .skip-link:focus {
    background: rgba(0,0,0,0.2);
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Screen Reader Announcement */
.krauss-sr-announcement {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #ff9f19;
    color: white;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 16px;
    z-index: 999999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Screen Reader Mode Active Styles */
body.krauss-screen-reader-active {
    position: relative;
}

body.krauss-screen-reader-active *:focus {
    outline: 3px solid #ff9f19 !important;
    outline-offset: 2px !important;
}

/* Reading Order Indicators */
.krauss-reading-order {
    position: absolute;
    left: -25px;
    top: 0;
    background: #ff9f19;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
    font-weight: bold;
    z-index: 1000;
}

/* Keyboard Navigation Hints */
.krauss-keyboard-hint {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    margin-bottom: 5px;
    z-index: 999999;
}

.krauss-keyboard-hint::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 20px;
    border: 5px solid transparent;
    border-top-color: #333;
}

/* Enhanced Focus Styles for Screen Reader Mode */
body.krauss-screen-reader-active a:focus,
body.krauss-screen-reader-active button:focus,
body.krauss-screen-reader-active input:focus,
body.krauss-screen-reader-active select:focus,
body.krauss-screen-reader-active textarea:focus,
body.krauss-screen-reader-active [tabindex]:focus {
    position: relative;
    z-index: 10;
}

/* Visual Indicators for ARIA */
body.krauss-screen-reader-active [aria-required="true"]::after {
    content: " *";
    color: #ff9f19;
    font-weight: bold;
}

body.krauss-screen-reader-active [aria-invalid="true"] {
    border-color: #f44336 !important;
    background-color: #ffebee !important;
}

/* Speech Controls for Screen Reader */
#krauss-speech-controls {
    position: fixed;
    bottom: 100px;
    right: 20px;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 999998;
}

.speech-control-btn {
    padding: 8px 12px;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
    border-radius: 4px;
    font-size: 16px;
    transition: all 0.2s;
}

.speech-control-btn:hover {
    background: #f5f5f5;
    border-color: #ff9f19;
}

.speech-control-btn:active {
    background: #ff9f19;
    color: white;
}

/* Notification Styles */
.krauss-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #ff9f19;
    color: white;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 16px;
    z-index: 999999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Mobile adjustments for skip links */
@media (max-width: 768px) {
    .krauss-skip-links {
        font-size: 14px;
    }
    
    .krauss-skip-links .skip-link {
        padding: 6px 12px;
        margin: 0 2px;
    }
    
    .krauss-reading-order {
        display: none;
    }
    
    #krauss-speech-controls {
        bottom: 80px;
        right: 10px;
        left: 10px;
        max-width: calc(100vw - 20px);
    }
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .accessibility-panel {
        width: 300px;
        max-width: calc(100vw - 40px);
    }
    
    .krauss-widget-bottom-left .accessibility-panel,
    .krauss-widget-top-left .accessibility-panel {
        left: 20px;
        right: 20px;
    }
    
    .krauss-widget-bottom-right .accessibility-panel,
    .krauss-widget-top-right .accessibility-panel {
        right: 20px;
        left: 20px;
    }
    
    #krauss-accessibility-toggle {
        padding: 10px 15px;
        font-size: 12px;
    }
    
    #krauss-accessibility-toggle .widget-text {
        display: none;
    }
}