/* Gaya untuk mod sunting langsung */
.wpc-live-edit-mode {
    outline: 2px dashed #0073aa !important;
    min-height: 200px;
    padding: 20px;
    cursor: text;
    max-width: none;
    width: 100%;
}

.wpc-live-edit-mode:focus {
    outline: 2px solid #0073aa !important;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.3);
}

/* Kawalan sunting */
#wpc-live-editor-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999 !important;
    display: flex;
    gap: 10px;
    background: white;
    padding: 10px;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border: 1px solid #ddd;
    flex-wrap: wrap;
    max-width: 500px;
}

.wpc-control-btn {
    padding: 10px 15px;
    background-color: #0073aa;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s, opacity 0.3s;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.wpc-control-btn:hover:not(:disabled) {
    background-color: #005a87;
}

.wpc-control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #999;
}

/* Butang Undo/Redo */
.wpc-control-btn#wpc-undo,
.wpc-control-btn#wpc-redo {
    background-color: #555d66;
    padding: 10px 12px;
    min-width: 45px;
}

.wpc-control-btn#wpc-undo:hover:not(:disabled),
.wpc-control-btn#wpc-redo:hover:not(:disabled) {
    background-color: #32373c;
}

/* Icon untuk butang */
.wpc-control-btn#wpc-undo::before {
    content: "↶";
    font-size: 18px;
    font-weight: bold;
}

.wpc-control-btn#wpc-redo::before {
    content: "↷";
    font-size: 18px;
    font-weight: bold;
}

.wpc-control-btn#wpc-cancel-edit {
    background-color: #737373;
}

.wpc-control-btn#wpc-cancel-edit:hover {
    background-color: #5a5a5a;
}

/* Mesej status */
.wpc-status-message {
    position: fixed;
    top: 70px;
    right: 20px;
    padding: 12px 15px;
    border-radius: 4px;
    color: white;
    font-weight: bold;
    z-index: 99999 !important;
    display: none;
    max-width: 300px;
    word-wrap: break-word;
    border-left: 4px solid;
}

.wpc-status-message.success {
    background-color: #46b450;
    border-left-color: #3d9745;
}

.wpc-status-message.error {
    background-color: #dc3232;
    border-left-color: #c12626;
}

.wpc-status-message.info {
    background-color: #0073aa;
    border-left-color: #005a87;
}

/* Penunjuk mod sunting */
.wpc-edit-indicator {
    position: sticky !important;
    top: 0;
    left: 0;
    background-color: #0073aa;
    color: white;
    padding: 8px 12px;
    border-radius: 0 0 5px 0;
    font-size: 12px;
    font-weight: bold;
    z-index: 9999 !important;
    display: inline-block;
    margin-bottom: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    font-family: Arial, sans-serif;
}

/* Elakkan konflik dengan elemen lain */
.canvas-content *[contenteditable="true"] {
    caret-color: #0073aa;
}

/* Gaya tambahan untuk antara muka yang lebih cantik */
body.admin-bar .wpc-live-edit-mode {
    margin-top: 32px; /* Sesuaikan dengan tinggi admin bar */
}

/* Pastikan kandungan mengambil lebar penuh */
.canvas-content {
    width: 100% !important;
    max-width: 100% !important;
}
/* ============================================================ */
/* Context Menu - Right Click Image Insert                      */
/* ============================================================ */
#wpc-context-menu {
    position: absolute;
    z-index: 999999;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    min-width: 240px;
    padding: 6px 0;
    opacity: 0;
    transform: scale(0.95) translateY(-5px);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    font-family: Arial, sans-serif;
}

#wpc-context-menu.wpc-ctx-show {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
}

.wpc-ctx-item {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.1s;
}

.wpc-ctx-item:hover {
    background: #f0f7ff;
    color: #0073aa;
}

.wpc-ctx-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.wpc-ctx-divider {
    height: 1px;
    background: #eee;
    margin: 4px 0;
}

/* ============================================================ */
/* Image Modal                                                  */
/* ============================================================ */
#wpc-image-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9999999;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
}

#wpc-image-modal {
    display: none;
}

#wpc-image-modal.wpc-modal-show {
    display: flex !important;
}

#wpc-image-modal-box {
    background: #fff;
    border-radius: 12px;
    padding: 28px 32px;
    width: 90%;
    max-width: 520px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    transform: scale(0.95);
    transition: transform 0.2s ease;
    font-family: Arial, sans-serif;
    max-height: 90vh;
    overflow-y: auto;
}

#wpc-image-modal.wpc-modal-show #wpc-image-modal-box {
    transform: scale(1);
}

#wpc-image-modal-box h3 {
    margin: 0 0 6px 0;
    font-size: 18px;
    color: #1a1a1a;
}

.wpc-modal-desc {
    color: #666;
    font-size: 13px;
    margin: 0 0 16px 0;
}

#wpc-image-url-input,
#wpc-image-alt-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 12px;
    transition: border-color 0.2s;
    outline: none;
}

#wpc-image-url-input:focus,
#wpc-image-alt-input:focus {
    border-color: #0073aa;
}

#wpc-image-url-input.wpc-input-error {
    border-color: #dc3232;
    animation: wpc-shake 0.3s ease;
}

@keyframes wpc-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

#wpc-image-preview-wrap {
    margin-bottom: 14px;
    text-align: center;
    background: #f9f9f9;
    border-radius: 6px;
    padding: 10px;
    border: 1px dashed #ccc;
}

.wpc-preview-label {
    font-size: 12px;
    color: #888;
    margin: 0 0 8px 0;
}

#wpc-image-preview {
    max-width: 100%;
    max-height: 180px;
    border-radius: 4px;
    object-fit: contain;
}

.wpc-modal-options label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#wpc-image-size {
    width: 100%;
    padding: 8px 10px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 12px;
    outline: none;
    cursor: pointer;
}

#wpc-image-size:focus {
    border-color: #0073aa;
}

.wpc-align-btns {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.wpc-align-btn {
    flex: 1;
    padding: 8px 10px;
    border: 2px solid #ddd;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
    color: #555;
}

.wpc-align-btn:hover {
    border-color: #0073aa;
    color: #0073aa;
}

.wpc-align-btn.active {
    border-color: #0073aa;
    background: #0073aa;
    color: #fff;
}

.wpc-modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.wpc-modal-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.wpc-modal-btn:active {
    transform: scale(0.97);
}

.wpc-modal-btn-primary {
    background: #0073aa;
    color: #fff;
}

.wpc-modal-btn-primary:hover {
    background: #005a87;
}

.wpc-modal-btn-cancel {
    background: #f0f0f0;
    color: #333;
}

.wpc-modal-btn-cancel:hover {
    background: #ddd;
}

/* Gambar yang dimasukkan */
.wpc-inserted-image-wrap {
    margin: 15px 0;
    position: relative;
}

.wpc-inserted-image-wrap img {
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Hover effect pada gambar dalam edit mode */
.wpc-live-edit-mode .wpc-inserted-image-wrap:hover img {
    outline: 2px solid #0073aa;
    box-shadow: 0 4px 12px rgba(0,115,170,0.3);
}
