/* PQW字体预览工具样式 - 优化版 */
:root {
    --pqw-primary-color: #3b82f6;
    --pqw-primary-hover: #2563eb;
    --pqw-danger-color: #ef4444;
    --pqw-danger-hover: #dc2626;
    --pqw-slider-bg: #e2e8f0;
    --pqw-slider-thumb-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
    --pqw-preview-bg: #fff;
    --pqw-text-color: #334155;
    --pqw-border-color: #e2e8f0;
    --pqw-container-bg: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    --pqw-container-shadow: 0 10px 40px rgba(0,0,0,0.08);
    --pqw-preview-shadow: inset 0 4px 12px rgba(0,0,0,0.03);
    --pqw-value-display-bg: rgba(59, 130, 246, 0.1);
    --pqw-loader-bg: rgba(255, 255, 255, 0.85);
    --pqw-slider-track-height: 6px;
    --pqw-slider-thumb-size: 20px;
}

/* === SEO优化样式 === */
.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* === 重新设计的静态信息区域 === */
.pqw-static-info {
    border: 1px solid var(--pqw-border-color);
    border-radius: 10px;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(5px);
}

.pqw-static-content {
    padding: 16px;
}

.pqw-static-desc {
    margin: 0 0 16px 0;
    color: #4b5563;
    font-size: 14px;
    line-height: 1.5;
    font-weight: 500;
    text-align: center;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.pqw-static-details {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.pqw-static-item {
    display: grid;
    grid-template-columns: 100px 1fr;
    align-items: start;
    gap: 12px;
    padding: 4px 0;
}

.pqw-static-label {
    font-weight: 600;
    color: #1f2937;
    font-size: 14px;
    text-align: right;
    line-height: 1.4;
}

.pqw-static-value {
    color: #4b5563;
    font-size: 14px;
    line-height: 1.4;
}

/* 字体名称特殊样式 */
.pqw-static-item:first-child .pqw-static-value {
    font-weight: 600;
    color: var(--pqw-primary-color);
}

/* 当字体名称为空时的样式 */
.pqw-static-value:empty::before {
    content: "未指定字体";
    color: #9ca3af;
    font-style: italic;
}

.pqw-noscript-notice {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
    color: #856404;
}

.pqw-noscript-notice h4 {
    margin: 0 0 12px 0;
    color: #856404;
    font-size: 1.1em;
}

.pqw-noscript-notice p {
    margin: 0 0 12px 0;
    line-height: 1.5;
}

.pqw-noscript-notice ul {
    margin: 8px 0;
    padding-left: 20px;
}

.pqw-noscript-notice li {
    margin-bottom: 4px;
    line-height: 1.4;
}

/* === 主容器 - 修改为自适应宽度 === */
.pqw-font-preview-container {
    width: 100%;
    margin: 20px 0;
    padding: 20px;
    background: var(--pqw-container-bg);
    border-radius: 12px;
    box-shadow: var(--pqw-container-shadow);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    position: relative;
    color: var(--pqw-text-color);
    box-sizing: border-box;
}

/* === 字体加载指示器 === */
.pqw-font-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--pqw-loader-bg);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    border-radius: 12px;
    backdrop-filter: blur(5px);
}

.pqw-loader-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(59, 130, 246, 0.2);
    border-top: 4px solid var(--pqw-primary-color);
    border-radius: 50%;
    animation: pqw-spin 1s linear infinite;
    margin-bottom: 15px;
    will-change: transform;
}

.pqw-font-loader span {
    font-size: 16px;
    font-weight: 600;
    color: var(--pqw-primary-color);
}

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

/* === 输入区域 === */
.pqw-input-group {
    margin-bottom: 20px;
}

.pqw-font-preview-container label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--pqw-text-color);
    font-size: 14px;
}

.pqw-preview-text {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 1px solid var(--pqw-border-color);
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    transition: all 0.3s ease;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.7);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.04);
    color: var(--pqw-text-color);
}

.pqw-preview-text:focus {
    outline: none;
    border-color: var(--pqw-primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15), inset 0 2px 4px rgba(0,0,0,0.04);
}

/* === 预览区域 === */
.pqw-preview-area {
    margin-top: 20px;
    padding: 20px;
    border: 1px solid var(--pqw-border-color);
    border-radius: 10px;
    min-height: 150px;
    background-color: var(--pqw-preview-bg);
    transition: all 0.3s ease;
    overflow-wrap: break-word;
    overflow-y: auto;
    max-height: 300px;
    box-shadow: var(--pqw-preview-shadow);
    line-height: 1.6;
    position: relative;
}

/* === 高级控制区域 === */
.pqw-advanced-controls {
    transition: all 0.3s ease;
    overflow: hidden;
}

.pqw-advanced-controls.pqw-collapsed {
    max-height: 0;
    opacity: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.pqw-advanced-controls.pqw-expanded {
    max-height: 1000px;
    opacity: 1;
    margin-top: 20px;
}

/* === 控制面板 === */
.pqw-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
}

.pqw-control-group {
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--pqw-border-color);
}

.pqw-slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* === 滑块样式 === */
.pqw-font-preview-container .pqw-slider-container input[type="range"] {
    flex: 1;
    height: var(--pqw-slider-track-height) !important;
    border-radius: 3px !important;
    background: var(--pqw-slider-bg) !important;
    outline: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    transition: background 0.3s;
    touch-action: manipulation;
    opacity: 0.9;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    border: none !important;
}

.pqw-font-preview-container .pqw-slider-container input[type="range"]:hover {
    background: #cbd5e1 !important;
    opacity: 1;
}

/* Webkit滑块轨道 */
.pqw-font-preview-container .pqw-slider-container input[type="range"]::-webkit-slider-track {
    background: var(--pqw-slider-bg) !important;
    border: none !important;
    border-radius: 3px !important;
    height: var(--pqw-slider-track-height) !important;
    -webkit-appearance: none !important;
}

/* Webkit滑块拇指样式 */
.pqw-font-preview-container .pqw-slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none !important;
    appearance: none !important;
    width: var(--pqw-slider-thumb-size) !important;
    height: var(--pqw-slider-thumb-size) !important;
    border-radius: 50% !important;
    background: var(--pqw-primary-color) !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
    border: 2px solid #ffffff !important;
}

.pqw-font-preview-container .pqw-slider-container input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--pqw-primary-hover) !important;
    transform: scale(1.1) !important;
    box-shadow: 0 3px 6px rgba(59, 130, 246, 0.3) !important;
}

.pqw-font-preview-container .pqw-slider-container input[type="range"]::-webkit-slider-thumb:active {
    transform: scale(1.2) !important;
    cursor: grabbing !important;
}

/* Firefox滑块轨道 */
.pqw-font-preview-container .pqw-slider-container input[type="range"]::-moz-range-track {
    background: var(--pqw-slider-bg) !important;
    border: none !important;
    border-radius: 3px !important;
    height: var(--pqw-slider-track-height) !important;
}

/* Firefox滑块拇指样式 */
.pqw-font-preview-container .pqw-slider-container input[type="range"]::-moz-range-thumb {
    width: var(--pqw-slider-thumb-size) !important;
    height: var(--pqw-slider-thumb-size) !important;
    border-radius: 50% !important;
    background: var(--pqw-primary-color) !important;
    cursor: pointer !important;
    border: 2px solid #ffffff !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
}

.pqw-font-preview-container .pqw-slider-container input[type="range"]::-moz-range-thumb:hover {
    background: var(--pqw-primary-hover) !important;
    transform: scale(1.1) !important;
    box-shadow: 0 3px 6px rgba(59, 130, 246, 0.3) !important;
}

.pqw-font-preview-container .pqw-slider-container input[type="range"]::-moz-range-thumb:active {
    transform: scale(1.2) !important;
    cursor: grabbing !important;
}

/* === 数值显示 === */
.pqw-value-display {
    min-width: 50px;
    text-align: center;
    font-weight: 700;
    color: var(--pqw-primary-color);
    font-size: 14px;
    padding: 5px 8px;
    background: var(--pqw-value-display-bg);
    border-radius: 6px;
}

/* === 按钮组 === */
.pqw-button-group {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.pqw-font-preview-container .pqw-button-group button {
    min-width: 140px;
    background: linear-gradient(to right, var(--pqw-primary-color), #6366f1);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pqw-font-preview-container .pqw-button-group button:hover {
    background: linear-gradient(to right, var(--pqw-primary-hover), #4f46e5);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(59, 130, 246, 0.25);
}

.pqw-font-preview-container .pqw-button-group button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.pqw-reset-btn {
    background: linear-gradient(to right, var(--pqw-danger-color), #dc2626) !important;
    box-shadow: 0 4px 6px rgba(239, 68, 68, 0.2) !important;
}

.pqw-reset-btn:hover {
    background: linear-gradient(to right, var(--pqw-danger-hover), #b91c1c) !important;
    box-shadow: 0 6px 12px rgba(239, 68, 68, 0.25) !important;
}

/* 高级设置按钮 */
.pqw-advanced-btn {
    background: linear-gradient(to right, #10b981, #059669) !important;
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.2) !important;
}

.pqw-advanced-btn:hover {
    background: linear-gradient(to right, #059669, #047857) !important;
    box-shadow: 0 6px 12px rgba(16, 185, 129, 0.25) !important;
}

/* 禁用状态 */
.pqw-reset-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
    transform: none !important;
}

/* === 样式控制区 === */
.pqw-style-controls {
    display: flex;
    justify-content: space-around;
    gap: 12px;
    margin-top: 15px;
    align-items: center;
    text-align: center;
}

.pqw-style-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 0;
}

/* 控制组标签 */
.pqw-style-group > label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--pqw-text-color);
    font-size: 14px;
    text-align: center;
    width: 100%;
}

/* 字体样式切换 */
.pqw-italic-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: auto;
}

/* 字体样式标签 */
.pqw-italic-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--pqw-text-color);
    text-align: center;
}

/* === 颜色选择器 === */
.pqw-color-picker {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: auto;
}

/* 颜色选择器输入框 */
.pqw-font-preview-container .pqw-color-picker input[type="color"] {
    width: 45px;
    height: 45px;
    border: 2px solid var(--pqw-border-color);
    border-radius: 8px;
    cursor: pointer;
    padding: 0;
    background: transparent;
    transition: all 0.3s ease;
    -webkit-appearance: none;
    appearance: none;
    overflow: hidden;
}

/* 内部色板样式 */
.pqw-font-preview-container .pqw-color-picker input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 6px;
    padding: 0;
}

.pqw-font-preview-container .pqw-color-picker input[type="color"]::-moz-color-swatch {
    border: none;
    border-radius: 6px;
}

.pqw-font-preview-container .pqw-color-picker input[type="color"]:hover {
    border-color: var(--pqw-primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    transform: scale(1.05);
}

.pqw-font-preview-container .pqw-color-picker input[type="color"]:focus {
    outline: none;
    border-color: var(--pqw-primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

/* === 切换开关 === */
.pqw-toggle-switch {
    position: relative;
    display: block;
    width: 50px;
    height: 26px;
    margin: 0 auto;
}

.pqw-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.pqw-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: .4s;
    border-radius: 34px;
}

.pqw-toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.pqw-toggle-switch input:checked + .pqw-toggle-slider {
    background: linear-gradient(to right, var(--pqw-primary-color), #6366f1);
}

.pqw-toggle-switch input:checked + .pqw-toggle-slider:before {
    transform: translateX(24px);
}

/* === 字体加载错误提示 === */
.pqw-font-error {
    color: #ef4444;
    padding: 8px;
    background-color: #fef2f2;
    border-radius: 4px;
    margin-bottom: 8px;
    font-size: 14px;
    text-align: center;
}

/* === 值显示文本样式 === */
.pqw-value-display span {
    display: inline-block;
    min-width: 25px;
}

/* === 响应式设计 === */
@media (max-width: 768px) {
    .pqw-font-preview-container {
        padding: 15px;
        margin: 15px 0;
    }
    
    .pqw-controls {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .pqw-control-group {
        padding: 10px;
    }
    
    .pqw-preview-text {
        min-height: 60px;
        padding: 10px;
        font-size: 14px;
    }
    
    .pqw-preview-area {
        padding: 15px;
        min-height: 100px;
        max-height: 200px;
    }
    
    .pqw-button-group {
        gap: 8px;
        margin-top: 15px;
    }
    
    .pqw-button-group button {
        flex: 1;
        min-width: auto;
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .pqw-value-display {
        min-width: 40px;
        font-size: 13px;
    }
    
    .pqw-font-preview-container .pqw-slider-container input[type="range"]::-webkit-slider-thumb {
        width: 22px !important;
        height: 22px !important;
    }
    
    .pqw-font-preview-container .pqw-slider-container input[type="range"]::-moz-range-thumb {
        width: 22px !important;
        height: 22px !important;
    }
    
    /* 颜色选择器在移动端调整 */
    .pqw-font-preview-container .pqw-color-picker input[type="color"] {
        width: 40px;
        height: 40px;
    }
    
    /* 样式控制区在移动端调整 */
    .pqw-style-controls {
        flex-direction: column;
        gap: 15px;
    }
    
    .pqw-style-group {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    .pqw-style-group > label {
        margin-bottom: 0;
        text-align: left;
        flex: 1;
    }
    
    .pqw-italic-toggle,
    .pqw-color-picker {
        flex-direction: row;
        gap: 12px;
    }
    
    /* 加载指示器在移动端调整 */
    .pqw-font-loader {
        padding: 12px;
        text-align: center;
    }
    
    .pqw-loader-spinner {
        width: 30px;
        height: 30px;
        margin-bottom: 10px;
    }
    
    .pqw-font-loader span {
        font-size: 14px;
    }
    
    /* 静态信息区域在移动端调整 */
    .pqw-static-content {
        padding: 12px;
    }
    
    .pqw-static-desc {
        font-size: 13px;
    }
    
    .pqw-static-item {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    
    .pqw-static-label {
        text-align: left;
        font-size: 13px;
    }
    
    .pqw-static-value {
        font-size: 13px;
    }
    
    .pqw-noscript-notice {
        padding: 12px;
    }
}

/* === 焦点状态可见性 === */
.pqw-font-preview-container button:focus-visible,
.pqw-font-preview-container input[type="color"]:focus-visible,
.pqw-font-preview-container input[type="range"]:focus-visible,
.pqw-toggle-switch input:focus-visible + .pqw-toggle-slider {
    outline: 2px solid var(--pqw-primary-color);
    outline-offset: 2px;
}

/* === 滑块触摸优化增强 === */
.pqw-slider-container input[type="range"] {
    touch-action: manipulation;
    -ms-touch-action: manipulation;
}

/* 字重限制样式 */
.pqw-font-weight-slider.limited {
    opacity: 0.7;
    position: relative;
}

.pqw-font-weight-slider.limited::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: var(--pqw-slider-track-height);
    background: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 3px,
        rgba(0, 0, 0, 0.1) 3px,
        rgba(0, 0, 0, 0.1) 6px
    );
    border-radius: 5px;
    pointer-events: none;
}

/* 超大屏幕适配 */
@media (min-width: 1200px) {
    .pqw-font-preview-container {
        padding: 25px;
    }
    
    .pqw-controls {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 20px;
    }
    
    .pqw-preview-area {
        min-height: 200px;
        max-height: 400px;
    }
}