/* ============================================================
   User Submitted Posts 投稿表单 → 适配 Puock 主题
   作用范围：#user-submitted-posts 内部的字段、chosen 下拉、
   编辑器工具条、提交按钮、错误提示。
   ============================================================ */

/* ------------------------------------------------------------
   1. 容器与字段基础
   ------------------------------------------------------------ */
html body #user-submitted-posts,
html body #user-submitted-posts form#usp_form {
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
    width: 100% !important;
}

/* 注意排除插件的蜜罐字段，它是靠 display:none 隐藏的 */
html body #user-submitted-posts fieldset:not(#usp_verify) {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 0 18px !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
}

html body #user-submitted-posts #usp_verify {
    display: none !important;
}

/* 模板里每个字段后面的 <br /> */
html body #user-submitted-posts fieldset > br,
html body #user-submitted-posts .wp-editor-tools br,
html body #user-submitted-posts #usp-submit br {
    display: none !important;
}

html body #user-submitted-posts fieldset > label,
html body #user-submitted-posts .usp_text-editor > label {
    display: block !important;
    margin: 0 0 8px !important;
    padding: 0 !important;
    color: var(--pk-c-font, #343a40) !important;
    font-size: 13.5px !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
    letter-spacing: 0 !important;
}

/* ------------------------------------------------------------
   2. 文本框（确定性色值：部分浏览器会干预 input 的背景）
   ------------------------------------------------------------ */
html body #user-submitted-posts input.usp-input {
    display: block !important;
    width: 100% !important;
    height: 46px !important;
    min-height: 46px !important;
    margin: 0 !important;
    padding: 0 14px !important;
    background-color: #f8f8f9 !important;
    border: 1px solid rgba(0, 0, 0, 0.18) !important;
    border-radius: 10px !important;
    color: #343a40 !important;
    font-size: 14px !important;
    line-height: 44px !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

html body #user-submitted-posts input.usp-input::placeholder {
    color: #98a2b3 !important;
    opacity: 1;
}

html body #user-submitted-posts input.usp-input:focus {
    outline: none !important;
    border-color: var(--pk-c-primary, #1c60f3) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--pk-c-primary, #1c60f3) 18%, transparent) !important;
}

/* 验证器标红时保留红色描边 */
html body #user-submitted-posts input.usp-input.parsley-error {
    border-color: #dc3545 !important;
}

/* ------------------------------------------------------------
   3. 原生下拉（chosen 未接管时的兜底）
   ------------------------------------------------------------ */
html body #user-submitted-posts select.usp-select {
    width: 100% !important;
    min-height: 46px !important;
    padding: 10px 14px !important;
    background-color: #f8f8f9 !important;
    border: 1px solid rgba(0, 0, 0, 0.18) !important;
    border-radius: 10px !important;
    color: #343a40 !important;
    font-size: 14px !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
}

html body #user-submitted-posts select.usp-select option {
    padding: 8px 10px !important;
    color: #343a40 !important;
    font-size: 14px !important;
}

/* ------------------------------------------------------------
   4. chosen 多选下拉
   ------------------------------------------------------------ */
html body #user-submitted-posts .chosen-container {
    width: 100% !important;
    font-size: 14px !important;
}

html body #user-submitted-posts .chosen-container-multi .chosen-choices {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 6px !important;
    min-height: 46px !important;
    margin: 0 !important;
    padding: 7px 10px !important;
    background-color: #f8f8f9 !important;
    background-image: none !important;
    border: 1px solid rgba(0, 0, 0, 0.18) !important;
    border-radius: 10px !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

html body #user-submitted-posts .chosen-container-active .chosen-choices,
html body #user-submitted-posts .chosen-container-multi.chosen-with-drop .chosen-choices {
    border-color: var(--pk-c-primary, #1c60f3) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--pk-c-primary, #1c60f3) 18%, transparent) !important;
}

html body #user-submitted-posts .chosen-container-multi .chosen-choices li.search-field {
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
    flex: 1 1 90px !important;
}

html body #user-submitted-posts .chosen-container-multi .chosen-choices li.search-field input[type="text"] {
    width: 100% !important;
    height: 28px !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    color: inherit !important;
    font-size: 13.5px !important;
}

/* 已选中的标签做成小胶囊 */
html body #user-submitted-posts .chosen-container-multi .chosen-choices li.search-choice {
    margin: 0 !important;
    padding: 3px 22px 3px 9px !important;
    float: none !important;
    background-color: color-mix(in srgb, var(--pk-c-primary, #1c60f3) 12%, transparent) !important;
    background-image: none !important;
    border: 1px solid color-mix(in srgb, var(--pk-c-primary, #1c60f3) 30%, transparent) !important;
    border-radius: 6px !important;
    color: var(--pk-c-primary, #1c60f3) !important;
    font-size: 12.5px !important;
    line-height: 20px !important;
    box-shadow: none !important;
}

html body #user-submitted-posts .chosen-container-multi .chosen-choices li.search-choice .search-choice-close {
    top: 8px !important;
    right: 7px !important;
    background-position: -42px 1px !important;
}

html body #user-submitted-posts .chosen-container-multi .chosen-choices li.search-choice .search-choice-close:hover {
    background-position: -42px -10px !important;
}

/* 下拉面板 */
html body #user-submitted-posts .chosen-container .chosen-drop {
    margin-top: 6px !important;
    background-color: var(--pk-bg-card, #ffffff) !important;
    border: 1px solid var(--bs-border-color-translucent, rgba(0, 0, 0, 0.12)) !important;
    border-radius: 10px !important;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.14) !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

html body #user-submitted-posts .chosen-container .chosen-results {
    max-height: 260px !important;
    margin: 0 !important;
    padding: 6px !important;
    color: var(--pk-c-font, #343a40) !important;
}

html body #user-submitted-posts .chosen-container .chosen-results li {
    padding: 8px 10px !important;
    border-bottom: 0 !important;
    border-radius: 6px !important;
    background: transparent !important;
    color: var(--pk-c-font, #343a40) !important;
    font-size: 13.5px !important;
    line-height: 1.5 !important;
}

html body #user-submitted-posts .chosen-container .chosen-results li.highlighted {
    background-color: var(--pk-c-primary, #1c60f3) !important;
    color: #ffffff !important;
}

html body #user-submitted-posts .chosen-container .chosen-results li.group-result {
    color: var(--pk-c-sub, #6c757d) !important;
    background: transparent !important;
    font-size: 12px !important;
    font-weight: 600 !important;
}

html body #user-submitted-posts .chosen-container .chosen-results li.result-selected {
    color: var(--pk-c-primary, #1c60f3) !important;
    background: transparent !important;
}

/* ------------------------------------------------------------
   5. 富文本编辑器
   ------------------------------------------------------------ */
html body #user-submitted-posts .usp_text-editor {
    margin: 0 !important;
}

html body #user-submitted-posts .wp-editor-tools {
    margin: 0 0 10px !important;
    padding: 0 !important;
}

html body #user-submitted-posts .wp-media-buttons {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 8px !important;
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
}

html body #user-submitted-posts .wp-editor-tools .button,
html body #user-submitted-posts .wp-editor-tools a.button,
html body #user-submitted-posts .wp-editor-tools button.button {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 32px !important;
    min-height: 32px !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0 12px !important;
    background-color: var(--pk-bg-card, #ffffff) !important;
    border: 1px solid var(--bs-border-color-translucent, rgba(0, 0, 0, 0.15)) !important;
    border-radius: 8px !important;
    background-image: none !important;
    color: var(--pk-c-sub, #6c757d) !important;
    font-size: 12.5px !important;
    font-weight: 500 !important;
    line-height: 1 !important;
    text-decoration: none !important;
    text-shadow: none !important;
    box-shadow: none !important;
    cursor: pointer;
    transition: color 0.16s ease, border-color 0.16s ease;
}

html body #user-submitted-posts .wp-editor-tools .button:hover,
html body #user-submitted-posts .wp-editor-tools a.button:hover {
    border-color: var(--pk-c-primary, #1c60f3) !important;
    color: var(--pk-c-primary, #1c60f3) !important;
    background-color: var(--pk-bg-card, #ffffff) !important;
}

html body #user-submitted-posts .wp-media-buttons-icon {
    width: 16px !important;
    height: 16px !important;
    margin: 0 6px 0 0 !important;
    color: currentColor !important;
    font-size: 16px !important;
    line-height: 1 !important;
    vertical-align: middle !important;
}

/* 编辑区外框 */
html body #user-submitted-posts #wp-uspcontent-editor-container {
    width: 100% !important;
    background-color: #f8f8f9 !important;
    border: 1px solid rgba(0, 0, 0, 0.18) !important;
    border-radius: 10px !important;
    overflow: hidden !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
}

html body #user-submitted-posts #wp-uspcontent-editor-container iframe {
    width: 100% !important;
    border: 0 !important;
    display: block !important;
}

/* 快捷标签栏 */
html body #user-submitted-posts .quicktags-toolbar {
    padding: 7px 10px !important;
    background: transparent !important;
    border: 0 !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
    box-shadow: none !important;
}

html body #user-submitted-posts .quicktags-toolbar input.ed_button,
html body #user-submitted-posts .quicktags-toolbar .button {
    height: 26px !important;
    min-height: 26px !important;
    margin: 0 4px 0 0 !important;
    padding: 0 9px !important;
    background-color: transparent !important;
    background-image: none !important;
    border: 1px solid var(--bs-border-color-translucent, rgba(0, 0, 0, 0.15)) !important;
    border-radius: 6px !important;
    color: var(--pk-c-sub, #6c757d) !important;
    font-size: 12px !important;
    line-height: 1 !important;
    text-shadow: none !important;
    box-shadow: none !important;
}

html body #user-submitted-posts .quicktags-toolbar input.ed_button:hover {
    color: var(--pk-c-primary, #1c60f3) !important;
    border-color: var(--pk-c-primary, #1c60f3) !important;
}

/* 文本域 */
html body #user-submitted-posts textarea.wp-editor-area {
    display: block !important;
    width: 100% !important;
    min-height: 260px !important;
    margin: 0 !important;
    padding: 14px !important;
    background-color: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    color: #343a40 !important;
    font-family: inherit !important;
    font-size: 14.5px !important;
    line-height: 1.75 !important;
    box-shadow: none !important;
    resize: vertical !important;
    box-sizing: border-box !important;
}

html body #user-submitted-posts textarea.wp-editor-area:focus {
    outline: none !important;
}

/* ------------------------------------------------------------
   6. 错误提示与提交按钮
   ------------------------------------------------------------ */
html body #user-submitted-posts #usp-error-message {
    margin: 0 0 18px !important;
    padding: 12px 14px !important;
    background-color: rgba(220, 53, 69, 0.08) !important;
    border: 1px solid rgba(220, 53, 69, 0.35) !important;
    border-radius: 10px !important;
    color: #dc3545 !important;
    font-size: 13.5px !important;
    line-height: 1.6 !important;
}

html body #user-submitted-posts #usp-error-message.usp-hidden {
    display: none !important;
}

html body #user-submitted-posts #usp-submit {
    margin: 6px 0 0 !important;
    padding: 0 !important;
}

html body #user-submitted-posts #usp-submit p {
    margin: 0 !important;
}

html body #user-submitted-posts input.usp-submit {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 48px !important;
    min-height: 48px !important;
    margin: 0 !important;
    padding: 0 22px !important;
    background-color: var(--pk-c-primary, #1c60f3) !important;
    background-image: none !important;
    border: 1px solid var(--pk-c-primary, #1c60f3) !important;
    border-radius: 10px !important;
    color: #ffffff !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    letter-spacing: 1.5px !important;
    text-transform: none !important;
    text-shadow: none !important;
    box-shadow: 0 3px 10px color-mix(in srgb, var(--pk-c-primary, #1c60f3) 25%, transparent) !important;
    cursor: pointer;
    transition: filter 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
}

html body #user-submitted-posts input.usp-submit:hover {
    background-color: var(--pk-c-primary, #1c60f3) !important;
    color: #ffffff !important;
    filter: brightness(1.08);
    transform: translateY(-1px);
}

html body #user-submitted-posts input.usp-submit:active {
    filter: brightness(0.96);
    transform: translateY(0);
}

/* ------------------------------------------------------------
   7. 深色模式
   ------------------------------------------------------------ */
body.puock-dark #user-submitted-posts input.usp-input,
html[data-bs-theme="dark"] #user-submitted-posts input.usp-input {
    background-color: #212529 !important;
    border-color: #495057 !important;
    color: #dee2e6 !important;
}

body.puock-dark #user-submitted-posts input.usp-input::placeholder,
html[data-bs-theme="dark"] #user-submitted-posts input.usp-input::placeholder {
    color: #8b949e !important;
}

body.puock-dark #user-submitted-posts select.usp-select,
html[data-bs-theme="dark"] #user-submitted-posts select.usp-select {
    background-color: #212529 !important;
    border-color: #495057 !important;
    color: #dee2e6 !important;
}

body.puock-dark #user-submitted-posts select.usp-select option,
html[data-bs-theme="dark"] #user-submitted-posts select.usp-select option {
    background-color: #212529 !important;
    color: #dee2e6 !important;
}

body.puock-dark #user-submitted-posts .chosen-container-multi .chosen-choices,
html[data-bs-theme="dark"] #user-submitted-posts .chosen-container-multi .chosen-choices {
    background-color: #212529 !important;
    border-color: #495057 !important;
}

body.puock-dark #user-submitted-posts .chosen-container .chosen-results li,
html[data-bs-theme="dark"] #user-submitted-posts .chosen-container .chosen-results li {
    color: #dee2e6 !important;
}

body.puock-dark #user-submitted-posts #wp-uspcontent-editor-container,
html[data-bs-theme="dark"] #user-submitted-posts #wp-uspcontent-editor-container {
    background-color: #212529 !important;
    border-color: #495057 !important;
}

body.puock-dark #user-submitted-posts .quicktags-toolbar,
html[data-bs-theme="dark"] #user-submitted-posts .quicktags-toolbar {
    border-bottom-color: rgba(255, 255, 255, 0.12) !important;
}

body.puock-dark #user-submitted-posts textarea.wp-editor-area,
html[data-bs-theme="dark"] #user-submitted-posts textarea.wp-editor-area {
    background-color: #212529 !important;
    color: #dee2e6 !important;
}

body.puock-dark #user-submitted-posts .wp-editor-tools .button,
html[data-bs-theme="dark"] #user-submitted-posts .wp-editor-tools .button,
body.puock-dark #user-submitted-posts .quicktags-toolbar input.ed_button,
html[data-bs-theme="dark"] #user-submitted-posts .quicktags-toolbar input.ed_button {
    background-color: #2b3035 !important;
    border-color: #495057 !important;
    color: #ced4da !important;
}

/* 「可视化 / 文本」切换标签：WordPress 硬编码 #f6f7f7 与 #f0f0f1，
   不跟着主题变量走，深色下是两个白块 */
body.puock-dark #user-submitted-posts .wp-editor-tabs button,
html[data-bs-theme="dark"] #user-submitted-posts .wp-editor-tabs button {
    background-color: #2b3035 !important;
    border-color: #495057 !important;
    color: #ced4da !important;
    text-shadow: none !important;
}

body.puock-dark #user-submitted-posts .wp-editor-tabs button:hover,
html[data-bs-theme="dark"] #user-submitted-posts .wp-editor-tabs button:hover {
    background-color: #343a40 !important;
    color: #f8f9fa !important;
}

/* TinyMCE 外壳：工具条、状态栏、下拉面板都是白底硬编码。
   内容区在 iframe 里，由编辑器自身的 content_css 控制，这里不越界。 */
body.puock-dark #user-submitted-posts .mce-panel,
body.puock-dark #user-submitted-posts .mce-toolbar-grp,
body.puock-dark #user-submitted-posts .mce-statusbar,
body.puock-dark #user-submitted-posts .mce-menu,
body.puock-dark #user-submitted-posts .mce-floatpanel,
html[data-bs-theme="dark"] #user-submitted-posts .mce-panel,
html[data-bs-theme="dark"] #user-submitted-posts .mce-toolbar-grp,
html[data-bs-theme="dark"] #user-submitted-posts .mce-statusbar,
html[data-bs-theme="dark"] #user-submitted-posts .mce-menu,
html[data-bs-theme="dark"] #user-submitted-posts .mce-floatpanel {
    background-color: #2b3035 !important;
    border-color: #495057 !important;
    color: #ced4da !important;
}

body.puock-dark #user-submitted-posts .mce-btn,
body.puock-dark #user-submitted-posts .mce-btn button,
html[data-bs-theme="dark"] #user-submitted-posts .mce-btn,
html[data-bs-theme="dark"] #user-submitted-posts .mce-btn button {
    background-color: transparent !important;
    background-image: none !important;
    border-color: transparent !important;
    color: #ced4da !important;
    text-shadow: none !important;
}

body.puock-dark #user-submitted-posts .mce-btn:hover,
body.puock-dark #user-submitted-posts .mce-btn button:hover,
html[data-bs-theme="dark"] #user-submitted-posts .mce-btn:hover,
html[data-bs-theme="dark"] #user-submitted-posts .mce-btn button:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: #f8f9fa !important;
}

/* ------------------------------------------------------------
   8. 移动端
   ------------------------------------------------------------ */
@media (max-width: 600px) {
    html body #user-submitted-posts input.usp-input {
        height: 44px !important;
        min-height: 44px !important;
        line-height: 42px !important;
    }

    html body #user-submitted-posts .chosen-container-multi .chosen-choices {
        min-height: 44px !important;
    }

    html body #user-submitted-posts input.usp-submit {
        height: 46px !important;
        min-height: 46px !important;
        letter-spacing: 1px !important;
    }

    html body #user-submitted-posts textarea.wp-editor-area {
        min-height: 220px !important;
    }
}
