/* ============================================================================
   Page Builder Styles
   ============================================================================ */

/* Element wrapper */
.swp_pelement {
    position: relative;
    margin: 10px;
    padding: 10px;
    border: 1px dashed #d0d0d0;
    border-radius: 6px;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    cursor: grab;
}

.swp_pelement:hover {
    border-color: #6c63ff;
    box-shadow: 0 2px 8px rgba(108, 99, 255, 0.12);
}

/* Element icon bar */
.swp_eicon {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    margin-bottom: 6px;
    background: #f7f7fa;
    border-radius: 4px;
    font-size: 14px;
    color: #888;
}

.swp_eicon>i {
    font-size: 16px;
    color: #6c63ff;
    margin-right: 4px;
}

.swp_econfig {
    display: flex;
    gap: 2px;
    margin-left: auto;
}

.swp_ebutton {
    padding: 3px 7px;
    cursor: pointer;
    border-radius: 3px;
    color: #666;
    transition: background 0.15s, color 0.15s;
}

.swp_ebutton:hover {
    background: #e8e6ff;
    color: #6c63ff;
}

/* Element holders */
.eholder {
    min-height: 30px;
    padding: 4px;
}

.peholder {
    min-height: 30px;
    padding: 4px;
}

/* Title / text inside elements */
.ehtitle {
    padding: 4px 8px;
    min-height: 24px;
}

.ehtitle[contenteditable="true"] {
    outline: 2px solid #6c63ff;
    border-radius: 3px;
    background: #fafafe;
}

/* Add element button */
.swp_eadd {
    display: flex;
    justify-content: center;
    padding: 12px;
    margin: 8px 10px;
    border: 2px dashed #d0d0d0;
    border-radius: 6px;
    cursor: pointer;
    color: #aaa;
    font-size: 22px;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.swp_eadd:hover {
    border-color: #6c63ff;
    color: #6c63ff;
    background: #f5f4ff;
}

/* Page builder container */
.swp_gpbuilder {
    padding: 10px;
    min-height: 100px;
    background: #fafafa;
    border-radius: 8px;
}

.swp_sortable {
    min-height: 40px;
}

/* Drag and drop states */
.swp_pb_dragging {
    opacity: 0.4;
    border-color: #6c63ff !important;
}

.swp_pb_dragover {
    background: #f0eeff !important;
    border-color: #6c63ff !important;
    border-style: solid !important;
}

/* ============================================================================
   Popup Overlay (shared for add panel + config)
   ============================================================================ */
.swp_pb_popup_overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.swp_pb_popup_overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.swp_pb_popup_box {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    width: 480px;
    max-width: 92vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: swp_pb_popIn 0.2s ease;
}

.swp_pb_popup_config {
    width: 520px;
}

@keyframes swp_pb_popIn {
    from {
        transform: scale(0.95) translateY(8px);
        opacity: 0;
    }

    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.swp_pb_popup_header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    font-weight: 600;
    font-size: 16px;
    color: #222;
    border-bottom: 1px solid #eee;
}

.swp_pb_popup_close {
    cursor: pointer;
    font-size: 22px;
    color: #999;
    line-height: 1;
}

.swp_pb_popup_close:hover {
    color: #333;
}

.swp_pb_popup_body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
}

.swp_pb_popup_footer {
    padding: 12px 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ============================================================================
   Element Picker Grid
   ============================================================================ */
.swp_pb_picker {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.swp_pb_picker_item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 10px;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.swp_pb_picker_item:hover {
    border-color: #6c63ff;
    background: #f5f4ff;
    transform: translateY(-2px);
}

.swp_pb_picker_item i {
    font-size: 24px;
    color: #6c63ff;
}

.swp_pb_picker_item span {
    font-size: 12px;
    color: #555;
    text-align: center;
}

.swp_pb_picker_templates {
    grid-column: span 3;
    flex-direction: row;
    gap: 10px;
    padding: 12px 16px;
    background: #f7f7fa;
}

.swp_pb_picker_templates i {
    font-size: 20px;
}

.swp_pb_picker_templates span {
    font-size: 13px;
}

/* ============================================================================
   Config Form
   ============================================================================ */
.swp_pb_formrow {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.swp_pb_formrow>label {
    width: 100px;
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 500;
    color: #444;
}

.swp_pb_formrow_quad {
    flex-wrap: wrap;
}

.swp_pb_quad {
    display: flex;
    gap: 6px;
}

.swp_pb_input {
    flex: 1;
    padding: 7px 10px;
    border: 1px solid #d0d0d0;
    border-radius: 5px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.swp_pb_input:focus {
    border-color: #6c63ff;
}

.swp_pb_input_sm {
    width: 60px;
    padding: 7px 8px;
    border: 1px solid #d0d0d0;
    border-radius: 5px;
    font-size: 13px;
    text-align: center;
    outline: none;
}

.swp_pb_input_sm:focus {
    border-color: #6c63ff;
}

.swp_pb_textarea {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #d0d0d0;
    border-radius: 5px;
    font-size: 12px;
    font-family: monospace;
    resize: vertical;
    outline: none;
}

.swp_pb_textarea:focus {
    border-color: #6c63ff;
}

.swp_pb_check_label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #666;
    cursor: pointer;
    width: auto !important;
}

.swp_pb_formrow_note {
    font-size: 12px;
    color: #888;
    font-style: italic;
}

/* Align buttons */
.swp_pb_align_btns {
    display: flex;
    gap: 2px;
    border: 1px solid #d0d0d0;
    border-radius: 5px;
    overflow: hidden;
}

.swp_pb_align_btn {
    padding: 6px 10px;
    border: none;
    background: #fff;
    cursor: pointer;
    color: #888;
    font-size: 14px;
    transition: background 0.15s, color 0.15s;
}

.swp_pb_align_btn:hover {
    background: #f5f4ff;
    color: #6c63ff;
}

.swp_pb_align_btn.active {
    background: #6c63ff;
    color: #fff;
}

/* Buttons */
.swp_pb_btn {
    padding: 8px 20px;
    background: #6c63ff;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.swp_pb_btn:hover {
    background: #5a52e0;
}

.swp_pb_btn_sm {
    padding: 5px 12px;
    background: #6c63ff;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

.swp_pb_btn_sm:hover {
    background: #5a52e0;
}

.swp_pb_btn_danger_sm {
    background: #e74c3c;
}

.swp_pb_btn_danger_sm:hover {
    background: #c0392b;
}

/* ============================================================================
   Templates List
   ============================================================================ */
.swp_pb_template_item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    margin-bottom: 8px;
}

.swp_pb_template_item span {
    font-size: 14px;
    color: #333;
    font-weight: 500;
}

.swp_pb_template_actions {
    display: flex;
    gap: 6px;
}

/* Post items / member chips (dynamic content) */
.swp_pb_post_item {
    display: flex;
    justify-content: space-between;
    padding: 6px 10px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
}

.swp_pb_post_item strong {
    color: #333;
}

.swp_pb_post_item span {
    color: #999;
    font-size: 12px;
}

.swp_pb_members_grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px;
}

.swp_pb_member_chip {
    padding: 4px 10px;
    background: #f0eeff;
    color: #5a52e0;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

/* Empty state */
.swp_pb_empty {
    padding: 20px;
    text-align: center;
    color: #aaa;
    font-size: 13px;
}

/* Spinner keyframe */
@keyframes swp_spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* ============================================================================
   Responsive
   ============================================================================ */
@media (max-width: 600px) {
    .swp_pb_picker {
        grid-template-columns: repeat(2, 1fr);
    }

    .swp_pb_picker_templates {
        grid-column: span 2;
    }

    .swp_pb_popup_box,
    .swp_pb_popup_config {
        width: 96vw;
        max-height: 90vh;
    }

    .swp_pb_formrow {
        flex-direction: column;
        align-items: flex-start;
    }

    .swp_pb_formrow>label {
        width: auto;
        margin-bottom: 4px;
    }
}