/**
 * Product Card — Frontend Editor Styles
 * Adapted to Zibll theme native UI style
 */

/* ===== Editor Container ===== */
.product-card-editor-wrap {
    display: none;
}

.product-card-editor-wrap.active {
    display: block;
}

.pc-editor-main {
    padding: 20px;
}

/* ===== Sidebar Button ===== */
.product-card-sidebar-btn .but {
    display: block;
    width: 100%;
    text-align: center;
}

.product-card-sidebar-btn .jb-vip1 {
    background: linear-gradient(135deg, #8B1A2B, #C41E3A);
    color: #fff;
    border: none;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* ===== Field Title ===== */
.pc-field-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--main-color, #333);
    margin-bottom: 10px;
}

.pc-field-title .badg {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

/* ===== Image Upload Area ===== */
.pc-image-upload-wrap {
    text-align: center;
}

.pc-image-preview {
    max-width: 220px;
    margin: 0 auto;
    border-radius: 8px;
    overflow: hidden;
    border: 2px dashed var(--muted-border-color, #ddd);
}

.pc-image-preview img {
    width: 100%;
    display: block;
}

.pc-image-placeholder {
    padding: 40px 20px;
    color: var(--muted-2-color, #999);
    cursor: pointer;
    transition: all 0.2s;
}

.pc-image-placeholder:hover {
    background: var(--muted-bg-color, #f9f9f9);
    color: var(--main-color, #666);
}

.pc-image-placeholder i {
    font-size: 32px;
    display: block;
    margin-bottom: 8px;
}

/* ===== Flavor Row ===== */
.pc-flavor-row {
    border: 1px solid var(--muted-border-color, #eee);
    border-radius: 8px;
    padding: 12px;
    background: var(--muted-bg-color, #fafafa);
}

.pc-flavor-name input {
    width: 100%;
}

/* ===== Taste Profile Row ===== */
.pc-profile-row {
    border: 1px solid var(--muted-border-color, #eee);
    border-radius: 8px;
    padding: 12px;
    background: var(--muted-bg-color, #fafafa);
}

/* ===== Unified Slider Component (initial rows & new rows shared) ===== */
.pc-range-input {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: linear-gradient(to right, #8B1A2B 0%, #8B1A2B var(--range-pct, 50%), #e0e0e0 var(--range-pct, 50%), #e0e0e0 100%);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    transition: background 0.05s;
}

/* Chrome / Edge / Safari Slider Knob */
.pc-range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #8B1A2B;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    transition: transform 0.1s;
}

.pc-range-input::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.pc-range-input::-webkit-slider-thumb:active {
    transform: scale(1.05);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
}

/* Firefox Slider Knob */
.pc-range-input::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #8B1A2B;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

/* Firefox Track */
.pc-range-input::-moz-range-track {
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
}

.pc-range-display {
    min-width: 32px;
    font-weight: 700;
    font-size: 13px;
    color: #8B1A2B;
    text-align: center;
    line-height: 1;
}

/* ===== Category Selector ===== */
.pc-category-select {
    padding: 5px 0;
}

.pc-category-select label {
    display: inline-block;
    margin-bottom: 5px;
}

/* ===== Sidebar Hide ===== */
.newposts-wrap.product-card-active .sidebar > .zib-widget:not(.product-card-sidebar-btn),
.newposts-wrap.product-card-active .sidebar > .newpost-cat-drop,
.newposts-wrap.product-card-active .sidebar > .newpost-topics-drop,
.newposts-wrap.product-card-active .sidebar > .newpost-custom-filter-,
.newposts-wrap.product-card-active .sidebar .title-theme,
.newposts-wrap.product-card-active .sidebar .separator,
.newposts-wrap.product-card-active .sidebar .but-average,
.newposts-wrap.product-card-active .sidebar .new-posts-submit,
.newposts-wrap.product-card-active .sidebar .zib-widget:not(.product-card-sidebar-btn) {
    display: none !important;
}

/* Hide original editor content, keep only Product Card editor */
.newposts-wrap.product-card-active .editor-main-box > :not(#product-card-editor) {
    display: none !important;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    /*
     * Fix: mobile input fields invisible (Flavors / Taste Profile)
     *
     * Root cause chain:
     *   1. Zibll .flex sets overflow:hidden + height:100% (from a non-overridden early rule)
     *   2. Zibll .flex also sets align-items:center (last .flex rule wins)
     *   3. Zibll .flex1 on the child sets overflow:hidden
     *   4. Mobile flex-direction:column + align-items:center → child width collapses to 0
     *   5. TWO layers of overflow:hidden (row + child) clip the zero-width input → invisible
     *
     * Fix: override overflow/height on rows, force stretch alignment, restore child overflow
     */

    /* ── Flavor rows: use display:block to bypass ALL Zibll flex conflicts ── */
    #product-card-editor .pc-flavor-row {
        display: block !important;
        overflow: visible !important;
        height: auto !important;
        width: 100% !important;
    }

    #product-card-editor .pc-flavor-row .pc-flavor-name {
        display: block !important;
        width: 100% !important;
        overflow: visible !important;
        flex: none !important;
    }

    #product-card-editor .pc-flavor-row .pc-flavor-name input.form-control {
        display: block !important;
        width: 100% !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* ── Profile rows ── */
    #product-card-editor .pc-profile-row {
        flex-wrap: wrap;
        align-items: stretch !important;
        overflow: visible !important;   /* kill Zibll .flex overflow:hidden */
        height: auto !important;         /* kill Zibll .flex height:100% */
    }

    #product-card-editor .pc-profile-row .pc-profile-name {
        overflow: visible !important;    /* kill Zibll .flex1 overflow:hidden */
        min-width: 0;
        flex: 1 1 auto !important;
    }

    #product-card-editor .pc-profile-row .pc-profile-value {
        width: 100% !important;
        margin-left: 0 !important;
        margin-top: 8px;
    }

    /* ── Delete buttons: full-width = better mobile tap target ── */
    #product-card-editor .pc-flavor-row .pc-remove-item,
    #product-card-editor .pc-profile-row .pc-remove-item {
        width: 100%;
        margin-left: 0 !important;
        margin-top: 8px;
    }
}

/* ===== Sidebar Widget Visibility: Card Editor Mode ===== */
/* When Product Card VIP Editor is active, hide all sidebar widgets except Product Card */
body.card-editor-active .sidebar .zib-widget:not(.product-card-sidebar-btn) {
    display: none !important;
}

/* ===== Custom Submit Buttons (independent from Zibll styles, avoid JS conflicts) ===== */
.pc-card-submit {
    display: inline-block;
    padding: 10px 28px;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s;
    color: #fff;
    text-align: center;
    line-height: 1.5;
}

.pc-card-submit:hover {
    opacity: 0.88;
    transform: translateY(-1px);
}

.pc-card-submit:active {
    transform: translateY(0);
}

.pc-card-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.pc-btn-draft {
    background: linear-gradient(135deg, #52c41a, #73d13d);
}

.pc-btn-publish {
    background: linear-gradient(135deg, #1677ff, #4096ff);
}

/* ===== Emoji Autocomplete Dropdown ===== */
.pc-emoji-dropdown {
    position: absolute;
    z-index: 99999;
    background: #fff;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    max-height: 260px;
    overflow-y: auto;
    padding: 4px 0;
}

.pc-emoji-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    cursor: pointer;
    transition: background 0.15s;
}

.pc-emoji-option:hover {
    background: var(--muted-bg-color, #f5f5f5);
}

.pc-emoji-icon {
    font-size: 20px;
    line-height: 1;
    width: 28px;
    text-align: center;
}

.pc-emoji-label {
    font-size: 14px;
    color: var(--main-color, #333);
}
