/* ═══════════════════════════════════════════════════════════
   TECHNEX Post Editor Modal — Premium Redesign 2026
   ═══════════════════════════════════════════════════════════ */

/* ── Overlay ── */
.pe-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99998;
    background: rgba(10, 12, 22, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: none;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 20px;
}

.pe-overlay.open {
    display: flex;
    animation: peOverlayIn .25s ease-out;
}

@keyframes peOverlayIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Modal Shell ── */
.pe-modal {
    background: #ffffff;
    border: 1px solid rgba(91, 95, 248, 0.16);
    border-radius: 20px;
    width: 100%;
    max-width: 1080px;
    max-height: 88vh;
    box-shadow:
        0 4px 20px -2px rgba(15, 17, 25, 0.08),
        0 24px 60px -10px rgba(10, 12, 22, 0.22),
        0 0 0 1px rgba(91, 95, 248, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: peModalIn .3s cubic-bezier(.22, .61, .36, 1);
}

@keyframes peModalIn {
    from { opacity: 0; transform: translateY(24px) scale(.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

#technexPostEditorOverlay.pe-overlay.open {
    overflow: hidden;
}

#technexPostEditorOverlay .pe-modal {
    max-height: 88vh;
    overflow: hidden;
}

.pe-modal--manage {
    max-width: 680px;
}

/* ── Header ── */
.pe-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid #eef0f6;
    background: linear-gradient(135deg, rgba(91, 95, 248, 0.04), rgba(99, 35, 236, 0.02));
    flex-shrink: 0;
}

.pe-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    flex: 1;
}

.pe-back-btn, .pe-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #8b8fa8;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    transition: all .2s ease;
}

.pe-back-btn:hover, .pe-close-btn:hover {
    background: rgba(91, 95, 248, 0.08);
    color: #5b5ff8;
    transform: scale(1.05);
}

.pe-title-text {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    letter-spacing: -0.01em;
}

/* ── Body (Scrollable Container) ── */
.pe-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: #fafbfd;
    overscroll-behavior: contain;
}

/* ── Columns Layout (Desktop) ── */
.pe-columns {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    width: 100%;
}

@media (min-width: 1025px) {
    .pe-columns {
        grid-template-columns: 340px 1fr;
        gap: 28px;
    }
}

.pe-col-left {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

.pe-col-right {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

/* ── Fields ── */
.pe-field {
    min-width: 0;
    max-width: 100%;
}

.pe-field label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 6px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.pe-field label .req {
    color: #ef4444;
    font-weight: 700;
}

/* ── Inputs & Controls ── */
.pe-input {
    width: 100%;
    box-sizing: border-box;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    color: #1e293b;
    background: #ffffff;
    outline: none;
    transition: all .2s ease;
    max-width: 100%;
    min-width: 0;
}

.pe-textarea-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.45;
    resize: none;
    min-height: 70px;
    padding: 10px 14px;
    overflow-y: auto;
}

.pe-input:focus {
    border-color: #5b5ff8;
    box-shadow: 0 0 0 4px rgba(91, 95, 248, 0.14);
}

.pe-input::placeholder {
    color: #94a3b8;
}

.pe-select {
    height: 42px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 38px;
    cursor: pointer;
}

/* ── Cover Image Dropzone ── */
.pe-image-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: all .25s ease;
    position: relative;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    min-height: 140px;
}

.pe-upload-icon {
    color: #64748b;
    transition: all 0.2s ease;
}

.pe-image-zone #peImageHint {
    font-size: 12px;
    color: #64748b;
    font-weight: 500;
    line-height: 1.4;
}

.pe-image-zone #peImageHint small {
    color: #94a3b8;
    font-size: 11px;
}

.pe-image-zone:hover,
.pe-image-zone.drag-over {
    border-color: #5b5ff8;
    background: rgba(91, 95, 248, 0.02);
}

.pe-image-zone:hover .pe-upload-icon {
    color: #5b5ff8;
    transform: translateY(-2px);
}

.pe-image-zone img {
    max-width: 100%;
    max-height: 150px;
    border-radius: 8px;
    margin-top: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.pe-image-zone.has-image {
    padding: 0;
    border: none;
    background: transparent;
}

.pe-image-zone.has-image .pe-upload-icon {
    display: none;
}

.pe-image-zone.has-image:hover,
.pe-image-zone.has-image.drag-over {
    border: none;
    background: #f1f5f9;
}

.pe-image-zone.has-image img {
    margin-top: 0;
    width: 100%;
    max-height: none;
    aspect-ratio: 2 / 1;
    object-fit: cover;
    border-radius: 12px;
    display: block;
}

/* ── Text Editors ── */
.pe-editor-wrap {
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    background: #ffffff;
    transition: all .2s ease;
    display: flex;
    flex-direction: column;
}

.pe-editor-wrap:focus-within {
    border-color: #5b5ff8;
    box-shadow: 0 0 0 4px rgba(91, 95, 248, 0.12);
}

/* Tabs */
.pe-editor-tabs {
    display: flex;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    flex-shrink: 0;
}

.pe-tab-btn {
    background: none;
    border: none;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all .2s ease;
}

.pe-tab-btn:hover {
    color: #5b5ff8;
}

.pe-tab-btn.active {
    color: #5b5ff8;
    border-bottom-color: #5b5ff8;
    background: #ffffff;
}

/* Toolbars */
.pe-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 10px;
    border-bottom: 1px solid #e2e8f0;
    background: #fafbfc;
    flex-shrink: 0;
}

.pe-tool-btn {
    background: none;
    border: none;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 12px;
    color: #475569;
    cursor: pointer;
    min-width: 28px;
    transition: all .15s ease;
    font-weight: 600;
}

.pe-tool-btn:hover {
    background: rgba(91, 95, 248, 0.08);
    color: #5b5ff8;
}

/* Textareas & Previews */
.pe-textarea {
    width: 100%;
    border: none;
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    box-sizing: border-box;
    font-family: inherit;
    outline: none;
    color: #1e293b;
    background: #ffffff;
    flex: 1 1 auto;
}

.pe-textarea::placeholder {
    color: #94a3b8;
}

.pe-textarea.hidden {
    display: none;
}

.pe-preview {
    width: 100%;
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.6;
    color: #1e293b;
    display: none;
    background: #ffffff;
    overflow-y: auto;
    box-sizing: border-box;
    flex: 1 1 auto;
}

.pe-preview.active {
    display: block;
}

.pe-preview img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 12px 0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

/* Editor Bottom Bar */
.pe-editor-footer {
    padding: 8px 12px;
    border-top: 1px solid #e2e8f0;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    transition: all .2s ease;
    background: #f8fafc;
    flex-shrink: 0;
}

.pe-editor-footer:hover,
.pe-editor-footer.drag-over {
    background: rgba(91, 95, 248, 0.04);
    color: #5b5ff8;
}

/* Resizable content images */
.pe-img-wrap {
    position: relative;
    display: inline-block;
    max-width: 100%;
    margin: 8px 0;
}

.pe-resizable-img {
    display: block;
    height: auto;
    max-width: 100%;
}

.pe-img-resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 14px;
    height: 14px;
    background: #5b5ff8;
    border: 2px solid #ffffff;
    border-radius: 3px 0 0 0;
    cursor: nwse-resize;
}

/* ── Error Bar ── */
.pe-error {
    color: #ef4444;
    font-size: 13px;
    font-weight: 600;
    margin-top: 4px;
    display: none;
    padding: 10px 14px;
    background: rgba(239, 68, 68, 0.06);
    border-radius: 10px;
    border: 1px solid rgba(239, 68, 68, 0.12);
}

.pe-error.show {
    display: block;
}

/* ── Footer ── */
.pe-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid #eef0f6;
    background: linear-gradient(135deg, rgba(91, 95, 248, 0.02), #ffffff);
    flex-shrink: 0;
}

.pe-btn-cancel {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #475569;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s ease;
}

.pe-btn-cancel:hover {
    background: #e2e8f0;
    transform: translateY(-1px);
}

.pe-btn-create {
    background: linear-gradient(135deg, #5b5ff8, #6c3ce9);
    border: none;
    color: #ffffff;
    padding: 10px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all .25s ease;
    box-shadow: 0 4px 12px rgba(91, 95, 248, 0.25);
}

.pe-btn-create:hover {
    background: linear-gradient(135deg, #4a4ed6, #5b2fd1);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(91, 95, 248, 0.35);
}

.pe-btn-create:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.pe-create-more {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: auto;
    font-size: 13px;
    color: #64748b;
    font-weight: 600;
}

.pe-create-more input[type="checkbox"] {
    accent-color: #5b5ff8;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.pe-draft-saved-hint {
    font-size: 11px;
    font-weight: 500;
    color: #059669;
    margin-left: 6px;
}

.pe-draft-saved-hint[hidden] {
    display: none !important;
}

/* ── Manage Posts Modal ── */
.pe-manage-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#peManageList {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pe-manage-pagination {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 8px;
    margin-top: 4px;
}

.pe-manage-page-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1.5px solid #e2e8f0;
    background: #ffffff;
    color: #475569;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all .2s ease;
}

.pe-manage-page-btn:hover {
    border-color: #5b5ff8;
    color: #5b5ff8;
    background: rgba(91, 95, 248, 0.04);
}

.pe-manage-page-btn.active {
    background: linear-gradient(135deg, #5b5ff8, #6c3ce9);
    border-color: transparent;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(91, 95, 248, 0.25);
}

.pe-manage-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    background: #ffffff;
    transition: all .2s ease;
}

.pe-manage-item:hover {
    border-color: rgba(91, 95, 248, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.pe-manage-info {
    flex: 1;
    min-width: 0;
}

.pe-manage-title {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    word-break: break-word;
    overflow-wrap: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pe-manage-meta {
    font-size: 12px;
    color: #64748b;
    margin-top: 4px;
}

.pe-manage-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    width: 120px;
    justify-content: flex-end;
}

.pe-manage-edit, .pe-manage-del {
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s ease;
}

.pe-manage-edit {
    background: rgba(16, 185, 129, 0.08);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.pe-manage-edit:hover {
    background: rgba(16, 185, 129, 0.14);
    transform: translateY(-1px);
}

.pe-manage-del {
    background: rgba(239, 68, 68, 0.06);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.15);
}

.pe-manage-del:hover {
    background: rgba(239, 68, 68, 0.1);
    transform: translateY(-1px);
}

.pe-manage-loading, .pe-manage-empty {
    text-align: center;
    color: #64748b;
    padding: 32px;
    font-size: 14px;
}

/* ── Delete Confirmation Dialog ── */
.pe-delete-confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000025;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.pe-delete-confirm-overlay[hidden] {
    display: none !important;
}

.pe-delete-confirm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 12, 22, 0.5);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.pe-delete-confirm-modal {
    position: relative;
    z-index: 1;
    width: min(440px, calc(100vw - 32px));
    background: #ffffff;
    border: 1px solid rgba(239, 68, 68, 0.15);
    border-radius: 16px;
    padding: 24px 24px 20px;
    box-shadow:
        0 4px 20px -2px rgba(239, 68, 68, 0.06),
        0 20px 50px -12px rgba(10, 12, 22, 0.2);
    animation: peDeleteIn .25s ease-out;
}

@keyframes peDeleteIn {
    from { opacity: 0; transform: scale(.95); }
    to   { opacity: 1; transform: scale(1); }
}

.pe-delete-confirm-title {
    margin: 0 0 12px;
    font-size: 18px;
    font-weight: 700;
    color: #ef4444;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pe-delete-confirm-title::before {
    content: '⚠';
    font-size: 20px;
}

.pe-delete-confirm-message {
    margin: 0 0 20px;
    font-size: 14px;
    line-height: 1.6;
    color: #475569;
}

.pe-delete-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.pe-delete-confirm-cancel,
.pe-delete-confirm-submit {
    min-width: 120px;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all .2s ease;
}

.pe-delete-confirm-cancel {
    border: 1.5px solid #e2e8f0;
    background: #ffffff;
    color: #475569;
}

.pe-delete-confirm-cancel:hover {
    background: #f1f5f9;
    transform: translateY(-1px);
}

.pe-delete-confirm-submit {
    border: none;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.pe-delete-confirm-submit:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.35);
}

.pe-delete-confirm-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

/* ── Crop Modal ── */
.pe-crop-modal {
    position: fixed;
    inset: 0;
    z-index: 100001;
    background: rgba(10, 12, 22, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.pe-crop-modal[hidden] {
    display: none !important;
}

.pe-crop-dialog {
    background: #ffffff;
    border-radius: 16px;
    width: min(720px, 100%);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow:
        0 4px 20px -2px rgba(0, 0, 0, 0.05),
        0 24px 60px -10px rgba(0, 0, 0, 0.2);
    animation: peModalIn .3s cubic-bezier(.22, .61, .36, 1);
}

.pe-crop-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #eef0f6;
    background: linear-gradient(135deg, rgba(91, 95, 248, 0.03), transparent);
}

.pe-crop-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
}

.pe-crop-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #8b8fa8;
    line-height: 1;
    padding: 4px;
    border-radius: 6px;
    transition: all .2s ease;
}

.pe-crop-close:hover {
    background: rgba(91, 95, 248, 0.08);
    color: #5b5ff8;
}

.pe-crop-body {
    padding: 16px;
    background: #f8fafc;
    max-height: 55vh;
    overflow: hidden;
}

.pe-crop-body img {
    display: block;
    max-width: 100%;
    max-height: 50vh;
}

.pe-crop-submit {
    margin: 0 20px 20px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #5b5ff8, #6c3ce9);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all .25s ease;
    box-shadow: 0 2px 8px rgba(91, 95, 248, 0.3);
}

.pe-crop-submit:hover {
    background: linear-gradient(135deg, #4a4ed6, #5b2fd1);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(91, 95, 248, 0.4);
}

.pe-crop-submit:disabled {
    opacity: .5;
    cursor: not-allowed;
    box-shadow: none;
}

/* ── Responsive breakpoints ── */
@media (max-width: 1024px) {
    .pe-overlay {
        padding: 10px;
    }
    .pe-modal {
        max-height: 94vh;
    }
    #technexPostEditorOverlay .pe-modal {
        max-height: 94vh;
    }
    .pe-body {
        padding: 16px;
    }
    .pe-columns {
        gap: 16px;
    }
}

@media (max-width: 767px) {
    .pe-overlay {
        padding: 0;
        align-items: flex-end;
    }
    .pe-modal {
        max-height: 92vh;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.15);
        animation: peModalMobileIn .3s cubic-bezier(.22, .61, .36, 1);
    }
    @keyframes peModalMobileIn {
        from { transform: translateY(100%); }
        to   { transform: translateY(0); }
    }
    #technexPostEditorOverlay .pe-modal {
        max-height: 92vh;
    }
    .pe-header {
        padding: 14px 16px;
    }
    .pe-body {
        padding: 16px;
        gap: 16px;
    }
    .pe-footer {
        padding: 14px 16px;
        flex-direction: row;
        justify-content: flex-end;
    }
    .pe-manage-item {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .pe-manage-actions {
        width: 100%;
        justify-content: flex-end;
    }
}
