/**
 * 字体选择器样式
 * 使用 Tailwind CSS 风格的现代设计
 */

/* 🎨 字体选择器主容器 */
.font-selector-container {
    margin-bottom: 8px;
    position: relative;
}

/* 🏷️ 字体选择器头部 */
.font-selector-header {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}

.font-selector-label {
    width: 40px;
    font-size: 12px;
    color: #4b5563;
    margin-right: 8px;
}

/* 🔘 字体选择切换按钮 */
.font-selector-toggle {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px;
    background-color: white;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 12px;
    color: #4b5563;
}

.font-selector-toggle:hover {
    background-color: #f3f4f6;
    border-color: #9ca3af;
}

.font-selector-toggle:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.current-font-name {
    color: #1f2937;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 8px;
}

.dropdown-arrow {
    color: #6b7280;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.font-selector-toggle[aria-expanded="true"] .dropdown-arrow {
    transform: rotate(180deg);
}

/* 📋 字体选择下拉菜单 */
.font-selector-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    max-height: 420px;
    overflow: hidden;
    margin-top: 4px;
}

.font-selector-dropdown.open {
    display: block;
}

/* 🔍 搜索框容器 */
.font-search-container {
    padding: 8px 12px;
    border-bottom: 1px solid #e5e7eb;
    position: relative;
}

.font-search-input {
    width: 100%;
    padding: 6px 12px 6px 32px;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    font-size: 12px;
    color: #374151;
    background-color: #ffffff;
    transition: all 0.2s ease;
    height: 28px;
}

.font-search-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.font-search-container:focus-within .font-search-icon {
    color: #3b82f6;
}

.font-search-input::placeholder {
    color: #9ca3af;
}

/* 🔍 搜索图标 */
.font-search-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: #9ca3af;
    pointer-events: none;
}

/* 📝 字体列表容器 */
.font-list-container {
    max-height: 320px;
    overflow-y: auto;
    /* 自定义滚动条样式 */
    scrollbar-width: thin;
    scrollbar-color: #d1d5db #f9fafb;
}

.font-list-container::-webkit-scrollbar {
    width: 6px;
}

.font-list-container::-webkit-scrollbar-track {
    background: #f9fafb;
}

.font-list-container::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.font-list-container::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* 🏷️ 字体分类标题 */
.font-category {
    border-bottom: 1px solid #f3f4f6;
}

.font-category:last-child {
    border-bottom: none;
}

.font-category-title {
    font-size: 11px;
    font-weight: 600;
    color: #d1d5db; /* 改为更浅的浅灰色 */
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 16px 12px 8px; /* 增加1倍行间距：上边距从8px到16px，下边距从4px到8px */
    margin: 0;
    background-color: transparent; /* 移除灰色背景 */
    border-bottom: 1px solid #f3f4f6;
}

/* 🆕 最近使用字体样式 - 与整体风格保持一致 */
.recent-fonts-category {
    border-bottom: 1px solid #f3f4f6;
}

.recent-fonts-title {
    /* 继承 .font-category-title 的样式，无需特殊设置 */
}

.recent-font-item {
    /* 继承默认的字体项样式，无需特殊样式 */
}

.recent-font-item:hover {
    /* 使用默认的悬停样式 */
}

.recent-font-item.selected {
    /* 使用默认的选中样式 */
}

.recent-font-item .font-preview {
    /* 使用默认的字体预览样式 */
}

/* 👨‍👩‍👧‍👦 字体族组 */
.font-family-group {
    /* 移除分割线 border-bottom: 1px solid #f9fafb; */
}

.font-family-group:last-child {
    /* 移除分割线相关样式 border-bottom: none; */
}

.font-family-header {
    font-size: 11px;
    font-weight: 500;
    color: #4b5563;
    padding: 6px 12px 2px;
    background-color: #fafbfc;
    border-bottom: 1px solid #f3f4f6;
}

/* 🎯 字体项目 */
.font-item {
    display: block;
    padding: 4px 12px; /* 缩小上下内边距从8px到4px */
    cursor: pointer;
    transition: all 0.15s ease;
    /* 移除分割线 border-bottom: 1px solid #f9fafb; */
}

.font-item:last-child {
    /* 移除分割线相关样式 border-bottom: none; */
}

.font-item:hover {
    background-color: #f3f4f6;
}

.font-item.selected {
    background-color: #dbeafe;
    border-color: #bfdbfe;
}

.font-item.selected:hover {
    background-color: #bfdbfe;
}

/* 🔍 字体预览文本 */
.font-preview {
    display: block;
    font-size: 13px;
    color: #1f2937;
    line-height: 1.2; /* 缩小行高从1.4到1.2 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.font-item.selected .font-preview {
    color: #1e40af;
    font-weight: 500;
}

/* 🎨 系统字体特殊样式 */
.font-item.system-font .font-preview {
    font-size: 12px;
}

/* 🎭 自定义字体特殊样式 */
.font-item.custom-font {
    padding-left: 12px; /* 与普通字体项保持一致的左边距 */
}

.font-item.custom-font .font-preview {
    font-size: 14px;
    padding: 0; /* 移除额外的上下内边距 */
}

/* 🔄 加载状态 */
.font-loading {
    position: relative;
    opacity: 0.6;
}

.font-loading::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translateY(-50%) rotate(0deg); }
    100% { transform: translateY(-50%) rotate(360deg); }
}

/* 📱 响应式设计 */
@media (max-width: 768px) {
    .font-selector-dropdown {
        max-height: 360px;
    }
    
    .font-list-container {
        max-height: 280px;
    }
    
    .font-preview {
        font-size: 12px;
    }
    
    .font-item.custom-font .font-preview {
        font-size: 13px;
    }
}

/* 🎪 动画效果 */
.font-selector-dropdown {
    opacity: 0;
    transform: translateY(-4px);
    transition: all 0.2s ease;
}

.font-selector-dropdown.open {
    opacity: 1;
    transform: translateY(0);
}

/* 🌟 焦点可访问性 */
.font-item:focus {
    outline: none;
    background-color: #dbeafe;
    box-shadow: inset 0 0 0 2px #3b82f6;
}

/* 🎯 选中状态指示器 - 已移除小勾符号，保持简洁界面 */
/* 
.font-item.selected::before {
    content: '✓';
    position: absolute;
    left: 8px;
    color: #1e40af;
    font-weight: bold;
    font-size: 12px;
}

.font-item.custom-font.selected::before {
    left: 6px;
}
*/

/* 🔤 字体变体徽章 */
.font-variant-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 4px;
    background-color: #e5e7eb;
    color: #6b7280;
    font-size: 9px;
    border-radius: 3px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.font-item.selected .font-variant-badge {
    background-color: #bfdbfe;
    color: #1e40af;
}

/* 🎨 自定义颜色主题 */
:root {
    --font-selector-primary: #3b82f6;
    --font-selector-primary-light: #dbeafe;
    --font-selector-primary-dark: #1e40af;
    --font-selector-gray-50: #f9fafb;
    --font-selector-gray-100: #f3f4f6;
    --font-selector-gray-200: #e5e7eb;
    --font-selector-gray-300: #d1d5db;
    --font-selector-gray-400: #9ca3af;
    --font-selector-gray-500: #6b7280;
    --font-selector-gray-600: #4b5563;
    --font-selector-gray-700: #374151;
    --font-selector-gray-900: #1f2937;
}

/* 📁 字体族可展开容器 */
.font-family-expandable {
    /* 移除分割线 border-bottom: 1px solid #f9fafb; */
}

.font-family-expandable:last-child {
    /* 移除分割线相关样式 border-bottom: none; */
}

/* 🔘 展开/收缩按钮容器 */
.font-preview-container {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

/* 📖 字体预览改进 - 紧凑显示 */
.font-item.single-variant .font-preview,
.font-item.family-header .font-preview {
    font-size: 14px; /* 缩小字号从16px到14px */
    font-weight: 400;
    line-height: 1.2; /* 缩小行高从1.3到1.2 */
    flex: 1;
    /* 确保字体预览使用实际字体渲染 */
    font-feature-settings: "liga" 1, "kern" 1;
    text-rendering: optimizeLegibility;
}

/* 🎯 字体族头部样式 */
.font-item.family-header {
    background-color: #fafbfc;
    /* 移除分割线 border-bottom: 1px solid #e5e7eb; */
}

.font-item.family-header:hover {
    background-color: #f3f4f6;
}

.font-item.family-header.selected {
    background-color: #dbeafe;
    border-color: #bfdbfe;
}

/* 🔘 展开/收缩按钮 */
.font-expand-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    color: #6b7280;
    transition: all 0.2s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
}

.font-expand-btn:hover {
    background-color: #e5e7eb;
    color: #374151;
}

.font-expand-btn:focus {
    outline: none;
    background-color: #e5e7eb;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* ↕️ 展开箭头样式 */
.expand-arrow {
    width: 12px;
    height: 12px;
    transition: all 0.2s ease;
}

/* 📦 字体变体容器 */
.font-variants-container {
    background-color: #fefefe;
    /* 移除分割线 border-top: 1px solid #f3f4f6; */
}

/* 🔸 字体变体项样式 */
.font-item.variant-item {
    padding: 2px 12px 2px 24px; /* 缩小上下内边距，增加左边距表示层级关系 */
    background-color: #fefefe;
    /* 移除分割线 border-bottom: 1px solid #f9fafb; */
    position: relative;
}

.font-item.variant-item:before {
    content: '';
    position: absolute;
    left: 12px;
    top: 50%;
    width: 8px;
    height: 1px;
    background-color: #d1d5db;
    transform: translateY(-50%);
}

.font-item.variant-item:hover {
    background-color: #f9fafb;
}

.font-item.variant-item.selected {
    background-color: #eff6ff;
    border-color: #dbeafe;
}

.font-item.variant-item .font-preview {
    font-size: 12px; /* 缩小变体项字号从14px到12px */
    color: #4b5563;
    line-height: 1.2; /* 添加紧凑行高 */
}

.font-item.variant-item.selected .font-preview {
    color: #1e40af;
    font-weight: 500;
}

/* 🎨 改进单一字体变体的显示 */
.font-item.single-variant {
    background-color: #ffffff;
}

.font-item.single-variant:hover {
    background-color: #f9fafb;
}

.font-item.single-variant.selected {
    background-color: #eff6ff;
    border-color: #dbeafe;
}

.font-item.single-variant .font-preview {
    color: #1f2937;
    font-weight: 400;
}

.font-item.single-variant.selected .font-preview {
    color: #1e40af;
    font-weight: 500;
}

/* 📱 响应式改进 */
@media (max-width: 768px) {
    .font-item.single-variant .font-preview,
    .font-item.family-header .font-preview {
        font-size: 14px;
    }
    
    .font-item.variant-item {
        padding-left: 20px;
    }
    
    .font-expand-btn {
        padding: 1px;
        width: 14px;
        height: 14px;
    }
    
    .expand-arrow {
        width: 10px;
        height: 10px;
    }
} 