/**
 * AccessiMate Frontend CSS
 * Modern accessibility toolbar with clean design
 */

/* CSS Variables for consistent theming */
:root {
    --accessimate-primary: #2563eb;
    --accessimate-primary-hover: #1d4ed8;
    --accessimate-primary-light: #3b82f6;
    --accessimate-secondary: #64748b;
    --accessimate-success: #10b981;
    --accessimate-warning: #f59e0b;
    --accessimate-danger: #ef4444;
    --accessimate-dark: #1e293b;
    --accessimate-light: #f8fafc;
    --accessimate-white: #ffffff;
    --accessimate-gray-100: #f1f5f9;
    --accessimate-gray-200: #e2e8f0;
    --accessimate-gray-300: #cbd5e1;
    --accessimate-gray-400: #94a3b8;
    --accessimate-gray-500: #64748b;
    --accessimate-gray-600: #475569;
    --accessimate-gray-700: #334155;
    --accessimate-gray-800: #1e293b;
    --accessimate-gray-900: #0f172a;

    --accessimate-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --accessimate-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --accessimate-shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --accessimate-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --accessimate-shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    --accessimate-radius: 0.5rem;
    --accessimate-radius-lg: 0.75rem;
    --accessimate-radius-xl: 1rem;
    --accessimate-radius-full: 9999px;

    --accessimate-font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --accessimate-transition: all 0.15s ease-in-out;
}

/* Reset and base styles for AccessiMate components */
.accessimate-toolbar *,
.accessimate-toolbar *::before,
.accessimate-toolbar *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Main toolbar container */
.accessimate-toolbar {
    position: fixed;
    z-index: 999999;
    font-family: var(--accessimate-font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--accessimate-gray-800);
}

/* Toolbar positioning */
.accessimate-top-right {
    top: 20px;
    right: 20px;
}

.accessimate-top-left {
    top: 20px;
    left: 20px;
}

.accessimate-bottom-right {
    bottom: 20px;
    right: 20px;
}

.accessimate-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Responsive positioning for mobile */
@media (max-width: 768px) {
    .accessimate-toolbar {
        top: 10px !important;
        right: 10px !important;
        bottom: auto !important;
        left: auto !important;
    }
}

/* Toggle button */
.accessimate-toolbar-toggle {
    position: relative;
}

.accessimate-toolbar-toggle button {
    background: linear-gradient(135deg, var(--accessimate-primary), var(--accessimate-primary-light));
    color: var(--accessimate-white);
    border: none;
    border-radius: var(--accessimate-radius-full);
    width: 56px;
    height: 56px;
    cursor: pointer;
    font-size: 24px;
    box-shadow: var(--accessimate-shadow-lg);
    transition: var(--accessimate-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.accessimate-toolbar-toggle button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    opacity: 0;
    transition: var(--accessimate-transition);
}

.accessimate-toolbar-toggle button:hover {
    transform: translateY(-2px);
    box-shadow: var(--accessimate-shadow-xl);
    background: linear-gradient(135deg, var(--accessimate-primary-hover), var(--accessimate-primary));
}

.accessimate-toolbar-toggle button:hover::before {
    opacity: 1;
}

.accessimate-toolbar-toggle button:focus {
    outline: 3px solid rgba(37, 99, 235, 0.3);
    outline-offset: 2px;
}

.accessimate-toolbar-toggle button:active {
    transform: translateY(0);
}

.accessimate-icon {
    display: inline-block;
    font-style: normal;
    font-variant: normal;
    text-rendering: auto;
    line-height: 1;
}

/* Panel styles */
.accessimate-panel {
    position: absolute;
    background: var(--accessimate-white);
    border: 1px solid var(--accessimate-gray-200);
    border-radius: var(--accessimate-radius-xl);
    box-shadow: var(--accessimate-shadow-xl);
    width: 320px;
    max-width: 90vw;
    backdrop-filter: blur(10px);
    overflow: hidden;
    transition: var(--accessimate-transition);
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

.accessimate-panel.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Panel positioning based on toolbar position */
.accessimate-top-right .accessimate-panel,
.accessimate-top-left .accessimate-panel {
    top: 70px;
}

.accessimate-bottom-right .accessimate-panel,
.accessimate-bottom-left .accessimate-panel {
    bottom: 70px;
}

.accessimate-top-right .accessimate-panel,
.accessimate-bottom-right .accessimate-panel {
    right: 0;
}

.accessimate-top-left .accessimate-panel,
.accessimate-bottom-left .accessimate-panel {
    left: 0;
}

/* Mobile panel adjustments */
@media (max-width: 768px) {
    .accessimate-panel {
        width: calc(100vw - 20px);
        left: 10px !important;
        right: 10px !important;
        max-width: none;
    }
}

/* Panel header */
.accessimate-panel-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--accessimate-gray-100);
    background: linear-gradient(135deg, var(--accessimate-gray-50) 0%, var(--accessimate-white) 100%);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.accessimate-panel-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--accessimate-gray-800);
    margin: 0;
}

.accessimate-panel-header button {
    background: none;
    border: none;
    color: var(--accessimate-gray-400);
    cursor: pointer;
    font-size: 24px;
    width: 32px;
    height: 32px;
    border-radius: var(--accessimate-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--accessimate-transition);
}

.accessimate-panel-header button:hover {
    background: var(--accessimate-gray-100);
    color: var(--accessimate-gray-600);
}

/* Panel content */
.accessimate-panel-content {
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
}

/* Custom scrollbar */
.accessimate-panel-content::-webkit-scrollbar {
    width: 6px;
}

.accessimate-panel-content::-webkit-scrollbar-track {
    background: var(--accessimate-gray-100);
    border-radius: var(--accessimate-radius);
}

.accessimate-panel-content::-webkit-scrollbar-thumb {
    background: var(--accessimate-gray-300);
    border-radius: var(--accessimate-radius);
}

.accessimate-panel-content::-webkit-scrollbar-thumb:hover {
    background: var(--accessimate-gray-400);
}

/* Option containers */
.accessimate-option {
    margin-bottom: 16px;
}

.accessimate-option:last-child {
    margin-bottom: 0;
}

/* Button styles */
.accessimate-btn {
    width: 100%;
    padding: 12px 16px;
    background: var(--accessimate-gray-50);
    border: 1px solid var(--accessimate-gray-200);
    border-radius: var(--accessimate-radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--accessimate-gray-700);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--accessimate-transition);
    text-align: left;
    position: relative;
    overflow: hidden;
}

.accessimate-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.accessimate-btn:hover {
    background: var(--accessimate-gray-100);
    border-color: var(--accessimate-gray-300);
    transform: translateY(-1px);
    box-shadow: var(--accessimate-shadow);
}

.accessimate-btn:hover::before {
    left: 100%;
}

.accessimate-btn:focus {
    outline: 2px solid var(--accessimate-primary);
    outline-offset: 2px;
}

.accessimate-btn.active {
    background: linear-gradient(135deg, var(--accessimate-primary), var(--accessimate-primary-light));
    border-color: var(--accessimate-primary);
    color: var(--accessimate-light);
    box-shadow: var(--accessimate-shadow-md);
}

.accessimate-btn.active:hover {
    background: linear-gradient(135deg, var(--accessimate-primary-hover), var(--accessimate-primary));
    transform: translateY(-1px);
}

/* Reset button special styling */
.accessimate-btn-reset {
    background: linear-gradient(135deg, var(--accessimate-gray-100), var(--accessimate-gray-50));
    border-color: var(--accessimate-gray-300);
    color: var(--accessimate-gray-600);
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--accessimate-gray-200);
}

.accessimate-btn-reset:hover {
    background: linear-gradient(135deg, var(--accessimate-gray-200), var(--accessimate-gray-100));
    color: var(--accessimate-gray-700);
}

/* Font size controls */
.accessimate-font-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    padding: 12px;
    background: var(--accessimate-gray-50);
    border-radius: var(--accessimate-radius);
    border: 1px solid var(--accessimate-gray-200);
}

.accessimate-font-controls label {
    font-weight: 500;
    color: var(--accessimate-gray-700);
    margin-bottom: 0;
}

.accessimate-btn-sm {
    padding: 8px 12px;
    background: var(--accessimate-white);
    border: 1px solid var(--accessimate-gray-300);
    border-radius: var(--accessimate-radius);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--accessimate-gray-600);
    transition: var(--accessimate-transition);
    min-width: 40px;
}

.accessimate-btn-sm:hover {
    background: var(--accessimate-primary);
    border-color: var(--accessimate-primary);
    color: var(--accessimate-white);
    transform: scale(1.05);
}

.accessimate-btn-sm:focus {
    outline: 2px solid var(--accessimate-primary);
    outline-offset: 2px;
}

#accessimate-font-current {
    font-weight: 600;
    color: var(--accessimate-primary-light);
    min-width: 50px;
    text-align: center;
}

/* Skip link */
.accessimate-skip-link {
    position: absolute;
    left: -9999px;
    top: 20px;
    z-index: 999999;
    background: var(--accessimate-dark);
    color: var(--accessimate-white);
    padding: 12px 20px;
    text-decoration: none;
    border-radius: var(--accessimate-radius);
    font-weight: 500;
    font-size: 14px;
    transition: var(--accessimate-transition);
    box-shadow: var(--accessimate-shadow-lg);
}

.accessimate-skip-link:focus {
    left: 20px;
    outline: 2px solid var(--accessimate-primary);
    outline-offset: 2px;
}

/* Accessibility states */
body.accessimate-high-contrast {
    filter: contrast(150%) !important;
}

body.accessimate-high-contrast * {
    text-shadow: none !important;
    box-shadow: none !important;
}

body.accessimate-enhanced-focus *:focus {
    outline: 3px solid var(--accessimate-warning) !important;
    outline-offset: 2px !important;
    z-index: 999 !important;
    position: relative !important;
}

body.accessimate-highlight-links a {
    background: linear-gradient(45deg, #ffff00, #fff200) !important;
    color: #000000 !important;
    text-decoration: underline !important;
    padding: 2px 4px !important;
    border-radius: 3px !important;
    font-weight: 600 !important;
}

body.accessimate-simplified-text .accessimate-needs-simplification {
    background: linear-gradient(45deg, rgba(59, 130, 246, 0.1), rgba(37, 99, 235, 0.1)) !important;
    border-left: 4px solid var(--accessimate-primary) !important;
    padding: 8px 12px !important;
    margin: 8px 0 !important;
    border-radius: 0 var(--accessimate-radius) var(--accessimate-radius) 0 !important;
}

/* Loading states */
.accessimate-btn.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.accessimate-btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    margin: auto;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: accessimate-spin 1s linear infinite;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
}

@keyframes accessimate-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Tooltip styles */
.accessimate-tooltip {
    position: relative;
}

.accessimate-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accessimate-dark);
    color: var(--accessimate-white);
    padding: 6px 12px;
    border-radius: var(--accessimate-radius);
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: var(--accessimate-transition);
    margin-bottom: 8px;
    z-index: 1000;
}

.accessimate-tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: var(--accessimate-dark);
    opacity: 0;
    pointer-events: none;
    transition: var(--accessimate-transition);
    margin-bottom: 4px;
}

.accessimate-tooltip:hover::after,
.accessimate-tooltip:hover::before {
    opacity: 1;
}

/* Status indicators */
.accessimate-status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: var(--accessimate-radius);
    font-size: 12px;
    font-weight: 500;
}

.accessimate-status-indicator.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accessimate-success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.accessimate-status-indicator.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accessimate-warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.accessimate-status-indicator.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accessimate-danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Animation classes */
.accessimate-fade-in {
    animation: accessimate-fadeIn 0.3s ease-out;
}

.accessimate-slide-in {
    animation: accessimate-slideIn 0.3s ease-out;
}

@keyframes accessimate-fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes accessimate-slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* High contrast mode adjustments */
@media (prefers-contrast: high) {
    :root {
        --accessimate-gray-100: #ffffff;
        --accessimate-gray-200: #f0f0f0;
        --accessimate-gray-300: #d0d0d0;
    }

    .accessimate-btn {
        border-width: 2px;
    }

    .accessimate-panel {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {

    .accessimate-toolbar *,
    .accessimate-toolbar *::before,
    .accessimate-toolbar *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print styles */
@media print {
    .accessimate-toolbar {
        display: none !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --accessimate-white: #1e293b;
        --accessimate-gray-50: #334155;
        --accessimate-gray-100: #475569;
        --accessimate-gray-200: #64748b;
        --accessimate-gray-800: #f1f5f9;
        --accessimate-gray-700: #e2e8f0;
        --accessimate-gray-600: #cbd5e1;
    }

    .accessimate-panel {
        backdrop-filter: blur(10px) brightness(0.8);
    }
}

/* ================================
    HIGHLIGHT TITLES
   ================================ */

body.accessimate-highlight-titles h1,
body.accessimate-highlight-titles h2,
body.accessimate-highlight-titles h3,
body.accessimate-highlight-titles h4,
body.accessimate-highlight-titles h5,
body.accessimate-highlight-titles h6 {
    outline-style: solid !important;
    outline-color: var(--accessimate-primary) !important;
    outline-width: 2px !important;
    outline-offset: 2px !important;
}

/* ================================
    HIGHLIGHT All
   ================================ */
body.accessimate-highlight-all *:hover {
    outline-style: solid !important;
    outline-color: var(--accessimate-primary) !important;
    outline-width: 2px !important;
    outline-offset: 2px !important;
}

body.accessimate-highlight-titles .accessimate-toolbar h1,
body.accessimate-highlight-titles .accessimate-toolbar h2,
body.accessimate-highlight-titles .accessimate-toolbar h3,
body.accessimate-highlight-titles .accessimate-toolbar h4,
body.accessimate-highlight-titles .accessimate-toolbar h5,
body.accessimate-highlight-titles .accessimate-toolbar h6,
body.accessimate-highlight-all .accessimate-toolbar:hover,
body.accessimate-highlight-all .accessimate-toolbar *:hover {
    outline-style: solid !important;
    outline-color: unset !important;
    outline-width: 0 !important;
    outline-offset: 0 !important;
}

/* ================================
    Feature Magnifier.
   ================================ */
.accessimate-markup-text-magnifier {
    color: #fff !important;
    font-size: 36px !important;
    position: absolute !important;
    padding: 16px !important;
    border-radius: 4px !important;
    background: #333 !important;
    line-height: 1.5 !important;
    z-index: 999999999 !important;
    word-break: break-word !important;
    width: -moz-fit-content !important;
    width: fit-content !important;
}