/**
 * 通用AI文案润色组件样式
 * 可在任何页面中复用
 */

/* 统一AI润色组件色板（沿用站点主题蓝） */
:root {
    --polish-primary: #0d6efd;
    --polish-primary-dark: #0b5ed7;
    --polish-primary-light: rgba(13, 110, 253, 0.08);
    --polish-border: rgba(13, 110, 253, 0.15);
    --polish-shadow: rgba(15, 23, 42, 0.12);
}

/* AI润色按钮 - 品牌化胶囊样式 */
.polish-btn:not(.dh-icon-button) {
    border: 1px solid rgba(13, 110, 253, 0.25);
    background: rgba(255, 255, 255, 0.9);
    color: var(--polish-primary);
    cursor: pointer;
    border-radius: 24px;
    height: 36px;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    position: relative;
    flex-shrink: 0;
    box-shadow: 0 10px 20px rgba(13, 110, 253, 0.12);
}

.polish-btn:not(.dh-icon-button) i {
    font-size: 15px;
    filter: none;
}

.polish-btn:not(.dh-icon-button) span {
    white-space: nowrap;
}

.polish-btn:not(.dh-icon-button):hover {
    transform: translateY(-1px);
    background: #ffffff;
    color: var(--polish-primary-dark);
    box-shadow: 0 14px 24px rgba(13, 110, 253, 0.18);
}

.polish-btn:not(.dh-icon-button):focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.35);
}

.polish-btn:not(.dh-icon-button):disabled {
    background: transparent;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.45;
}

.polish-btn:not(.dh-icon-button):active {
    transform: scale(0.98);
}

.polish-btn.is-loading,
.input-action-btn.polish-btn.is-loading,
.polish-btn-compact.is-loading {
    position: relative;
    pointer-events: none;
    color: #8c97a8;
}

.polish-btn.is-loading .sparkle-icon,
.polish-btn-compact.is-loading .sparkle-icon {
    opacity: 0;
}

.polish-btn.is-loading::after,
.polish-btn-compact.is-loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(13, 110, 253, 0.35);
    border-top-color: rgba(13, 110, 253, 0.9);
    border-radius: 50%;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    margin: auto;
    animation: polishSpin 0.85s linear infinite;
}

/* 紧凑型图标按钮（/image页需求） */
.polish-btn-compact,
.input-action-btn.polish-btn.polish-btn-compact {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    background: none !important;
    background-color: transparent !important;
    color: #6c757d;
    box-shadow: none !important;
    border: none !important;
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.polish-btn-compact .sparkle-icon {
    font-size: 18px;
    line-height: 1;
    display: inline-flex;
}

.polish-btn-compact span:not(.sparkle-icon) {
    display: none;
}

.polish-btn-compact:hover,
.input-action-btn.polish-btn.polish-btn-compact:hover {
    background: none !important;
    background-color: transparent !important;
    box-shadow: none !important;
    transform: scale(1.05);
    color: #007bff;
}

.polish-btn-compact:focus-visible,
.input-action-btn.polish-btn.polish-btn-compact:focus-visible {
    box-shadow: 0 0 0 2px rgba(73, 80, 87, 0.3);
}

.polish-btn-compact:disabled {
    opacity: 0.6;
    box-shadow: none;
    transform: none;
}

.polish-undo-btn {
    width: 32px;
    height: 32px;
    border-radius: 16px;
    border: 1px solid rgba(15, 23, 42, 0.16);
    background: rgba(255, 255, 255, 0.85);
    color: #5a6474;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-left: 4px;
    font-size: 14px;
}

.polish-undo-btn i {
    font-size: 14px;
}

.polish-undo-btn:hover:not(:disabled) {
    color: #0b5ed7;
    border-color: rgba(13, 110, 253, 0.6);
    box-shadow: 0 6px 14px rgba(13, 110, 253, 0.18);
    background: #ffffff;
}

.polish-undo-btn:disabled {
    opacity: 0.4;
}

.polish-input-loading {
    color: #94a3b8 !important;
    background-image: linear-gradient(120deg, rgba(13, 110, 253, 0.07), rgba(13, 110, 253, 0));
    background-size: 200% 100%;
    animation: polishInputLoading 1.6s ease infinite;
    transition: color 0.2s ease;
    pointer-events: none;
    caret-color: transparent;
}

.polish-text-updated {
    animation: polishFlash 1.8s ease;
}

/* 输入框内按钮样式（适配不同布局） */
.input-actions .polish-btn {
    margin-right: 8px;
}

/* AI润色弹窗样式 */
.polish-popup {
    max-width: 720px;
    max-height: 75vh;
    background: #ffffff;
    border-radius: 32px;
    box-shadow: 0 25px 65px rgba(11, 20, 37, 0.35);
    border: none;
    overflow: hidden;
    position: relative;
}

.polish-popup::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 96px;
    background: linear-gradient(90deg, #11d2ff 0%, #23a2ff 50%, #248bff 100%);
    border-radius: 32px 32px 0 0;
    z-index: 0;
}

.polish-popup .popup-header {
    padding: 18px 32px;
    border-bottom: 3px solid #ffffff;
    background: transparent;
    color: #ffffff;
    border-radius: 32px 32px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 1;
}

.polish-popup .popup-header .popup-close {
    color: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    transition: background 0.2s ease, color 0.2s ease;
}

.polish-popup .popup-header .popup-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.polish-popup .popup-title {
    font-size: 20px;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.polish-popup .popup-title i {
    color: #ffffff;
    font-size: 20px;
}

.polish-popup .popup-content {
    padding: 48px 32px;
    max-height: 52vh;
    overflow-y: auto;
    background: #ffffff;
}

/* 加载状态时禁止滚动条 */

.polish-popup .polish-loading {
    text-align: center;
    padding: 60px 20px;
    overflow: hidden; /* 禁止滚动条 */
    color: #4a5568;
}

.polish-popup .popup-content.loading {
    overflow: hidden; /* 加载时禁止整个内容区域滚动 */
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;

}

.polish-options {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.polish-option {
    padding: 18px 20px;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    background: #f9fafb;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
    color: #1b2a40;
}

.polish-option:hover {
    border-color: rgba(13, 110, 253, 0.35);
    background: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.12);
}

.polish-option:active {
    transform: scale(0.99);
    box-shadow: 0 8px 18px rgba(13, 110, 253, 0.15);
}

.polish-option-text {
    font-size: 14px;
    line-height: 1.6;
    color: #111827;
    margin-bottom: 8px;
    font-weight: 600;
    padding-right: 30px; /* 为右上角的勾选标记留空间 */
}

.polish-option-reason {
    font-size: 13px;
    color: #4b5563;
    line-height: 1.5;
    padding-right: 30px;
}

/* 加载状态样式 */
.polish-loading {
    text-align: center;
    padding: 40px 20px;
    color: #4a5568;
}

.polish-loading i {
    font-size: 32px;
    color: #07bff9;
    margin-bottom: 18px;
    display: block;
    animation: polishSpin 1.2s linear infinite;
}

.polish-loading p {
    margin: 0;
    font-size: 16px;
    color: #2e3b54;
}

/* 错误状态样式 */
.polish-error {
    text-align: center;
    padding: 20px;
    color: #b42318;
    background: #fff7f5;
    border-radius: 12px;
    margin: 16px 0;
    border: 1px solid rgba(244, 63, 94, 0.18);
    box-shadow: 0 10px 24px rgba(244, 63, 94, 0.12);
}

.polish-error i {
    font-size: 26px;
    margin-bottom: 12px;
    display: block;
    color: #f04438;
}

.polish-error p {
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
}

/* 弹窗底部按钮样式 */
.polish-popup .popup-footer {
    padding: 18px 24px;
    border-top: 1px solid #f2f3f8;
    background: #ffffff;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-radius: 0 0 16px 16px;
}

.polish-popup .btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 80px;
}

.polish-popup .btn-primary {
    background: linear-gradient(135deg, #0d6efd, #5d8eff);
    color: white;
    box-shadow: 0 12px 24px rgba(13, 110, 253, 0.22);
}

.polish-popup .btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    background: linear-gradient(135deg, #0b5ed7, #4f7ef5);
    box-shadow: 0 16px 32px rgba(13, 110, 253, 0.28);
}

.polish-popup .btn-primary:disabled {
    background: rgba(255, 255, 255, 0.35);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.polish-popup .btn-secondary {
    background: #f4f6fb;
    color: #0d1b3d;
    border: 1px solid #e5e7eb;
}

.polish-popup .btn-secondary:hover {
    background: #e9eef9;
    color: #02102a;
    border-color: rgba(13, 110, 253, 0.2);
}

/* 动画效果 */
@keyframes polishSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes polishInputLoading {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

@keyframes polishFlash {
    0% { box-shadow: 0 0 0 0 rgba(13, 110, 253, 0.35); background-color: rgba(17, 194, 255, 0.08); }
    70% { box-shadow: 0 0 0 10px rgba(13, 110, 253, 0); background-color: rgba(17, 194, 255, 0.0); }
    100% { box-shadow: none; background-color: inherit; }
}

/* 响应式适配 */
@media (max-width: 768px) {
    .polish-popup {
        max-width: 95vw;
        margin: 10px;
    }
    
    .polish-popup .popup-header,
    .polish-popup .popup-content,
    .polish-popup .popup-footer {
        padding: 16px;
    }
    
    .polish-option {
        padding: 12px;
    }
    
    .polish-option-text {
        font-size: 13px;
        padding-right: 25px;
    }
    
    .polish-option-reason {
        font-size: 11px;
        padding-right: 25px;
    }
    
    .polish-option.selected::before {
        width: 18px;
        height: 18px;
        font-size: 11px;
        top: 10px;
        right: 10px;
    }
}

@media (max-width: 480px) {
    .polish-btn:not(.dh-icon-button) span {
        display: none; /* 在小屏幕上只显示图标 */
    }

    .polish-btn:not(.dh-icon-button) {
        padding: 0 10px;
        min-width: 36px;
        justify-content: center;
    }

    .polish-btn-compact .sparkle-icon {
        display: inline-flex !important;
    }
    
    .polish-popup .popup-footer {
        flex-direction: column;
        gap: 8px;
    }
    
    .polish-popup .btn {
        width: 100%;
    }
}

/* 深色模式支持（可选） */
@media (prefers-color-scheme: dark) {
    .polish-popup {
        background: #ffffff;
        box-shadow: 0 25px 65px rgba(11, 20, 37, 0.35);
        border: none;
    }

    .polish-popup .popup-header {
        background: linear-gradient(90deg, #11d2ff 0%, #23a2ff 50%, #248bff 100%);
        border-bottom: none;
    }

    .polish-popup .popup-title {
        color: #ffffff;
    }

    .polish-popup .popup-content {
        background: #ffffff;
    }

    .polish-option {
        background: #f9fafb;
        border-color: #e5e7eb;
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
        color: #1b2a40;
    }

    .polish-option:hover {
        background: #ffffff;
        border-color: rgba(13, 110, 253, 0.35);
    }

    .polish-option-text {
        color: #111827;
    }

    .polish-option-reason {
        color: #4b5563;
    }

    .polish-popup .popup-footer {
        background: #ffffff;
        border-top: 1px solid #f2f3f8;
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .polish-option {
        border-width: 3px;
    }
    
    .polish-option:hover,
    .polish-option.selected {
        border-width: 3px;
        border-color: #000;
    }
    
    .polish-popup .btn {
        border-width: 2px;
    }
}
