/**
 * 车辆选择组件 - 前端样式
 */

/* 包装器 - 用于突破WordPress主题宽度限制 */
.wd-car-selection-wrapper {
    width: 100%;
    position: relative;
}

.wd-car-selection-wrapper.wd-car-full-width {
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw !important;
    margin-right: -50vw !important;
    max-width: none !important;
}

/* 主容器 */
.wd-car-selection-widget {
    --primary-color: #00d4ff;
    --hover-color: rgba(255, 255, 255, 0.1);
    --border-color: rgba(255, 255, 255, 0.2);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    font-family: "Helvetica Neue", Arial, sans-serif;
    background: #1e1e2e;
    color: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    display: flex;
    height: 600px;
    width: 100%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* 主内容区域 */
.wd-car-main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

/* 当前车辆显示区域 */
.wd-car-display-area {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.1), rgba(0, 212, 255, 0.05));
}

.wd-current-vehicle-display {
    text-align: center;
}

.wd-vehicle-name {
    font-size: 24px;
    font-weight: 600;
    margin: 0;
    color: var(--primary-color);
    text-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
    transition: var(--transition);
}

/* 控制区域 */
.wd-control-area {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.wd-page-title {
    font-size: 18px;
    font-weight: 500;
    margin: 0;
    color: #ffffff;
}

/* 车型列表容器 */
.wd-car-list-container {
    flex: 1;
    padding: 0 20px 20px;
    display: flex;
    flex-direction: column;
}

.wd-car-list-wrapper {
    height: 180px;
    overflow-x: auto;
    overflow-y: hidden;
    border: none;
    border-radius: 0;
    background: transparent;
    cursor: grab;
    user-select: none;
}

.wd-car-list-wrapper:active,
.wd-car-list-wrapper.wd-dragging {
    cursor: grabbing;
}

.wd-car-list {
    display: flex;
    gap: 16px;
    padding: 16px;
    min-height: calc(180px - 32px);
    white-space: nowrap;
}

/* 拖动状态样式 */
.wd-brand-list.wd-dragging,
.wd-car-list-wrapper.wd-dragging {
    cursor: grabbing !important;
    user-select: none;
}

.wd-brand-list.wd-dragging *,
.wd-car-list-wrapper.wd-dragging * {
    pointer-events: none;
}

/* 确保品牌项目在非拖拽状态下可点击 */
.wd-brand-item {
    pointer-events: auto !important;
}

.wd-brand-list.wd-dragging .wd-brand-item {
    pointer-events: none !important;
}

/* 车型项目 */
.wd-car-item {
    flex-shrink: 0;
    width: 180px;
    height: 135px;
    position: relative;
    border: none;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(5px);
}

.wd-car-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 212, 255, 0.2);
}

.wd-car-item.active {
    border: 1px solid var(--primary-color);
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.2), rgba(0, 212, 255, 0.1));
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.4);
}

.wd-car-image-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.wd-car-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    transition: var(--transition);
}

.wd-car-thumbnail.wd-image-error {
    display: none;
}

.wd-car-name-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 12px;
    background: transparent;
    border-radius: 0 0 8px 8px;
}

.wd-car-name {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    text-align: center;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.9), 
                 0 0 8px rgba(0, 0, 0, 0.8),
                 -1px -1px 1px rgba(0, 0, 0, 0.8);
    line-height: 1.2;
}

/* 品牌侧边栏 */
.wd-brand-sidebar {
    width: 300px;
    min-width: 300px;
    max-width: 300px;
    background: rgba(0, 0, 0, 0.3);
    border-left: 1px solid var(--border-color);
    display: flex !important;
    position: relative;
    backdrop-filter: blur(10px);
    flex-shrink: 0;
    overflow: hidden;
    /* 默认高度，会被内联样式覆盖 */
    height: calc(100vh - 180px);
    max-height: calc(100vh - 180px);
}

.wd-brand-list {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    cursor: grab;
    user-select: none;
}

.wd-brand-list:active {
    cursor: grabbing;
}

/* 字母分组 */
.wd-letter-group {
    margin-bottom: 24px;
}

.wd-letter-header {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

/* 品牌项目 */
.wd-brand-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 4px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

.wd-brand-item:hover {
    background: var(--hover-color);
    border-color: var(--border-color);
    transform: translateX(4px);
}

.wd-brand-item.active {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.2), rgba(0, 212, 255, 0.1));
    border-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.3);
}

.wd-brand-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    margin-right: 12px;
    border-radius: 50%;
    background: transparent;
    padding: 4px;
    transition: var(--transition);
}

.wd-brand-logo.wd-image-error {
    background: var(--primary-color);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.wd-brand-name {
    font-size: 14px;
    font-weight: 500;
    color: #ffffff;
    flex: 1;
}

.wd-brand-item.active .wd-brand-name {
    color: var(--primary-color);
    font-weight: 600;
}

/* 字母索引 */
.wd-alphabet-index {
    position: absolute;
    right: 8px;
    top: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    width: 30px;
    height: calc(100% - 40px);
}

.wd-alphabet-item {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--border-color);
    cursor: pointer;
    transition: var(--transition);
    border-radius: 50%;
    flex-shrink: 0;
    flex-grow: 0;
}

.wd-alphabet-item:hover,
.wd-alphabet-item.active {
    color: var(--primary-color);
    background: rgba(0, 212, 255, 0.2);
    transform: scale(1.2);
}

/* 加载和错误状态 */
.wd-car-loading,
.wd-brand-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100px;
    color: var(--border-color);
    font-size: 14px;
}

.wd-car-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--border-color);
    font-size: 16px;
    text-align: center;
}

.wd-car-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100px;
    color: #ff6b6b;
    text-align: center;
}

.wd-car-error button {
    margin-top: 12px;
    padding: 8px 16px;
    background: var(--primary-color);
    color: #ffffff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: var(--transition);
}

.wd-car-error button:hover {
    background: #0099cc;
    transform: translateY(-2px);
}

/* 滚动条样式 */
.wd-car-list-wrapper::-webkit-scrollbar,
.wd-brand-list::-webkit-scrollbar {
    height: 6px;
    width: 6px;
}

.wd-car-list-wrapper::-webkit-scrollbar-track,
.wd-brand-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.wd-car-list-wrapper::-webkit-scrollbar-thumb,
.wd-brand-list::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
    transition: var(--transition);
}

.wd-car-list-wrapper::-webkit-scrollbar-thumb:hover,
.wd-brand-list::-webkit-scrollbar-thumb:hover {
    background: #0099cc;
}

/* 覆盖WordPress主题的最大宽度限制 */
.wd-car-selection-wrapper.wd-car-full-width .wd-car-selection-widget {
    max-width: none !important;
    width: 100% !important;
}

/* 确保侧边栏在全宽模式下也能正确显示 */
.wd-car-selection-wrapper.wd-car-full-width .wd-brand-sidebar {
    display: flex !important;
    width: 300px !important;
    min-width: 300px !important;
    max-width: 300px !important;
}

/* 确保组件在各种主题中都能正确显示 */
.wd-car-selection-widget {
    box-sizing: border-box;
    margin: 0 auto;
}

/* 确保侧边栏在所有情况下都显示 */
.wd-brand-sidebar {
    visibility: visible !important;
    opacity: 1 !important;
}

/* 2K和4K显示优化 */
@media (min-width: 2560px) {
    .wd-car-selection-widget {
        min-height: 700px;
    }
    
    .wd-brand-sidebar {
        width: 400px !important;
        min-width: 400px !important;
        max-width: 400px !important;
    }
    
    .wd-car-item {
        width: 220px;
        height: 160px;
    }
    
    .wd-car-name {
        font-size: 16px;
    }
    
    .wd-brand-name {
        font-size: 18px;
    }
    
    .wd-brand-logo {
        width: 60px;
        height: 60px;
    }
    
    .wd-vehicle-name {
        font-size: 36px;
    }
    
    .wd-page-title {
        font-size: 28px;
    }
}

@media (min-width: 3840px) {
    .wd-car-selection-widget {
        min-height: 900px;
    }
    
    .wd-brand-sidebar {
        width: 500px !important;
        min-width: 500px !important;
        max-width: 500px !important;
    }
    
    .wd-car-item {
        width: 280px;
        height: 200px;
    }
    
    .wd-car-name {
        font-size: 18px;
    }
    
    .wd-brand-name {
        font-size: 20px;
    }
    
    .wd-brand-logo {
        width: 80px;
        height: 80px;
    }
    
    .wd-vehicle-name {
        font-size: 42px;
    }
    
    .wd-page-title {
        font-size: 32px;
    }
    
    .wd-brand-list,
    .wd-car-display-area,
    .wd-control-area,
    .wd-car-list-container {
        padding: 30px;
    }
}

/* 动画效果 */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wd-car-selection-widget {
    animation: fadeIn 0.6s ease-out;
}

.wd-brand-sidebar {
    animation: slideInRight 0.6s ease-out;
}

.wd-car-main-content {
    animation: slideInLeft 0.6s ease-out;
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .wd-car-selection-widget {
        --border-color: #ffffff;
        --hover-color: rgba(255, 255, 255, 0.3);
    }
    
    .wd-car-item,
    .wd-brand-item {
        border-width: 2px;
    }
}

/* 减少动画模式支持 */
@media (prefers-reduced-motion: reduce) {
    .wd-car-selection-widget *,
    .wd-car-selection-widget *::before,
    .wd-car-selection-widget *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 深色模式优化 */
@media (prefers-color-scheme: light) {
    .wd-car-selection-widget {
        background: #f8fafc;
        color: #1a202c;
    }
    
    .wd-brand-sidebar {
        background: rgba(255, 255, 255, 0.8);
    }
    
    .wd-car-list-wrapper {
        background: transparent;
    }
    
    .wd-car-item {
        background: rgba(255, 255, 255, 0.9);
    }
} 