/* 可访问性优化样式 */

/* 颜色对比度优化 */
:root {
    /* 高对比度颜色变量 */
    --text-primary: #1a1a1a;      /* 主文字颜色 - 与白色背景对比度 16.5:1 */
    --text-secondary: #4a5568;    /* 次要文字颜色 - 与白色背景对比度 7.1:1 */
    --text-muted: #718096;        /* 弱化文字颜色 - 与白色背景对比度 4.5:1 */
    --bg-primary: #ffffff;        /* 主背景色 */
    --bg-secondary: #f7fafc;      /* 次要背景色 */
    --accent-primary: #667eea;    /* 主强调色 - 与白色背景对比度 4.5:1 */
    --accent-secondary: #5a67d8;  /* 次要强调色 - 与白色背景对比度 4.5:1 */
    --border-color: #e2e8f0;      /* 边框颜色 */
    --error-color: #e53e3e;       /* 错误颜色 - 与白色背景对比度 4.5:1 */
    --success-color: #38a169;     /* 成功颜色 - 与白色背景对比度 4.5:1 */
    --warning-color: #d69e2e;     /* 警告颜色 - 与白色背景对比度 4.5:1 */
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    :root {
        --text-primary: #000000;
        --text-secondary: #333333;
        --text-muted: #666666;
        --accent-primary: #0000ff;
        --accent-secondary: #000080;
        --border-color: #000000;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    :root {
        --text-primary: #ffffff;
        --text-secondary: #e2e8f0;
        --text-muted: #a0aec0;
        --bg-primary: #1a202c;
        --bg-secondary: #2d3748;
        --accent-primary: #90cdf4;
        --accent-secondary: #63b3ed;
        --border-color: #4a5568;
    }
}

/* 焦点指示器优化 */
*:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* 按钮焦点样式 */
button:focus,
.btn:focus,
.filter-tag:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

/* 输入框焦点样式 */
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

/* 链接焦点样式 */
a:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
    text-decoration: underline;
}

/* 键盘导航优化 */
.keyboard-navigable {
    position: relative;
}

.keyboard-navigable:focus {
    z-index: 10;
}

/* 跳过链接 */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--accent-primary);
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 1000;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 6px;
}

/* 屏幕阅读器专用内容 */
.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;
}

/* 屏幕阅读器可见但视觉隐藏 */
.sr-only-focusable:focus {
    position: static;
    width: auto;
    height: auto;
    padding: inherit;
    margin: inherit;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* ARIA live区域样式 */
.aria-live {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* 加载状态可访问性 */
.loading-indicator[aria-hidden="true"] {
    display: none;
}

/* 错误状态可访问性 */
.error-message {
    color: var(--error-color);
    background: #fed7d7;
    border: 1px solid var(--error-color);
    padding: 12px;
    border-radius: 4px;
    margin: 8px 0;
}

/* 成功状态可访问性 */
.success-message {
    color: var(--success-color);
    background: #c6f6d5;
    border: 1px solid var(--success-color);
    padding: 12px;
    border-radius: 4px;
    margin: 8px 0;
}

/* 车辆卡片可访问性 */
.vehicle-card {
    position: relative;
}

.vehicle-card:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* 品牌选择可访问性 */
.brand-item {
    position: relative;
}

.brand-item:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* 筛选标签可访问性 */
.filter-tag {
    position: relative;
}

.filter-tag:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* 搜索建议可访问性 */
.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
}

.suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s ease;
}

.suggestion-item:hover,
.suggestion-item:focus {
    background: var(--bg-secondary);
    outline: none;
}

.suggestion-item[aria-selected="true"] {
    background: var(--accent-primary);
    color: white;
}

/* 移动端可访问性优化 */
@media (max-width: 768px) {
    /* 触摸目标最小尺寸 */
    .touch-target {
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* 移动端焦点样式 */
    *:focus {
        outline-width: 3px;
    }
    
    /* 移动端按钮样式 */
    button,
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
    .vehicle-card {
        border: 2px solid var(--text-primary);
    }
    
    .brand-item {
        border: 1px solid var(--text-primary);
    }
    
    .filter-tag {
        border: 2px solid var(--text-primary);
    }
}

/* 打印样式优化 */
@media print {
    .skip-link,
    .aria-live,
    .sr-only {
        display: none;
    }
    
    .vehicle-card {
        break-inside: avoid;
        border: 1px solid #000;
    }
    
    a[href]:after {
        content: " (" attr(href) ")";
    }
}
