/* ===================================================
   汉字转拼音工具 - 样式文件  (htp = hanzi-to-pinyin)
   =================================================== */

/* ---------- 整体容器 ---------- */
.htp-container {
    max-width: 800px;
    margin: 0 auto;
    box-sizing: border-box;
}

/* ---------- 选项面板（将声调+分隔+对照开关细分到一个卡片） ---------- */
.htp-options-panel {
    background: #f8fafd;
    border: 1px solid #eaeef6;
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 12px;
}

/* ---------- 选项行 ---------- */
.htp-options-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 22px;
    margin-bottom: 8px;
    align-items: flex-start;
}

.htp-option-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.htp-option-label {
    font-size: 12px;
    font-weight: 600;
    color: #888;
    white-space: nowrap;
    user-select: none;
}

.htp-option-btns {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.htp-opt-btn {
    padding: 4px 11px;
    border: 1.5px solid #dde3ec;
    border-radius: 14px;
    background: #f7f9fb;
    color: #666;
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s;
    white-space: nowrap;
    user-select: none;
}

.htp-opt-btn:hover {
    background: #eef3ff;
    border-color: #4f8ef7;
    color: #4f8ef7;
}

.htp-opt-btn.active {
    background: linear-gradient(135deg, #eef3ff, #dde8ff);
    border-color: #4f8ef7;
    color: #2a5ef7;
    font-weight: 600;
    box-shadow: 0 1px 6px rgba(79, 142, 247, 0.18);
}

.htp-opt-btn:active {
    transform: scale(0.95);
}

/* ---------- 对照开关 ---------- */
.htp-mapping-toggle {
    margin-bottom: 0;
}

.htp-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #666;
    cursor: pointer;
    user-select: none;
}

.htp-checkbox-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: #4f8ef7;
}

/* ---------- 通用 section 标签 ---------- */
.htp-section-label {
    font-size: 13px;
    font-weight: 600;
    color: #555;
    user-select: none;
}

/* ---------- 输入区 ---------- */
.htp-input-section {
    margin-bottom: 10px;
}

.htp-input-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    flex-wrap: wrap;
}

.htp-char-count {
    font-size: 12px;
    color: #aaa;
    flex: 1;
    transition: color 0.2s;
}

.htp-char-count.has-hanzi   { color: #4caf90; font-weight: 600; }
.htp-char-count.warn-orange { color: #f90;    font-weight: 600; }
.htp-char-count.warn-red    { color: #e53935; font-weight: 700; }

.htp-clear-btn {
    padding: 2px 10px;
    border: 1px solid #e0e5ec;
    border-radius: 12px;
    background: #f5f7fb;
    color: #999;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.htp-clear-btn:hover {
    background: #fff0f0;
    color: #e55;
    border-color: #f5b8b8;
}

.htp-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #dde3ec;
    border-radius: 10px;
    font-size: 15px;
    color: #333;
    background: #fff;
    resize: vertical;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
    line-height: 1.7;
    font-family: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC', sans-serif;
}

.htp-textarea:focus {
    border-color: #4f8ef7;
    box-shadow: 0 0 0 3px rgba(79, 142, 247, 0.12);
}

.htp-textarea::placeholder {
    color: #ccc;
    font-size: 13px;
}

/* ---------- 操作行 ---------- */
.htp-action-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.htp-submit-btn {
    padding: 8px 26px;
    background: linear-gradient(135deg, #4f8ef7, #3a72d8);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.18s, transform 0.12s, box-shadow 0.18s, background 0.18s;
    box-shadow: 0 2px 8px rgba(79, 142, 247, 0.28);
    white-space: nowrap;
}

.htp-submit-btn:hover {
    opacity: 0.9;
    transform: scale(1.02) translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 142, 247, 0.35);
}

.htp-submit-btn:active {
    transform: scale(0.97);
}

.htp-shortcut-tip {
    font-size: 11px;
    color: #bbb;
    opacity: 0.8;
    white-space: nowrap;
    user-select: none;
}

.htp-ai-btn {
    padding: 7px 16px;
    border: 1.5px solid #dde3ec;
    border-radius: 8px;
    background: #f7f9fb;
    color: #666;
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
    white-space: nowrap;
}

.htp-ai-btn:hover {
    background: #fff8ee;
    border-color: #f5a623;
    color: #c87710;
}

.htp-ai-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* ---------- 结果区 ---------- */
@keyframes htpFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.htp-result {
    display: none;
    margin-bottom: 12px;
}

.htp-result.visible {
    display: block;
    animation: htpFadeIn 0.22s ease;
}

.htp-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 7px;
    flex-wrap: wrap;
    gap: 6px;
}

.htp-result-title {
    font-size: 13px;
    font-weight: 600;
    color: #555;
}

.htp-result-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.htp-stat-badge {
    font-size: 12px;
    color: #888;
    background: #f0f4fb;
    border: 1px solid #dde6ff;
    border-radius: 10px;
    padding: 2px 10px;
}

.htp-stat-badge--success {
    color: #1a7a50;
    background: #edfaf3;
    border-color: #a8dfbf;
    font-weight: 600;
}

.htp-stat-badge:empty { display: none; }

.htp-copy-btn {
    padding: 4px 14px;
    border: 1px solid #dde3ec;
    border-radius: 16px;
    background: #f7f9fb;
    color: #555;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}

.htp-copy-btn:hover {
    background: #eef3ff;
    border-color: #4f8ef7;
    color: #4f8ef7;
}

.htp-copy-btn.success {
    background: #eaffec;
    border-color: #5cc;
    color: #0a9;
    pointer-events: none;
}

/* 拼音结果文本框空时隐藏 header */
.htp-result:not(.visible) .htp-result-header,
.htp-result:not(.visible) .htp-result-copy-hint {
    display: none;
}

/* 拼音结果文本框 */
.htp-result-box {
    padding: 14px 18px;
    background: linear-gradient(135deg, #f7f9ff, #eef3ff);
    border: 2px solid #c8d9ff;
    border-radius: 10px;
    font-size: 18px;
    letter-spacing: 0.05em;
    color: #1e3fa8;
    word-break: break-all;
    line-height: 2;
    font-family: 'Segoe UI', 'PingFang SC', 'Noto Sans', sans-serif;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    user-select: all;
    min-height: 50px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.htp-result-box:empty { display: none; }

.htp-result-box:hover {
    background: linear-gradient(135deg, #eef3ff, #dde8ff);
    border-color: #4f8ef7;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

@keyframes htpCopiedFlash {
    0%   { background: linear-gradient(135deg, #c8e4ff, #b0d4ff); }
    70%  { background: linear-gradient(135deg, #c8e4ff, #b0d4ff); }
    100% { background: linear-gradient(135deg, #f7f9ff, #eef3ff); }
}

.htp-result-box.copied {
    animation: htpCopiedFlash 0.7s ease;
}

.htp-result-copy-hint {
    font-size: 11px;
    color: #a8b8c8;
    text-align: right;
    margin-top: 4px;
    user-select: none;
}

/* ---------- 错误提示 ---------- */
.htp-error-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
    padding: 9px 14px;
    background: #fff8f0;
    border: 1px solid #fdd8aa;
    border-radius: 8px;
    font-size: 13px;
    color: #c75;
    animation: htpFadeIn 0.2s ease;
}

.htp-error-icon { flex-shrink: 0; font-size: 15px; }

/* ---------- 汉字对照表 ---------- */
.htp-mapping-section {
    margin-bottom: 12px;
    padding: 10px 12px;
    background: #fafbff;
    border: 1px solid #e8edf5;
    border-radius: 10px;
    animation: htpFadeIn 0.22s ease;
}

.htp-mapping-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.htp-mapping-count {
    font-size: 11px;
    color: #aaa;
}

.htp-mapping-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.htp-mapping-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 10px;
    background: #fff;
    border: 1px solid #e0e5ec;
    border-radius: 8px;
    min-width: 44px;
    text-align: center;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s, transform 0.1s;
    cursor: pointer;
    user-select: none;
}

.htp-mapping-item:hover {
    border-color: #4f8ef7;
    box-shadow: 0 2px 8px rgba(79, 142, 247, 0.12);
    background: #eef3ff;
}

.htp-mapping-item--copied {
    background: #ddeeff !important;
    border-color: #4f8ef7 !important;
    transform: scale(0.93);
    transition: transform 0.1s ease, background 0.1s ease !important;
}

.htp-mapping-char {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
    line-height: 1.2;
}

.htp-mapping-pinyin {
    font-size: 11px;
    color: #4f8ef7;
    font-weight: 500;
    letter-spacing: 0.03em;
    line-height: 1.2;
}

/* ---------- AI 区隐藏类 ---------- */
.htp-ai-hidden {
    display: none;
}

/* ---------- 剪贴板辅助元素（替代内联样式） ---------- */
.htp-clipboard-tmp {
    position: fixed;
    top: -9999px;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
}

/* ---------- 表单底部提示行 ---------- */
.htp-form-hint {
    font-size: 11px;
    color: #c0c8d8;
    margin-bottom: 12px;
    user-select: none;
    letter-spacing: 0.01em;
}

/* ---------- AI 解析区 ---------- */
.htp-ai-section {
    margin-bottom: 12px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #fffdf7, #fff8ee);
    border: 1px solid #fce4b0;
    border-radius: 10px;
    animation: htpFadeIn 0.22s ease;
}

.htp-ai-header {
    font-size: 13px;
    font-weight: 600;
    color: #c87710;
    margin-bottom: 6px;
}

.htp-ai-content {
    font-size: 13px;
    color: #555;
    line-height: 1.75;
    white-space: pre-wrap;
    word-break: break-word;
}

/* AI 加载状态 */
.htp-ai-loading {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #aaa;
}

.htp-ai-loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #ddd;
    border-top-color: #f5a623;
    border-radius: 50%;
    animation: htpSpin 0.7s linear infinite;
}

@keyframes htpSpin {
    to { transform: rotate(360deg); }
}

/* ---------- 快速示例 ---------- */
.htp-samples-section {
    padding-top: 10px;
    border-top: 1px solid #eef0f5;
    margin-bottom: 4px;
}

.htp-samples-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 7px;
}

.htp-samples-hint {
    font-size: 11px;
    color: #bbb;
}

.htp-sample-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.htp-sample-btn {
    padding: 4px 12px;
    border: 1px solid #dde3ec;
    border-radius: 14px;
    background: #f7f9fb;
    color: #555;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
    white-space: nowrap;
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

.htp-sample-btn:hover {
    background: #eef3ff;
    border-color: #4f8ef7;
    color: #4f8ef7;
    transform: translateY(-1px);
}

.htp-sample-btn:active { transform: scale(0.95); }

/* ---------- Toast ---------- */
@keyframes htpToastIn {
    from { opacity: 0; transform: translateY(12px) translateX(-50%) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) translateX(-50%) scale(1); }
}

@keyframes htpToastOut {
    from { opacity: 1; transform: translateY(0) translateX(-50%) scale(1); }
    to   { opacity: 0; transform: translateY(8px) translateX(-50%) scale(0.95); }
}

.htp-toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 22px;
    background: rgba(40, 56, 90, 0.92);
    color: #fff;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    z-index: 9999;
    display: none;
    white-space: nowrap;
    pointer-events: auto;
    cursor: pointer;
}

.htp-toast.warn    { background: rgba(196, 119, 0, 0.92); }
.htp-toast.warning { background: rgba(196, 119, 0, 0.92); }
.htp-toast.error   { background: rgba(192, 40,  40, 0.92); }
.htp-toast.success { background: rgba(30,  120, 70, 0.92); }

.htp-toast.show {
    display: block;
    animation: htpToastIn 0.2s ease forwards;
}

.htp-toast.hide {
    animation: htpToastOut 0.2s ease forwards;
}

/* ---------- 提交按钮加载状态 ---------- */
.htp-submit-btn--loading {
    opacity: 0.7;
    cursor: not-allowed;
    background: linear-gradient(135deg, #7aabf7, #5b8de0);
    pointer-events: none;
}

/* ---------- 响应式 平板端 ≤768px ---------- */
@media (max-width: 768px) {
    .htp-container {
        max-width: 100%;
        padding: 0 4px;
    }

    .htp-options-row { gap: 8px 14px; }

    .htp-result-box { font-size: 16px; }

    .htp-mapping-char { font-size: 17px; }
}

/* ---------- 响应式 手机端 ≤640px ---------- */
@media (max-width: 640px) {
    .htp-container { max-width: 100%; }

    .htp-options-row { gap: 8px 16px; }

    .htp-result-box { font-size: 15px; }

    .htp-mapping-char { font-size: 16px; }

    .htp-action-row { gap: 8px; }

    .htp-shortcut-tip { display: none; }
}
